# HG changeset patch # User Antoine Bodin # Date 1296523308 -3600 # Node ID 18c7dbaf6632966386cf0eef70bcb555024d189e # Parent 2f4f55db2600e11431d2e7e88cd29e035288b16e A cache dir for each repo & fixed md5sum check diff -r 2f4f55db2600 -r 18c7dbaf6632 tazpkg --- a/tazpkg Fri Jan 28 23:03:37 2011 +0100 +++ b/tazpkg Tue Feb 01 02:21:48 2011 +0100 @@ -53,6 +53,7 @@ TOP_DIR=`pwd` TMP_DIR=$tmp/$RANDOM INSTALL_LIST="" +SAVE_CACHE_DIR="$CACHE_DIR" # Path to tazpkg used dir and configuration files INSTALLED=$LOCALSTATE/installed @@ -232,6 +233,21 @@ fi } +get_cache_dir() +{ + echo $rep > $tmp/rep + if [ "$rep" = /var/lib/tazpkg ]; then + CACHE_DIR="$SAVE_CACHE_DIR/$SLITAZ_VERSION/packages" + elif [ "${rep%-incoming}" = "$rep" ]; then + CACHE_DIR="$SAVE_CACHE_DIR/${rep##*/}/packages" + else + rep="${rep%-incoming}" + CACHE_DIR="$SAVE_CACHE_DIR/${rep##*/}/packages-incoming" + fi + [ -d "$CACHE_DIR" ] || mkdir -p $CACHE_DIR + echo $CACHE_DIR > $tmp/cachedir +} + # get an already installed package from packages.equiv equivalent_pkg() { @@ -297,7 +313,7 @@ $rep/packages.list | head -1) [ "$pkg" ] || pkg=$(grep -sh "^$1-.[\.0-9]" \ $rep/packages.list | head -1) - [ "$pkg" ] && break + [ "$pkg" ] && get_cache_dir && break done if [ -z "$pkg" ]; then # Check for vitual package @@ -319,9 +335,12 @@ local filename local check_only check_only="$1" - filename=$(get_package_filename $PACKAGE) - if [ -n "$filename" ]; then + filename=`get_package_filename $PACKAGE` + if [ "$filename" ]; then PACKAGE=$filename + CACHE_DIR=$(cat $tmp/cachedir) + rep=$(cat $tmp/rep) + rm -f $tmp/rep $tmp/cachedir else echo "" eval_gettext "Unable to find: \$PACKAGE in the mirrored packages list."; echo @@ -2609,19 +2628,18 @@ [ "$root" ] && ROOT="$root" && check_dir "$root" [ "$list" ] && INSTALL_LIST="$list" AUTOEXEC="no" - if ! check_for_package_in_list check; then - PACKAGE=get-$PACKAGE + check_for_package_in_list check || { PACKAGE=get-$PACKAGE AUTOEXEC=$PACKAGE check_for_package_in_list if [ -n "$(get_installed_package_pathname $PACKAGE $ROOT)" ]; then + CACHE_DIR="${CACHE_DIR%/*}/get" + [ -d "$CACHE_DIR" ] || mkdir -p $CACHE_DIR $AUTOEXEC $ROOT exit 0 fi - fi + } # Check if forced install. - if [ "$DO_CHECK" = "no" ]; then - rm -f $CACHE_DIR/$PACKAGE.tazpkg - else + if ! [ "$DO_CHECK" = "no" ]; then check_for_installed_package $ROOT fi cd $CACHE_DIR @@ -2632,7 +2650,7 @@ eval_gettext "Continuing \$PACKAGE download"; echo download $PACKAGE.tazpkg } - if [ "$(md5sum $PACKAGE.tazpkg)" != "$(fgrep " $PACKAGE.tazpkg" /var/lib/tazpkg/packages.md5)" ]; then + if [ "$(md5sum $PACKAGE.tazpkg)" != "$(fgrep " $PACKAGE.tazpkg" $rep/packages.md5)" ]; then rm -f $PACKAGE.tazpkg download $PACKAGE.tazpkg fi