tazwok diff tazwok @ rev 304

Rework function hgup (now named update-wok); it can handle wok compressed in tarballs, it uses a clean-wok (in LOCAL_REPOSITORY) and only copy clean-wok to main wok if --local option is specified.
author Antoine Bodin <gokhlayeh@slitaz.org>
date Fri Feb 18 01:31:01 2011 +0100 (2011-02-18)
parents d2ec01797dca
children 434b101698f0
line diff
     1.1 --- a/tazwok	Thu Feb 17 00:25:21 2011 +0100
     1.2 +++ b/tazwok	Fri Feb 18 01:31:01 2011 +0100
     1.3 @@ -59,7 +59,7 @@
     1.4    clean-src       Remove old/unrelated-to-wok sources.
     1.5    remove         Remove a package from the wok.
     1.6    webserver      Enable/disable webserver on localhost.
     1.7 -  hgup           Pull and update a wok under Hg.
     1.8 +  update-wok     Update the wok.
     1.9    maintainers    List all maintainers in the wok.
    1.10    maintained-by  List packages maintained by a contributor.
    1.11    tags           List all tags used in wok receipts.\n
    1.12 @@ -123,6 +123,7 @@
    1.13  	# Check commons directories, create them if user is root.
    1.14  	if test $(id -u) = 0 ; then
    1.15  		check_dir $WOK || chmod 777 $WOK
    1.16 +		check_dir $LOCAL_REPOSITORY/clean-wok || chmod 777 $LOCAL_REPOSITORY/clean-wok
    1.17  		check_dir $PACKAGES_REPOSITORY
    1.18  		check_dir $SOURCES_REPOSITORY
    1.19  		check_dir $INCOMING_REPOSITORY
    1.20 @@ -2814,14 +2815,55 @@
    1.21  			echo ""
    1.22  		fi
    1.23  	;;
    1.24 -	hgup)
    1.25 +	update-wok)
    1.26  		# Pull and update a Hg wok.
    1.27 +		get_options_list="local"
    1.28  		get_tazwok_config
    1.29 -		if ls -l $WOK/.hg/hgrc | fgrep -q "root"; then
    1.30 -			check_root
    1.31 +		clean_wok=$LOCAL_REPOSITORY/clean-wok
    1.32 +		cd $clean_wok
    1.33 +		if ! [ "$local" ]; then
    1.34 +			if [ "$WOK_UPDATE_METHOD" = hg ]; then
    1.35 +				if ! [ -f "$INSTALLED/mercurial/receipt" ]; then
    1.36 +
    1.37 +					# Auto-install only if we are in a cook chroot.
    1.38 +					if [ -x /usr/bin/clean-chroot ]; then
    1.39 +						echo "" >&2
    1.40 +						echo "You need to install mercurial	to get wok from hg (recommended). Oherwise, you can switch wok get method to \"tarball\" into $LOCAL_RESOSITORY/tazwok.conf (per-repository configuration, it not always exists) or /etc/slitaz/tazwok.conf (global configuration)." | fold >&2
    1.41 +						echo "">&2
    1.42 +					else
    1.43 +						tazpkg get-install mercurial
    1.44 +					fi
    1.45 +
    1.46 +				fi
    1.47 +				if [ -d .hg ]; then
    1.48 +					hg pull -u || exit 1
    1.49 +				else
    1.50 +					hg clone $HG_WOK . || exit 1
    1.51 +				fi
    1.52 +				[ -x /usr/bin/clean-chroot ] && clean-chroot
    1.53 +			else
    1.54 +				{ mkdir .tmp && cd .tmp
    1.55 +					wget "$TARBALL_WOK" &&
    1.56 +					case $TARBALL_WOK in
    1.57 +						*bz2) tar xjf *.bz2 -C wok; rm *.bz2;;
    1.58 +						*lzma) unlzma -c *.lzma | tar xf - -C wok; rm *.lzma ;;
    1.59 +						*gz) tar xzf *.gz -C wok; rm*.gz ;;
    1.60 +					esac &&
    1.61 +					rm -r $(ls -d $clean_wok/*) &&
    1.62 +					cp -a wok/* $clean_wok &&
    1.63 +					cd .. &&
    1.64 +					rm -r .tmp
    1.65 +				} || { echo "That's not cool: it fails!" >&2
    1.66 +				exit 1; }
    1.67 +			fi
    1.68  		fi
    1.69 -		cd $WOK
    1.70 -		hg pull && hg update
    1.71 +
    1.72 +		# Handle removed packages (removing receipt from wok is enough).
    1.73 +		for dir in $(ls -d $WOK/*); do
    1.74 +			[ -d "$dir" ] || rm $WOK/$dir/receipt
    1.75 +		done
    1.76 +
    1.77 +		cp -a * $WOK
    1.78  	;;
    1.79  	maintainers)
    1.80  		get_tazwok_config