tazpkg diff modules/recharge @ rev 840

Add a bunch of modules with new-style support of 'root' (not all commands are modules yet); strip and compress resources.
author Aleksej Bobylev <al.bobylev@gmail.com>
date Fri Aug 28 16:10:34 2015 +0300 (2015-08-28)
parents 4fbdffec7f48
children 8a73a58ed3cb
line diff
     1.1 --- a/modules/recharge	Sat Aug 15 17:41:08 2015 +0300
     1.2 +++ b/modules/recharge	Fri Aug 28 16:10:34 2015 +0300
     1.3 @@ -15,31 +15,8 @@
     1.4  # Connect function libraries
     1.5  . /lib/libtaz.sh
     1.6  
     1.7 -
     1.8 -
     1.9 -
    1.10  # Get TazPkg working environment
    1.11 -# ------------------------------
    1.12 -
    1.13 -[ ! -d "$root/etc/slitaz" ] && mkdir -p "$root/etc/slitaz"
    1.14 -[ ! -e "$root/etc/slitaz/slitaz.conf" ] && cp /etc/slitaz/slitaz.conf "$root/etc/slitaz"
    1.15 -[ ! -e "$root/etc/slitaz/tazpkg.conf" ] && cp /etc/slitaz/tazpkg.conf "$root/etc/slitaz"
    1.16 -[ ! -e "$root/etc/slitaz-release" ] && echo 'cooking' > "$root/etc/slitaz-release"
    1.17 -
    1.18 -# Read configuration
    1.19 -if [ -n "$root" ]; then
    1.20 -	# Patch external conf files to correctly handle --root value
    1.21 -	slitaz_conf=$(mktemp); cp "$root/etc/slitaz/slitaz.conf" $slitaz_conf
    1.22 -	tazpkg_conf=$(mktemp); cp "$root/etc/slitaz/tazpkg.conf" $tazpkg_conf
    1.23 -	sed -i "s| /| $root/|g; s|\"/|\"$root/|g" $slitaz_conf $tazpkg_conf
    1.24 -	. $slitaz_conf; . $tazpkg_conf; rm $slitaz_conf $tazpkg_conf
    1.25 -else
    1.26 -	. /etc/slitaz/slitaz.conf; . /etc/slitaz/tazpkg.conf
    1.27 -fi
    1.28 -
    1.29 -# Silent make missing files
    1.30 -mkdir -p "$PKGS_DB"
    1.31 -[ ! -e "$PKGS_DB/mirror" ] && echo "$ONLINE_PKGS" > "$PKGS_DB/mirror"
    1.32 +. @@MODULES@@/getenv
    1.33  
    1.34  
    1.35  
    1.36 @@ -52,7 +29,7 @@
    1.37  get_from_mirror() {
    1.38  	case "$mirror" in
    1.39  		http://* | https://* | ftp://*)
    1.40 -			busybox wget -c -q -T 30 -U $UA "$mirror$1" 2>/dev/null;;
    1.41 +			busybox wget -c -q -T 30 -U "$UA" "$mirror$1" 2>/dev/null;;
    1.42  		*)
    1.43  			ln -sf "$mirror$1" .;;
    1.44  	esac
    1.45 @@ -67,8 +44,8 @@
    1.46  	action 'Restoring database files...'
    1.47  	[ -e 'ID'  -a ! -e 'ID.bak' ]  && rm ID
    1.48  	[ -e 'IDs' -a ! -e 'IDs.bak' ] && rm IDs
    1.49 -	for file in $(ls $1/*.bak); do
    1.50 -		mv -f $file ${file%.bak}
    1.51 +	for file in $(ls "$1"/*.bak); do
    1.52 +		mv -f "$file" "${file%.bak}"
    1.53  	done
    1.54  	status
    1.55  
    1.56 @@ -93,10 +70,10 @@
    1.57  esac
    1.58  
    1.59  for path in $repo_to_recharge; do
    1.60 -	[ ! -f $path/mirror ] && continue	# skip
    1.61 -	cd $path
    1.62 +	[ ! -f "$path/mirror" ] && continue	# skip
    1.63 +	cd "$path"
    1.64  	# Mirror URL will have a trailing slash
    1.65 -	mirror="$(cat mirror)"; mirror="${mirror%/}/"
    1.66 +	mirror=$(cat mirror); mirror="${mirror%/}/"
    1.67  
    1.68  	# Repository name
    1.69  	if [ "$path" == "$PKGS_DB" ]; then
    1.70 @@ -120,7 +97,8 @@
    1.71  	[ -e 'IDs' ] && _ 'Database timestamp: %s' "$(date -d "@$(awk '{print $2}' IDs)" "+%x %R")"
    1.72  
    1.73  	# Check if recharging is needed
    1.74 -	if [ -f 'IDs' ] && cmp -s IDs IDs.bak; then
    1.75 +	if [ -f 'IDs' ] && [ -f 'packages.info' ] && [ -f 'files.list.lzma' ] && \
    1.76 +		cmp -s IDs IDs.bak; then
    1.77  		footer "$(_ 'Repository "%s" is up to date.' "$repo_name")"
    1.78  		rm IDs.bak ID.bak
    1.79  		continue
    1.80 @@ -132,38 +110,39 @@
    1.81  		packages.equiv files.list.lzma extra.list mirrors packages.info; do
    1.82  		[ -f "$i" ] && mv -f $i $i.bak 2>/dev/null
    1.83  	done
    1.84 -	:; status		# Always "[ Done ]"
    1.85 +	# Always "[ Done ]"
    1.86 +	:; status
    1.87  
    1.88  	# Download and extract bundle: extra.list, mirrors, files-list.md5,
    1.89  	#   packages.{info,desc,md5,txt,list,equiv}
    1.90  	bundle='bundle.tar.lzma'
    1.91 -	action 'Getting "%s"...' $bundle
    1.92 -	get_from_mirror $bundle
    1.93 +	action 'Getting "%s"...' "$bundle"
    1.94 +	get_from_mirror "$bundle"
    1.95  	if [ -f "$bundle" ]; then
    1.96 -		busybox tar -xaf $bundle; rm $bundle
    1.97 +		busybox tar -xaf "$bundle"; rm "$bundle"
    1.98  	else
    1.99 -		recharging_failed $path; continue
   1.100 +		recharging_failed "$path"; continue
   1.101  	fi
   1.102  
   1.103  	# Download files.list.lzma
   1.104  	files_local='files.list.lzma'; files_remote='files-list.lzma'
   1.105  	if [ -e "$files_local.bak" ]; then
   1.106 -		md5sum $files_local.bak | awk '{printf $1}' > files-list.md5.bak
   1.107 +		md5sum "$files_local.bak" | awk '{printf $1}' > files-list.md5.bak
   1.108  		if cmp -s files-list.md5 files-list.md5.bak; then
   1.109 -			mv $files_local.bak $files_remote
   1.110 +			mv "$files_local.bak" "$files_remote"
   1.111  		else
   1.112 -			action 'Getting "%s"...' $files_remote
   1.113 -			get_from_mirror $files_remote
   1.114 +			action 'Getting "%s"...' "$files_remote"
   1.115 +			get_from_mirror "$files_remote"
   1.116  		fi
   1.117  	else
   1.118 -		action 'Getting "%s"...' $files_remote
   1.119 -		get_from_mirror $files_remote
   1.120 +		action 'Getting "%s"...' "$files_remote"
   1.121 +		get_from_mirror "$files_remote"
   1.122  	fi
   1.123  
   1.124  	if [ ! -e "$files_remote" ]; then
   1.125 -		recharging_failed $path; continue
   1.126 +		recharging_failed "$path"; continue
   1.127  	fi
   1.128 -	mv -f $files_remote $files_local
   1.129 +	mv -f "$files_remote" "$files_local"
   1.130  
   1.131  	# Remove old database files (but packages.list.bak, extra.list.bak)
   1.132  	for i in packages.desc packages.$SUM packages.txt packages.equiv \
   1.133 @@ -179,7 +158,7 @@
   1.134  		rm packages.list.bak
   1.135  		if [ -f 'extra.list.bak' ]; then
   1.136  			if [ -f 'extra.list' ]; then
   1.137 -				awk -F'|' '{print $1 " (extra)"}' extra.list > extra.list1
   1.138 +				awk -F'|' '{print $1 " (extra)"}' extra.list     > extra.list1
   1.139  				awk -F'|' '{print $1 " (extra)"}' extra.list.bak > extra.list1.bak
   1.140  				diff -u extra.list1.bak extra.list1 | grep ^+[a-z] >> packages.diff
   1.141  				rm extra.list.bak extra.list1 extra.list1.bak
   1.142 @@ -195,7 +174,7 @@
   1.143  			cat packages.diff
   1.144  			footer "$(emsg "$(_p \
   1.145  			'%s new package on the mirror.' \
   1.146 -			'%s new packages on the mirror.' $new_pkgs \
   1.147 +			'%s new packages on the mirror.' "$new_pkgs" \
   1.148  			"<c 32>$new_pkgs</c>")")"
   1.149  		fi
   1.150  	else
   1.151 @@ -204,3 +183,6 @@
   1.152  	fi
   1.153  done
   1.154  newline
   1.155 +
   1.156 +# Close tazpkg-notify
   1.157 +echo "quit" > /tmp/tazpkg-notify.fifo