bugfixes with unquoted expressions

SVN-Revision: 6
This commit is contained in:
Mike Baker 2004-03-28 01:36:26 +00:00
parent 359df15b04
commit 1846528b08

View File

@ -34,7 +34,7 @@ ipkg_src_byname() {
} }
ipkg_dests() { ipkg_dests() {
local destre=`echo $1 | ipkg_protect_slashes` local destre="`echo $1 | ipkg_protect_slashes`"
sed -ne "/^dest[[:space:]]\+$destre/{ sed -ne "/^dest[[:space:]]\+$destre/{
s/^dest[[:space:]]\+[^[:space:]]\+[[:space:]]\+// s/^dest[[:space:]]\+[^[:space:]]\+[[:space:]]\+//
s/^/`echo $IPKG_OFFLINE_ROOT | ipkg_protect_slashes`/ s/^/`echo $IPKG_OFFLINE_ROOT | ipkg_protect_slashes`/
@ -80,12 +80,12 @@ ipkg_load_configuration() {
IPKG_CONF="$IPKG_CONF_DIR/ipkg.conf" IPKG_CONF="$IPKG_CONF_DIR/ipkg.conf"
if [ -z "$IPKG_OFFLINE_ROOT" ]; then if [ -z "$IPKG_OFFLINE_ROOT" ]; then
IPKG_OFFLINE_ROOT=`ipkg_option offline_root` IPKG_OFFLINE_ROOT="`ipkg_option offline_root`"
fi fi
# Export IPKG_OFFLINE_ROOT for use by update-alternatives # Export IPKG_OFFLINE_ROOT for use by update-alternatives
export IPKG_OFFLINE_ROOT export IPKG_OFFLINE_ROOT
if [ -n "$DEST_NAME" ]; then 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 [ -z "$IPKG_ROOT" ]; then
if [ -d "$IPKG_OFFLINE_ROOT$DEST_NAME" ]; then if [ -d "$IPKG_OFFLINE_ROOT$DEST_NAME" ]; then
IPKG_ROOT="$IPKG_OFFLINE_ROOT$DEST_NAME"; IPKG_ROOT="$IPKG_OFFLINE_ROOT$DEST_NAME";
@ -97,7 +97,7 @@ Valid destinations are directories or one of the dest names from $IPKG_CONF:" >&
fi fi
fi fi
else else
IPKG_ROOT=`ipkg_dest_default` IPKG_ROOT="`ipkg_dest_default`"
fi fi
# Global ipkg state directories # Global ipkg state directories
@ -110,11 +110,11 @@ Valid destinations are directories or one of the dest names from $IPKG_CONF:" >&
IPKG_STATE_DIR=$IPKG_ROOT/$IPKG_DIR_PREFIX IPKG_STATE_DIR=$IPKG_ROOT/$IPKG_DIR_PREFIX
# Proxy Support # Proxy Support
IPKG_PROXY_USERNAME=`ipkg_option proxy_username` IPKG_PROXY_USERNAME="`ipkg_option proxy_username`"
IPKG_PROXY_PASSWORD=`ipkg_option proxy_password` IPKG_PROXY_PASSWORD="`ipkg_option proxy_password`"
IPKG_HTTP_PROXY=`ipkg_option http_proxy` IPKG_HTTP_PROXY="`ipkg_option http_proxy`"
IPKG_FTP_PROXY=`ipkg_option ftp_proxy` IPKG_FTP_PROXY="`ipkg_option ftp_proxy`"
IPKG_NO_PROXY=`ipkg_option no_proxy` IPKG_NO_PROXY="`ipkg_option no_proxy`"
if [ -n "$IPKG_HTTP_PROXY" ]; then if [ -n "$IPKG_HTTP_PROXY" ]; then
export http_proxy="$IPKG_HTTP_PROXY" export http_proxy="$IPKG_HTTP_PROXY"
fi fi
@ -171,7 +171,7 @@ Force Options (use when ipkg is too smart for its own good):
} }
ipkg_dir_part() { 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 if [ -z "$dir" ]; then
dir="./" dir="./"
fi fi
@ -190,13 +190,13 @@ ipkg_download() {
local src="$1" local src="$1"
local dest="$2" local dest="$2"
local src_file=`ipkg_file_part $src` local src_file="`ipkg_file_part $src`"
local dest_dir=`ipkg_dir_part $dest` local dest_dir="`ipkg_dir_part $dest`"
if [ -z "$dest_dir" ]; then if [ -z "$dest_dir" ]; then
dest_dir="$IPKG_TMP" dest_dir="$IPKG_TMP"
fi fi
local dest_file=`ipkg_file_part $dest` local dest_file="`ipkg_file_part $dest`"
if [ -z "$dest_file" ]; then if [ -z "$dest_file" ]; then
dest_file="$src_file" dest_file="$src_file"
fi fi
@ -244,7 +244,7 @@ ipkg_update() {
local err= local err=
for src_name in `ipkg_src_names`; do 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 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 echo "ipkg_update: Error downloading $src/Packages to $IPKG_LISTS_DIR/$src_name" >&2
err=t err=t
@ -439,11 +439,11 @@ ipkg_files() {
if [ -n "$DEST_NAME" ]; then if [ -n "$DEST_NAME" ]; then
dests=$IPKG_ROOT dests=$IPKG_ROOT
else else
dests=`ipkg_dests_all` dests="`ipkg_dests_all`"
fi fi
for dest in $dests; do for dest in $dests; do
if [ -f $dest/$IPKG_DIR_PREFIX/info/$pkg.list ]; then 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 sed -e "s/^/$dest_sed/" < $dest/$IPKG_DIR_PREFIX/info/$pkg.list
fi fi
done done
@ -453,15 +453,15 @@ ipkg_search() {
local pattern="$1" local pattern="$1"
for dest_name in `ipkg_dest_names`; do for dest_name in `ipkg_dest_names`; do
dest=`ipkg_dest_byname $dest_name` dest="`ipkg_dest_byname $dest_name`"
dest_sed=`echo $dest | ipkg_protect_slashes` dest_sed="`echo $dest | ipkg_protect_slashes`"
set +o noglob 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 set -o noglob
for file in $list_files; do for file in $list_files; do
if sed "s/^/$dest_sed/" $file | grep -q $pattern; then 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)" [ "$dest_name" != `ipkg_dest_default_name` ] && pkg="$pkg ($dest_name)"
sed "s/^/$dest_sed/" $file | grep $pattern | sed "s/^/$pkg: /" sed "s/^/$dest_sed/" $file | grep $pattern | sed "s/^/$pkg: /"
fi fi
@ -510,10 +510,10 @@ ipkg_status_update() {
ipkg_unsatisfied_dependences() { ipkg_unsatisfied_dependences() {
local pkg=$1 local pkg=$1
local deps=`ipkg_get_depends $pkg` local deps="`ipkg_get_depends $pkg`"
local remaining_deps= local remaining_deps=
for dep in $deps; do for dep in $deps; do
local installed=`ipkg_get_installed $dep` local installed="`ipkg_get_installed $dep`"
if [ "$installed" != "installed" ] ; then if [ "$installed" != "installed" ] ; then
remaining_deps="$remaining_deps $dep" remaining_deps="$remaining_deps $dep"
fi fi
@ -524,35 +524,35 @@ ipkg_unsatisfied_dependences() {
ipkg_safe_pkg_name() { ipkg_safe_pkg_name() {
local pkg=$1 local pkg=$1
local spkg=`echo pkg_$pkg | sed -e y/-+./___/` local spkg="`echo pkg_$pkg | sed -e y/-+./___/`"
echo $spkg echo $spkg
} }
ipkg_set_depends() { ipkg_set_depends() {
local pkg=$1; shift local pkg=$1; shift
local new_deps="$*" local new_deps="$*"
pkg=`ipkg_safe_pkg_name $pkg` pkg="`ipkg_safe_pkg_name $pkg`"
## setvar ${pkg}_depends "$new_deps" ## setvar ${pkg}_depends "$new_deps"
echo $new_deps > /tmp/ipkg/${pkg}.depends echo $new_deps > /tmp/ipkg/${pkg}.depends
} }
ipkg_get_depends() { ipkg_get_depends() {
local pkg=$1 local pkg=$1
pkg=`ipkg_safe_pkg_name $pkg` pkg="`ipkg_safe_pkg_name $pkg`"
cat /tmp/ipkg/${pkg}.depends cat /tmp/ipkg/${pkg}.depends
## eval "echo \$${pkg}_depends" ## eval "echo \$${pkg}_depends"
} }
ipkg_set_installed() { ipkg_set_installed() {
local pkg=$1 local pkg=$1
pkg=`ipkg_safe_pkg_name $pkg` pkg="`ipkg_safe_pkg_name $pkg`"
echo installed > /tmp/ipkg/${pkg}.installed echo installed > /tmp/ipkg/${pkg}.installed
## setvar ${pkg}_installed "installed" ## setvar ${pkg}_installed "installed"
} }
ipkg_set_uninstalled() { ipkg_set_uninstalled() {
local pkg=$1 local pkg=$1
pkg=`ipkg_safe_pkg_name $pkg` pkg="`ipkg_safe_pkg_name $pkg`"
### echo ipkg_set_uninstalled $pkg > /dev/console ### echo ipkg_set_uninstalled $pkg > /dev/console
echo uninstalled > /tmp/ipkg/${pkg}.installed echo uninstalled > /tmp/ipkg/${pkg}.installed
## setvar ${pkg}_installed "uninstalled" ## setvar ${pkg}_installed "uninstalled"
@ -560,7 +560,7 @@ ipkg_set_uninstalled() {
ipkg_get_installed() { ipkg_get_installed() {
local pkg=$1 local pkg=$1
pkg=`ipkg_safe_pkg_name $pkg` pkg="`ipkg_safe_pkg_name $pkg`"
if [ -f /tmp/ipkg/${pkg}.installed ]; then if [ -f /tmp/ipkg/${pkg}.installed ]; then
cat /tmp/ipkg/${pkg}.installed cat /tmp/ipkg/${pkg}.installed
fi fi
@ -570,7 +570,7 @@ ipkg_get_installed() {
ipkg_depends() { ipkg_depends() {
local new_pkgs="$*" local new_pkgs="$*"
local all_deps= 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 for pkg in $installed_pkgs; do
ipkg_set_installed $pkg ipkg_set_installed $pkg
done done
@ -626,7 +626,7 @@ ipkg_get_install_dest() {
local info_dir=$sd/info local info_dir=$sd/info
local requested_pkgs="$*" local requested_pkgs="$*"
local pkgs=`ipkg_depends $*` local pkgs="`ipkg_depends $*`"
mkdir -p $info_dir mkdir -p $info_dir
for pkg in $pkgs; do for pkg in $pkgs; do
@ -644,14 +644,14 @@ Status: install ok not-installed" | ipkg_status_update_sd $sd $pkg
curcheck=0 curcheck=0
## echo "pkgs to install: {$pkgs}" > /dev/console ## echo "pkgs to install: {$pkgs}" > /dev/console
for pkg in $pkgs; do for pkg in $pkgs; do
curcheck=`expr $curcheck + 1` curcheck="`expr $curcheck + 1`"
local is_installed=`ipkg_get_installed $pkg` local is_installed="`ipkg_get_installed $pkg`"
if [ "$is_installed" = "installed" ]; then if [ "$is_installed" = "installed" ]; then
echo "$pkg is installed" > /dev/console echo "$pkg is installed" > /dev/console
continue continue
fi fi
local remaining_deps=`ipkg_unsatisfied_dependences $pkg` local remaining_deps="`ipkg_unsatisfied_dependences $pkg`"
if [ -n "$remaining_deps" ]; then if [ -n "$remaining_deps" ]; then
new_pkgs="$new_pkgs $pkg" new_pkgs="$new_pkgs $pkg"
### echo "Dependences not satisfied for $pkg: $remaining_deps" ### echo "Dependences not satisfied for $pkg: $remaining_deps"
@ -663,7 +663,7 @@ Status: install ok not-installed" | ipkg_status_update_sd $sd $pkg
local filename= local filename=
for src in `ipkg_src_names`; do for src in `ipkg_src_names`; do
if ipkg_require_list $src; then 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 [ -n "$filename" ] && break
fi fi
done done
@ -691,7 +691,7 @@ Status: install ok not-installed" | ipkg_status_update_sd $sd $pkg
fi fi
ipkg_set_installed $pkg ipkg_set_installed $pkg
pkgs_installed=`expr $pkgs_installed + 1` pkgs_installed="`expr $pkgs_installed + 1`"
rm $tmp_pkg_file rm $tmp_pkg_file
done done
### echo "Installed $pkgs_installed package(s) this round" ### echo "Installed $pkgs_installed package(s) this round"
@ -722,8 +722,8 @@ ipkg_install_file_dest() {
return 1 return 1
fi fi
local pkg=`ipkg_file_part $filename | sed 's/\([a-z0-9.+-]\+\)_.*/\1/'` local pkg="`ipkg_file_part $filename | sed 's/\([a-z0-9.+-]\+\)_.*/\1/'`"
local ext=`echo $filename | sed 's/.*\.//'` local ext="`echo $filename | sed 's/.*\.//'`"
local pkg_extract_stdout local pkg_extract_stdout
if [ "$ext" = "ipk" ]; then if [ "$ext" = "ipk" ]; then
pkg_extract_stdout="tar -xzOf" pkg_extract_stdout="tar -xzOf"
@ -735,7 +735,7 @@ ipkg_install_file_dest() {
fi fi
# Check dependencies # 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 # Don't worry about deps that are scheduled for installation
local missing_deps= local missing_deps=
@ -784,7 +784,7 @@ Status: install ok pending" | ipkg_status_update_sd $sd $pkg
echo -n "Unpacking $pkg..." echo -n "Unpacking $pkg..."
set +o noglob set +o noglob
for file in $IPKG_TMP/$pkg/control/*; do 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 mv $file $info_dir/$pkg.$base_file
done done
set -o noglob set -o noglob
@ -807,7 +807,7 @@ Status: install ok pending" | ipkg_status_update_sd $sd $pkg
fi fi
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= local new_conffiles=
if [ -f "$info_dir/$pkg.conffiles" ]; then if [ -f "$info_dir/$pkg.conffiles" ]; then
for conffile in `cat $info_dir/$pkg.conffiles`; do for conffile in `cat $info_dir/$pkg.conffiles`; do
@ -844,20 +844,20 @@ diff -u $dest/$conffile $IPKG_TMP/$pkg/data/$conffile"
done done
fi fi
if [ -n "$use_maintainers_conffile" ]; then 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" new_conffiles="$new_conffiles $conffile $md5sum"
else else
new_conffiles="$new_conffiles $conffile <custom>" new_conffiles="$new_conffiles $conffile <custom>"
rm $IPKG_TMP/$pkg/data/$conffile rm $IPKG_TMP/$pkg/data/$conffile
fi fi
else 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" new_conffiles="$new_conffiles $conffile $md5sum"
fi fi
done done
fi fi
local owd=`pwd` local owd="`pwd`"
(cd $IPKG_TMP/$pkg/data/; tar cf - . | (cd $owd; cd $dest; tar xf -)) (cd $IPKG_TMP/$pkg/data/; tar cf - . | (cd $owd; cd $dest; tar xf -))
rm -rf $IPKG_TMP/$pkg/data rm -rf $IPKG_TMP/$pkg/data
rmdir $IPKG_TMP/$pkg rmdir $IPKG_TMP/$pkg
@ -870,7 +870,7 @@ diff -u $dest/$conffile $IPKG_TMP/$pkg/data/$conffile"
if [ -n "$new_conffiles" ]; then if [ -n "$new_conffiles" ]; then
new_conffiles='Conffiles: '`echo $new_conffiles | ipkg_protect_slashes` new_conffiles='Conffiles: '`echo $new_conffiles | ipkg_protect_slashes`
fi 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\\ sed -e "s/\(Package:.*\)/\1\\
Status: install ok installed\\ Status: install ok installed\\
Root: ${sed_safe_root}\\ Root: ${sed_safe_root}\\
@ -925,7 +925,7 @@ ipkg_install_pending() {
if [ -d "$IPKG_PENDING_DIR" ]; then if [ -d "$IPKG_PENDING_DIR" ]; then
set +o noglob 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 set -o noglob
if [ -n "$pending" ]; then if [ -n "$pending" ]; then
echo "The following packages in $IPKG_PENDING_DIR will now be installed:" echo "The following packages in $IPKG_PENDING_DIR will now be installed:"
@ -941,7 +941,7 @@ ipkg_install_pending() {
} }
ipkg_install_wanted() { 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 if [ -n "$wanted" ]; then
echo "The following package were previously requested but have not been installed:" echo "The following package were previously requested but have not been installed:"
@ -967,13 +967,13 @@ ipkg_install_wanted() {
ipkg_upgrade_pkg() { ipkg_upgrade_pkg() {
local pkg="$1" 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= is_installed=
for dest_name in `ipkg_dest_names`; do 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 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 if [ -n "$inst_ver" ]; then
is_installed=t is_installed=t
@ -984,7 +984,7 @@ ipkg_upgrade_pkg() {
if [ "$avail_ver" = "$inst_ver" ]; then if [ "$avail_ver" = "$inst_ver" ]; then
echo "Package $pkg ($inst_ver) installed in $dest_name is up to date" echo "Package $pkg ($inst_ver) installed in $dest_name is up to date"
elif ipkg-compare-versions $avail_ver '>>' $inst_ver; then elif [ "$avail_ver" -gt "$inst_ver" ]; then
echo "Upgrading $pkg ($dest_name) from $inst_ver to $avail_ver" echo "Upgrading $pkg ($dest_name) from $inst_ver to $avail_ver"
ipkg_get_install_dest $dest $pkg ipkg_get_install_dest $dest $pkg
else else
@ -1002,7 +1002,7 @@ ipkg_upgrade_pkg() {
ipkg_upgrade() { ipkg_upgrade() {
if [ $# -lt 1 ]; then if [ $# -lt 1 ]; then
local pkgs=`ipkg_status_matching 'Status:.*[[:space:]]installed'` local pkgs="`ipkg_status_matching 'Status:.*[[:space:]]installed'`"
else else
pkgs="$*" pkgs="$*"
fi fi
@ -1029,14 +1029,14 @@ ipkg_remove_pkg_dest() {
echo "ipkg_remove: Removing $pkg... " echo "ipkg_remove: Removing $pkg... "
local files=`cat $info_dir/$pkg.list` local files="`cat $info_dir/$pkg.list`"
export PKG_ROOT=$dest export PKG_ROOT=$dest
if [ -x "$info_dir/$pkg.prerm" ]; then if [ -x "$info_dir/$pkg.prerm" ]; then
$info_dir/$pkg.prerm remove $info_dir/$pkg.prerm remove
fi 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= local dirs_to_remove=
for file in $files; do for file in $files; do