busybox: Fix build on OSX/BSD (fix needs to be cleaned up.)
[openwrt.git] / scripts / ipkg
index dd44dd6..311f3ab 100755 (executable)
@@ -32,6 +32,8 @@ ipkg_is_upgrade () {
   return 1
 }         
 
   return 1
 }         
 
+which md5sum 2>&1 >/dev/null || alias md5sum=md5
+
 ipkg_srcs() {
        local srcre="$1"
        sed -ne "s/^src[[:space:]]\+$srcre[[:space:]]\+//p" < $IPKG_CONF
 ipkg_srcs() {
        local srcre="$1"
        sed -ne "s/^src[[:space:]]\+$srcre[[:space:]]\+//p" < $IPKG_CONF
@@ -43,7 +45,7 @@ ipkg_src_names() {
 
 ipkg_src_byname() {
        local src="$1"
 
 ipkg_src_byname() {
        local src="$1"
-       ipkg_srcs $src | head -1
+       ipkg_srcs $src | head -1
 }
 
 ipkg_dests() {
 }
 
 ipkg_dests() {
@@ -68,16 +70,16 @@ ipkg_state_dirs() {
 }
 
 ipkg_dest_default() {
 }
 
 ipkg_dest_default() {
-       ipkg_dests_all | head -1
+       ipkg_dests_all | head -1
 }
 
 ipkg_dest_default_name() {
 }
 
 ipkg_dest_default_name() {
-       ipkg_dest_names | head -1
+       ipkg_dest_names | head -1
 }
 
 ipkg_dest_byname() {
        local dest="$1"
 }
 
 ipkg_dest_byname() {
        local dest="$1"
-       ipkg_dests $dest | head -1
+       ipkg_dests $dest | head -1
 }
 
 ipkg_option() {
 }
 
 ipkg_option() {
@@ -117,7 +119,11 @@ Valid destinations are directories or one of the dest names from $IPKG_CONF:" >&
        IPKG_DIR_PREFIX=usr/lib/ipkg
        IPKG_LISTS_DIR=$IPKG_OFFLINE_ROOT/$IPKG_DIR_PREFIX/lists
        IPKG_PENDING_DIR=$IPKG_OFFLINE_ROOT/$IPKG_DIR_PREFIX/pending
        IPKG_DIR_PREFIX=usr/lib/ipkg
        IPKG_LISTS_DIR=$IPKG_OFFLINE_ROOT/$IPKG_DIR_PREFIX/lists
        IPKG_PENDING_DIR=$IPKG_OFFLINE_ROOT/$IPKG_DIR_PREFIX/pending
-       IPKG_TMP=$IPKG_ROOT/tmp/ipkg
+       if [ -z "$IPKG_TMP" ]; then
+               IPKG_TMP=$IPKG_ROOT/tmp/ipkg
+       fi
+
+       [ -e "$IPKG_TMP" ] || mkdir -p $IPKG_TMP
 
        # Destination specific ipkg meta-data directory
        IPKG_STATE_DIR=$IPKG_ROOT/$IPKG_DIR_PREFIX
 
        # Destination specific ipkg meta-data directory
        IPKG_STATE_DIR=$IPKG_ROOT/$IPKG_DIR_PREFIX
@@ -228,7 +234,6 @@ ipkg_download() {
                proxyoption="--proxy=on"
        fi
 
                proxyoption="--proxy=on"
        fi
 
-       echo "Downloading $src ..."
        rm -f $IPKG_TMP/$src_file
        case "$src" in
        http://* | ftp://*)
        rm -f $IPKG_TMP/$src_file
        case "$src" in
        http://* | ftp://*)
@@ -246,7 +251,6 @@ ipkg_download() {
                ;;
        esac
 
                ;;
        esac
 
-       echo "Done."
        return 0
 }
 
        return 0
 }
 
@@ -546,20 +550,20 @@ ipkg_set_depends() {
        local new_deps="$*"
        pkg="`ipkg_safe_pkg_name $pkg`"
        ## setvar ${pkg}_depends "$new_deps"
        local new_deps="$*"
        pkg="`ipkg_safe_pkg_name $pkg`"
        ## setvar ${pkg}_depends "$new_deps"
-       echo $new_deps > /tmp/ipkg/${pkg}.depends
+       echo $new_deps > $IPKG_TMP/${pkg}.depends
 }
 
 ipkg_get_depends() {
        local pkg=$1
        pkg="`ipkg_safe_pkg_name $pkg`"
 }
 
 ipkg_get_depends() {
        local pkg=$1
        pkg="`ipkg_safe_pkg_name $pkg`"
-       cat /tmp/ipkg/${pkg}.depends
+       cat $IPKG_TMP/${pkg}.depends
        ## eval "echo \$${pkg}_depends"
 }
 
 ipkg_set_installed() {
        local pkg=$1
        pkg="`ipkg_safe_pkg_name $pkg`"
        ## eval "echo \$${pkg}_depends"
 }
 
 ipkg_set_installed() {
        local pkg=$1
        pkg="`ipkg_safe_pkg_name $pkg`"
-       echo installed > /tmp/ipkg/${pkg}.installed
+       echo installed > $IPKG_TMP/${pkg}.installed
        ## setvar ${pkg}_installed "installed"
 }
 
        ## setvar ${pkg}_installed "installed"
 }
 
@@ -567,15 +571,15 @@ ipkg_set_uninstalled() {
        local pkg=$1
        pkg="`ipkg_safe_pkg_name $pkg`"
        ### echo ipkg_set_uninstalled $pkg > /dev/console
        local pkg=$1
        pkg="`ipkg_safe_pkg_name $pkg`"
        ### echo ipkg_set_uninstalled $pkg > /dev/console
-       echo uninstalled > /tmp/ipkg/${pkg}.installed
+       echo uninstalled > $IPKG_TMP/${pkg}.installed
        ## setvar ${pkg}_installed "uninstalled"
 }
 
 ipkg_get_installed() {
        local pkg=$1
        pkg="`ipkg_safe_pkg_name $pkg`"
        ## setvar ${pkg}_installed "uninstalled"
 }
 
 ipkg_get_installed() {
        local pkg=$1
        pkg="`ipkg_safe_pkg_name $pkg`"
-       if [ -f /tmp/ipkg/${pkg}.installed ]; then
-               cat /tmp/ipkg/${pkg}.installed
+       if [ -f $IPKG_TMP/${pkg}.installed ]; then
+               cat $IPKG_TMP/${pkg}.installed
        fi
        ## eval "echo \$${pkg}_installed"
 }
        fi
        ## eval "echo \$${pkg}_installed"
 }
@@ -603,8 +607,7 @@ s/ \+/ /g'`
                        ipkg_set_depends $pkg $new_deps
                done
 
                        ipkg_set_depends $pkg $new_deps
                done
 
-               new_deps=`echo $new_deps | sed -e 's/[[:space:]]\+/\\
-/g' | sort | uniq`
+               new_deps=`echo $new_deps | sed -e 's/[[:space:]]\+/\n/g' | sort | uniq`
 
                local maybe_new_pkgs=
                for pkg in $new_deps; do
 
                local maybe_new_pkgs=
                for pkg in $new_deps; do
@@ -660,7 +663,7 @@ Status: install ok not-installed" | ipkg_status_update_sd $sd $pkg
                        curcheck="`expr $curcheck + 1`"
                        local is_installed="`ipkg_get_installed $pkg`"
                        if [ "$is_installed" = "installed" ]; then
                        curcheck="`expr $curcheck + 1`"
                        local is_installed="`ipkg_get_installed $pkg`"
                        if [ "$is_installed" = "installed" ]; then
-                               echo "$pkg is installed" > /dev/console
+                               echo "$pkg is installed"
                                continue
                        fi
 
                                continue
                        fi
 
@@ -688,9 +691,6 @@ Status: install ok not-installed" | ipkg_status_update_sd $sd $pkg
                                return 1;
                        fi
 
                                return 1;
                        fi
 
-                       [ -e "$IPKG_TMP" ] || mkdir -p $IPKG_TMP
-
-                       echo ""
                        local tmp_pkg_file="$IPKG_TMP/"`ipkg_file_part $filename`
                        if ! ipkg_download `ipkg_src_byname $src`/$filename $tmp_pkg_file; then
                                echo "ipkg_get_install: Perhaps you need to run \`ipkg update'?"
                        local tmp_pkg_file="$IPKG_TMP/"`ipkg_file_part $filename`
                        if ! ipkg_download `ipkg_src_byname $src`/$filename $tmp_pkg_file; then
                                echo "ipkg_get_install: Perhaps you need to run \`ipkg update'?"
@@ -785,7 +785,7 @@ ipkg_install_file_dest() {
                        echo "Package: $pkg
 Status: install ok pending" | ipkg_status_update_sd $sd $pkg
                        mkdir -p $IPKG_PENDING_DIR
                        echo "Package: $pkg
 Status: install ok pending" | ipkg_status_update_sd $sd $pkg
                        mkdir -p $IPKG_PENDING_DIR
-                       cp $filename $IPKG_PENDING_DIR
+                       cp -f $filename $IPKG_PENDING_DIR
                        rm -r $IPKG_TMP/$pkg/control
                        rm -r $IPKG_TMP/$pkg/data
                        rmdir $IPKG_TMP/$pkg
                        rm -r $IPKG_TMP/$pkg/control
                        rm -r $IPKG_TMP/$pkg/data
                        rmdir $IPKG_TMP/$pkg
@@ -904,7 +904,6 @@ ipkg_install_file() {
 }
 
 ipkg_install() {
 }
 
 ipkg_install() {
-
        while [ $# -gt 0 ]; do
                local pkg="$1"
                shift
        while [ $# -gt 0 ]; do
                local pkg="$1"
                shift
@@ -922,11 +921,7 @@ ipkg_install() {
                                ipkg_install_file $ipkg_filename
                        ;;
                *.ipk  | *.deb)
                                ipkg_install_file $ipkg_filename
                        ;;
                *.ipk  | *.deb)
-                       if [ -f "$pkg" ]; then
                                ipkg_install_file $pkg
                                ipkg_install_file $pkg
-                       else
-                               echo "File not found $pkg" >&2
-                       fi
                        ;;
                *)
                        ipkg_get_install $pkg || true
                        ;;
                *)
                        ipkg_get_install $pkg || true
@@ -982,7 +977,7 @@ ipkg_install_wanted() {
 
 ipkg_upgrade_pkg() {
        local pkg="$1"
 
 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
 
        is_installed=
        for dest_name in `ipkg_dest_names`; do
This page took 0.026622 seconds and 4 git commands to generate.