tazwok rev 225

Add nounpack option for get-src & SRC_WANTED variable support
author Antoine Bodin <gokhlayeh@slitaz.org>
date Fri Feb 04 19:36:57 2011 +0100 (2011-02-04)
parents c1c9086a9e31
children ba91b130e283
files tazwok
line diff
     1.1 --- a/tazwok	Thu Feb 03 19:36:57 2011 +0000
     1.2 +++ b/tazwok	Fri Feb 04 19:36:57 2011 +0100
     1.3 @@ -423,6 +423,10 @@
     1.4  # Check for src tarball and wget if needed.
     1.5  check_for_tarball()
     1.6  {
     1.7 +	if [ "$SRC_WANTED" ]; then
     1.8 +		tazwok get-src "$SRC_WANTED" --target=$WOK/$PACKAGE/$PACKAGE-$VERSION || return 1
     1.9 +		return
    1.10 +	fi
    1.11  	if [ "$WGET_URL" ]; then
    1.12  		report step "Checking for source tarball"
    1.13  			
    1.14 @@ -456,81 +460,78 @@
    1.15  		
    1.16  		# Untaring source if necessary. We don't need to extract source if
    1.17  		# the package is built with a wanted source package.
    1.18 -		if [ ! "$WANTED" ]; then
    1.19 -			report step "Untaring source tarball"
    1.20 -			if [ "$target" ]; then
    1.21 -				src="$target"
    1.22 +		if [ "$WANTED" ] || [ "$nounpack" ]; then
    1.23 +			return
    1.24 +		fi
    1.25 +
    1.26 +		report step "Untaring source tarball"
    1.27 +		if [ "$target" ]; then
    1.28 +			src="$target"
    1.29 +		else
    1.30 +			set_src_path
    1.31 +		fi
    1.32 +		if [ ! -d "$src" ]; then
    1.33 +			
    1.34 +			# Log process.
    1.35 +			echo "untaring source tarball" >> $LOG
    1.36 +			
    1.37 +			tmp_src=$WOK/$PACKAGE/tmp-src-$$
    1.38 +			mkdir $tmp_src
    1.39 +			if [ -f "$SOURCES_REPOSITORY/$PACKAGE-$VERSION.tar.lzma" ]; then
    1.40 +				lzma d $SOURCES_REPOSITORY/$PACKAGE-$VERSION.tar.lzma -so | \
    1.41 +					tar xf - -C $tmp_src
    1.42  			else
    1.43 -				set_src_path
    1.44 -			fi
    1.45 -			if [ ! -d "$src" ]; then
    1.46 +				case "$TARBALL" in
    1.47 +					*zip|*xpi) { cd $tmp_src; unzip -o $SOURCES_REPOSITORY/$TARBALL; };;
    1.48 +					*bz2) tar xjf $SOURCES_REPOSITORY/$TARBALL -C $tmp_src;;
    1.49 +					*tar) tar xf $SOURCES_REPOSITORY/$TARBALL -C $tmp_src;;
    1.50 +					*lzma) unlzma -c $SOURCES_REPOSITORY/$TARBALL | tar xf - -C $tmp_src;;
    1.51 +					*xz) unxz -c $SOURCES_REPOSITORY/$TARBALL | tar xf - -C $tmp_src;;
    1.52 +					*Z) uncompress -c $SOURCES_REPOSITORY/$TARBALL | tar xf - -C $tmp_src;;
    1.53 +					*) tar xzf $SOURCES_REPOSITORY/$TARBALL -C $tmp_src;;
    1.54 +				esac || return 1
    1.55  				
    1.56 -				# Log process.
    1.57 -				echo "untaring source tarball" >> $LOG
    1.58 -				
    1.59 -				tmp_src=$WOK/$PACKAGE/tmp-src-$$
    1.60 -				mkdir $tmp_src
    1.61 -				if [ -f "$SOURCES_REPOSITORY/$PACKAGE-$VERSION.tar.lzma" ]; then
    1.62 -					lzma d $SOURCES_REPOSITORY/$PACKAGE-$VERSION.tar.lzma -so | \
    1.63 -						tar xf - -C $tmp_src
    1.64 -				else
    1.65 -					case "$TARBALL" in
    1.66 -						*zip|*xpi) { cd $tmp_src; unzip -o $SOURCES_REPOSITORY/$TARBALL; };;
    1.67 -						*bz2) tar xjf $SOURCES_REPOSITORY/$TARBALL -C $tmp_src;;
    1.68 -						*tar) tar xf $SOURCES_REPOSITORY/$TARBALL -C $tmp_src;;
    1.69 -						*lzma) unlzma -c $SOURCES_REPOSITORY/$TARBALL | tar xf - -C $tmp_src;;
    1.70 -						*xz) unxz -c $SOURCES_REPOSITORY/$TARBALL | tar xf - -C $tmp_src;;
    1.71 -						*Z) uncompress -c $SOURCES_REPOSITORY/$TARBALL | tar xf - -C $tmp_src;;
    1.72 -						*) tar xzf $SOURCES_REPOSITORY/$TARBALL -C $tmp_src;;
    1.73 -					esac || return 1
    1.74 -					
    1.75 -					# Check if uncompressed tarball is in a root dir or not.
    1.76 -					if [ "$(ls -A $tmp_src | wc -l)" -gt 1 ]; then
    1.77 -						if check_for_var_modification src _pkg; then
    1.78 -							mv $tmp_src $tmp_src-1
    1.79 -							mkdir $tmp_src
    1.80 -							mv $tmp_src-1 $tmp_src/$PACKAGE-$VERSION
    1.81 -						else
    1.82 -							mv $tmp_src/* $WOK/$PACKAGE
    1.83 -							repack_src=no
    1.84 -							rm -r $tmp_src
    1.85 -						fi
    1.86 -					fi
    1.87 -					
    1.88 -					if [ "$repack_src" = yes ]; then
    1.89 -						report step "Repacking sources in .tar.lzma format"
    1.90 -						cd $tmp_src
    1.91 -						tar -c * | lzma e $SOURCES_REPOSITORY/$PACKAGE-$VERSION.tar.lzma -si
    1.92 -						rm $SOURCES_REPOSITORY/$TARBALL
    1.93 -						prev_VERSION=$(get_pkg_version $INCOMING_REPOSITORY)
    1.94 -
    1.95 -						# Remove previous tarball if it's not used either by
    1.96 -						# incoming and legacy packages.
    1.97 -						[ "$prev_VERSION" != "$(get_pkg_version $PACKAGES_REPOSITORY)" ] && \
    1.98 -							remove_previous_tarball
    1.99 -
   1.100 -					fi
   1.101 -				fi
   1.102 -				if [ "$1" = "get-src" ]; then
   1.103 -					if [ -d "$tmp_src" ]; then
   1.104 +				# Check if uncompressed tarball is in a root dir or not.
   1.105 +				if [ "$(ls -A $tmp_src | wc -l)" -gt 1 ]; then
   1.106 +					if check_for_var_modification src _pkg; then
   1.107 +						mv $tmp_src $tmp_src-1
   1.108 +						mkdir $tmp_src
   1.109 +						mv $tmp_src-1 $tmp_src/$PACKAGE-$VERSION
   1.110 +					else
   1.111 +						mv $tmp_src/* $WOK/$PACKAGE
   1.112 +						repack_src=no
   1.113  						rm -r $tmp_src
   1.114  					fi
   1.115  				fi
   1.116 -				if [ -d "$tmp_src" ]; then
   1.117 -					if ! check_for_var_modification src _pkg; then
   1.118 -						src="${src%/*}/$(ls $tmp_src)"
   1.119 -					fi
   1.120 -					mv $(echo $tmp_src/*) "$src"
   1.121 -					rm -r $tmp_src
   1.122 -								
   1.123 -					# Permissions settings.
   1.124 -					chown -R root.root "$src"
   1.125 +				
   1.126 +				if [ "$repack_src" = yes ]; then
   1.127 +					report step "Repacking sources in .tar.lzma format"
   1.128 +					cd $tmp_src
   1.129 +					tar -c * | lzma e $SOURCES_REPOSITORY/$PACKAGE-$VERSION.tar.lzma -si
   1.130 +					rm $SOURCES_REPOSITORY/$TARBALL
   1.131 +					prev_VERSION=$(get_pkg_version $INCOMING_REPOSITORY)
   1.132 +
   1.133 +					# Remove previous tarball if it's not used either by
   1.134 +					# incoming and legacy packages.
   1.135 +					[ "$prev_VERSION" != "$(get_pkg_version $PACKAGES_REPOSITORY)" ] && \
   1.136 +						remove_previous_tarball
   1.137 +
   1.138  				fi
   1.139 -			else
   1.140 -				echo "There's already something at $src. Abord." >&2
   1.141  			fi
   1.142 -			report end-step
   1.143 +			if [ -d "$tmp_src" ]; then
   1.144 +				if ! check_for_var_modification src _pkg; then
   1.145 +					src="${src%/*}/$(ls $tmp_src)"
   1.146 +				fi
   1.147 +				mv $(echo $tmp_src/*) "$src"
   1.148 +				rm -r $tmp_src
   1.149 +							
   1.150 +				# Permissions settings.
   1.151 +				chown -R root.root "$src"
   1.152 +			fi
   1.153 +		else
   1.154 +			echo "There's already something at $src. Abord." >&2
   1.155  		fi
   1.156 +		report end-step
   1.157  	fi
   1.158  }
   1.159  
   1.160 @@ -2604,7 +2605,7 @@
   1.161  	;;
   1.162  	get-src)
   1.163  		check_root
   1.164 -		get_options_list="target"
   1.165 +		get_options_list="target nounpack"
   1.166  		get_tazwok_config
   1.167  		check_for_package_on_cmdline
   1.168  		check_for_receipt
   1.169 @@ -2612,7 +2613,7 @@
   1.170  		if [ "$WGET_URL" ];then
   1.171  			source_lib report
   1.172  			report start
   1.173 -			check_for_tarball get-src
   1.174 +			check_for_tarball
   1.175  		else
   1.176  			echo "No tarball to download for $PACKAGE"
   1.177  		fi