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 "s/[0-9]*/ & /g")
25 B
=$
(echo $2 |
sed "s/[0-9]*/ & /g")
26 while [ \
! -z "$A" ] && [ \
! -z "$B" ]; do {
27 set $A; a
=$1; shift; A
=$
*
28 set $B; b
=$1; shift; B
=$
*
29 { [ "$a" -gt "$b" ] 2>- ||
[ "$a" ">" "$b" ]; } && { return 0; }
36 sed -ne "s/^src[[:space:]]\+$srcre[[:space:]]\+//p" < $IPKG_CONF
40 sed -ne "s/^src[[:space:]]\+\([^[:space:]]\+\).*/\1/p" < $IPKG_CONF
45 ipkg_srcs
$src |
head -1
49 local destre
="`echo $1 | ipkg_protect_slashes`"
50 sed -ne "/^dest[[:space:]]\+$destre/{
51 s/^dest[[:space:]]\+[^[:space:]]\+[[:space:]]\+//
52 s/^/`echo $IPKG_OFFLINE_ROOT | ipkg_protect_slashes`/
58 sed -ne "s/^dest[[:space:]]\+\([^[:space:]]\+\).*/\1/p" < $IPKG_CONF
66 ipkg_dests_all |
sed "s|\$|/$IPKG_DIR_PREFIX|"
70 ipkg_dests_all |
head -1
73 ipkg_dest_default_name
() {
74 ipkg_dest_names |
head -1
79 ipkg_dests
$dest |
head -1
84 sed -ne "s/^option[[:space:]]\+$option[[:space:]]\+//p" < $IPKG_CONF
87 ipkg_load_configuration
() {
88 if [ -z "$IPKG_CONF_DIR" ]; then
92 IPKG_CONF
="$IPKG_CONF_DIR/ipkg.conf"
94 if [ -z "$IPKG_OFFLINE_ROOT" ]; then
95 IPKG_OFFLINE_ROOT
="`ipkg_option offline_root`"
97 # Export IPKG_OFFLINE_ROOT for use by update-alternatives
98 export IPKG_OFFLINE_ROOT
99 if [ -n "$DEST_NAME" ]; then
100 IPKG_ROOT
="`ipkg_dest_byname $DEST_NAME`"
101 if [ -z "$IPKG_ROOT" ]; then
102 if [ -d "$IPKG_OFFLINE_ROOT$DEST_NAME" ]; then
103 IPKG_ROOT
="$IPKG_OFFLINE_ROOT$DEST_NAME";
105 echo "ipkg: invalid destination specification: $DEST_NAME
106 Valid destinations are directories or one of the dest names from $IPKG_CONF:" >&2
112 IPKG_ROOT
="`ipkg_dest_default`"
115 # Global ipkg state directories
116 IPKG_DIR_PREFIX
=usr
/lib
/ipkg
117 IPKG_LISTS_DIR
=$IPKG_OFFLINE_ROOT/$IPKG_DIR_PREFIX/lists
118 IPKG_PENDING_DIR
=$IPKG_OFFLINE_ROOT/$IPKG_DIR_PREFIX/pending
119 IPKG_TMP
=$IPKG_ROOT/tmp
/ipkg
121 # Destination specific ipkg meta-data directory
122 IPKG_STATE_DIR
=$IPKG_ROOT/$IPKG_DIR_PREFIX
125 IPKG_PROXY_USERNAME
="`ipkg_option proxy_username`"
126 IPKG_PROXY_PASSWORD
="`ipkg_option proxy_password`"
127 IPKG_HTTP_PROXY
="`ipkg_option http_proxy`"
128 IPKG_FTP_PROXY
="`ipkg_option ftp_proxy`"
129 IPKG_NO_PROXY
="`ipkg_option no_proxy`"
130 if [ -n "$IPKG_HTTP_PROXY" ]; then
131 export http_proxy
="$IPKG_HTTP_PROXY"
134 if [ -n "$IPKG_FTP_PROXY" ]; then
135 export ftp_proxy
="$IPKG_FTP_PROXY"
138 if [ -n "$IPKG_NO_PROXY" ]; then
139 export no_proxy
="$IPKG_NO_PROXY"
142 IPKG_STATUS_FIELDS
='\(Package\|Status\|Essential\|Version\|Conffiles\|Root\)'
146 [ $# -gt 0 ] && echo "ipkg: $*"
148 usage: ipkg [options...] sub-command [arguments...]
149 where sub-command is one of:
151 Package Manipulation:
152 update Update list of available packages
153 upgrade Upgrade all installed packages to latest version
154 install <pkg> Download and install <pkg> (and dependencies)
155 install <file.ipk> Install package <file.ipk>
156 install <file.deb> Install package <file.deb>
157 remove <pkg> Remove package <pkg>
159 Informational Commands:
160 list List available packages and descriptions
161 files <pkg> List all files belonging to <pkg>
162 search <file> Search for a packaging providing <file>
163 info [pkg [<field>]] Display all/some info fields for <pkg> or all
164 status [pkg [<field>]] Display all/some status fields for <pkg> or all
165 depends <pkg> Print uninstalled package dependencies for <pkg>
168 -d <dest_name> Use <dest_name> as the the root directory for
169 -dest <dest_name> package installation, removal, upgrading.
170 <dest_name> should be a defined dest name from the
171 configuration file, (but can also be a directory
173 -o <offline_root> Use <offline_root> as the root for offline installation.
174 -offline <offline_root>
176 Force Options (use when ipkg is too smart for its own good):
177 -force-depends Make dependency checks warnings instead of errors
178 -force-defaults Use default options for questions asked by ipkg.
179 (no prompts). Note that this will not prevent
180 package installation scripts from prompting.
186 local dir
="`echo $1 | sed -ne 's/\(.*\/\).*/\1/p'`"
187 if [ -z "$dir" ]; then
194 echo $1 |
sed 's/.*\///'
197 ipkg_protect_slashes
() {
205 local src_file
="`ipkg_file_part $src`"
206 local dest_dir
="`ipkg_dir_part $dest`"
207 if [ -z "$dest_dir" ]; then
211 local dest_file
="`ipkg_file_part $dest`"
212 if [ -z "$dest_file" ]; then
213 dest_file
="$src_file"
218 local proxypassword
=""
221 if [ -n "$IPKG_PROXY_USERNAME" ]; then
222 proxyuser
="--proxy-user=\"$IPKG_PROXY_USERNAME\""
223 proxypassword
="--proxy-passwd=\"$IPKG_PROXY_PASSWORD\""
226 if [ -n "$IPKG_PROXY_HTTP" -o -n "$IPKG_PROXY_FTP" ]; then
227 proxyoption
="--proxy=on"
230 echo "Downloading $src ..."
231 rm -f $IPKG_TMP/$src_file
234 if ! wget
--passive-ftp $proxyoption $proxyuser $proxypassword -P $IPKG_TMP $src; then
235 echo "ipkg_download: ERROR: Failed to retrieve $src, returning $err"
238 mv $IPKG_TMP/$src_file $dest_dir/$dest_file 2>/dev
/null
241 ln -s `echo $src | sed 's/^file://'` $dest_dir/$dest_file 2>/dev
/null
253 if [ ! -e "$IPKG_LISTS_DIR" ]; then
254 mkdir
-p $IPKG_LISTS_DIR
258 for src_name
in `ipkg_src_names`; do
259 local src
="`ipkg_src_byname $src_name`"
260 if ! ipkg_download
$src/Packages
$IPKG_LISTS_DIR/$src_name; then
261 echo "ipkg_update: Error downloading $src/Packages to $IPKG_LISTS_DIR/$src_name" >&2
264 echo "Updated list of available packages in $IPKG_LISTS_DIR/$src_name"
268 [ -n "$err" ] && return 1
274 for src
in `ipkg_src_names`; do
275 if ipkg_require_list
$src; then
279 s/^Package:[[:space:]]*\<\([a-z0-9.+-]*$1[a-z0-9.+-]*\).*/\1/
283 s/^Description:[[:space:]]*\(.*\)/\1/
290 " $IPKG_LISTS_DIR/$src
295 ipkg_extract_paragraph
() {
297 sed -ne "/Package:[[:space:]]*$pkg[[:space:]]*\$/,/^\$/p"
300 ipkg_extract_field
() {
320 ipkg_extract_value
() {
321 sed -e "s/^[^:]*:[[:space:]]*//"
324 ipkg_require_list
() {
325 [ $# -lt 1 ] && return 1
327 if [ ! -f "$IPKG_LISTS_DIR/$src" ]; then
328 echo "ERROR: File not found: $IPKG_LISTS_DIR/$src" >&2
329 echo " You probably want to run \`ipkg update'" >&2
336 for src
in `ipkg_src_names`; do
337 if ipkg_require_list
$src; then
340 cat $IPKG_LISTS_DIR/$src
343 ipkg_extract_paragraph
$1 < $IPKG_LISTS_DIR/$src
346 ipkg_extract_paragraph
$1 < $IPKG_LISTS_DIR/$src | ipkg_extract_field
$2
354 [ $# -lt 1 ] && return 0
357 if [ -f $sd/status
]; then
363 ipkg_extract_paragraph
$1 < $sd/status
366 ipkg_extract_paragraph
$1 < $sd/status | ipkg_extract_field
$2
374 for sd
in `ipkg_state_dirs`; do
375 ipkg_status_sd
$sd $
*
380 if [ -n "$DEST_NAME" ]; then
381 ipkg_status_sd
$IPKG_STATE_DIR $
*
387 ipkg_status_matching_sd
() {
390 if [ -f $sd/status
]; then
394 s/^Package:[[:space:]]*//
413 ipkg_status_matching_all
() {
414 for sd
in `ipkg_state_dirs`; do
415 ipkg_status_matching_sd
$sd $
*
419 ipkg_status_matching
() {
420 if [ -n "$DEST_NAME" ]; then
421 ipkg_status_matching_sd
$IPKG_STATE_DIR $
*
423 ipkg_status_matching_all $
*
427 ipkg_status_installed_sd
() {
430 ipkg_status_sd
$sd $pkg Status |
grep -q "Status: install ok installed"
433 ipkg_status_installed_all
() {
435 for sd
in `ipkg_state_dirs`; do
436 if `ipkg_status_installed_sd $sd $*`; then
443 ipkg_status_mentioned_sd
() {
446 [ -n "`ipkg_status_sd $sd $pkg Status`" ]
451 if [ -n "$DEST_NAME" ]; then
454 dests
="`ipkg_dests_all`"
456 for dest
in $dests; do
457 if [ -f $dest/$IPKG_DIR_PREFIX/info
/$pkg.list
]; then
458 dest_sed
="`echo $dest | ipkg_protect_slashes`"
459 sed -e "s/^/$dest_sed/" < $dest/$IPKG_DIR_PREFIX/info
/$pkg.list
467 for dest_name
in `ipkg_dest_names`; do
468 dest
="`ipkg_dest_byname $dest_name`"
469 dest_sed
="`echo $dest | ipkg_protect_slashes`"
472 local list_files
="`ls -1 $dest/$IPKG_DIR_PREFIX/info/*.list 2>/dev/null`"
474 for file in $list_files; do
475 if sed "s/^/$dest_sed/" $file |
grep -q $pattern; then
476 local pkg
="`echo $file | sed "s
/^.
*\
/\
(.
*\
)\.list
/\
1/"`"
477 [ "$dest_name" != `ipkg_dest_default_name` ] && pkg
="$pkg ($dest_name)"
478 sed "s/^/$dest_sed/" $file |
grep $pattern |
sed "s/^/$pkg: /"
484 ipkg_status_remove_sd
() {
488 if [ ! -f $sd/status
]; then
492 sed -ne "/Package:[[:space:]]*$pkg[[:space:]]*\$/,/^\$/!p" < $sd/status
> $sd/status.new
493 mv $sd/status.new
$sd/status
496 ipkg_status_remove_all
() {
497 for sd
in `ipkg_state_dirs`; do
498 ipkg_status_remove_sd
$sd $
*
502 ipkg_status_remove
() {
503 if [ -n "$DEST_NAME" ]; then
504 ipkg_status_remove_sd
$IPKG_STATE_DIR $
*
506 ipkg_status_remove_all $
*
510 ipkg_status_update_sd
() {
514 ipkg_status_remove_sd
$sd $pkg
515 ipkg_extract_field
"$IPKG_STATUS_FIELDS" >> $sd/status
516 echo "" >> $sd/status
519 ipkg_status_update
() {
520 ipkg_status_update_sd
$IPKG_STATE_DIR $
*
523 ipkg_unsatisfied_dependences
() {
525 local deps
="`ipkg_get_depends $pkg`"
526 local remaining_deps
=
528 local installed
="`ipkg_get_installed $dep`"
529 if [ "$installed" != "installed" ] ; then
530 remaining_deps
="$remaining_deps $dep"
533 ## echo "ipkg_unsatisfied_dependences pkg=$pkg $remaining_deps" > /dev/console
537 ipkg_safe_pkg_name
() {
539 local spkg
="`echo pkg_$pkg | sed -e y/-+./___/`"
546 pkg
="`ipkg_safe_pkg_name $pkg`"
547 ## setvar ${pkg}_depends "$new_deps"
548 echo $new_deps > /tmp
/ipkg
/${pkg}.depends
553 pkg
="`ipkg_safe_pkg_name $pkg`"
554 cat /tmp
/ipkg
/${pkg}.depends
555 ## eval "echo \$${pkg}_depends"
558 ipkg_set_installed
() {
560 pkg
="`ipkg_safe_pkg_name $pkg`"
561 echo installed
> /tmp
/ipkg
/${pkg}.installed
562 ## setvar ${pkg}_installed "installed"
565 ipkg_set_uninstalled
() {
567 pkg
="`ipkg_safe_pkg_name $pkg`"
568 ### echo ipkg_set_uninstalled $pkg > /dev/console
569 echo uninstalled
> /tmp
/ipkg
/${pkg}.installed
570 ## setvar ${pkg}_installed "uninstalled"
573 ipkg_get_installed
() {
575 pkg
="`ipkg_safe_pkg_name $pkg`"
576 if [ -f /tmp
/ipkg
/${pkg}.installed
]; then
577 cat /tmp
/ipkg
/${pkg}.installed
579 ## eval "echo \$${pkg}_installed"
585 local installed_pkgs
="`ipkg_status_matching_all 'Status:.*[[:space:]]installed'`"
586 for pkg
in $installed_pkgs; do
587 ipkg_set_installed
$pkg
589 while [ -n "$new_pkgs" ]; do
590 all_deps
="$all_deps $new_pkgs"
592 for pkg
in $new_pkgs; do
593 if echo $pkg |
grep -q '[^a-z0-9.+-]'; then
594 echo "ipkg_depends: ERROR: Package name $pkg contains illegal characters (should be [a-z0-9.+-])" >&2
597 # TODO: Fix this. For now I am ignoring versions and alternations in dependencies.
598 new_deps
="$new_deps "`ipkg_info $pkg '\(Pre-\)\?Depends' | ipkg_extract_value | sed -e 's/([^)]*)//g
599 s/\(|[[:space:]]*[a-z0-9.+-]\+[[:space:]]*\)\+//g
602 ipkg_set_depends
$pkg $new_deps
605 new_deps
=`echo $new_deps | sed -e 's/[[:space:]]\+/\\
608 local maybe_new_pkgs
=
609 for pkg
in $new_deps; do
610 if ! echo $installed_pkgs |
grep -q "\<$pkg\>"; then
611 maybe_new_pkgs
="$maybe_new_pkgs $pkg"
616 for pkg
in $maybe_new_pkgs; do
617 if ! echo $all_deps |
grep -q "\<$pkg\>"; then
618 if [ -z "`ipkg_info $pkg`" ]; then
619 echo "ipkg_depends: Warning: $pkg mentioned in dependency but no package found in $IPKG_LISTS_DIR" >&2
620 ipkg_set_installed
$pkg
622 new_pkgs
="$new_pkgs $pkg"
623 ipkg_set_uninstalled
$pkg
626 ipkg_set_uninstalled
$pkg
634 ipkg_get_install_dest
() {
637 local sd
=$dest/$IPKG_DIR_PREFIX
638 local info_dir
=$sd/info
640 local requested_pkgs
="$*"
641 local pkgs
="`ipkg_depends $*`"
645 if ! ipkg_status_mentioned_sd
$sd $pkg; then
647 Status: install ok not-installed" | ipkg_status_update_sd
$sd $pkg
650 ## mark the packages that we were directly requested to install as uninstalled
651 for pkg
in $requested_pkgs; do ipkg_set_uninstalled
$pkg; done
654 local pkgs_installed
=0
655 while [ -n "pkgs" ]; do
657 ## echo "pkgs to install: {$pkgs}" > /dev/console
659 curcheck
="`expr $curcheck + 1`"
660 local is_installed
="`ipkg_get_installed $pkg`"
661 if [ "$is_installed" = "installed" ]; then
662 echo "$pkg is installed" > /dev
/console
666 local remaining_deps
="`ipkg_unsatisfied_dependences $pkg`"
667 if [ -n "$remaining_deps" ]; then
668 new_pkgs
="$new_pkgs $pkg"
669 ### echo "Dependences not satisfied for $pkg: $remaining_deps"
670 if [ $curcheck -ne `echo $pkgs|wc -w` ]; then
676 for src
in `ipkg_src_names`; do
677 if ipkg_require_list
$src; then
678 filename
="`ipkg_extract_paragraph $pkg < $IPKG_LISTS_DIR/$src | ipkg_extract_field Filename | ipkg_extract_value`"
679 [ -n "$filename" ] && break
683 if [ -z "$filename" ]; then
684 echo "ipkg_get_install: ERROR: Cannot find package $pkg in $IPKG_LISTS_DIR"
685 echo "ipkg_get_install: Check the spelling and maybe run \`ipkg update'."
686 ipkg_status_remove_sd
$sd $pkg
690 [ -e "$IPKG_TMP" ] || mkdir
-p $IPKG_TMP
693 local tmp_pkg_file
="$IPKG_TMP/"`ipkg_file_part $filename`
694 if ! ipkg_download
`ipkg_src_byname $src`/$filename $tmp_pkg_file; then
695 echo "ipkg_get_install: Perhaps you need to run \`ipkg update'?"
699 if ! ipkg_install_file_dest
$dest $tmp_pkg_file; then
700 echo "ipkg_get_install: ERROR: Failed to install $tmp_pkg_file"
701 echo "ipkg_get_install: I'll leave it there for you to try a manual installation"
705 ipkg_set_installed
$pkg
706 pkgs_installed
="`expr $pkgs_installed + 1`"
709 ### echo "Installed $pkgs_installed package(s) this round"
710 if [ $pkgs_installed -eq 0 ]; then
711 if [ -z "$new_pkgs" ]; then
723 ipkg_get_install_dest
$IPKG_ROOT $
*
726 ipkg_install_file_dest
() {
729 local sd
=$dest/$IPKG_DIR_PREFIX
730 local info_dir
=$sd/info
732 if [ ! -f "$filename" ]; then
733 echo "ipkg_install_file: ERROR: File $filename not found"
737 local pkg
="`ipkg_file_part $filename | sed 's/\([a-z0-9.+-]\+\)_.*/\1/'`"
738 local ext
="`echo $filename | sed 's/.*\.//'`"
739 local pkg_extract_stdout
740 if [ "$ext" = "ipk" ]; then
741 pkg_extract_stdout
="tar -xzOf"
742 elif [ "$ext" = "deb" ]; then
743 pkg_extract_stdout
="ar p"
745 echo "ipkg_install_file: ERROR: File $filename has unknown extension $ext (not .ipk or .deb)"
750 local depends
="`ipkg_depends $pkg | sed -e "s
/\
<$pkg\
>//"`"
752 # Don't worry about deps that are scheduled for installation
754 for dep
in $depends; do
755 if ! ipkg_status_all
$dep |
grep -q 'Status:[[:space:]]install'; then
756 missing_deps
="$missing_deps $dep"
760 if [ ! -z "$missing_deps" ]; then
761 if [ -n "$FORCE_DEPENDS" ]; then
762 echo "ipkg_install_file: Warning: $pkg depends on the following uninstalled programs: $missing_deps"
764 echo "ipkg_install_file: ERROR: $pkg depends on the following uninstalled programs:
766 echo "ipkg_install_file: You may want to use \`ipkg install' to install these."
771 mkdir
-p $IPKG_TMP/$pkg/control
772 mkdir
-p $IPKG_TMP/$pkg/data
775 if ! $pkg_extract_stdout $filename .
/control.
tar.gz |
(cd $IPKG_TMP/$pkg/control
; tar -xzf - ) ; then
776 echo "ipkg_install_file: ERROR unpacking control.tar.gz from $filename"
780 if [ -n "$IPKG_OFFLINE_ROOT" ]; then
781 if grep -q '^InstallsOffline:[[:space:]]*no' $IPKG_TMP/$pkg/control
/control
; then
782 echo "*** Warning: Package $pkg may not be installed in offline mode"
783 echo "*** Warning: Scheduling $filename for pending installation (installing into $IPKG_PENDING_DIR)"
785 Status: install ok pending" | ipkg_status_update_sd
$sd $pkg
786 mkdir
-p $IPKG_PENDING_DIR
787 cp $filename $IPKG_PENDING_DIR
788 rm -r $IPKG_TMP/$pkg/control
789 rm -r $IPKG_TMP/$pkg/data
796 echo -n "Unpacking $pkg..."
798 for file in $IPKG_TMP/$pkg/control
/*; do
799 local base_file
="`ipkg_file_part $file`"
800 mv $file $info_dir/$pkg.
$base_file
803 rm -r $IPKG_TMP/$pkg/control
805 if ! $pkg_extract_stdout $filename .
/data.
tar.gz |
(cd $IPKG_TMP/$pkg/data
; tar -xzf - ) ; then
806 echo "ipkg_install_file: ERROR unpacking data.tar.gz from $filename"
811 echo -n "Configuring $pkg..."
812 export PKG_ROOT
=$dest
813 if [ -x "$info_dir/$pkg.preinst" ]; then
814 if ! $info_dir/$pkg.preinst
install; then
815 echo "$info_dir/$pkg.preinst failed. Aborting installation of $pkg"
816 rm -rf $IPKG_TMP/$pkg/data
822 local old_conffiles
="`ipkg_status_sd $sd $pkg Conffiles | ipkg_extract_value`"
824 if [ -f "$info_dir/$pkg.conffiles" ]; then
825 for conffile
in `cat $info_dir/$pkg.conffiles`; do
826 if [ -f "$dest/$conffile" ] && ! echo " $old_conffiles " |
grep -q " $conffile "`md5sum $dest/$conffile | sed 's/ .*//'`; then
827 local use_maintainers_conffile
=
828 if [ -z "$FORCE_DEFAULTS" ]; then
830 echo -n "Configuration file \`$conffile'
831 ==> File on system created by you or by a script.
832 ==> File also in package provided by package maintainer.
833 What would you like to do about it ? Your options are:
834 Y or I : install the package maintainer's version
835 N or O : keep your currently-installed version
836 D : show the differences between the versions (if diff is installed)
837 The default action is to keep your current version.
838 *** `ipkg_file_part $conffile` (Y/I/N/O/D) [default=N] ? "
841 [YyIi
] |
[Yy
][Ee
][Ss
])
842 use_maintainers_conffile
=t
847 diff -u $dest/$conffile $IPKG_TMP/$pkg/data/$conffile"
848 diff -u $dest/$conffile $IPKG_TMP/$pkg/data
/$conffile || true
849 echo "[Press ENTER to continue]"
858 if [ -n "$use_maintainers_conffile" ]; then
859 local md5sum="`md5sum $IPKG_TMP/$pkg/data/$conffile | sed 's/ .*//'`"
860 new_conffiles
="$new_conffiles $conffile $md5sum"
862 new_conffiles
="$new_conffiles $conffile <custom>"
863 rm $IPKG_TMP/$pkg/data
/$conffile
866 md5sum="`md5sum $IPKG_TMP/$pkg/data/$conffile | sed 's/ .*//'`"
867 new_conffiles
="$new_conffiles $conffile $md5sum"
873 (cd $IPKG_TMP/$pkg/data
/; tar cf
- . |
(cd $owd; cd $dest; tar xf
-))
874 rm -rf $IPKG_TMP/$pkg/data
876 $pkg_extract_stdout $filename .
/data.
tar.gz |
tar tzf
- |
sed -e 's/^\.//' > $info_dir/$pkg.list
878 if [ -x "$info_dir/$pkg.postinst" ]; then
879 $info_dir/$pkg.postinst configure
882 if [ -n "$new_conffiles" ]; then
883 new_conffiles
='Conffiles: '`echo $new_conffiles | ipkg_protect_slashes`
885 local sed_safe_root
="`echo $dest | sed -e "s
/^
${IPKG_OFFLINE_ROOT}//" | ipkg_protect_slashes`"
886 sed -e "s/\(Package:.*\)/\1\\
887 Status: install ok installed\\
888 Root: ${sed_safe_root}\\
889 ${new_conffiles}/" $info_dir/$pkg.control | ipkg_status_update_sd
$sd $pkg
891 rm -f $info_dir/$pkg.control
892 rm -f $info_dir/$pkg.conffiles
893 rm -f $info_dir/$pkg.preinst
894 rm -f $info_dir/$pkg.postinst
899 ipkg_install_file
() {
900 ipkg_install_file_dest
$IPKG_ROOT $
*
905 while [ $# -gt 0 ]; do
911 local tmp_pkg_file
="$IPKG_TMP/"`ipkg_file_part $pkg`
912 if ipkg_download
$pkg $tmp_pkg_file; then
913 ipkg_install_file
$tmp_pkg_file
917 file:/*.ipk |
file://*.deb
)
918 local ipkg_filename
="`echo $pkg|sed 's/^file://'`"
919 ipkg_install_file
$ipkg_filename
922 if [ -f "$pkg" ]; then
923 ipkg_install_file
$pkg
925 echo "File not found $pkg" >&2
929 ipkg_get_install
$pkg || true
935 ipkg_install_pending
() {
936 [ -n "$IPKG_OFFLINE_ROOT" ] && return 0
938 if [ -d "$IPKG_PENDING_DIR" ]; then
940 local pending
="`ls -1d $IPKG_PENDING_DIR/*.ipk 2> /dev/null`" || true
942 if [ -n "$pending" ]; then
943 echo "The following packages in $IPKG_PENDING_DIR will now be installed:"
945 for filename
in $pending; do
946 if ipkg_install_file
$filename; then
955 ipkg_install_wanted
() {
956 local wanted
="`ipkg_status_matching 'Status:[[:space:]]*install.*not-installed'`"
958 if [ -n "$wanted" ]; then
959 echo "The following package were previously requested but have not been installed:"
962 if [ -n "$FORCE_DEFAULTS" ]; then
963 echo "Installing them now."
965 echo -n "Install them now [Y/n] ? "
982 local avail_ver
="`ipkg_info $pkg Version | ipkg_extract_value | head -1`"
985 for dest_name
in `ipkg_dest_names`; do
986 local dest
="`ipkg_dest_byname $dest_name`"
987 local sd
=$dest/$IPKG_DIR_PREFIX
988 local inst_ver
="`ipkg_status_sd $sd $pkg Version | ipkg_extract_value`"
989 if [ -n "$inst_ver" ]; then
992 if [ -z "$avail_ver" ]; then
993 echo "Assuming locally installed package $pkg ($inst_ver) is up to date"
997 if [ "$avail_ver" = "$inst_ver" ]; then
998 echo "Package $pkg ($inst_ver) installed in $dest_name is up to date"
999 elif ipkg_is_upgrade
"$avail_ver" "$inst_ver"; then
1000 echo "Upgrading $pkg ($dest_name) from $inst_ver to $avail_ver"
1001 ipkg_get_install_dest
$dest $pkg
1003 echo "Not downgrading package $pkg from $inst_ver to $avail_ver"
1008 if [ -z "$is_installed" ]; then
1009 echo "Package $pkg does not appear to be installed"
1016 if [ $# -lt 1 ]; then
1017 local pkgs
="`ipkg_status_matching 'Status:.*[[:space:]]installed'`"
1022 for pkg
in $pkgs; do
1023 ipkg_upgrade_pkg
$pkg
1027 ipkg_remove_pkg_dest
() {
1030 local sd
=$dest/$IPKG_DIR_PREFIX
1031 local info_dir
=$sd/info
1033 if ! ipkg_status_installed_sd
$sd $pkg; then
1034 echo "ipkg_remove: Package $pkg does not appear to be installed in $dest"
1035 if ipkg_status_mentioned_sd
$sd $pkg; then
1036 echo "Purging mention of $pkg from the ipkg database"
1037 ipkg_status_remove_sd
$sd $pkg
1042 echo "ipkg_remove: Removing $pkg... "
1044 local files
="`cat $info_dir/$pkg.list`"
1046 export PKG_ROOT
=$dest
1047 if [ -x "$info_dir/$pkg.prerm" ]; then
1048 $info_dir/$pkg.prerm remove
1051 local conffiles
="`ipkg_status_sd $sd $pkg Conffiles | ipkg_extract_value`"
1053 local dirs_to_remove
=
1054 for file in $files; do
1055 if [ -d "$dest/$file" ]; then
1056 dirs_to_remove
="$dirs_to_remove $dest/$file"
1058 if echo " $conffiles " |
grep -q " $file "; then
1059 if echo " $conffiles " |
grep -q " $file "`md5sum $dest/$file | sed 's/ .*//'`; then
1068 local removed_a_dir
=t
1069 while [ -n "$removed_a_dir" ]; do
1071 local new_dirs_to_remove
=
1072 for dir
in $dirs_to_remove; do
1073 if rmdir $dir >/dev
/null
2>&1; then
1076 new_dirs_to_remove
="$new_dirs_to_remove $dir"
1079 dirs_to_remove
="$new_dirs_to_remove"
1082 if [ -n "$dirs_to_remove" ]; then
1083 echo "ipkg_remove: Warning: Not removing the following directories since they are not empty:" >&2
1084 echo "$dirs_to_remove" |
sed -e 's/\/[/]\+/\//g' >&2
1087 if [ -x "$info_dir/$pkg.postrm" ]; then
1088 $info_dir/$pkg.postrm remove
1091 ipkg_status_remove_sd
$sd $pkg
1093 rm -f $info_dir/$pkg.
*
1101 for dest
in `ipkg_dests_all`; do
1102 local sd
=$dest/$IPKG_DIR_PREFIX
1103 if ipkg_status_mentioned_sd
$sd $pkg; then
1104 ipkg_remove_pkg_dest
$dest $pkg
1110 while [ $# -gt 0 ]; do
1113 if [ -n "$DEST_NAME" ]; then
1114 ipkg_remove_pkg_dest
$IPKG_ROOT $pkg
1116 ipkg_remove_pkg
$pkg
1126 while [ $# -gt 0 ]; do
1130 [ $# -gt 1 ] || ipkg_usage
"option $arg requires an argument"
1135 [ $# -gt 1 ] || ipkg_usage
"option $arg requires an argument"
1136 IPKG_OFFLINE_ROOT
="$2"
1146 ipkg_usage
"unknown option $arg"
1155 [ $# -lt 1 ] && ipkg_usage
"ipkg must have one sub-command argument"
1159 ipkg_load_configuration
1163 update|upgrade|list|info|status|install_pending
)
1165 install|depends|remove|files|search
)
1166 [ $# -lt 1 ] && ipkg_usage
"ERROR: the \`\`$cmd'' command requires an argument"
1169 echo "ERROR: unknown sub-command \`$cmd'"
1174 # Only install pending if we have an interactive sub-command
1177 ipkg_install_pending
1183 for a
in `ls $IPKG_TMP`; do