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]+)[^A-Za-z]?/ \1 /g").
25 B
=$
(echo $2 |
sed -r "s/([0-9]+)[^A-Za-z]?/ \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 IPKG_TMP
=$IPKG_ROOT/tmp
/ipkg
122 # Destination specific ipkg meta-data directory
123 IPKG_STATE_DIR
=$IPKG_ROOT/$IPKG_DIR_PREFIX
126 IPKG_PROXY_USERNAME
="`ipkg_option proxy_username`"
127 IPKG_PROXY_PASSWORD
="`ipkg_option proxy_password`"
128 IPKG_HTTP_PROXY
="`ipkg_option http_proxy`"
129 IPKG_FTP_PROXY
="`ipkg_option ftp_proxy`"
130 IPKG_NO_PROXY
="`ipkg_option no_proxy`"
131 if [ -n "$IPKG_HTTP_PROXY" ]; then
132 export http_proxy
="$IPKG_HTTP_PROXY"
135 if [ -n "$IPKG_FTP_PROXY" ]; then
136 export ftp_proxy
="$IPKG_FTP_PROXY"
139 if [ -n "$IPKG_NO_PROXY" ]; then
140 export no_proxy
="$IPKG_NO_PROXY"
143 IPKG_STATUS_FIELDS
='\(Package\|Status\|Essential\|Version\|Conffiles\|Root\)'
147 [ $# -gt 0 ] && echo "ipkg: $*"
149 usage: ipkg [options...] sub-command [arguments...]
150 where sub-command is one of:
152 Package Manipulation:
153 update Update list of available packages
154 upgrade Upgrade all installed packages to latest version
155 install <pkg> Download and install <pkg> (and dependencies)
156 install <file.ipk> Install package <file.ipk>
157 install <file.deb> Install package <file.deb>
158 remove <pkg> Remove package <pkg>
160 Informational Commands:
161 list List available packages and descriptions
162 files <pkg> List all files belonging to <pkg>
163 search <file> Search for a packaging providing <file>
164 info [pkg [<field>]] Display all/some info fields for <pkg> or all
165 status [pkg [<field>]] Display all/some status fields for <pkg> or all
166 depends <pkg> Print uninstalled package dependencies for <pkg>
169 -d <dest_name> Use <dest_name> as the the root directory for
170 -dest <dest_name> package installation, removal, upgrading.
171 <dest_name> should be a defined dest name from the
172 configuration file, (but can also be a directory
174 -o <offline_root> Use <offline_root> as the root for offline installation.
175 -offline <offline_root>
177 Force Options (use when ipkg is too smart for its own good):
178 -force-depends Make dependency checks warnings instead of errors
179 -force-defaults Use default options for questions asked by ipkg.
180 (no prompts). Note that this will not prevent
181 package installation scripts from prompting.
187 local dir
="`echo $1 | sed -ne 's/\(.*\/\).*/\1/p'`"
188 if [ -z "$dir" ]; then
195 echo $1 |
sed 's/.*\///'
198 ipkg_protect_slashes
() {
206 local src_file
="`ipkg_file_part $src`"
207 local dest_dir
="`ipkg_dir_part $dest`"
208 if [ -z "$dest_dir" ]; then
212 local dest_file
="`ipkg_file_part $dest`"
213 if [ -z "$dest_file" ]; then
214 dest_file
="$src_file"
219 local proxypassword
=""
222 if [ -n "$IPKG_PROXY_USERNAME" ]; then
223 proxyuser
="--proxy-user=\"$IPKG_PROXY_USERNAME\""
224 proxypassword
="--proxy-passwd=\"$IPKG_PROXY_PASSWORD\""
227 if [ -n "$IPKG_PROXY_HTTP" -o -n "$IPKG_PROXY_FTP" ]; then
228 proxyoption
="--proxy=on"
231 echo "Downloading $src ..."
232 rm -f $IPKG_TMP/$src_file
235 if ! wget
--passive-ftp $proxyoption $proxyuser $proxypassword -P $IPKG_TMP $src; then
236 echo "ipkg_download: ERROR: Failed to retrieve $src, returning $err"
239 mv $IPKG_TMP/$src_file $dest_dir/$dest_file 2>/dev
/null
242 ln -s `echo $src | sed 's/^file://'` $dest_dir/$dest_file 2>/dev
/null
254 if [ ! -e "$IPKG_LISTS_DIR" ]; then
255 mkdir
-p $IPKG_LISTS_DIR
259 for src_name
in `ipkg_src_names`; do
260 local src
="`ipkg_src_byname $src_name`"
261 if ! ipkg_download
$src/Packages
$IPKG_LISTS_DIR/$src_name; then
262 echo "ipkg_update: Error downloading $src/Packages to $IPKG_LISTS_DIR/$src_name" >&2
265 echo "Updated list of available packages in $IPKG_LISTS_DIR/$src_name"
269 [ -n "$err" ] && return 1
275 for src
in `ipkg_src_names`; do
276 if ipkg_require_list
$src; then
280 s/^Package:[[:space:]]*\<\([a-z0-9.+-]*$1[a-z0-9.+-]*\).*/\1/
284 s/^Description:[[:space:]]*\(.*\)/\1/
291 " $IPKG_LISTS_DIR/$src
296 ipkg_extract_paragraph
() {
298 sed -ne "/Package:[[:space:]]*$pkg[[:space:]]*\$/,/^\$/p"
301 ipkg_extract_field
() {
321 ipkg_extract_value
() {
322 sed -e "s/^[^:]*:[[:space:]]*//"
325 ipkg_require_list
() {
326 [ $# -lt 1 ] && return 1
328 if [ ! -f "$IPKG_LISTS_DIR/$src" ]; then
329 echo "ERROR: File not found: $IPKG_LISTS_DIR/$src" >&2
330 echo " You probably want to run \`ipkg update'" >&2
337 for src
in `ipkg_src_names`; do
338 if ipkg_require_list
$src; then
341 cat $IPKG_LISTS_DIR/$src
344 ipkg_extract_paragraph
$1 < $IPKG_LISTS_DIR/$src
347 ipkg_extract_paragraph
$1 < $IPKG_LISTS_DIR/$src | ipkg_extract_field
$2
355 [ $# -lt 1 ] && return 0
358 if [ -f $sd/status
]; then
364 ipkg_extract_paragraph
$1 < $sd/status
367 ipkg_extract_paragraph
$1 < $sd/status | ipkg_extract_field
$2
375 for sd
in `ipkg_state_dirs`; do
376 ipkg_status_sd
$sd $
*
381 if [ -n "$DEST_NAME" ]; then
382 ipkg_status_sd
$IPKG_STATE_DIR $
*
388 ipkg_status_matching_sd
() {
391 if [ -f $sd/status
]; then
395 s/^Package:[[:space:]]*//
414 ipkg_status_matching_all
() {
415 for sd
in `ipkg_state_dirs`; do
416 ipkg_status_matching_sd
$sd $
*
420 ipkg_status_matching
() {
421 if [ -n "$DEST_NAME" ]; then
422 ipkg_status_matching_sd
$IPKG_STATE_DIR $
*
424 ipkg_status_matching_all $
*
428 ipkg_status_installed_sd
() {
431 ipkg_status_sd
$sd $pkg Status |
grep -q "Status: install ok installed"
434 ipkg_status_installed_all
() {
436 for sd
in `ipkg_state_dirs`; do
437 if `ipkg_status_installed_sd $sd $*`; then
444 ipkg_status_mentioned_sd
() {
447 [ -n "`ipkg_status_sd $sd $pkg Status`" ]
452 if [ -n "$DEST_NAME" ]; then
455 dests
="`ipkg_dests_all`"
457 for dest
in $dests; do
458 if [ -f $dest/$IPKG_DIR_PREFIX/info
/$pkg.list
]; then
459 dest_sed
="`echo $dest | ipkg_protect_slashes`"
460 sed -e "s/^/$dest_sed/" < $dest/$IPKG_DIR_PREFIX/info
/$pkg.list
468 for dest_name
in `ipkg_dest_names`; do
469 dest
="`ipkg_dest_byname $dest_name`"
470 dest_sed
="`echo $dest | ipkg_protect_slashes`"
473 local list_files
="`ls -1 $dest/$IPKG_DIR_PREFIX/info/*.list 2>/dev/null`"
475 for file in $list_files; do
476 if sed "s/^/$dest_sed/" $file |
grep -q $pattern; then
477 local pkg
="`echo $file | sed "s
/^.
*\
/\
(.
*\
)\.list
/\
1/"`"
478 [ "$dest_name" != `ipkg_dest_default_name` ] && pkg
="$pkg ($dest_name)"
479 sed "s/^/$dest_sed/" $file |
grep $pattern |
sed "s/^/$pkg: /"
485 ipkg_status_remove_sd
() {
489 if [ ! -f $sd/status
]; then
493 sed -ne "/Package:[[:space:]]*$pkg[[:space:]]*\$/,/^\$/!p" < $sd/status
> $sd/status.new
494 mv $sd/status.new
$sd/status
497 ipkg_status_remove_all
() {
498 for sd
in `ipkg_state_dirs`; do
499 ipkg_status_remove_sd
$sd $
*
503 ipkg_status_remove
() {
504 if [ -n "$DEST_NAME" ]; then
505 ipkg_status_remove_sd
$IPKG_STATE_DIR $
*
507 ipkg_status_remove_all $
*
511 ipkg_status_update_sd
() {
515 ipkg_status_remove_sd
$sd $pkg
516 ipkg_extract_field
"$IPKG_STATUS_FIELDS" >> $sd/status
517 echo "" >> $sd/status
520 ipkg_status_update
() {
521 ipkg_status_update_sd
$IPKG_STATE_DIR $
*
524 ipkg_unsatisfied_dependences
() {
526 local deps
="`ipkg_get_depends $pkg`"
527 local remaining_deps
=
529 local installed
="`ipkg_get_installed $dep`"
530 if [ "$installed" != "installed" ] ; then
531 remaining_deps
="$remaining_deps $dep"
534 ## echo "ipkg_unsatisfied_dependences pkg=$pkg $remaining_deps" > /dev/console
538 ipkg_safe_pkg_name
() {
540 local spkg
="`echo pkg_$pkg | sed -e y/-+./___/`"
547 pkg
="`ipkg_safe_pkg_name $pkg`"
548 ## setvar ${pkg}_depends "$new_deps"
549 echo $new_deps > /tmp
/ipkg
/${pkg}.depends
554 pkg
="`ipkg_safe_pkg_name $pkg`"
555 cat /tmp
/ipkg
/${pkg}.depends
556 ## eval "echo \$${pkg}_depends"
559 ipkg_set_installed
() {
561 pkg
="`ipkg_safe_pkg_name $pkg`"
562 echo installed
> /tmp
/ipkg
/${pkg}.installed
563 ## setvar ${pkg}_installed "installed"
566 ipkg_set_uninstalled
() {
568 pkg
="`ipkg_safe_pkg_name $pkg`"
569 ### echo ipkg_set_uninstalled $pkg > /dev/console
570 echo uninstalled
> /tmp
/ipkg
/${pkg}.installed
571 ## setvar ${pkg}_installed "uninstalled"
574 ipkg_get_installed
() {
576 pkg
="`ipkg_safe_pkg_name $pkg`"
577 if [ -f /tmp
/ipkg
/${pkg}.installed
]; then
578 cat /tmp
/ipkg
/${pkg}.installed
580 ## eval "echo \$${pkg}_installed"
586 local installed_pkgs
="`ipkg_status_matching_all 'Status:.*[[:space:]]installed'`"
587 for pkg
in $installed_pkgs; do
588 ipkg_set_installed
$pkg
590 while [ -n "$new_pkgs" ]; do
591 all_deps
="$all_deps $new_pkgs"
593 for pkg
in $new_pkgs; do
594 if echo $pkg |
grep -q '[^a-z0-9.+-]'; then
595 echo "ipkg_depends: ERROR: Package name $pkg contains illegal characters (should be [a-z0-9.+-])" >&2
598 # TODO: Fix this. For now I am ignoring versions and alternations in dependencies.
599 new_deps
="$new_deps "`ipkg_info $pkg '\(Pre-\)\?Depends' | ipkg_extract_value | sed -e 's/([^)]*)//g
600 s/\(|[[:space:]]*[a-z0-9.+-]\+[[:space:]]*\)\+//g
603 ipkg_set_depends
$pkg $new_deps
606 new_deps
=`echo $new_deps | sed -e 's/[[:space:]]\+/\\
609 local maybe_new_pkgs
=
610 for pkg
in $new_deps; do
611 if ! echo $installed_pkgs |
grep -q "\<$pkg\>"; then
612 maybe_new_pkgs
="$maybe_new_pkgs $pkg"
617 for pkg
in $maybe_new_pkgs; do
618 if ! echo $all_deps |
grep -q "\<$pkg\>"; then
619 if [ -z "`ipkg_info $pkg`" ]; then
620 echo "ipkg_depends: Warning: $pkg mentioned in dependency but no package found in $IPKG_LISTS_DIR" >&2
621 ipkg_set_installed
$pkg
623 new_pkgs
="$new_pkgs $pkg"
624 ipkg_set_uninstalled
$pkg
627 ipkg_set_uninstalled
$pkg
635 ipkg_get_install_dest
() {
638 local sd
=$dest/$IPKG_DIR_PREFIX
639 local info_dir
=$sd/info
641 local requested_pkgs
="$*"
642 local pkgs
="`ipkg_depends $*`"
646 if ! ipkg_status_mentioned_sd
$sd $pkg; then
648 Status: install ok not-installed" | ipkg_status_update_sd
$sd $pkg
651 ## mark the packages that we were directly requested to install as uninstalled
652 for pkg
in $requested_pkgs; do ipkg_set_uninstalled
$pkg; done
655 local pkgs_installed
=0
656 while [ -n "pkgs" ]; do
658 ## echo "pkgs to install: {$pkgs}" > /dev/console
660 curcheck
="`expr $curcheck + 1`"
661 local is_installed
="`ipkg_get_installed $pkg`"
662 if [ "$is_installed" = "installed" ]; then
663 echo "$pkg is installed" > /dev
/console
667 local remaining_deps
="`ipkg_unsatisfied_dependences $pkg`"
668 if [ -n "$remaining_deps" ]; then
669 new_pkgs
="$new_pkgs $pkg"
670 ### echo "Dependences not satisfied for $pkg: $remaining_deps"
671 if [ $curcheck -ne `echo $pkgs|wc -w` ]; then
677 for src
in `ipkg_src_names`; do
678 if ipkg_require_list
$src; then
679 filename
="`ipkg_extract_paragraph $pkg < $IPKG_LISTS_DIR/$src | ipkg_extract_field Filename | ipkg_extract_value`"
680 [ -n "$filename" ] && break
684 if [ -z "$filename" ]; then
685 echo "ipkg_get_install: ERROR: Cannot find package $pkg in $IPKG_LISTS_DIR"
686 echo "ipkg_get_install: Check the spelling and maybe run \`ipkg update'."
687 ipkg_status_remove_sd
$sd $pkg
691 [ -e "$IPKG_TMP" ] || mkdir
-p $IPKG_TMP
694 local tmp_pkg_file
="$IPKG_TMP/"`ipkg_file_part $filename`
695 if ! ipkg_download
`ipkg_src_byname $src`/$filename $tmp_pkg_file; then
696 echo "ipkg_get_install: Perhaps you need to run \`ipkg update'?"
700 if ! ipkg_install_file_dest
$dest $tmp_pkg_file; then
701 echo "ipkg_get_install: ERROR: Failed to install $tmp_pkg_file"
702 echo "ipkg_get_install: I'll leave it there for you to try a manual installation"
706 ipkg_set_installed
$pkg
707 pkgs_installed
="`expr $pkgs_installed + 1`"
710 ### echo "Installed $pkgs_installed package(s) this round"
711 if [ $pkgs_installed -eq 0 ]; then
712 if [ -z "$new_pkgs" ]; then
724 ipkg_get_install_dest
$IPKG_ROOT $
*
727 ipkg_install_file_dest
() {
730 local sd
=$dest/$IPKG_DIR_PREFIX
731 local info_dir
=$sd/info
733 if [ ! -f "$filename" ]; then
734 echo "ipkg_install_file: ERROR: File $filename not found"
738 local pkg
="`ipkg_file_part $filename | sed 's/\([a-z0-9.+-]\+\)_.*/\1/'`"
739 local ext
="`echo $filename | sed 's/.*\.//'`"
740 local pkg_extract_stdout
741 if [ "$ext" = "ipk" ]; then
742 pkg_extract_stdout
="tar -xzOf"
743 elif [ "$ext" = "deb" ]; then
744 pkg_extract_stdout
="ar p"
746 echo "ipkg_install_file: ERROR: File $filename has unknown extension $ext (not .ipk or .deb)"
751 local depends
="`ipkg_depends $pkg | sed -e "s
/\
<$pkg\
>//"`"
753 # Don't worry about deps that are scheduled for installation
755 for dep
in $depends; do
756 if ! ipkg_status_all
$dep |
grep -q 'Status:[[:space:]]install'; then
757 missing_deps
="$missing_deps $dep"
761 if [ ! -z "$missing_deps" ]; then
762 if [ -n "$FORCE_DEPENDS" ]; then
763 echo "ipkg_install_file: Warning: $pkg depends on the following uninstalled programs: $missing_deps"
765 echo "ipkg_install_file: ERROR: $pkg depends on the following uninstalled programs:
767 echo "ipkg_install_file: You may want to use \`ipkg install' to install these."
772 mkdir
-p $IPKG_TMP/$pkg/control
773 mkdir
-p $IPKG_TMP/$pkg/data
776 if ! $pkg_extract_stdout $filename .
/control.
tar.gz |
(cd $IPKG_TMP/$pkg/control
; tar -xzf - ) ; then
777 echo "ipkg_install_file: ERROR unpacking control.tar.gz from $filename"
781 if [ -n "$IPKG_OFFLINE_ROOT" ]; then
782 if grep -q '^InstallsOffline:[[:space:]]*no' $IPKG_TMP/$pkg/control
/control
; then
783 echo "*** Warning: Package $pkg may not be installed in offline mode"
784 echo "*** Warning: Scheduling $filename for pending installation (installing into $IPKG_PENDING_DIR)"
786 Status: install ok pending" | ipkg_status_update_sd
$sd $pkg
787 mkdir
-p $IPKG_PENDING_DIR
788 cp $filename $IPKG_PENDING_DIR
789 rm -r $IPKG_TMP/$pkg/control
790 rm -r $IPKG_TMP/$pkg/data
797 echo -n "Unpacking $pkg..."
799 for file in $IPKG_TMP/$pkg/control
/*; do
800 local base_file
="`ipkg_file_part $file`"
801 mv $file $info_dir/$pkg.
$base_file
804 rm -r $IPKG_TMP/$pkg/control
806 if ! $pkg_extract_stdout $filename .
/data.
tar.gz |
(cd $IPKG_TMP/$pkg/data
; tar -xzf - ) ; then
807 echo "ipkg_install_file: ERROR unpacking data.tar.gz from $filename"
812 echo -n "Configuring $pkg..."
813 export PKG_ROOT
=$dest
814 if [ -x "$info_dir/$pkg.preinst" ]; then
815 if ! $info_dir/$pkg.preinst
install; then
816 echo "$info_dir/$pkg.preinst failed. Aborting installation of $pkg"
817 rm -rf $IPKG_TMP/$pkg/data
823 local old_conffiles
="`ipkg_status_sd $sd $pkg Conffiles | ipkg_extract_value`"
825 if [ -f "$info_dir/$pkg.conffiles" ]; then
826 for conffile
in `cat $info_dir/$pkg.conffiles`; do
827 if [ -f "$dest/$conffile" ] && ! echo " $old_conffiles " |
grep -q " $conffile "`md5sum $dest/$conffile | sed 's/ .*//'`; then
828 local use_maintainers_conffile
=
829 if [ -z "$FORCE_DEFAULTS" ]; then
831 echo -n "Configuration file \`$conffile'
832 ==> File on system created by you or by a script.
833 ==> File also in package provided by package maintainer.
834 What would you like to do about it ? Your options are:
835 Y or I : install the package maintainer's version
836 N or O : keep your currently-installed version
837 D : show the differences between the versions (if diff is installed)
838 The default action is to keep your current version.
839 *** `ipkg_file_part $conffile` (Y/I/N/O/D) [default=N] ? "
842 [YyIi
] |
[Yy
][Ee
][Ss
])
843 use_maintainers_conffile
=t
848 diff -u $dest/$conffile $IPKG_TMP/$pkg/data/$conffile"
849 diff -u $dest/$conffile $IPKG_TMP/$pkg/data
/$conffile || true
850 echo "[Press ENTER to continue]"
859 if [ -n "$use_maintainers_conffile" ]; then
860 local md5sum="`md5sum $IPKG_TMP/$pkg/data/$conffile | sed 's/ .*//'`"
861 new_conffiles
="$new_conffiles $conffile $md5sum"
863 new_conffiles
="$new_conffiles $conffile <custom>"
864 rm $IPKG_TMP/$pkg/data
/$conffile
867 md5sum="`md5sum $IPKG_TMP/$pkg/data/$conffile | sed 's/ .*//'`"
868 new_conffiles
="$new_conffiles $conffile $md5sum"
874 (cd $IPKG_TMP/$pkg/data
/; tar cf
- . |
(cd $owd; cd $dest; tar xf
-))
875 rm -rf $IPKG_TMP/$pkg/data
877 $pkg_extract_stdout $filename .
/data.
tar.gz |
tar tzf
- |
sed -e 's/^\.//' > $info_dir/$pkg.list
879 if [ -x "$info_dir/$pkg.postinst" ]; then
880 $info_dir/$pkg.postinst configure
883 if [ -n "$new_conffiles" ]; then
884 new_conffiles
='Conffiles: '`echo $new_conffiles | ipkg_protect_slashes`
886 local sed_safe_offline_root
="`echo ${IPKG_OFFLINE_ROOT} | ipkg_protect_slashes`"
887 local sed_safe_root
="`echo $dest | sed -e "s
/^
${sed_safe_offline_root}//" | ipkg_protect_slashes`"
888 sed -e "s/\(Package:.*\)/\1\\
889 Status: install ok installed\\
890 Root: ${sed_safe_root}\\
891 ${new_conffiles}/" $info_dir/$pkg.control | ipkg_status_update_sd
$sd $pkg
893 rm -f $info_dir/$pkg.control
894 rm -f $info_dir/$pkg.conffiles
895 rm -f $info_dir/$pkg.preinst
896 rm -f $info_dir/$pkg.postinst
901 ipkg_install_file
() {
902 ipkg_install_file_dest
$IPKG_ROOT $
*
907 while [ $# -gt 0 ]; do
913 local tmp_pkg_file
="$IPKG_TMP/"`ipkg_file_part $pkg`
914 if ipkg_download
$pkg $tmp_pkg_file; then
915 ipkg_install_file
$tmp_pkg_file
919 file:/*.ipk |
file://*.deb
)
920 local ipkg_filename
="`echo $pkg|sed 's/^file://'`"
921 ipkg_install_file
$ipkg_filename
924 if [ -f "$pkg" ]; then
925 ipkg_install_file
$pkg
927 echo "File not found $pkg" >&2
931 ipkg_get_install
$pkg || true
937 ipkg_install_pending
() {
938 [ -n "$IPKG_OFFLINE_ROOT" ] && return 0
940 if [ -d "$IPKG_PENDING_DIR" ]; then
942 local pending
="`ls -1d $IPKG_PENDING_DIR/*.ipk 2> /dev/null`" || true
944 if [ -n "$pending" ]; then
945 echo "The following packages in $IPKG_PENDING_DIR will now be installed:"
947 for filename
in $pending; do
948 if ipkg_install_file
$filename; then
957 ipkg_install_wanted
() {
958 local wanted
="`ipkg_status_matching 'Status:[[:space:]]*install.*not-installed'`"
960 if [ -n "$wanted" ]; then
961 echo "The following package were previously requested but have not been installed:"
964 if [ -n "$FORCE_DEFAULTS" ]; then
965 echo "Installing them now."
967 echo -n "Install them now [Y/n] ? "
984 local avail_ver
="`ipkg_info $pkg Version | ipkg_extract_value | head -1`"
987 for dest_name
in `ipkg_dest_names`; do
988 local dest
="`ipkg_dest_byname $dest_name`"
989 local sd
=$dest/$IPKG_DIR_PREFIX
990 local inst_ver
="`ipkg_status_sd $sd $pkg Version | ipkg_extract_value`"
991 if [ -n "$inst_ver" ]; then
994 if [ -z "$avail_ver" ]; then
995 echo "Assuming locally installed package $pkg ($inst_ver) is up to date"
999 if [ "$avail_ver" = "$inst_ver" ]; then
1000 echo "Package $pkg ($inst_ver) installed in $dest_name is up to date"
1001 elif ipkg_is_upgrade
"$avail_ver" "$inst_ver"; then
1002 echo "Upgrading $pkg ($dest_name) from $inst_ver to $avail_ver"
1003 ipkg_get_install_dest
$dest $pkg
1005 echo "Not downgrading package $pkg from $inst_ver to $avail_ver"
1010 if [ -z "$is_installed" ]; then
1011 echo "Package $pkg does not appear to be installed"
1018 if [ $# -lt 1 ]; then
1019 local pkgs
="`ipkg_status_matching 'Status:.*[[:space:]]installed'`"
1024 for pkg
in $pkgs; do
1025 ipkg_upgrade_pkg
$pkg
1029 ipkg_remove_pkg_dest
() {
1032 local sd
=$dest/$IPKG_DIR_PREFIX
1033 local info_dir
=$sd/info
1035 if ! ipkg_status_installed_sd
$sd $pkg; then
1036 echo "ipkg_remove: Package $pkg does not appear to be installed in $dest"
1037 if ipkg_status_mentioned_sd
$sd $pkg; then
1038 echo "Purging mention of $pkg from the ipkg database"
1039 ipkg_status_remove_sd
$sd $pkg
1044 echo "ipkg_remove: Removing $pkg... "
1046 local files
="`cat $info_dir/$pkg.list`"
1048 export PKG_ROOT
=$dest
1049 if [ -x "$info_dir/$pkg.prerm" ]; then
1050 $info_dir/$pkg.prerm remove
1053 local conffiles
="`ipkg_status_sd $sd $pkg Conffiles | ipkg_extract_value`"
1055 local dirs_to_remove
=
1056 for file in $files; do
1057 if [ -d "$dest/$file" ]; then
1058 dirs_to_remove
="$dirs_to_remove $dest/$file"
1060 if echo " $conffiles " |
grep -q " $file "; then
1061 if echo " $conffiles " |
grep -q " $file "`md5sum $dest/$file | sed 's/ .*//'`; then
1070 local removed_a_dir
=t
1071 while [ -n "$removed_a_dir" ]; do
1073 local new_dirs_to_remove
=
1074 for dir
in $dirs_to_remove; do
1075 if rmdir $dir >/dev
/null
2>&1; then
1078 new_dirs_to_remove
="$new_dirs_to_remove $dir"
1081 dirs_to_remove
="$new_dirs_to_remove"
1084 if [ -n "$dirs_to_remove" ]; then
1085 echo "ipkg_remove: Warning: Not removing the following directories since they are not empty:" >&2
1086 echo "$dirs_to_remove" |
sed -e 's/\/[/]\+/\//g' >&2
1089 if [ -x "$info_dir/$pkg.postrm" ]; then
1090 $info_dir/$pkg.postrm remove
1093 ipkg_status_remove_sd
$sd $pkg
1095 rm -f $info_dir/$pkg.
*
1103 for dest
in `ipkg_dests_all`; do
1104 local sd
=$dest/$IPKG_DIR_PREFIX
1105 if ipkg_status_mentioned_sd
$sd $pkg; then
1106 ipkg_remove_pkg_dest
$dest $pkg
1112 while [ $# -gt 0 ]; do
1115 if [ -n "$DEST_NAME" ]; then
1116 ipkg_remove_pkg_dest
$IPKG_ROOT $pkg
1118 ipkg_remove_pkg
$pkg
1128 while [ $# -gt 0 ]; do
1132 [ $# -gt 1 ] || ipkg_usage
"option $arg requires an argument"
1137 [ $# -gt 1 ] || ipkg_usage
"option $arg requires an argument"
1138 IPKG_OFFLINE_ROOT
="$2"
1148 ipkg_usage
"unknown option $arg"
1157 [ $# -lt 1 ] && ipkg_usage
"ipkg must have one sub-command argument"
1161 ipkg_load_configuration
1165 update|upgrade|list|info|status|install_pending
)
1167 install|depends|remove|files|search
)
1168 [ $# -lt 1 ] && ipkg_usage
"ERROR: the \`\`$cmd'' command requires an argument"
1171 echo "ERROR: unknown sub-command \`$cmd'"
1176 # Only install pending if we have an interactive sub-command
1179 ipkg_install_pending
1185 for a
in `ls $IPKG_TMP`; do