# explicitly enable it first and disable it afterwards.
set -o noglob
+ipkg_is_upgrade () {
+ local A B a b
+ A=$(echo $1 | sed "s/[0-9]*/ & /g")
+ B=$(echo $2 | sed "s/[0-9]*/ & /g")
+ while [ \! -z "$A" ] && [ \! -z "$B" ]; do {
+ set $A; a=$1; shift; A=$*
+ set $B; b=$1; shift; B=$*
+ { [ "$a" -gt "$b" ] 2>&- || [ "$a" ">" "$b" ]; } && { return 0; }
+ }; done
+ return 1;
+}
+
ipkg_srcs() {
local srcre="$1"
sed -ne "s/^src[[:space:]]\+$srcre[[:space:]]\+//p" < $IPKG_CONF
}
ipkg_dests() {
- local destre=`echo $1 | ipkg_protect_slashes`
+ local destre="`echo $1 | ipkg_protect_slashes`"
sed -ne "/^dest[[:space:]]\+$destre/{
s/^dest[[:space:]]\+[^[:space:]]\+[[:space:]]\+//
s/^/`echo $IPKG_OFFLINE_ROOT | ipkg_protect_slashes`/
IPKG_CONF="$IPKG_CONF_DIR/ipkg.conf"
if [ -z "$IPKG_OFFLINE_ROOT" ]; then
- IPKG_OFFLINE_ROOT=`ipkg_option offline_root`
+ IPKG_OFFLINE_ROOT="`ipkg_option offline_root`"
fi
# Export IPKG_OFFLINE_ROOT for use by update-alternatives
export IPKG_OFFLINE_ROOT
if [ -n "$DEST_NAME" ]; then
- IPKG_ROOT=`ipkg_dest_byname $DEST_NAME`
+ IPKG_ROOT="`ipkg_dest_byname $DEST_NAME`"
if [ -z "$IPKG_ROOT" ]; then
if [ -d "$IPKG_OFFLINE_ROOT$DEST_NAME" ]; then
IPKG_ROOT="$IPKG_OFFLINE_ROOT$DEST_NAME";
fi
fi
else
- IPKG_ROOT=`ipkg_dest_default`
+ IPKG_ROOT="`ipkg_dest_default`"
fi
# Global ipkg state directories
IPKG_STATE_DIR=$IPKG_ROOT/$IPKG_DIR_PREFIX
# Proxy Support
- IPKG_PROXY_USERNAME=`ipkg_option proxy_username`
- IPKG_PROXY_PASSWORD=`ipkg_option proxy_password`
- IPKG_HTTP_PROXY=`ipkg_option http_proxy`
- IPKG_FTP_PROXY=`ipkg_option ftp_proxy`
- IPKG_NO_PROXY=`ipkg_option no_proxy`
+ IPKG_PROXY_USERNAME="`ipkg_option proxy_username`"
+ IPKG_PROXY_PASSWORD="`ipkg_option proxy_password`"
+ IPKG_HTTP_PROXY="`ipkg_option http_proxy`"
+ IPKG_FTP_PROXY="`ipkg_option ftp_proxy`"
+ IPKG_NO_PROXY="`ipkg_option no_proxy`"
if [ -n "$IPKG_HTTP_PROXY" ]; then
export http_proxy="$IPKG_HTTP_PROXY"
fi
}
ipkg_dir_part() {
- local dir=`echo $1 | sed -ne 's/\(.*\/\).*/\1/p'`
+ local dir="`echo $1 | sed -ne 's/\(.*\/\).*/\1/p'`"
if [ -z "$dir" ]; then
dir="./"
fi
local src="$1"
local dest="$2"
- local src_file=`ipkg_file_part $src`
- local dest_dir=`ipkg_dir_part $dest`
+ local src_file="`ipkg_file_part $src`"
+ local dest_dir="`ipkg_dir_part $dest`"
if [ -z "$dest_dir" ]; then
dest_dir="$IPKG_TMP"
fi
- local dest_file=`ipkg_file_part $dest`
+ local dest_file="`ipkg_file_part $dest`"
if [ -z "$dest_file" ]; then
dest_file="$src_file"
fi
local err=
for src_name in `ipkg_src_names`; do
- local src=`ipkg_src_byname $src_name`
+ local src="`ipkg_src_byname $src_name`"
if ! ipkg_download $src/Packages $IPKG_LISTS_DIR/$src_name; then
echo "ipkg_update: Error downloading $src/Packages to $IPKG_LISTS_DIR/$src_name" >&2
err=t
if [ -n "$DEST_NAME" ]; then
dests=$IPKG_ROOT
else
- dests=`ipkg_dests_all`
+ dests="`ipkg_dests_all`"
fi
for dest in $dests; do
if [ -f $dest/$IPKG_DIR_PREFIX/info/$pkg.list ]; then
- dest_sed=`echo $dest | ipkg_protect_slashes`
+ dest_sed="`echo $dest | ipkg_protect_slashes`"
sed -e "s/^/$dest_sed/" < $dest/$IPKG_DIR_PREFIX/info/$pkg.list
fi
done
local pattern="$1"
for dest_name in `ipkg_dest_names`; do
- dest=`ipkg_dest_byname $dest_name`
- dest_sed=`echo $dest | ipkg_protect_slashes`
+ dest="`ipkg_dest_byname $dest_name`"
+ dest_sed="`echo $dest | ipkg_protect_slashes`"
set +o noglob
- local list_files=`ls -1 $dest/$IPKG_DIR_PREFIX/info/*.list 2>/dev/null`
+ local list_files="`ls -1 $dest/$IPKG_DIR_PREFIX/info/*.list 2>/dev/null`"
set -o noglob
for file in $list_files; do
if sed "s/^/$dest_sed/" $file | grep -q $pattern; then
- local pkg=`echo $file | sed "s/^.*\/\(.*\)\.list/\1/"`
+ local pkg="`echo $file | sed "s/^.*\/\(.*\)\.list/\1/"`"
[ "$dest_name" != `ipkg_dest_default_name` ] && pkg="$pkg ($dest_name)"
sed "s/^/$dest_sed/" $file | grep $pattern | sed "s/^/$pkg: /"
fi
ipkg_unsatisfied_dependences() {
local pkg=$1
- local deps=`ipkg_get_depends $pkg`
+ local deps="`ipkg_get_depends $pkg`"
local remaining_deps=
for dep in $deps; do
- local installed=`ipkg_get_installed $dep`
+ local installed="`ipkg_get_installed $dep`"
if [ "$installed" != "installed" ] ; then
remaining_deps="$remaining_deps $dep"
fi
ipkg_safe_pkg_name() {
local pkg=$1
- local spkg=`echo pkg_$pkg | sed -e y/-+./___/`
+ local spkg="`echo pkg_$pkg | sed -e y/-+./___/`"
echo $spkg
}
ipkg_set_depends() {
local pkg=$1; shift
local new_deps="$*"
- pkg=`ipkg_safe_pkg_name $pkg`
+ pkg="`ipkg_safe_pkg_name $pkg`"
## setvar ${pkg}_depends "$new_deps"
echo $new_deps > /tmp/ipkg/${pkg}.depends
}
ipkg_get_depends() {
local pkg=$1
- pkg=`ipkg_safe_pkg_name $pkg`
+ pkg="`ipkg_safe_pkg_name $pkg`"
cat /tmp/ipkg/${pkg}.depends
## eval "echo \$${pkg}_depends"
}
ipkg_set_installed() {
local pkg=$1
- pkg=`ipkg_safe_pkg_name $pkg`
+ pkg="`ipkg_safe_pkg_name $pkg`"
echo installed > /tmp/ipkg/${pkg}.installed
## setvar ${pkg}_installed "installed"
}
ipkg_set_uninstalled() {
local pkg=$1
- pkg=`ipkg_safe_pkg_name $pkg`
+ pkg="`ipkg_safe_pkg_name $pkg`"
### echo ipkg_set_uninstalled $pkg > /dev/console
echo uninstalled > /tmp/ipkg/${pkg}.installed
## setvar ${pkg}_installed "uninstalled"
ipkg_get_installed() {
local pkg=$1
- pkg=`ipkg_safe_pkg_name $pkg`
+ pkg="`ipkg_safe_pkg_name $pkg`"
if [ -f /tmp/ipkg/${pkg}.installed ]; then
cat /tmp/ipkg/${pkg}.installed
fi
ipkg_depends() {
local new_pkgs="$*"
local all_deps=
- local installed_pkgs=`ipkg_status_matching_all 'Status:.*[[:space:]]installed'`
+ local installed_pkgs="`ipkg_status_matching_all 'Status:.*[[:space:]]installed'`"
for pkg in $installed_pkgs; do
ipkg_set_installed $pkg
done
local info_dir=$sd/info
local requested_pkgs="$*"
- local pkgs=`ipkg_depends $*`
+ local pkgs="`ipkg_depends $*`"
mkdir -p $info_dir
for pkg in $pkgs; do
curcheck=0
## echo "pkgs to install: {$pkgs}" > /dev/console
for pkg in $pkgs; do
- curcheck=`expr $curcheck + 1`
- local is_installed=`ipkg_get_installed $pkg`
+ curcheck="`expr $curcheck + 1`"
+ local is_installed="`ipkg_get_installed $pkg`"
if [ "$is_installed" = "installed" ]; then
echo "$pkg is installed" > /dev/console
continue
fi
- local remaining_deps=`ipkg_unsatisfied_dependences $pkg`
+ local remaining_deps="`ipkg_unsatisfied_dependences $pkg`"
if [ -n "$remaining_deps" ]; then
new_pkgs="$new_pkgs $pkg"
### echo "Dependences not satisfied for $pkg: $remaining_deps"
local filename=
for src in `ipkg_src_names`; do
if ipkg_require_list $src; then
- filename=`ipkg_extract_paragraph $pkg < $IPKG_LISTS_DIR/$src | ipkg_extract_field Filename | ipkg_extract_value`
+ filename="`ipkg_extract_paragraph $pkg < $IPKG_LISTS_DIR/$src | ipkg_extract_field Filename | ipkg_extract_value`"
[ -n "$filename" ] && break
fi
done
fi
ipkg_set_installed $pkg
- pkgs_installed=`expr $pkgs_installed + 1`
+ pkgs_installed="`expr $pkgs_installed + 1`"
rm $tmp_pkg_file
done
### echo "Installed $pkgs_installed package(s) this round"
return 1
fi
- local pkg=`ipkg_file_part $filename | sed 's/\([a-z0-9.+-]\+\)_.*/\1/'`
- local ext=`echo $filename | sed 's/.*\.//'`
+ local pkg="`ipkg_file_part $filename | sed 's/\([a-z0-9.+-]\+\)_.*/\1/'`"
+ local ext="`echo $filename | sed 's/.*\.//'`"
local pkg_extract_stdout
if [ "$ext" = "ipk" ]; then
pkg_extract_stdout="tar -xzOf"
fi
# Check dependencies
- local depends=`ipkg_depends $pkg | sed -e "s/\<$pkg\>//"`
+ local depends="`ipkg_depends $pkg | sed -e "s/\<$pkg\>//"`"
# Don't worry about deps that are scheduled for installation
local missing_deps=
echo -n "Unpacking $pkg..."
set +o noglob
for file in $IPKG_TMP/$pkg/control/*; do
- local base_file=`ipkg_file_part $file`
+ local base_file="`ipkg_file_part $file`"
mv $file $info_dir/$pkg.$base_file
done
set -o noglob
fi
fi
- local old_conffiles=`ipkg_status_sd $sd $pkg Conffiles | ipkg_extract_value`
+ local old_conffiles="`ipkg_status_sd $sd $pkg Conffiles | ipkg_extract_value`"
local new_conffiles=
if [ -f "$info_dir/$pkg.conffiles" ]; then
for conffile in `cat $info_dir/$pkg.conffiles`; do
done
fi
if [ -n "$use_maintainers_conffile" ]; then
- local md5sum=`md5sum $IPKG_TMP/$pkg/data/$conffile | sed 's/ .*//'`
+ local md5sum="`md5sum $IPKG_TMP/$pkg/data/$conffile | sed 's/ .*//'`"
new_conffiles="$new_conffiles $conffile $md5sum"
else
new_conffiles="$new_conffiles $conffile <custom>"
rm $IPKG_TMP/$pkg/data/$conffile
fi
else
- md5sum=`md5sum $IPKG_TMP/$pkg/data/$conffile | sed 's/ .*//'`
+ md5sum="`md5sum $IPKG_TMP/$pkg/data/$conffile | sed 's/ .*//'`"
new_conffiles="$new_conffiles $conffile $md5sum"
fi
done
fi
- local owd=`pwd`
+ local owd="`pwd`"
(cd $IPKG_TMP/$pkg/data/; tar cf - . | (cd $owd; cd $dest; tar xf -))
rm -rf $IPKG_TMP/$pkg/data
rmdir $IPKG_TMP/$pkg
if [ -n "$new_conffiles" ]; then
new_conffiles='Conffiles: '`echo $new_conffiles | ipkg_protect_slashes`
fi
- local sed_safe_root=`echo $dest | sed -e "s/^${IPKG_OFFLINE_ROOT}//" | ipkg_protect_slashes`
+ local sed_safe_root="`echo $dest | sed -e "s/^${IPKG_OFFLINE_ROOT}//" | ipkg_protect_slashes`"
sed -e "s/\(Package:.*\)/\1\\
Status: install ok installed\\
Root: ${sed_safe_root}\\
if [ -d "$IPKG_PENDING_DIR" ]; then
set +o noglob
- local pending=`ls -1d $IPKG_PENDING_DIR/*.ipk 2> /dev/null` || true
+ local pending="`ls -1d $IPKG_PENDING_DIR/*.ipk 2> /dev/null`" || true
set -o noglob
if [ -n "$pending" ]; then
echo "The following packages in $IPKG_PENDING_DIR will now be installed:"
}
ipkg_install_wanted() {
- local wanted=`ipkg_status_matching 'Status:[[:space:]]*install.*not-installed'`
+ local wanted="`ipkg_status_matching 'Status:[[:space:]]*install.*not-installed'`"
if [ -n "$wanted" ]; then
echo "The following package were previously requested but have not been installed:"
ipkg_upgrade_pkg() {
local pkg="$1"
- local avail_ver=`ipkg_info $pkg Version | ipkg_extract_value | head -1`
+ local avail_ver="`ipkg_info $pkg Version | ipkg_extract_value | head -1`"
is_installed=
for dest_name in `ipkg_dest_names`; do
- local dest=`ipkg_dest_byname $dest_name`
+ local dest="`ipkg_dest_byname $dest_name`"
local sd=$dest/$IPKG_DIR_PREFIX
- local inst_ver=`ipkg_status_sd $sd $pkg Version | ipkg_extract_value`
+ local inst_ver="`ipkg_status_sd $sd $pkg Version | ipkg_extract_value`"
if [ -n "$inst_ver" ]; then
is_installed=t
if [ "$avail_ver" = "$inst_ver" ]; then
echo "Package $pkg ($inst_ver) installed in $dest_name is up to date"
- elif ipkg-compare-versions $avail_ver '>>' $inst_ver; then
+ elif ipkg_is_upgrade "$avail_ver" "$inst_ver"; then
echo "Upgrading $pkg ($dest_name) from $inst_ver to $avail_ver"
ipkg_get_install_dest $dest $pkg
else
ipkg_upgrade() {
if [ $# -lt 1 ]; then
- local pkgs=`ipkg_status_matching 'Status:.*[[:space:]]installed'`
+ local pkgs="`ipkg_status_matching 'Status:.*[[:space:]]installed'`"
else
pkgs="$*"
fi
echo "ipkg_remove: Removing $pkg... "
- local files=`cat $info_dir/$pkg.list`
+ local files="`cat $info_dir/$pkg.list`"
export PKG_ROOT=$dest
if [ -x "$info_dir/$pkg.prerm" ]; then
$info_dir/$pkg.prerm remove
fi
- local conffiles=`ipkg_status_sd $sd $pkg Conffiles | ipkg_extract_value`
+ local conffiles="`ipkg_status_sd $sd $pkg Conffiles | ipkg_extract_value`"
local dirs_to_remove=
for file in $files; do