2 # ipkg - the itsy package management system
4 # Copyright (C) 2001 Carl D. Worth
6 # This program is free software; you can redistribute it and/or modify
7 # it under the terms of the GNU General Public License as published by
8 # the Free Software Foundation; either version 2, or (at your option)
11 # This program is distributed in the hope that it will be useful,
12 # but WITHOUT ANY WARRANTY; without even the implied warranty of
13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 # GNU General Public License for more details.
18 # By default do not do globbing. Any command wanting globbing should
19 # explicitly enable it first and disable it afterwards.
24 A
=$
(echo $1 |
sed -r "s/([0-9]+)[^[:alnum:]]*/ \1 /g").
25 B
=$
(echo $2 |
sed -r "s/([0-9]+)[^[:alnum:]]*/ \1 /g").
26 while [ \
! -z "$A" ] && [ \
! -z "$B" ]; do {
27 set $A; a
=$1; shift; A
=$
*
28 set $B; b
=$1; shift; B
=$
*
29 [ "$a" -lt "$b" ] 2>&- && return 1
30 { [ "$a" -gt "$b" ] 2>&- ||
[ "$a" ">" "$b" ]; } && return
37 sed -ne "s/^src[[:space:]]\+$srcre[[:space:]]\+//p" < $IPKG_CONF
41 sed -ne "s/^src[[:space:]]\+\([^[:space:]]\+\).*/\1/p" < $IPKG_CONF
46 ipkg_srcs
$src |
head -1
50 local destre
="`echo $1 | ipkg_protect_slashes`"
51 sed -ne "/^dest[[:space:]]\+$destre/{
52 s/^dest[[:space:]]\+[^[:space:]]\+[[:space:]]\+//
53 s/^/`echo $IPKG_OFFLINE_ROOT | ipkg_protect_slashes`/
59 sed -ne "s/^dest[[:space:]]\+\([^[:space:]]\+\).*/\1/p" < $IPKG_CONF
67 ipkg_dests_all |
sed "s|\$|/$IPKG_DIR_PREFIX|"
71 ipkg_dests_all |
head -1
74 ipkg_dest_default_name
() {
75 ipkg_dest_names |
head -1
80 ipkg_dests
$dest |
head -1
85 sed -ne "s/^option[[:space:]]\+$option[[:space:]]\+//p" < $IPKG_CONF
88 ipkg_load_configuration
() {
89 if [ -z "$IPKG_CONF_DIR" ]; then
93 IPKG_CONF
="$IPKG_CONF_DIR/ipkg.conf"
95 if [ -z "$IPKG_OFFLINE_ROOT" ]; then
96 IPKG_OFFLINE_ROOT
="`ipkg_option offline_root`"
98 # Export IPKG_OFFLINE_ROOT for use by update-alternatives
99 export IPKG_OFFLINE_ROOT
100 if [ -n "$DEST_NAME" ]; then
101 IPKG_ROOT
="`ipkg_dest_byname $DEST_NAME`"
102 if [ -z "$IPKG_ROOT" ]; then
103 if [ -d "$IPKG_OFFLINE_ROOT$DEST_NAME" ]; then
104 IPKG_ROOT
="$IPKG_OFFLINE_ROOT$DEST_NAME";
106 echo "ipkg: invalid destination specification: $DEST_NAME
107 Valid destinations are directories or one of the dest names from $IPKG_CONF:" >&2
113 IPKG_ROOT
="`ipkg_dest_default`"
116 # Global ipkg state directories
117 IPKG_DIR_PREFIX
=usr
/lib
/ipkg
118 IPKG_LISTS_DIR
=$IPKG_OFFLINE_ROOT/$IPKG_DIR_PREFIX/lists
119 IPKG_PENDING_DIR
=$IPKG_OFFLINE_ROOT/$IPKG_DIR_PREFIX/pending
120 if [ -z "$IPKG_TMP" ]; then
121 IPKG_TMP
=$IPKG_ROOT/tmp
/ipkg
124 [ -e "$IPKG_TMP" ] || mkdir
-p $IPKG_TMP
126 # Destination specific ipkg meta-data directory
127 IPKG_STATE_DIR
=$IPKG_ROOT/$IPKG_DIR_PREFIX
130 IPKG_PROXY_USERNAME
="`ipkg_option proxy_username`"
131 IPKG_PROXY_PASSWORD
="`ipkg_option proxy_password`"
132 IPKG_HTTP_PROXY
="`ipkg_option http_proxy`"
133 IPKG_FTP_PROXY
="`ipkg_option ftp_proxy`"
134 IPKG_NO_PROXY
="`ipkg_option no_proxy`"
135 if [ -n "$IPKG_HTTP_PROXY" ]; then
136 export http_proxy
="$IPKG_HTTP_PROXY"
139 if [ -n "$IPKG_FTP_PROXY" ]; then
140 export ftp_proxy
="$IPKG_FTP_PROXY"
143 if [ -n "$IPKG_NO_PROXY" ]; then
144 export no_proxy
="$IPKG_NO_PROXY"
147 IPKG_STATUS_FIELDS
='\(Package\|Status\|Essential\|Version\|Conffiles\|Root\)'
151 [ $# -gt 0 ] && echo "ipkg: $*"
153 usage: ipkg [options...] sub-command [arguments...]
154 where sub-command is one of:
156 Package Manipulation:
157 update Update list of available packages
158 upgrade Upgrade all installed packages to latest version
159 install <pkg> Download and install <pkg> (and dependencies)
160 install <file.ipk> Install package <file.ipk>
161 install <file.deb> Install package <file.deb>
162 remove <pkg> Remove package <pkg>
164 Informational Commands:
165 list List available packages and descriptions
166 files <pkg> List all files belonging to <pkg>
167 search <file> Search for a packaging providing <file>
168 info [pkg [<field>]] Display all/some info fields for <pkg> or all
169 status [pkg [<field>]] Display all/some status fields for <pkg> or all
170 depends <pkg> Print uninstalled package dependencies for <pkg>
173 -d <dest_name> Use <dest_name> as the the root directory for
174 -dest <dest_name> package installation, removal, upgrading.
175 <dest_name> should be a defined dest name from the
176 configuration file, (but can also be a directory
178 -o <offline_root> Use <offline_root> as the root for offline installation.
179 -offline <offline_root>
181 Force Options (use when ipkg is too smart for its own good):
182 -force-depends Make dependency checks warnings instead of errors
183 -force-defaults Use default options for questions asked by ipkg.
184 (no prompts). Note that this will not prevent
185 package installation scripts from prompting.
191 local dir
="`echo $1 | sed -ne 's/\(.*\/\).*/\1/p'`"
192 if [ -z "$dir" ]; then
199 echo $1 |
sed 's/.*\///'
202 ipkg_protect_slashes
() {
210 local src_file
="`ipkg_file_part $src`"
211 local dest_dir
="`ipkg_dir_part $dest`"
212 if [ -z "$dest_dir" ]; then
216 local dest_file
="`ipkg_file_part $dest`"
217 if [ -z "$dest_file" ]; then
218 dest_file
="$src_file"
223 local proxypassword
=""
226 if [ -n "$IPKG_PROXY_USERNAME" ]; then
227 proxyuser
="--proxy-user=\"$IPKG_PROXY_USERNAME\""
228 proxypassword
="--proxy-passwd=\"$IPKG_PROXY_PASSWORD\""
231 if [ -n "$IPKG_PROXY_HTTP" -o -n "$IPKG_PROXY_FTP" ]; then
232 proxyoption
="--proxy=on"
235 echo "Downloading $src ..."
236 rm -f $IPKG_TMP/$src_file
239 if ! wget
--passive-ftp $proxyoption $proxyuser $proxypassword -P $IPKG_TMP $src; then
240 echo "ipkg_download: ERROR: Failed to retrieve $src, returning $err"
243 mv $IPKG_TMP/$src_file $dest_dir/$dest_file 2>/dev
/null
246 ln -s `echo $src | sed 's/^file://'` $dest_dir/$dest_file 2>/dev
/null
258 if [ ! -e "$IPKG_LISTS_DIR" ]; then
259 mkdir
-p $IPKG_LISTS_DIR
263 for src_name
in `ipkg_src_names`; do
264 local src
="`ipkg_src_byname $src_name`"
265 if ! ipkg_download
$src/Packages
$IPKG_LISTS_DIR/$src_name; then
266 echo "ipkg_update: Error downloading $src/Packages to $IPKG_LISTS_DIR/$src_name" >&2
269 echo "Updated list of available packages in $IPKG_LISTS_DIR/$src_name"
273 [ -n "$err" ] && return 1
279 for src
in `ipkg_src_names`; do
280 if ipkg_require_list
$src; then
284 s/^Package:[[:space:]]*\<\([a-z0-9.+-]*$1[a-z0-9.+-]*\).*/\1/
288 s/^Description:[[:space:]]*\(.*\)/\1/
295 " $IPKG_LISTS_DIR/$src
300 ipkg_extract_paragraph
() {
302 sed -ne "/Package:[[:space:]]*$pkg[[:space:]]*\$/,/^\$/p"
305 ipkg_extract_field
() {
325 ipkg_extract_value
() {
326 sed -e "s/^[^:]*:[[:space:]]*//"
329 ipkg_require_list
() {
330 [ $# -lt 1 ] && return 1
332 if [ ! -f "$IPKG_LISTS_DIR/$src" ]; then
333 echo "ERROR: File not found: $IPKG_LISTS_DIR/$src" >&2
334 echo " You probably want to run \`ipkg update'" >&2
341 for src
in `ipkg_src_names`; do
342 if ipkg_require_list
$src; then
345 cat $IPKG_LISTS_DIR/$src
348 ipkg_extract_paragraph
$1 < $IPKG_LISTS_DIR/$src
351 ipkg_extract_paragraph
$1 < $IPKG_LISTS_DIR/$src | ipkg_extract_field
$2
359 [ $# -lt 1 ] && return 0
362 if [ -f $sd/status
]; then
368 ipkg_extract_paragraph
$1 < $sd/status
371 ipkg_extract_paragraph
$1 < $sd/status | ipkg_extract_field
$2
379 for sd
in `ipkg_state_dirs`; do
380 ipkg_status_sd
$sd $
*
385 if [ -n "$DEST_NAME" ]; then
386 ipkg_status_sd
$IPKG_STATE_DIR $
*
392 ipkg_status_matching_sd
() {
395 if [ -f $sd/status
]; then
399 s/^Package:[[:space:]]*//
418 ipkg_status_matching_all
() {
419 for sd
in `ipkg_state_dirs`; do
420 ipkg_status_matching_sd
$sd $
*
424 ipkg_status_matching
() {
425 if [ -n "$DEST_NAME" ]; then
426 ipkg_status_matching_sd
$IPKG_STATE_DIR $
*
428 ipkg_status_matching_all $
*
432 ipkg_status_installed_sd
() {
435 ipkg_status_sd
$sd $pkg Status |
grep -q "Status: install ok installed"
438 ipkg_status_installed_all
() {
440 for sd
in `ipkg_state_dirs`; do
441 if `ipkg_status_installed_sd $sd $*`; then
448 ipkg_status_mentioned_sd
() {
451 [ -n "`ipkg_status_sd $sd $pkg Status`" ]
456 if [ -n "$DEST_NAME" ]; then
459 dests
="`ipkg_dests_all`"
461 for dest
in $dests; do
462 if [ -f $dest/$IPKG_DIR_PREFIX/info
/$pkg.list
]; then
463 dest_sed
="`echo $dest | ipkg_protect_slashes`"
464 sed -e "s/^/$dest_sed/" < $dest/$IPKG_DIR_PREFIX/info
/$pkg.list
472 for dest_name
in `ipkg_dest_names`; do
473 dest
="`ipkg_dest_byname $dest_name`"
474 dest_sed
="`echo $dest | ipkg_protect_slashes`"
477 local list_files
="`ls -1 $dest/$IPKG_DIR_PREFIX/info/*.list 2>/dev/null`"
479 for file in $list_files; do
480 if sed "s/^/$dest_sed/" $file |
grep -q $pattern; then
481 local pkg
="`echo $file | sed "s
/^.
*\
/\
(.
*\
)\.list
/\
1/"`"
482 [ "$dest_name" != `ipkg_dest_default_name` ] && pkg
="$pkg ($dest_name)"
483 sed "s/^/$dest_sed/" $file |
grep $pattern |
sed "s/^/$pkg: /"
489 ipkg_status_remove_sd
() {
493 if [ ! -f $sd/status
]; then
497 sed -ne "/Package:[[:space:]]*$pkg[[:space:]]*\$/,/^\$/!p" < $sd/status
> $sd/status.new
498 mv $sd/status.new
$sd/status
501 ipkg_status_remove_all
() {
502 for sd
in `ipkg_state_dirs`; do
503 ipkg_status_remove_sd
$sd $
*
507 ipkg_status_remove
() {
508 if [ -n "$DEST_NAME" ]; then
509 ipkg_status_remove_sd
$IPKG_STATE_DIR $
*
511 ipkg_status_remove_all $
*
515 ipkg_status_update_sd
() {
519 ipkg_status_remove_sd
$sd $pkg
520 ipkg_extract_field
"$IPKG_STATUS_FIELDS" >> $sd/status
521 echo "" >> $sd/status
524 ipkg_status_update
() {
525 ipkg_status_update_sd
$IPKG_STATE_DIR $
*
528 ipkg_unsatisfied_dependences
() {
530 local deps
="`ipkg_get_depends $pkg`"
531 local remaining_deps
=
533 local installed
="`ipkg_get_installed $dep`"
534 if [ "$installed" != "installed" ] ; then
535 remaining_deps
="$remaining_deps $dep"
538 ## echo "ipkg_unsatisfied_dependences pkg=$pkg $remaining_deps" > /dev/console
542 ipkg_safe_pkg_name
() {
544 local spkg
="`echo pkg_$pkg | sed -e y/-+./___/`"
551 pkg
="`ipkg_safe_pkg_name $pkg`"
552 ## setvar ${pkg}_depends "$new_deps"
553 echo $new_deps > $IPKG_TMP/${pkg}.depends
558 pkg
="`ipkg_safe_pkg_name $pkg`"
559 cat $IPKG_TMP/${pkg}.depends
560 ## eval "echo \$${pkg}_depends"
563 ipkg_set_installed
() {
565 pkg
="`ipkg_safe_pkg_name $pkg`"
566 echo installed
> $IPKG_TMP/${pkg}.installed
567 ## setvar ${pkg}_installed "installed"
570 ipkg_set_uninstalled
() {
572 pkg
="`ipkg_safe_pkg_name $pkg`"
573 ### echo ipkg_set_uninstalled $pkg > /dev/console
574 echo uninstalled
> $IPKG_TMP/${pkg}.installed
575 ## setvar ${pkg}_installed "uninstalled"
578 ipkg_get_installed
() {
580 pkg
="`ipkg_safe_pkg_name $pkg`"
581 if [ -f $IPKG_TMP/${pkg}.installed
]; then
582 cat $IPKG_TMP/${pkg}.installed
584 ## eval "echo \$${pkg}_installed"
590 local installed_pkgs
="`ipkg_status_matching_all 'Status:.*[[:space:]]installed'`"
591 for pkg
in $installed_pkgs; do
592 ipkg_set_installed
$pkg
594 while [ -n "$new_pkgs" ]; do
595 all_deps
="$all_deps $new_pkgs"
597 for pkg
in $new_pkgs; do
598 if echo $pkg |
grep -q '[^a-z0-9.+-]'; then
599 echo "ipkg_depends: ERROR: Package name $pkg contains illegal characters (should be [a-z0-9.+-])" >&2
602 # TODO: Fix this. For now I am ignoring versions and alternations in dependencies.
603 new_deps
="$new_deps "`ipkg_info $pkg '\(Pre-\)\?Depends' | ipkg_extract_value | sed -e 's/([^)]*)//g
604 s/\(|[[:space:]]*[a-z0-9.+-]\+[[:space:]]*\)\+//g
607 ipkg_set_depends
$pkg $new_deps
610 new_deps
=`echo $new_deps | sed -e 's/[[:space:]]\+/\\
613 local maybe_new_pkgs
=
614 for pkg
in $new_deps; do
615 if ! echo $installed_pkgs |
grep -q "\<$pkg\>"; then
616 maybe_new_pkgs
="$maybe_new_pkgs $pkg"
621 for pkg
in $maybe_new_pkgs; do
622 if ! echo $all_deps |
grep -q "\<$pkg\>"; then
623 if [ -z "`ipkg_info $pkg`" ]; then
624 echo "ipkg_depends: Warning: $pkg mentioned in dependency but no package found in $IPKG_LISTS_DIR" >&2
625 ipkg_set_installed
$pkg
627 new_pkgs
="$new_pkgs $pkg"
628 ipkg_set_uninstalled
$pkg
631 ipkg_set_uninstalled
$pkg
639 ipkg_get_install_dest
() {
642 local sd
=$dest/$IPKG_DIR_PREFIX
643 local info_dir
=$sd/info
645 local requested_pkgs
="$*"
646 local pkgs
="`ipkg_depends $*`"
650 if ! ipkg_status_mentioned_sd
$sd $pkg; then
652 Status: install ok not-installed" | ipkg_status_update_sd
$sd $pkg
655 ## mark the packages that we were directly requested to install as uninstalled
656 for pkg
in $requested_pkgs; do ipkg_set_uninstalled
$pkg; done
659 local pkgs_installed
=0
660 while [ -n "pkgs" ]; do
662 ## echo "pkgs to install: {$pkgs}" > /dev/console
664 curcheck
="`expr $curcheck + 1`"
665 local is_installed
="`ipkg_get_installed $pkg`"
666 if [ "$is_installed" = "installed" ]; then
667 echo "$pkg is installed" > /dev
/console
671 local remaining_deps
="`ipkg_unsatisfied_dependences $pkg`"
672 if [ -n "$remaining_deps" ]; then
673 new_pkgs
="$new_pkgs $pkg"
674 ### echo "Dependences not satisfied for $pkg: $remaining_deps"
675 if [ $curcheck -ne `echo $pkgs|wc -w` ]; then
681 for src
in `ipkg_src_names`; do
682 if ipkg_require_list
$src; then
683 filename
="`ipkg_extract_paragraph $pkg < $IPKG_LISTS_DIR/$src | ipkg_extract_field Filename | ipkg_extract_value`"
684 [ -n "$filename" ] && break
688 if [ -z "$filename" ]; then
689 echo "ipkg_get_install: ERROR: Cannot find package $pkg in $IPKG_LISTS_DIR"
690 echo "ipkg_get_install: Check the spelling and maybe run \`ipkg update'."
691 ipkg_status_remove_sd
$sd $pkg
696 local tmp_pkg_file
="$IPKG_TMP/"`ipkg_file_part $filename`
697 if ! ipkg_download
`ipkg_src_byname $src`/$filename $tmp_pkg_file; then
698 echo "ipkg_get_install: Perhaps you need to run \`ipkg update'?"
702 if ! ipkg_install_file_dest
$dest $tmp_pkg_file; then
703 echo "ipkg_get_install: ERROR: Failed to install $tmp_pkg_file"
704 echo "ipkg_get_install: I'll leave it there for you to try a manual installation"
708 ipkg_set_installed
$pkg
709 pkgs_installed
="`expr $pkgs_installed + 1`"
712 ### echo "Installed $pkgs_installed package(s) this round"
713 if [ $pkgs_installed -eq 0 ]; then
714 if [ -z "$new_pkgs" ]; then
726 ipkg_get_install_dest
$IPKG_ROOT $
*
729 ipkg_install_file_dest
() {
732 local sd
=$dest/$IPKG_DIR_PREFIX
733 local info_dir
=$sd/info
735 if [ ! -f "$filename" ]; then
736 echo "ipkg_install_file: ERROR: File $filename not found"
740 local pkg
="`ipkg_file_part $filename | sed 's/\([a-z0-9.+-]\+\)_.*/\1/'`"
741 local ext
="`echo $filename | sed 's/.*\.//'`"
742 local pkg_extract_stdout
743 if [ "$ext" = "ipk" ]; then
744 pkg_extract_stdout
="tar -xzOf"
745 elif [ "$ext" = "deb" ]; then
746 pkg_extract_stdout
="ar p"
748 echo "ipkg_install_file: ERROR: File $filename has unknown extension $ext (not .ipk or .deb)"
753 local depends
="`ipkg_depends $pkg | sed -e "s
/\
<$pkg\
>//"`"
755 # Don't worry about deps that are scheduled for installation
757 for dep
in $depends; do
758 if ! ipkg_status_all
$dep |
grep -q 'Status:[[:space:]]install'; then
759 missing_deps
="$missing_deps $dep"
763 if [ ! -z "$missing_deps" ]; then
764 if [ -n "$FORCE_DEPENDS" ]; then
765 echo "ipkg_install_file: Warning: $pkg depends on the following uninstalled programs: $missing_deps"
767 echo "ipkg_install_file: ERROR: $pkg depends on the following uninstalled programs:
769 echo "ipkg_install_file: You may want to use \`ipkg install' to install these."
774 mkdir
-p $IPKG_TMP/$pkg/control
775 mkdir
-p $IPKG_TMP/$pkg/data
778 if ! $pkg_extract_stdout $filename .
/control.
tar.gz |
(cd $IPKG_TMP/$pkg/control
; tar -xzf - ) ; then
779 echo "ipkg_install_file: ERROR unpacking control.tar.gz from $filename"
783 if [ -n "$IPKG_OFFLINE_ROOT" ]; then
784 if grep -q '^InstallsOffline:[[:space:]]*no' $IPKG_TMP/$pkg/control
/control
; then
785 echo "*** Warning: Package $pkg may not be installed in offline mode"
786 echo "*** Warning: Scheduling $filename for pending installation (installing into $IPKG_PENDING_DIR)"
788 Status: install ok pending" | ipkg_status_update_sd
$sd $pkg
789 mkdir
-p $IPKG_PENDING_DIR
790 cp $filename $IPKG_PENDING_DIR
791 rm -r $IPKG_TMP/$pkg/control
792 rm -r $IPKG_TMP/$pkg/data
799 echo -n "Unpacking $pkg..."
801 for file in $IPKG_TMP/$pkg/control
/*; do
802 local base_file
="`ipkg_file_part $file`"
803 mv $file $info_dir/$pkg.
$base_file
806 rm -r $IPKG_TMP/$pkg/control
808 if ! $pkg_extract_stdout $filename .
/data.
tar.gz |
(cd $IPKG_TMP/$pkg/data
; tar -xzf - ) ; then
809 echo "ipkg_install_file: ERROR unpacking data.tar.gz from $filename"
814 echo -n "Configuring $pkg..."
815 export PKG_ROOT
=$dest
816 if [ -x "$info_dir/$pkg.preinst" ]; then
817 if ! $info_dir/$pkg.preinst
install; then
818 echo "$info_dir/$pkg.preinst failed. Aborting installation of $pkg"
819 rm -rf $IPKG_TMP/$pkg/data
825 local old_conffiles
="`ipkg_status_sd $sd $pkg Conffiles | ipkg_extract_value`"
827 if [ -f "$info_dir/$pkg.conffiles" ]; then
828 for conffile
in `cat $info_dir/$pkg.conffiles`; do
829 if [ -f "$dest/$conffile" ] && ! echo " $old_conffiles " |
grep -q " $conffile "`md5sum $dest/$conffile | sed 's/ .*//'`; then
830 local use_maintainers_conffile
=
831 if [ -z "$FORCE_DEFAULTS" ]; then
833 echo -n "Configuration file \`$conffile'
834 ==> File on system created by you or by a script.
835 ==> File also in package provided by package maintainer.
836 What would you like to do about it ? Your options are:
837 Y or I : install the package maintainer's version
838 N or O : keep your currently-installed version
839 D : show the differences between the versions (if diff is installed)
840 The default action is to keep your current version.
841 *** `ipkg_file_part $conffile` (Y/I/N/O/D) [default=N] ? "
844 [YyIi
] |
[Yy
][Ee
][Ss
])
845 use_maintainers_conffile
=t
850 diff -u $dest/$conffile $IPKG_TMP/$pkg/data/$conffile"
851 diff -u $dest/$conffile $IPKG_TMP/$pkg/data
/$conffile || true
852 echo "[Press ENTER to continue]"
861 if [ -n "$use_maintainers_conffile" ]; then
862 local md5sum="`md5sum $IPKG_TMP/$pkg/data/$conffile | sed 's/ .*//'`"
863 new_conffiles
="$new_conffiles $conffile $md5sum"
865 new_conffiles
="$new_conffiles $conffile <custom>"
866 rm $IPKG_TMP/$pkg/data
/$conffile
869 md5sum="`md5sum $IPKG_TMP/$pkg/data/$conffile | sed 's/ .*//'`"
870 new_conffiles
="$new_conffiles $conffile $md5sum"
876 (cd $IPKG_TMP/$pkg/data
/; tar cf
- . |
(cd $owd; cd $dest; tar xf
-))
877 rm -rf $IPKG_TMP/$pkg/data
879 rm -f $info_dir/$pkg.list
880 $pkg_extract_stdout $filename .
/data.
tar.gz |
tar tzf
- |
sed -e 's/^\.//' > $info_dir/$pkg.list
882 if [ -x "$info_dir/$pkg.postinst" ]; then
883 $info_dir/$pkg.postinst configure
886 if [ -n "$new_conffiles" ]; then
887 new_conffiles
='Conffiles: '`echo $new_conffiles | ipkg_protect_slashes`
889 local sed_safe_offline_root
="`echo ${IPKG_OFFLINE_ROOT} | ipkg_protect_slashes`"
890 local sed_safe_root
="`echo $dest | sed -e "s
/^
${sed_safe_offline_root}//" | ipkg_protect_slashes`"
891 sed -e "s/\(Package:.*\)/\1\\
892 Status: install ok installed\\
893 Root: ${sed_safe_root}\\
894 ${new_conffiles}/" $info_dir/$pkg.control | ipkg_status_update_sd
$sd $pkg
896 rm -f $info_dir/$pkg.control
897 rm -f $info_dir/$pkg.conffiles
898 rm -f $info_dir/$pkg.preinst
899 rm -f $info_dir/$pkg.postinst
904 ipkg_install_file
() {
905 ipkg_install_file_dest
$IPKG_ROOT $
*
910 while [ $# -gt 0 ]; do
916 local tmp_pkg_file
="$IPKG_TMP/"`ipkg_file_part $pkg`
917 if ipkg_download
$pkg $tmp_pkg_file; then
918 ipkg_install_file
$tmp_pkg_file
922 file:/*.ipk |
file://*.deb
)
923 local ipkg_filename
="`echo $pkg|sed 's/^file://'`"
924 ipkg_install_file
$ipkg_filename
927 if [ -f "$pkg" ]; then
928 ipkg_install_file
$pkg
930 echo "File not found $pkg" >&2
934 ipkg_get_install
$pkg || true
940 ipkg_install_pending
() {
941 [ -n "$IPKG_OFFLINE_ROOT" ] && return 0
943 if [ -d "$IPKG_PENDING_DIR" ]; then
945 local pending
="`ls -1d $IPKG_PENDING_DIR/*.ipk 2> /dev/null`" || true
947 if [ -n "$pending" ]; then
948 echo "The following packages in $IPKG_PENDING_DIR will now be installed:"
950 for filename
in $pending; do
951 if ipkg_install_file
$filename; then
960 ipkg_install_wanted
() {
961 local wanted
="`ipkg_status_matching 'Status:[[:space:]]*install.*not-installed'`"
963 if [ -n "$wanted" ]; then
964 echo "The following package were previously requested but have not been installed:"
967 if [ -n "$FORCE_DEFAULTS" ]; then
968 echo "Installing them now."
970 echo -n "Install them now [Y/n] ? "
987 local avail_ver
="`ipkg_info $pkg Version | ipkg_extract_value | head -1`"
990 for dest_name
in `ipkg_dest_names`; do
991 local dest
="`ipkg_dest_byname $dest_name`"
992 local sd
=$dest/$IPKG_DIR_PREFIX
993 local inst_ver
="`ipkg_status_sd $sd $pkg Version | ipkg_extract_value`"
994 if [ -n "$inst_ver" ]; then
997 if [ -z "$avail_ver" ]; then
998 echo "Assuming locally installed package $pkg ($inst_ver) is up to date"
1002 if [ "$avail_ver" = "$inst_ver" ]; then
1003 echo "Package $pkg ($inst_ver) installed in $dest_name is up to date"
1004 elif ipkg_is_upgrade
"$avail_ver" "$inst_ver"; then
1005 echo "Upgrading $pkg ($dest_name) from $inst_ver to $avail_ver"
1006 ipkg_get_install_dest
$dest $pkg
1008 echo "Not downgrading package $pkg from $inst_ver to $avail_ver"
1013 if [ -z "$is_installed" ]; then
1014 echo "Package $pkg does not appear to be installed"
1021 if [ $# -lt 1 ]; then
1022 local pkgs
="`ipkg_status_matching 'Status:.*[[:space:]]installed'`"
1027 for pkg
in $pkgs; do
1028 ipkg_upgrade_pkg
$pkg
1032 ipkg_remove_pkg_dest
() {
1035 local sd
=$dest/$IPKG_DIR_PREFIX
1036 local info_dir
=$sd/info
1038 if ! ipkg_status_installed_sd
$sd $pkg; then
1039 echo "ipkg_remove: Package $pkg does not appear to be installed in $dest"
1040 if ipkg_status_mentioned_sd
$sd $pkg; then
1041 echo "Purging mention of $pkg from the ipkg database"
1042 ipkg_status_remove_sd
$sd $pkg
1047 echo "ipkg_remove: Removing $pkg... "
1049 local files
="`cat $info_dir/$pkg.list`"
1051 export PKG_ROOT
=$dest
1052 if [ -x "$info_dir/$pkg.prerm" ]; then
1053 $info_dir/$pkg.prerm remove
1056 local conffiles
="`ipkg_status_sd $sd $pkg Conffiles | ipkg_extract_value`"
1058 local dirs_to_remove
=
1059 for file in $files; do
1060 if [ -d "$dest/$file" ]; then
1061 dirs_to_remove
="$dirs_to_remove $dest/$file"
1063 if echo " $conffiles " |
grep -q " $file "; then
1064 if echo " $conffiles " |
grep -q " $file "`md5sum $dest/$file | sed 's/ .*//'`; then
1073 local removed_a_dir
=t
1074 while [ -n "$removed_a_dir" ]; do
1076 local new_dirs_to_remove
=
1077 for dir
in $dirs_to_remove; do
1078 if rmdir $dir >/dev
/null
2>&1; then
1081 new_dirs_to_remove
="$new_dirs_to_remove $dir"
1084 dirs_to_remove
="$new_dirs_to_remove"
1087 if [ -n "$dirs_to_remove" ]; then
1088 echo "ipkg_remove: Warning: Not removing the following directories since they are not empty:" >&2
1089 echo "$dirs_to_remove" |
sed -e 's/\/[/]\+/\//g' >&2
1092 if [ -x "$info_dir/$pkg.postrm" ]; then
1093 $info_dir/$pkg.postrm remove
1096 ipkg_status_remove_sd
$sd $pkg
1098 rm -f $info_dir/$pkg.
*
1106 for dest
in `ipkg_dests_all`; do
1107 local sd
=$dest/$IPKG_DIR_PREFIX
1108 if ipkg_status_mentioned_sd
$sd $pkg; then
1109 ipkg_remove_pkg_dest
$dest $pkg
1115 while [ $# -gt 0 ]; do
1118 if [ -n "$DEST_NAME" ]; then
1119 ipkg_remove_pkg_dest
$IPKG_ROOT $pkg
1121 ipkg_remove_pkg
$pkg
1131 while [ $# -gt 0 ]; do
1135 [ $# -gt 1 ] || ipkg_usage
"option $arg requires an argument"
1140 [ $# -gt 1 ] || ipkg_usage
"option $arg requires an argument"
1141 IPKG_OFFLINE_ROOT
="$2"
1151 ipkg_usage
"unknown option $arg"
1160 [ $# -lt 1 ] && ipkg_usage
"ipkg must have one sub-command argument"
1164 ipkg_load_configuration
1168 update|upgrade|list|info|status|install_pending
)
1170 install|depends|remove|files|search
)
1171 [ $# -lt 1 ] && ipkg_usage
"ERROR: the \`\`$cmd'' command requires an argument"
1174 echo "ERROR: unknown sub-command \`$cmd'"
1179 # Only install pending if we have an interactive sub-command
1182 ipkg_install_pending
1188 for a
in `ls $IPKG_TMP`; do