tazpkg rev 575

tazpkg: restore user mirror selection
author Richard Dunbar <mojo@slitaz.org>
date Sun Mar 25 00:30:57 2012 +0000 (2012-03-25)
parents 456401591663
children 915b983a7f6d
files tazpkg
line diff
     1.1 --- a/tazpkg	Fri Mar 23 00:50:13 2012 -0300
     1.2 +++ b/tazpkg	Sun Mar 25 00:30:57 2012 +0000
     1.3 @@ -398,7 +398,7 @@
     1.4  	shift
     1.5  	for i in $mirrors; do
     1.6  		case "$i" in
     1.7 -		http://*|ftp://*) wget -c $i/$@ && break;;
     1.8 +		http://*|ftp://*) wget -c $i$@ && break;;
     1.9  		*) ln -sf $i/$1 . && break;;
    1.10  		esac
    1.11  	done
    1.12 @@ -2280,15 +2280,10 @@
    1.13  		for path in $repository_to_recharge; do
    1.14  			[ -f $path/mirror ] || continue
    1.15  			cd $path
    1.16 -
    1.17 -			# We use 'head -1' instead of 'cat' because previous versions of
    1.18 -			# tazpkg filled mirror file with several entries, but we want only
    1.19 -			# one.
    1.20 -			primary_mirror=$(head -1 mirror)
    1.21 -
    1.22 +			
    1.23  			# Quietly check if recharging is needed.
    1.24  			[ -f ID ] && mv ID ID.bak
    1.25 -			download_from $primary_mirror ID >/dev/null 2>/dev/null
    1.26 +			download_from "$(cat mirror)" ID >/dev/null 2>/dev/null
    1.27  			if [ -f ID ] && fgrep -q `cat ID.bak 2>/dev/null || echo "null"` ID; then
    1.28  				if [ "$path" = "$LOCALSTATE" ]; then
    1.29  					repository_name=Main
    1.30 @@ -2304,9 +2299,9 @@
    1.31  			if [ -f ID ]; then
    1.32  				mv -f ID ID.bak
    1.33  				cat ID.bak > ID
    1.34 +                                rm ID.bak
    1.35  			fi
    1.36 -			rm ID.bak
    1.37 -
    1.38 +			
    1.39  			echo ""
    1.40  			if [ "$path" != "$LOCALSTATE" ]; then
    1.41  				echo -e "`gettext \"Recharging undigest\"` $(basename $path):"
    1.42 @@ -2323,12 +2318,19 @@
    1.43  				status
    1.44  			fi
    1.45  
    1.46 -			for i in desc md5 txt list equiv; do
    1.47 -				download_from $primary_mirror packages.$i
    1.48 +                        for i in desc md5 txt list equiv; do
    1.49 +				download_from "$(cat mirror)" packages.$i
    1.50  			done
    1.51  
    1.52 -			download_from $primary_mirror files.list.lzma
    1.53 -
    1.54 +			download_from "$(cat mirror)" files.list.lzma
    1.55 +                                 
    1.56 +                        download_from "$(sed 's|packages/.*||' < mirror)" mirrors
    1.57 +    		        [ -f mirrors ] || mv mirrors.bak mirrors 2> /dev/null
    1.58 +         		suffix=$(head -1 mirror)
    1.59 +        		suffix=packages${suffix#*/packages}
    1.60 +        		for i in $(cat mirrors 2> /dev/null); do
    1.61 +        		fgrep -qs $i mirror || echo $i$suffix >> mirror
    1.62 +        		done
    1.63  			if [ -f "packages.list.bak" ]; then
    1.64  				diff -u packages.list.bak packages.list | grep ^+[a-z] > packages.diff
    1.65  				sed -i s/+// packages.diff