2 # ipkg - the itsy package management system
4 # Copyright (C) 2001 Carl D. Worth
6 # Modified by Rod Whitby to remove the sort and uniq calls for the fsg3.
8 # This program is free software; you can redistribute it and/or modify
9 # it under the terms of the GNU General Public License as published by
10 # the Free Software Foundation; either version 2, or (at your option)
13 # This program is distributed in the hope that it will be useful,
14 # but WITHOUT ANY WARRANTY; without even the implied warranty of
15 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 # GNU General Public License for more details.
20 # By default do not do globbing. Any command wanting globbing should
21 # explicitly enable it first and disable it afterwards.
26 sed -ne "s/^src[[:space:]]\+$srcre[[:space:]]\+//p" < $IPKG_CONF
30 sed -ne "s/^src[[:space:]]\+\([^[:space:]]\+\).*/\1/p" < $IPKG_CONF
35 ipkg_srcs
$src |
head -1
39 local destre
=`echo $1 | ipkg_protect_slashes`
40 sed -ne "/^dest[[:space:]]\+$destre/{
41 s/^dest[[:space:]]\+[^[:space:]]\+[[:space:]]\+//
42 s/^/`echo $IPKG_OFFLINE_ROOT | ipkg_protect_slashes`/
48 sed -ne "s/^dest[[:space:]]\+\([^[:space:]]\+\).*/\1/p" < $IPKG_CONF
56 ipkg_dests_all |
sed "s|\$|/$IPKG_DIR_PREFIX|"
60 ipkg_dests_all |
head -1
63 ipkg_dest_default_name
() {
64 ipkg_dest_names |
head -1
69 ipkg_dests
$dest |
head -1
74 sed -ne "s/^option[[:space:]]\+$option[[:space:]]\+//p" < $IPKG_CONF
77 ipkg_load_configuration
() {
78 if [ -z "$IPKG_CONF_DIR" ]; then
82 IPKG_CONF
="$IPKG_CONF_DIR/ipkg.conf"
84 if [ -z "$IPKG_OFFLINE_ROOT" ]; then
85 IPKG_OFFLINE_ROOT
=`ipkg_option offline_root`
87 # Export IPKG_OFFLINE_ROOT for use by update-alternatives
88 export IPKG_OFFLINE_ROOT
89 if [ -n "$DEST_NAME" ]; then
90 IPKG_ROOT
=`ipkg_dest_byname $DEST_NAME`
91 if [ -z "$IPKG_ROOT" ]; then
92 if [ -d "$IPKG_OFFLINE_ROOT$DEST_NAME" ]; then
93 IPKG_ROOT
="$IPKG_OFFLINE_ROOT$DEST_NAME";
95 echo "ipkg: invalid destination specification: $DEST_NAME
96 Valid destinations are directories or one of the dest names from $IPKG_CONF:" >&2
102 IPKG_ROOT
=`ipkg_dest_default`
105 # Global ipkg state directories
106 IPKG_DIR_PREFIX
=usr
/lib
/ipkg
107 IPKG_LISTS_DIR
=$IPKG_OFFLINE_ROOT/$IPKG_DIR_PREFIX/lists
108 IPKG_PENDING_DIR
=$IPKG_OFFLINE_ROOT/$IPKG_DIR_PREFIX/pending
109 IPKG_TMP
=$IPKG_ROOT/tmp
/ipkg
111 # Destination specific ipkg meta-data directory
112 IPKG_STATE_DIR
=$IPKG_ROOT/$IPKG_DIR_PREFIX
115 IPKG_PROXY_USERNAME
=`ipkg_option proxy_username`
116 IPKG_PROXY_PASSWORD
=`ipkg_option proxy_password`
117 IPKG_HTTP_PROXY
=`ipkg_option http_proxy`
118 IPKG_FTP_PROXY
=`ipkg_option ftp_proxy`
119 IPKG_NO_PROXY
=`ipkg_option no_proxy`
120 if [ -n "$IPKG_HTTP_PROXY" ]; then
121 export http_proxy
="$IPKG_HTTP_PROXY"
124 if [ -n "$IPKG_FTP_PROXY" ]; then
125 export ftp_proxy
="$IPKG_FTP_PROXY"
128 if [ -n "$IPKG_NO_PROXY" ]; then
129 export no_proxy
="$IPKG_NO_PROXY"
132 IPKG_STATUS_FIELDS
='\(Package\|Status\|Essential\|Version\|Conffiles\|Root\)'
136 [ $# -gt 0 ] && echo "ipkg: $*"
138 usage: ipkg [options...] sub-command [arguments...]
139 where sub-command is one of:
141 Package Manipulation:
142 update Update list of available packages
143 upgrade Upgrade all installed packages to latest version
144 install <pkg> Download and install <pkg> (and dependencies)
145 install <file.ipk> Install package <file.ipk>
146 install <file.deb> Install package <file.deb>
147 remove <pkg> Remove package <pkg>
149 Informational Commands:
150 list List available packages and descriptions
151 files <pkg> List all files belonging to <pkg>
152 search <file> Search for a packaging providing <file>
153 info [pkg [<field>]] Display all/some info fields for <pkg> or all
154 status [pkg [<field>]] Display all/some status fields for <pkg> or all
155 depends <pkg> Print uninstalled package dependencies for <pkg>
158 -d <dest_name> Use <dest_name> as the the root directory for
159 -dest <dest_name> package installation, removal, upgrading.
160 <dest_name> should be a defined dest name from the
161 configuration file, (but can also be a directory
163 -o <offline_root> Use <offline_root> as the root for offline installation.
164 -offline <offline_root>
166 Force Options (use when ipkg is too smart for its own good):
167 -force-depends Make dependency checks warnings instead of errors
168 -force-defaults Use default options for questions asked by ipkg.
169 (no prompts). Note that this will not prevent
170 package installation scripts from prompting.
176 local dir
=`echo $1 | sed -ne 's/\(.*\/\).*/\1/p'`
177 if [ -z "$dir" ]; then
184 echo $1 |
sed 's/.*\///'
187 ipkg_protect_slashes
() {
195 local src_file
=`ipkg_file_part $src`
196 local dest_dir
=`ipkg_dir_part $dest`
197 if [ -z "$dest_dir" ]; then
201 local dest_file
=`ipkg_file_part $dest`
202 if [ -z "$dest_file" ]; then
203 dest_file
="$src_file"
208 local proxypassword
=""
211 if [ -n "$IPKG_PROXY_USERNAME" ]; then
212 proxyuser
="--proxy-user=\"$IPKG_PROXY_USERNAME\""
213 proxypassword
="--proxy-passwd=\"$IPKG_PROXY_PASSWORD\""
216 if [ -n "$IPKG_PROXY_HTTP" -o -n "$IPKG_PROXY_FTP" ]; then
217 proxyoption
="--proxy=on"
220 echo "Downloading $src ..."
221 rm -f $IPKG_TMP/$src_file
224 if ! wget
--passive-ftp -nd $proxyoption $proxyuser $proxypassword -P $IPKG_TMP $src; then
225 echo "ipkg_download: ERROR: Failed to retrieve $src, returning $err"
228 mv $IPKG_TMP/$src_file $dest_dir/$dest_file 2>/dev
/null
231 ln -s `echo $src | sed 's/^file://'` $dest_dir/$dest_file 2>/dev
/null
243 if [ ! -e "$IPKG_LISTS_DIR" ]; then
244 mkdir
-p $IPKG_LISTS_DIR
248 for src_name
in `ipkg_src_names`; do
249 local src
=`ipkg_src_byname $src_name`
250 if ! ipkg_download
$src/Packages
$IPKG_LISTS_DIR/$src_name; then
251 echo "ipkg_update: Error downloading $src/Packages to $IPKG_LISTS_DIR/$src_name" >&2
254 echo "Updated list of available packages in $IPKG_LISTS_DIR/$src_name"
258 [ -n "$err" ] && return 1
264 for src
in `ipkg_src_names`; do
265 if ipkg_require_list
$src; then
269 s/^Package:[[:space:]]*\<\([a-z0-9.+-]*$1[a-z0-9.+-]*\).*/\1/
273 s/^Description:[[:space:]]*\(.*\)/\1/
280 " $IPKG_LISTS_DIR/$src
285 ipkg_extract_paragraph
() {
287 sed -ne "/Package:[[:space:]]*$pkg[[:space:]]*\$/,/^\$/p"
290 ipkg_extract_field
() {
310 ipkg_extract_value
() {
311 sed -e "s/^[^:]*:[[:space:]]*//"
314 ipkg_require_list
() {
315 [ $# -lt 1 ] && return 1
317 if [ ! -f "$IPKG_LISTS_DIR/$src" ]; then
318 echo "ERROR: File not found: $IPKG_LISTS_DIR/$src" >&2
319 echo " You probably want to run \`ipkg update'" >&2
326 for src
in `ipkg_src_names`; do
327 if ipkg_require_list
$src; then
330 cat $IPKG_LISTS_DIR/$src
333 ipkg_extract_paragraph
$1 < $IPKG_LISTS_DIR/$src
336 ipkg_extract_paragraph
$1 < $IPKG_LISTS_DIR/$src | ipkg_extract_field
$2
344 [ $# -lt 1 ] && return 0
347 if [ -f $sd/status
]; then
353 ipkg_extract_paragraph
$1 < $sd/status
356 ipkg_extract_paragraph
$1 < $sd/status | ipkg_extract_field
$2
364 for sd
in `ipkg_state_dirs`; do
365 ipkg_status_sd
$sd $
*
370 if [ -n "$DEST_NAME" ]; then
371 ipkg_status_sd
$IPKG_STATE_DIR $
*
377 ipkg_status_matching_sd
() {
380 if [ -f $sd/status
]; then
384 s/^Package:[[:space:]]*//
403 ipkg_status_matching_all
() {
404 for sd
in `ipkg_state_dirs`; do
405 ipkg_status_matching_sd
$sd $
*
409 ipkg_status_matching
() {
410 if [ -n "$DEST_NAME" ]; then
411 ipkg_status_matching_sd
$IPKG_STATE_DIR $
*
413 ipkg_status_matching_all $
*
417 ipkg_status_installed_sd
() {
420 ipkg_status_sd
$sd $pkg Status |
grep -q "Status: install ok installed"
423 ipkg_status_installed_all
() {
425 for sd
in `ipkg_state_dirs`; do
426 if `ipkg_status_installed_sd $sd $*`; then
433 ipkg_status_mentioned_sd
() {
436 [ -n "`ipkg_status_sd $sd $pkg Status`" ]
441 if [ -n "$DEST_NAME" ]; then
444 dests
=`ipkg_dests_all`
446 for dest
in $dests; do
447 if [ -f $dest/$IPKG_DIR_PREFIX/info
/$pkg.list
]; then
448 dest_sed
=`echo $dest | ipkg_protect_slashes`
449 sed -e "s/^/$dest_sed/" < $dest/$IPKG_DIR_PREFIX/info
/$pkg.list
457 for dest_name
in `ipkg_dest_names`; do
458 dest
=`ipkg_dest_byname $dest_name`
459 dest_sed
=`echo $dest | ipkg_protect_slashes`
462 local list_files
=`ls -1 $dest/$IPKG_DIR_PREFIX/info/*.list 2>/dev/null`
464 for file in $list_files; do
465 if sed "s/^/$dest_sed/" $file |
grep -q $pattern; then
466 local pkg
=`echo $file | sed "s/^.*\/\(.*\)\.list/\1/"`
467 [ "$dest_name" != `ipkg_dest_default_name` ] && pkg
="$pkg ($dest_name)"
468 sed "s/^/$dest_sed/" $file |
grep $pattern |
sed "s/^/$pkg: /"
474 ipkg_status_remove_sd
() {
478 if [ ! -f $sd/status
]; then
482 sed -ne "/Package:[[:space:]]*$pkg[[:space:]]*\$/,/^\$/!p" < $sd/status
> $sd/status.new
483 mv $sd/status.new
$sd/status
486 ipkg_status_remove_all
() {
487 for sd
in `ipkg_state_dirs`; do
488 ipkg_status_remove_sd
$sd $
*
492 ipkg_status_remove
() {
493 if [ -n "$DEST_NAME" ]; then
494 ipkg_status_remove_sd
$IPKG_STATE_DIR $
*
496 ipkg_status_remove_all $
*
500 ipkg_status_update_sd
() {
504 ipkg_status_remove_sd
$sd $pkg
505 ipkg_extract_field
"$IPKG_STATUS_FIELDS" >> $sd/status
506 echo "" >> $sd/status
509 ipkg_status_update
() {
510 ipkg_status_update_sd
$IPKG_STATE_DIR $
*
513 ipkg_unsatisfied_dependences
() {
515 local deps
=`ipkg_get_depends $pkg`
516 local remaining_deps
=
518 local installed
=`ipkg_get_installed $dep`
519 if [ "$installed" != "installed" ] ; then
520 remaining_deps
="$remaining_deps $dep"
523 ## echo "ipkg_unsatisfied_dependences pkg=$pkg $remaining_deps" > /dev/console
527 ipkg_safe_pkg_name
() {
529 local spkg
=`echo pkg_$pkg | sed -e y/-+./___/`
536 pkg
=`ipkg_safe_pkg_name $pkg`
537 ## setvar ${pkg}_depends "$new_deps"
538 echo $new_deps > /tmp
/ipkg
/${pkg}.depends
543 pkg
=`ipkg_safe_pkg_name $pkg`
544 cat /tmp
/ipkg
/${pkg}.depends
545 ## eval "echo \$${pkg}_depends"
548 ipkg_set_installed
() {
550 pkg
=`ipkg_safe_pkg_name $pkg`
551 echo installed
> /tmp
/ipkg
/${pkg}.installed
552 ## setvar ${pkg}_installed "installed"
555 ipkg_set_uninstalled
() {
557 pkg
=`ipkg_safe_pkg_name $pkg`
558 ### echo ipkg_set_uninstalled $pkg > /dev/console
559 echo uninstalled
> /tmp
/ipkg
/${pkg}.installed
560 ## setvar ${pkg}_installed "uninstalled"
563 ipkg_get_installed
() {
565 pkg
=`ipkg_safe_pkg_name $pkg`
566 if [ -f /tmp
/ipkg
/${pkg}.installed
]; then
567 cat /tmp
/ipkg
/${pkg}.installed
569 ## eval "echo \$${pkg}_installed"
575 local installed_pkgs
=`ipkg_status_matching_all 'Status:.*[[:space:]]installed'`
576 for pkg
in $installed_pkgs; do
577 ipkg_set_installed
$pkg
579 while [ -n "$new_pkgs" ]; do
580 all_deps
="$all_deps $new_pkgs"
582 for pkg
in $new_pkgs; do
583 if echo $pkg |
grep -q '[^a-z0-9.+-]'; then
584 echo "ipkg_depends: ERROR: Package name $pkg contains illegal characters (should be [a-z0-9.+-])" >&2
587 # TODO: Fix this. For now I am ignoring versions and alternations in dependencies.
588 new_deps
="$new_deps "`ipkg_info $pkg '\(Pre-\)\?Depends' | ipkg_extract_value | sed -e 's/([^)]*)//g
589 s/\(|[[:space:]]*[a-z0-9.+-]\+[[:space:]]*\)\+//g
592 ipkg_set_depends
$pkg $new_deps
595 new_deps
=`echo $new_deps | sed -e 's/[[:space:]]\+/\\
598 local maybe_new_pkgs
=
599 for pkg
in $new_deps; do
600 if ! echo $installed_pkgs |
grep -q "\<$pkg\>"; then
601 maybe_new_pkgs
="$maybe_new_pkgs $pkg"
606 for pkg
in $maybe_new_pkgs; do
607 if ! echo $all_deps |
grep -q "\<$pkg\>"; then
608 if [ -z "`ipkg_info $pkg`" ]; then
609 echo "ipkg_depends: Warning: $pkg mentioned in dependency but no package found in $IPKG_LISTS_DIR" >&2
610 ipkg_set_installed
$pkg
612 new_pkgs
="$new_pkgs $pkg"
613 ipkg_set_uninstalled
$pkg
616 ipkg_set_uninstalled
$pkg
624 ipkg_get_install_dest
() {
627 local sd
=$dest/$IPKG_DIR_PREFIX
628 local info_dir
=$sd/info
630 local requested_pkgs
="$*"
631 local pkgs
=`ipkg_depends $*`
635 if ! ipkg_status_mentioned_sd
$sd $pkg; then
637 Status: install ok not-installed" | ipkg_status_update_sd
$sd $pkg
640 ## mark the packages that we were directly requested to install as uninstalled
641 for pkg
in $requested_pkgs; do ipkg_set_uninstalled
$pkg; done
644 local pkgs_installed
=0
645 while [ -n "pkgs" ]; do
647 ## echo "pkgs to install: {$pkgs}" > /dev/console
649 curcheck
=`expr $curcheck + 1`
650 local is_installed
=`ipkg_get_installed $pkg`
651 if [ "$is_installed" = "installed" ]; then
652 echo "$pkg is installed" > /dev
/console
656 local remaining_deps
=`ipkg_unsatisfied_dependences $pkg`
657 if [ -n "$remaining_deps" ]; then
658 new_pkgs
="$new_pkgs $pkg"
659 ### echo "Dependences not satisfied for $pkg: $remaining_deps"
660 if [ $curcheck -ne `echo $pkgs|wc -w` ]; then
666 for src
in `ipkg_src_names`; do
667 if ipkg_require_list
$src; then
668 filename
=`ipkg_extract_paragraph $pkg < $IPKG_LISTS_DIR/$src | ipkg_extract_field Filename | ipkg_extract_value`
669 [ -n "$filename" ] && break
673 if [ -z "$filename" ]; then
674 echo "ipkg_get_install: ERROR: Cannot find package $pkg in $IPKG_LISTS_DIR"
675 echo "ipkg_get_install: Check the spelling and maybe run \`ipkg update'."
676 ipkg_status_remove_sd
$sd $pkg
680 [ -e "$IPKG_TMP" ] || mkdir
-p $IPKG_TMP
683 local tmp_pkg_file
="$IPKG_TMP/"`ipkg_file_part $filename`
684 if ! ipkg_download
`ipkg_src_byname $src`/$filename $tmp_pkg_file; then
685 echo "ipkg_get_install: Perhaps you need to run \`ipkg update'?"
689 if ! ipkg_install_file_dest
$dest $tmp_pkg_file; then
690 echo "ipkg_get_install: ERROR: Failed to install $tmp_pkg_file"
691 echo "ipkg_get_install: I'll leave it there for you to try a manual installation"
695 ipkg_set_installed
$pkg
696 pkgs_installed
=`expr $pkgs_installed + 1`
699 ### echo "Installed $pkgs_installed package(s) this round"
700 if [ $pkgs_installed -eq 0 ]; then
701 if [ -z "$new_pkgs" ]; then
713 ipkg_get_install_dest
$IPKG_ROOT $
*
716 ipkg_install_file_dest
() {
719 local sd
=$dest/$IPKG_DIR_PREFIX
720 local info_dir
=$sd/info
722 if [ ! -f "$filename" ]; then
723 echo "ipkg_install_file: ERROR: File $filename not found"
727 local pkg
=`ipkg_file_part $filename | sed 's/\([a-z0-9.+-]\+\)_.*/\1/'`
728 local ext
=`echo $filename | sed 's/.*\.//'`
729 local pkg_extract_stdout
730 if [ "$ext" = "ipk" ]; then
731 pkg_extract_stdout
="tar -xzOf"
732 elif [ "$ext" = "deb" ]; then
733 pkg_extract_stdout
="ar p"
735 echo "ipkg_install_file: ERROR: File $filename has unknown extension $ext (not .ipk or .deb)"
740 local depends
=`ipkg_depends $pkg | sed -e "s/\<$pkg\>//"`
742 # Don't worry about deps that are scheduled for installation
744 for dep
in $depends; do
745 if ! ipkg_status_all
$dep |
grep -q 'Status:[[:space:]]install'; then
746 missing_deps
="$missing_deps $dep"
750 if [ ! -z "$missing_deps" ]; then
751 if [ -n "$FORCE_DEPENDS" ]; then
752 echo "ipkg_install_file: Warning: $pkg depends on the following uninstalled programs: $missing_deps"
754 echo "ipkg_install_file: ERROR: $pkg depends on the following uninstalled programs:
756 echo "ipkg_install_file: You may want to use \`ipkg install' to install these."
761 mkdir
-p $IPKG_TMP/$pkg/control
762 mkdir
-p $IPKG_TMP/$pkg/data
765 if ! $pkg_extract_stdout $filename .
/control.
tar.gz |
(cd $IPKG_TMP/$pkg/control
; tar -xzf - ) ; then
766 echo "ipkg_install_file: ERROR unpacking control.tar.gz from $filename"
770 if [ -n "$IPKG_OFFLINE_ROOT" ]; then
771 if grep -q '^InstallsOffline:[[:space:]]*no' $IPKG_TMP/$pkg/control
/control
; then
772 echo "*** Warning: Package $pkg may not be installed in offline mode"
773 echo "*** Warning: Scheduling $filename for pending installation (installing into $IPKG_PENDING_DIR)"
775 Status: install ok pending" | ipkg_status_update_sd
$sd $pkg
776 mkdir
-p $IPKG_PENDING_DIR
777 cp $filename $IPKG_PENDING_DIR
778 rm -r $IPKG_TMP/$pkg/control
779 rm -r $IPKG_TMP/$pkg/data
786 echo -n "Unpacking $pkg..."
788 for file in $IPKG_TMP/$pkg/control
/*; do
789 local base_file
=`ipkg_file_part $file`
790 mv $file $info_dir/$pkg.
$base_file
793 rm -r $IPKG_TMP/$pkg/control
795 if ! $pkg_extract_stdout $filename .
/data.
tar.gz |
(cd $IPKG_TMP/$pkg/data
; tar -xzf - ) ; then
796 echo "ipkg_install_file: ERROR unpacking data.tar.gz from $filename"
801 echo -n "Configuring $pkg..."
802 export PKG_ROOT
=$dest
803 if [ -x "$info_dir/$pkg.preinst" ]; then
804 if ! $info_dir/$pkg.preinst
install; then
805 echo "$info_dir/$pkg.preinst failed. Aborting installation of $pkg"
806 rm -rf $IPKG_TMP/$pkg/data
812 local old_conffiles
=`ipkg_status_sd $sd $pkg Conffiles | ipkg_extract_value`
814 if [ -f "$info_dir/$pkg.conffiles" ]; then
815 for conffile
in `cat $info_dir/$pkg.conffiles`; do
816 if [ -f "$dest/$conffile" ] && ! echo " $old_conffiles " |
grep -q " $conffile "`md5sum $dest/$conffile | sed 's/ .*//'`; then
817 local use_maintainers_conffile
=
818 if [ -z "$FORCE_DEFAULTS" ]; then
820 echo -n "Configuration file \`$conffile'
821 ==> File on system created by you or by a script.
822 ==> File also in package provided by package maintainer.
823 What would you like to do about it ? Your options are:
824 Y or I : install the package maintainer's version
825 N or O : keep your currently-installed version
826 D : show the differences between the versions (if diff is installed)
827 The default action is to keep your current version.
828 *** `ipkg_file_part $conffile` (Y/I/N/O/D) [default=N] ? "
831 [YyIi
] |
[Yy
][Ee
][Ss
])
832 use_maintainers_conffile
=t
837 diff -u $dest/$conffile $IPKG_TMP/$pkg/data/$conffile"
838 diff -u $dest/$conffile $IPKG_TMP/$pkg/data
/$conffile || true
839 echo "[Press ENTER to continue]"
848 if [ -n "$use_maintainers_conffile" ]; then
849 local md5sum=`md5sum $IPKG_TMP/$pkg/data/$conffile | sed 's/ .*//'`
850 new_conffiles
="$new_conffiles $conffile $md5sum"
852 new_conffiles
="$new_conffiles $conffile <custom>"
853 rm $IPKG_TMP/$pkg/data
/$conffile
856 md5sum=`md5sum $IPKG_TMP/$pkg/data/$conffile | sed 's/ .*//'`
857 new_conffiles
="$new_conffiles $conffile $md5sum"
863 (cd $IPKG_TMP/$pkg/data
/; tar cf
- . |
(cd $owd; cd $dest; tar xf
-))
864 rm -rf $IPKG_TMP/$pkg/data
866 $pkg_extract_stdout $filename .
/data.
tar.gz |
tar tzf
- |
sed -e 's/^\.//' > $info_dir/$pkg.list
868 if [ -x "$info_dir/$pkg.postinst" ]; then
869 $info_dir/$pkg.postinst configure
872 if [ -n "$new_conffiles" ]; then
873 new_conffiles
='Conffiles: '`echo $new_conffiles | ipkg_protect_slashes`
875 local sed_safe_root
=`echo $dest | sed -e "s/^${IPKG_OFFLINE_ROOT}//" | ipkg_protect_slashes`
876 sed -e "s/\(Package:.*\)/\1\\
877 Status: install ok installed\\
878 Root: ${sed_safe_root}\\
879 ${new_conffiles}/" $info_dir/$pkg.control | ipkg_status_update_sd
$sd $pkg
881 rm -f $info_dir/$pkg.control
882 rm -f $info_dir/$pkg.conffiles
883 rm -f $info_dir/$pkg.preinst
884 rm -f $info_dir/$pkg.postinst
889 ipkg_install_file
() {
890 ipkg_install_file_dest
$IPKG_ROOT $
*
895 while [ $# -gt 0 ]; do
901 local tmp_pkg_file
="$IPKG_TMP/"`ipkg_file_part $pkg`
902 if ipkg_download
$pkg $tmp_pkg_file; then
903 ipkg_install_file
$tmp_pkg_file
907 file:/*.ipk |
file://*.deb
)
908 local ipkg_filename
="`echo $pkg|sed 's/^file://'`"
909 ipkg_install_file
$ipkg_filename
912 if [ -f "$pkg" ]; then
913 ipkg_install_file
$pkg
915 echo "File not found $pkg" >&2
919 ipkg_get_install
$pkg || true
925 ipkg_install_pending
() {
926 [ -n "$IPKG_OFFLINE_ROOT" ] && return 0
928 if [ -d "$IPKG_PENDING_DIR" ]; then
930 local pending
=`ls -1d $IPKG_PENDING_DIR/*.ipk 2> /dev/null` || true
932 if [ -n "$pending" ]; then
933 echo "The following packages in $IPKG_PENDING_DIR will now be installed:"
935 for filename
in $pending; do
936 if ipkg_install_file
$filename; then
945 ipkg_install_wanted
() {
946 local wanted
=`ipkg_status_matching 'Status:[[:space:]]*install.*not-installed'`
948 if [ -n "$wanted" ]; then
949 echo "The following package were previously requested but have not been installed:"
952 if [ -n "$FORCE_DEFAULTS" ]; then
953 echo "Installing them now."
955 echo -n "Install them now [Y/n] ? "
972 local avail_ver
=`ipkg_info $pkg Version | ipkg_extract_value | head -1`
975 for dest_name
in `ipkg_dest_names`; do
976 local dest
=`ipkg_dest_byname $dest_name`
977 local sd
=$dest/$IPKG_DIR_PREFIX
978 local inst_ver
=`ipkg_status_sd $sd $pkg Version | ipkg_extract_value`
979 if [ -n "$inst_ver" ]; then
982 if [ -z "$avail_ver" ]; then
983 echo "Assuming locally installed package $pkg ($inst_ver) is up to date"
987 if [ "$avail_ver" = "$inst_ver" ]; then
988 echo "Package $pkg ($inst_ver) installed in $dest_name is up to date"
989 elif ipkg-compare-versions
$avail_ver '>>' $inst_ver; then
990 echo "Upgrading $pkg ($dest_name) from $inst_ver to $avail_ver"
991 ipkg_get_install_dest
$dest $pkg
993 echo "Not downgrading package $pkg from $inst_ver to $avail_ver"
998 if [ -z "$is_installed" ]; then
999 echo "Package $pkg does not appear to be installed"
1006 if [ $# -lt 1 ]; then
1007 local pkgs
=`ipkg_status_matching 'Status:.*[[:space:]]installed'`
1012 for pkg
in $pkgs; do
1013 ipkg_upgrade_pkg
$pkg
1017 ipkg_remove_pkg_dest
() {
1020 local sd
=$dest/$IPKG_DIR_PREFIX
1021 local info_dir
=$sd/info
1023 if ! ipkg_status_installed_sd
$sd $pkg; then
1024 echo "ipkg_remove: Package $pkg does not appear to be installed in $dest"
1025 if ipkg_status_mentioned_sd
$sd $pkg; then
1026 echo "Purging mention of $pkg from the ipkg database"
1027 ipkg_status_remove_sd
$sd $pkg
1032 echo "ipkg_remove: Removing $pkg... "
1034 local files
=`cat $info_dir/$pkg.list`
1036 export PKG_ROOT
=$dest
1037 if [ -x "$info_dir/$pkg.prerm" ]; then
1038 $info_dir/$pkg.prerm remove
1041 local conffiles
=`ipkg_status_sd $sd $pkg Conffiles | ipkg_extract_value`
1043 local dirs_to_remove
=
1044 for file in $files; do
1045 if [ -d "$dest/$file" ]; then
1046 dirs_to_remove
="$dirs_to_remove $dest/$file"
1048 if echo " $conffiles " |
grep -q " $file "; then
1049 if echo " $conffiles " |
grep -q " $file "`md5sum $dest/$file | sed 's/ .*//'`; then
1058 local removed_a_dir
=t
1059 while [ -n "$removed_a_dir" ]; do
1061 local new_dirs_to_remove
=
1062 for dir
in $dirs_to_remove; do
1063 if rmdir $dir >/dev
/null
2>&1; then
1066 new_dirs_to_remove
="$new_dirs_to_remove $dir"
1069 dirs_to_remove
="$new_dirs_to_remove"
1072 if [ -n "$dirs_to_remove" ]; then
1073 echo "ipkg_remove: Warning: Not removing the following directories since they are not empty:" >&2
1074 echo "$dirs_to_remove" |
sed -e 's/\/[/]\+/\//g' >&2
1077 if [ -x "$info_dir/$pkg.postrm" ]; then
1078 $info_dir/$pkg.postrm remove
1081 ipkg_status_remove_sd
$sd $pkg
1083 rm -f $info_dir/$pkg.
*
1091 for dest
in `ipkg_dests_all`; do
1092 local sd
=$dest/$IPKG_DIR_PREFIX
1093 if ipkg_status_mentioned_sd
$sd $pkg; then
1094 ipkg_remove_pkg_dest
$dest $pkg
1100 while [ $# -gt 0 ]; do
1103 if [ -n "$DEST_NAME" ]; then
1104 ipkg_remove_pkg_dest
$IPKG_ROOT $pkg
1106 ipkg_remove_pkg
$pkg
1116 while [ $# -gt 0 ]; do
1120 [ $# -gt 1 ] || ipkg_usage
"option $arg requires an argument"
1125 [ $# -gt 1 ] || ipkg_usage
"option $arg requires an argument"
1126 IPKG_OFFLINE_ROOT
="$2"
1136 ipkg_usage
"unknown option $arg"
1145 [ $# -lt 1 ] && ipkg_usage
"ipkg must have one sub-command argument"
1149 ipkg_load_configuration
1153 update|upgrade|list|info|status|install_pending
)
1155 install|depends|remove|files|search
)
1156 [ $# -lt 1 ] && ipkg_usage
"ERROR: the \`\`$cmd'' command requires an argument"
1159 echo "ERROR: unknown sub-command \`$cmd'"
1164 # Only install pending if we have an interactive sub-command
1167 ipkg_install_pending
1173 for a
in `ls $IPKG_TMP`; do