tazpkg rev 546

Fix a bug that made tazpkg recharge slow
author Antoine Bodin <gokhlayeh@slitaz.org>
date Wed Feb 29 22:40:10 2012 +0100 (2012-02-29)
parents dfa04e57282f
children 2ed3cb7631cd
files tazpkg
line diff
     1.1 --- a/tazpkg	Wed Feb 29 20:27:20 2012 +0100
     1.2 +++ b/tazpkg	Wed Feb 29 22:40:10 2012 +0100
     1.3 @@ -2268,9 +2268,14 @@
     1.4  			[ -f $path/mirror ] || continue
     1.5  			cd $path
     1.6  
     1.7 +			# We use 'head -1' instead of 'cat' because previous versions of
     1.8 +			# tazpkg filled mirror file with several entries, but we want only
     1.9 +			# one.
    1.10 +			primary_mirror=$(head -1 mirror)
    1.11 +
    1.12  			# Quietly check if recharging is needed.
    1.13  			[ -f ID ] && mv ID ID.bak
    1.14 -			download_from "$(cat mirror)" ID >/dev/null 2>/dev/null
    1.15 +			download_from $primary_mirror ID >/dev/null 2>/dev/null
    1.16  			if [ -f ID ] && fgrep -q `cat ID.bak 2>/dev/null || echo "null"` ID; then
    1.17  				if [ "$path" = "$LOCALSTATE" ]; then
    1.18  					repository_name=Main
    1.19 @@ -2304,27 +2309,29 @@
    1.20  				done
    1.21  				status
    1.22  			fi
    1.23 +
    1.24 +			# Make sure we use the first mirror of mirrors list.
    1.25 +			download_from ${primary_mirror%%packages/*} mirrors
    1.26 +			[ -f mirrors ] || mv mirrors.bak mirrors 2> /dev/null
    1.27 +			if [ -s mirrors ]; then
    1.28 +				primary_mirror="$(head -1 mirrors)packages${primary_mirror#*/packages}"
    1.29 +				echo $primary_mirror > mirror
    1.30 +			fi
    1.31 +
    1.32  			for i in desc md5 txt list equiv; do
    1.33 -				download_from "$(cat mirror)" packages.$i
    1.34 +				download_from $primary_mirror packages.$i
    1.35  			done
    1.36 -			
    1.37 -			download_from "$(cat mirror)" files.list.lzma
    1.38 -			
    1.39 +
    1.40 +			download_from $primary_mirror files.list.lzma
    1.41 +
    1.42  			# ID file & wanted/depends/libraries files were implemented
    1.43  			# at the same time. Not all repositories have them.
    1.44  			if [ -f ID ]; then
    1.45  				for i in wanted depends libraries; do
    1.46 -					download_from "$(cat mirror)" $i.txt
    1.47 +					download_from $primary_mirror $i.txt
    1.48  				done
    1.49  			fi
    1.50  
    1.51 -			download_from "$(sed 's|packages/.*||' < mirror)" mirrors
    1.52 -			[ -f mirrors ] || mv mirrors.bak mirrors 2> /dev/null
    1.53 -			suffix=$(head -1 mirror)
    1.54 -			suffix=packages${suffix#*/packages}
    1.55 -			for i in $(cat mirrors 2> /dev/null); do
    1.56 -				fgrep -qs $i mirror || echo $i$suffix >> mirror
    1.57 -			done
    1.58  			if [ -f "packages.list.bak" ]; then
    1.59  				diff -u packages.list.bak packages.list | grep ^+[a-z] > packages.diff
    1.60  				sed -i s/+// packages.diff