tazwok rev 266

Fix auto-remove old sources; Add some warning messages when default behavior is not used; Add a new COOK_OPT: !repack_src (prevent repacking into tar.lzma); Add support for git/svn/mercurial into WGET_URL (syntax is WGET_URL="mercurial|ftp://ftp.mozilla.org/pub/mozilla.org/thunderbird/releases/3.1.7/linux-i686/xpi/ru.xpi"- or git| or subversion| - having the vcs package in BUILD_DEPENDS still needed), add BRANCH variable to optionaly specify a rev/tag/branch to use in this case; add better support for strange http/https/ftp URL: if WGET_URL doesn't contains TARBALL, downloaded file is named TARBALL (i.e.: WGET_URL=".../download?f=xyz&r=132" - in this case use TARBALL="pkg.tar.gz" will make things works and no more hack in receipt is needed); fs variable into genpkg_rules() is now absolute; fix a bug into source_receipt() which can cause downloading the wrong tarball (TARBALL was not unseted); Add clean-src command to remove old/unrelated-to-wok sources tarball; Fix: packages removed from wok are now deleted from repositories and files list, at check-incoming time for the ones into main repository; WARNING WARNING WARNING : this commit comes with an update-repository script which **should** be used on repositories builded with previous version of tazwok-experimental: update logs to make them compatible with new webserver command, move/remove sources and generate sources.list to make source repository consistent with new changes. usage is: update-repository LOCAL_REPOSITORY, i.e.: update-repository /home/slitaz/experimental. Even if don't use it will not leads to major problem, please do it.
author Antoine Bodin <gokhlayeh@slitaz.org>
date Sun Feb 13 23:38:35 2011 +0100 (2011-02-13)
parents 093de6dde7f8
children c627f671fbca
files tazwok update-repository
line diff
     1.1 --- a/tazwok	Sun Feb 13 23:10:02 2011 +0100
     1.2 +++ b/tazwok	Sun Feb 13 23:38:35 2011 +0100
     1.3 @@ -55,6 +55,7 @@
     1.4    gen-wok-db     (Re-)Generate wok lists with depends and wanted datas.
     1.5    gen-clean-wok  Generate a clean wok in a dir.
     1.6    clean-wok      Clean entirely the wok.
     1.7 +  clean-src       Remove old/unrelated-to-wok sources.
     1.8    remove         Remove a package from the wok.
     1.9    webserver      Enable/disable webserver on localhost.
    1.10    hgup           Pull and update a wok under Hg.
    1.11 @@ -134,6 +135,7 @@
    1.12  	for file in broken blocked commit incoming cooklist; do
    1.13  		[ ! -f $PACKAGES_REPOSITORY/$file ] && touch $PACKAGES_REPOSITORY/$file
    1.14  	done
    1.15 +	touch $SOURCES_REPOSITORY/sources.list
    1.16  	
    1.17  	# Limit memory usage.
    1.18  	ulimit -v $(awk '/MemTotal/ { print int(($2*80)/100) }' < /proc/meminfo)
    1.19 @@ -395,6 +397,7 @@
    1.20  	if check_for_var_modification src _pkg; then
    1.21  		src=$WOK/${WANTED:-$PACKAGE}/${WANTED:-$PACKAGE}-$VERSION
    1.22  	else
    1.23 +		tazwok_warning "Use original name or tarball root directory because src/_pkg are defined into the receipt (this is no more needed!)."
    1.24  		src=$WOK/${WANTED:-$PACKAGE}/${SOURCE:-${WANTED:-$PACKAGE}}-$VERSION
    1.25  	fi
    1.26  }
    1.27 @@ -415,14 +418,6 @@
    1.28  	grep -m1 -A1 -sh ^$PACKAGE$ $1/packages.txt | tail -1 | sed 's/ *//'
    1.29  }
    1.30  
    1.31 -remove_previous_tarball()
    1.32 -{
    1.33 -	[ "$prev_VERSION" ] || return
    1.34 -	if [ "$VERSION" != "$prev_VERSION" ]; then
    1.35 -		rm -f $SOURCES_REPOSITORY/$PACKAGE-$prev_VERSION.tar.lzma
    1.36 -	fi
    1.37 -}
    1.38 -
    1.39  remove_previous_package()
    1.40  {
    1.41  	[ "$prev_VERSION" ] || return
    1.42 @@ -437,94 +432,82 @@
    1.43  {
    1.44  	[ "$WGET_URL" ] || return 0
    1.45  	report step "Checking for source tarball"
    1.46 -	
    1.47 +	local repack_src TARBALL
    1.48 +	if [ "$repack_src" = yes ] && look_for_cookopt !repack_src; then
    1.49 +			repack_src=no
    1.50 +	fi
    1.51 +	if [ "$target" ]; then
    1.52 +		src="$target"
    1.53 +	else
    1.54 +		set_src_path
    1.55 +	fi
    1.56 +	tmp_src=$tmp/tarball-$$
    1.57  	if [ ! -f "$SOURCES_REPOSITORY/$TARBALL" ] && \
    1.58  		[ ! -f "$SOURCES_REPOSITORY/${SOURCE:-$PACKAGE}-$VERSION.tar.lzma" ] ; then
    1.59  		cd $SOURCES_REPOSITORY
    1.60 -		download $WGET_URL
    1.61 -		
    1.62 -		# If source tarball is unreachable, try to find it on SliTaz
    1.63 -		# mirror.
    1.64 -		if [ ! -f "$SOURCES_REPOSITORY/$TARBALL" ]; then
    1.65 -			report step "Download failed, try with mirror copy... "
    1.66 -			if [ "$SOURCE" ]; then
    1.67 -				download http://mirror.slitaz.org/sources/packages/${SOURCE:0:1}/$SOURCE-$VERSION.tar.lzma
    1.68 -			else
    1.69 -				download http://mirror.slitaz.org/sources/packages/${PACKAGE:0:1}/$PACKAGE-$VERSION.tar.lzma
    1.70 -			fi
    1.71 +		if [ "$SOURCE" ]; then
    1.72 +			alt_url="http://mirror.slitaz.org/sources/packages/${SOURCE:0:1}/$SOURCE-$VERSION.tar.lzma"
    1.73 +		else
    1.74 +			alt_url="http://mirror.slitaz.org/sources/packages/${PACKAGE:0:1}/$PACKAGE-$VERSION.tar.lzma"
    1.75  		fi
    1.76 +		download $WGET_URL $alt_url http://mirror.slitaz.org/sources/packages/${file:0:1}/$file
    1.77 +		unset alt_url
    1.78  		if [ ! -f "$SOURCES_REPOSITORY/$TARBALL" ] && \
    1.79 -			[ ! -f "$SOURCES_REPOSITORY/${SOURCE:-PACKAGE}-$VERSION.tar.lzma" ]; then
    1.80 -			report step "Download failed, try with mirror copy (again)... "
    1.81 -			file=$(basename $WGET_URL)
    1.82 -			download http://mirror.slitaz.org/sources/packages/${file:0:1}/$file
    1.83 -		fi
    1.84 -
    1.85 -		# Exit if download failed to avoid errors.
    1.86 -		if [ ! -f "$SOURCES_REPOSITORY/$TARBALL" ] && [ ! -f "$SOURCES_REPOSITORY/${SOURCE:-$PACKAGE}-$VERSION.tar.lzma" ; then
    1.87 +			[ ! -f "$SOURCES_REPOSITORY/${SOURCE:-$PACKAGE}-$VERSION.tar.lzma" ] && \
    1.88 +			[ ! -d $tmp_src ]; then
    1.89  			echo -e "\nDownload failed, exiting. Please check WGET_URL variable.\n" >&2
    1.90  			report end-step
    1.91  			return 1
    1.92  		fi
    1.93  	fi
    1.94  	report end-step
    1.95 -	
    1.96  	if [ -f "$SOURCES_REPOSITORY/${SOURCE:-$PACKAGE}-$VERSION.tar.lzma" ] && [ "$nounpack" ]; then
    1.97 +		[ -d "$tmp_src" ] && rm -r $tmp_src
    1.98  		return
    1.99  	fi
   1.100  
   1.101  	# Untaring source if necessary. We don't need to extract source if
   1.102  	# the package is built with a wanted source package.
   1.103  	if [ "$WANTED" ]; then
   1.104 +		[ -d "$tmp_src" ] && rm -r $tmp_src
   1.105  		return
   1.106  	fi
   1.107  
   1.108  	report step "Untaring source tarball"
   1.109 -	if [ "$target" ]; then
   1.110 -		src="$target"
   1.111 -	else
   1.112 -		set_src_path
   1.113 -	fi
   1.114  
   1.115  	# Log process.
   1.116  	echo "untaring source tarball" >> $LOG
   1.117 -			
   1.118 -	tmp_src=$WOK/$PACKAGE/tmp-src-$$
   1.119 -	mkdir $tmp_src
   1.120 -	if [ -f "$SOURCES_REPOSITORY/${SOURCE:-$PACKAGE}-$VERSION.tar.lzma" ]; then
   1.121 -		lzma d $SOURCES_REPOSITORY/${SOURCE:-$PACKAGE}-$VERSION.tar.lzma -so | \
   1.122 -			tar xf - -C $tmp_src
   1.123 -	elif [ -f "$SOURCES_REPOSITORY/$TARBALL" ]; then
   1.124 -		case "$TARBALL" in
   1.125 -			*zip|*xpi)
   1.126 -				cur_dir=$PWD	
   1.127 -				cd $tmp_src
   1.128 -				unzip -o $SOURCES_REPOSITORY/$TARBALL
   1.129 -				cd $cur_dir
   1.130 -				unset cur_dir
   1.131 -			 ;;
   1.132 -			*bz2|*tbz|*gem) tar xjf $SOURCES_REPOSITORY/$TARBALL -C $tmp_src;;
   1.133 -			*tar) tar xf $SOURCES_REPOSITORY/$TARBALL -C $tmp_src;;
   1.134 -			*lzma|*lz) unlzma -c $SOURCES_REPOSITORY/$TARBALL | tar xf - -C $tmp_src;;
   1.135 -			*xz) unxz -c $SOURCES_REPOSITORY/$TARBALL | tar xf - -C $tmp_src;;
   1.136 -			*Z|*taz) uncompress -c $SOURCES_REPOSITORY/$TARBALL | tar xf - -C $tmp_src;;
   1.137 -			*gz) tar xzf $SOURCES_REPOSITORY/$TARBALL -C $tmp_src;;
   1.138 -			*rpm)
   1.139 -				cur_dir=$PWD
   1.140 -				cd $tmp_src
   1.141 -				rpm2cpio $SOURCES_REPOSITORY/$TARBALL | cpio -idm --quiet
   1.142 -				cd $cur_dir
   1.143 -				unset cur_dir
   1.144 -			;;
   1.145 -			# It's a plain file or something receipt unpack itself.	
   1.146 -			*)
   1.147 -				mkdir $tmp_src/${SOURCE:-$PACKAGE}-$VERSION
   1.148 -				cp $SOURCES_REPOSITORY/$TARBALL $tmp_src/${SOURCE:-$PACKAGE}-$VERSION
   1.149 -			;;
   1.150 -		esac || { rm -f $TARBALL && return 1; }
   1.151 -		
   1.152 +
   1.153 +	# If $tmp_src exists, there's already the unpacked tarball into it.
   1.154 +	if ! [ -d $tmp_src ]; then
   1.155 +		mkdir $tmp_src
   1.156 +		if [ -f "$SOURCES_REPOSITORY/${SOURCE:-$PACKAGE}-$VERSION.tar.lzma" ] && [ "$repack_src" = yes ]; then
   1.157 +			lzma d $SOURCES_REPOSITORY/${SOURCE:-$PACKAGE}-$VERSION.tar.lzma -so | \
   1.158 +				tar xf - -C $tmp_src
   1.159 +			repack_src=no
   1.160 +			TARBALL=${SOURCE:-$PACKAGE}-$VERSION.tar.lzma
   1.161 +		elif [ -f "$SOURCES_REPOSITORY/$TARBALL" ]; then
   1.162 +			case "$TARBALL" in
   1.163 +				*zip|*xpi) cd $tmp_src && unzip -o $SOURCES_REPOSITORY/$TARBALL ;;
   1.164 +				*bz2|*tbz|*gem) tar xjf $SOURCES_REPOSITORY/$TARBALL -C $tmp_src;;
   1.165 +				*tar) tar xf $SOURCES_REPOSITORY/$TARBALL -C $tmp_src;;
   1.166 +				*lzma|*lz) unlzma -c $SOURCES_REPOSITORY/$TARBALL | tar xf - -C $tmp_src;;
   1.167 +				*xz) unxz -c $SOURCES_REPOSITORY/$TARBALL | tar xf - -C $tmp_src;;
   1.168 +				*Z|*taz) uncompress -c $SOURCES_REPOSITORY/$TARBALL | tar xf - -C $tmp_src;;
   1.169 +				*gz) tar xzf $SOURCES_REPOSITORY/$TARBALL -C $tmp_src;;
   1.170 +				*rpm) cd $tmp_src && rpm2cpio $SOURCES_REPOSITORY/$TARBALL | cpio -idm --quiet;;
   1.171 +
   1.172 +				# It's a plain file or something receipt unpack itself.	
   1.173 +				*)
   1.174 +					mkdir $tmp_src/${SOURCE:-$PACKAGE}-$VERSION
   1.175 +					cp $SOURCES_REPOSITORY/$TARBALL $tmp_src/${src##*/}
   1.176 +				;;
   1.177 +
   1.178 +			esac || { rm -f $SOURCES_REPOSITORY/$TARBALL; rm -r $tmp_src; return 1; }
   1.179 +		fi
   1.180 +
   1.181  		# Check if uncompressed tarball is in a root dir or not.
   1.182 -		if [ "$(ls -A $tmp_src | wc -l)" -gt 1 ]; then
   1.183 +		if [ "$(ls -A $tmp_src | wc -l)" -gt 1 ] || [ -f $(echo $tmp_src/*) ]; then
   1.184  			if check_for_var_modification src _pkg; then
   1.185  				mv $tmp_src $tmp_src-1
   1.186  				mkdir $tmp_src
   1.187 @@ -533,42 +516,49 @@
   1.188  				mv $tmp_src/* $WOK/$PACKAGE
   1.189  				repack_src=no
   1.190  				rm -r $tmp_src
   1.191 +				tazwok_warning "Put all files into $WOK/$PACKAGE; not sure about how to handle this tarball (no root dir)... Please try to remove src/_pkg definition from receipt if you encounter a problem."
   1.192  			fi
   1.193  		fi
   1.194 -	
   1.195 -		if [ "$repack_src" = yes ]; then
   1.196 +	fi
   1.197 +
   1.198 +	if [ "$repack_src" = yes ]; then
   1.199  			report step "Repacking sources in .tar.lzma format"
   1.200 +			[ "$TARBALL" ] && rm -f $SOURCES_REPOSITORY/$TARBALL
   1.201 +			TARBALL=${SOURCE:-$PACKAGE}-$VERSION.tar.lzma
   1.202  			cd $tmp_src
   1.203 -			tar -c * | lzma e $SOURCES_REPOSITORY/${SOURCE:-$PACKAGE}-$VERSION.tar.lzma -si
   1.204 -			rm $SOURCES_REPOSITORY/$TARBALL
   1.205 -			prev_VERSION=$(get_pkg_version $INCOMING_REPOSITORY)
   1.206 +			tar -c * | lzma e $SOURCES_REPOSITORY/$TARBALL -si
   1.207 +	fi
   1.208  
   1.209 -			# Remove previous tarball if it's not used either by
   1.210 -			# incoming and legacy packages.
   1.211 -			[ "$prev_VERSION" != "$(get_pkg_version $PACKAGES_REPOSITORY)" ] && \
   1.212 -				remove_previous_tarball
   1.213 -			report end-step
   1.214 +	# Remove previous tarball if no other package needs it. We take care to
   1.215 +	# keep tarball if the same package use it into main repository.
   1.216 +	if [ "$TARBALL" ]; then
   1.217 +		previous_tarball=$(grep ^$PACKAGE:incoming $SOURCES_REPOSITORY/sources.list | cut -f2)
   1.218 +		if [ "$previous_tarball" ]; then
   1.219 +			sed "/^$PACKAGE:incoming/ s/.*/$PACKAGE:incoming\t$TARBALL/" \
   1.220 +				-i $SOURCES_REPOSITORY/sources.list
   1.221 +			grep -q $'\t'$previous_tarball$ $SOURCES_REPOSITORY/sources.list || \
   1.222 +				rm -f $SOURCES_REPOSITORY/$previous_tarball
   1.223 +		else
   1.224 +			echo -e "$PACKAGE:incoming\t$TARBALL" >> $SOURCES_REPOSITORY/sources.list
   1.225  		fi
   1.226  	fi
   1.227 +
   1.228  	if [ "$nounpack" ]; then
   1.229  		[ -d "$tmp_src" ] && rm -r $tmp_src
   1.230  		return
   1.231  	fi
   1.232 -	if [ "$TARBALL" ]; then
   1.233 -		if [ ! -d "$src" ]; then
   1.234 -			if [ -d "$tmp_src" ]; then
   1.235 -				if ! check_for_var_modification src _pkg; then
   1.236 -					src="${src%/*}/$(ls $tmp_src)"
   1.237 -				fi
   1.238 -				mv $(echo $tmp_src/*) "$src"
   1.239 -				rm -r $tmp_src
   1.240 -						
   1.241 -				# Permissions settings.
   1.242 -				chown -R root.root "$src"
   1.243 -			fi
   1.244 -		else
   1.245 -			echo "There's already something at $src. Abort." >&2
   1.246 +	if [ ! -d "$src" ]; then
   1.247 +		if ! check_for_var_modification src _pkg; then
   1.248 +			src="${src%/*}/$(ls $tmp_src)"
   1.249  		fi
   1.250 +		mv $(echo $tmp_src/*) "$src"
   1.251 +		rm -r $tmp_src
   1.252 +
   1.253 +		# Permissions settings.
   1.254 +		chown -R root.root "$src"
   1.255 +	else
   1.256 +		[ -d "$tmp_src" ] && rm -r $tmp_src
   1.257 +		echo "There's already something at $src. Abort." >&2
   1.258  	fi
   1.259  }
   1.260  
   1.261 @@ -648,20 +638,88 @@
   1.262  	done
   1.263  }
   1.264  
   1.265 +# Function used by download().
   1.266 +revert_vcs_failure()
   1.267 +{
   1.268 +	cd $SOURCES_REPOSITORY
   1.269 +	rm -r $tmp_src
   1.270 +}
   1.271 +
   1.272  download()
   1.273  {
   1.274  	for file in $@; do
   1.275 +		echo "Downloading from ${file#*|}..."
   1.276  		case "$file" in
   1.277 -			[Hh][Tt][Tt][Pp][Ss]*)
   1.278 +			git\|*)
   1.279 +				file=${file#git|}
   1.280 +				if [ -d $INSTALLED/git ]; then
   1.281 +					mkdir $tmp_src
   1.282 +					cd $tmp_src
   1.283 +					if [ "$BRANCH" ]; then
   1.284 +						git clone $file ${src##*/} && cd ${src##*/} && \
   1.285 +							git checkout $BRANCH && rm -rf .git* && break
   1.286 +					else
   1.287 +						git clone $file ${src##*/} && rm -rf ${src##*/}/.git* && break
   1.288 +					fi
   1.289 +					revert_vcs_failure
   1.290 +				else
   1.291 +					tazwok_warning "Needs git to download the source tarball from $file, please add it as build-depend."
   1.292 +					continue
   1.293 +				fi
   1.294 +			;;
   1.295 +			subversion\|*)
   1.296 +				file=${file#subversion|}
   1.297 +				if [ -d $INSTALLED/subversion ]; then
   1.298 +					mkdir $tmp_src
   1.299 +					cd $tmp_src
   1.300 +					if [ "$BRANCH" ]; then
   1.301 +						echo t | svn co $file -r $BRANCH ${src##*/} && rm -rf ${src##*/}/.svn* && break
   1.302 +					else
   1.303 +						echo t | svn co $file ${src##*/} && rm -rf ${src##*/}/.svn* && break
   1.304 +					fi
   1.305 +					revert_vcs_failure
   1.306 +				else
   1.307 +					tazwok_warning "Needs subversion to download the source tarball from $file, please add it as build-depend."
   1.308 +					continue
   1.309 +				fi
   1.310 +			;;
   1.311 +			mercurial\|*)
   1.312 +				file=${file#mercurial|}
   1.313 +				if [ -d $INSTALLED/mercurial ]; then
   1.314 +					mkdir $tmp_src
   1.315 +					cd $tmp_src
   1.316 +					if [ "$BRANCH" ]; then
   1.317 +						hg clone $file --rev $BRANCH ${src##*/} && rm -rf ${src##*/}/.hg* && break
   1.318 +					else
   1.319 +						hg clone $file ${src##*/} && rm -rf ${src##*/}/.hg* && break
   1.320 +					fi
   1.321 +					revert_vcs_failure
   1.322 +				else
   1.323 +					tazwok_warning "Needs mercurial to download the source tarball from $file, please add it as build-depend."
   1.324 +					continue
   1.325 +				fi
   1.326 +			;;
   1.327 +			https*)
   1.328  				if [ -d $INSTALLED/wget ]; then
   1.329 -					wget --no-check-certificate -O $(basename $file) $file && break
   1.330 +					if [ "${WGET_URL%$TARBALL}" = "$WGET_URL" ] && [ "$file" = "$WGET_URL" ]; then
   1.331 +						wget -q --no-check-certificate -O $TARBALL $file && break
   1.332 +					else
   1.333 +						wget -q $file && break						
   1.334 +					fi
   1.335  				else
   1.336 -					tazwok_warning "$PACKAGE need wget to download the source tarball from $file, please add it as build-depend."
   1.337 -					return 1
   1.338 +					tazwok_warning "Needs wget to download the source tarball from $file, please add it as build-depend."
   1.339 +					continue
   1.340  				fi
   1.341 +			;;
   1.342 +			http*|ftp*)
   1.343 +				# Handle crappy URL.	
   1.344 +				if [ "${WGET_URL%$TARBALL}" = "$WGET_URL" ] && [ "$file" = "$WGET_URL" ]; then
   1.345 +					wget -q -O $TARBALL $file && break
   1.346 +				else
   1.347 +					wget -q $file && break
   1.348 +				fi
   1.349 +			;;
   1.350  		esac
   1.351 -		wget -q $file && break
   1.352 -		wget -O $(basename $file) $file && break
   1.353  	done
   1.354  }
   1.355  
   1.356 @@ -846,8 +904,8 @@
   1.357  	[ -d "taz" ] &&	rm -rf taz
   1.358  	
   1.359  	# Create the package tree and set useful variables.
   1.360 -	mkdir -p taz/$PACKAGE-$VERSION/fs
   1.361 -	fs=taz/$PACKAGE-$VERSION/fs
   1.362 +	mkdir -p $WOK/$PACKAGE/taz/$PACKAGE-$VERSION/fs
   1.363 +	fs=$WOK/$PACKAGE/taz/$PACKAGE-$VERSION/fs
   1.364  	
   1.365  	# Set $src for standard package and $_pkg variables.
   1.366  	set_src_path && set_pkg_path
   1.367 @@ -1082,6 +1140,23 @@
   1.368  			if [ "$pkg" -nt "packages.list" ]; then
   1.369  				updated_pkg="$updated_pkg
   1.370  $PACKAGE $pkg"
   1.371 +			elif [ ! -f $WOK/$PACKAGE/receipt ] && \
   1.372 +				[ "$COMMAND" = check-incoming -o "$pkg_repository" = "$INCOMING_REPOSITORY" ]; then
   1.373 +				erase_package_info
   1.374 +				echo "Removing $PACKAGE from $pkg_repository."	
   1.375 +				rm $pkg
   1.376 +				[ -d $WOK/$PACKAGE ] && rm -r $WOK/$PACKAGE
   1.377 +				if [ "$pkg_repository" = "$INCOMING_REPOSITORY" ]; then
   1.378 +					sed "/^$PACKAGE\t/d" -i $wan_db $dep_db
   1.379 +					for i in cookorder.txt cooklist commit blocked broken; do
   1.380 +						sed "/^$PACKAGE$/d" -i $PACKAGES_REPOSITORY/$i
   1.381 +					done	
   1.382 +					sed 1i"#PlanSort" -i $PACKAGES_REPOSITORY/cookorder.txt
   1.383 +					regen_cooklist=yes
   1.384 +				else
   1.385 +					echo "$PACKAGE" >> $PACKAGES_REPOSITORY/removed
   1.386 +					sed -n '1,10p' -i $PACKAGES_REPOSITORY/removed
   1.387 +				fi
   1.388  			fi
   1.389  		fi
   1.390  	done
   1.391 @@ -1191,7 +1266,7 @@
   1.392  	unset PACKAGE SOURCE VERSION EXTRAVERSION CATEGORY SHORT_DESC \
   1.393  		MAINTAINER WEB_SITE WGET_URL DEPENDS BUILD_DEPENDS WANTED \
   1.394  		PACKED_SIZE UNPACKED_SIZE COOK_OPT PROVIDE CONFIG_FILES TAGS \
   1.395 -		src _pkg DESTDIR CONFIG_SITE
   1.396 +		src _pkg DESTDIR CONFIG_SITE BRANCH TARBALL
   1.397  	. ${RECEIPT:-$PWD/receipt}
   1.398  }
   1.399  
   1.400 @@ -1693,10 +1768,6 @@
   1.401  	report end-step
   1.402  	
   1.403  	[ -s $tmp/checked ] || [ -s $tmp/cooklist ] || return
   1.404 -	if [ "$(sed 1!d $PACKAGES_REPOSITORY/cookorder.txt)" = "#PlanSort" ]; then
   1.405 -		sed 1d -i $PACKAGES_REPOSITORY/cookorder.txt
   1.406 -		plan_regen_cookorder=yes
   1.407 -	fi
   1.408  	
   1.409  	# Core toolchain should not be cooked unless cook-toolchain is used.
   1.410  	if ! [ -f /etc/config.site.tmptoolchain ] ; then
   1.411 @@ -1717,13 +1788,17 @@
   1.412  			echo $PACKAGE >> cooklist
   1.413  		done
   1.414  	fi
   1.415 -	[ "$plan_sort_depdb" ] && sort -o $dep_db $dep_db && unset plan_sort_depdb
   1.416 -	[ "$plan_regen_cookorder" ] && sort_db
   1.417  	sort_cooklist
   1.418  }
   1.419  
   1.420  sort_cooklist()
   1.421  {
   1.422 +	if [ "$(sed 1!d $PACKAGES_REPOSITORY/cookorder.txt)" = "#PlanSort" ]; then
   1.423 +		sed 1d -i $PACKAGES_REPOSITORY/cookorder.txt
   1.424 +		plan_regen_cookorder=yes
   1.425 +	fi
   1.426 +	[ "$plan_sort_depdb" ] && sort -o $dep_db $dep_db && unset plan_sort_depdb
   1.427 +	[ "$plan_regen_cookorder" ] && sort_db
   1.428  	report step "Sorting cooklist"
   1.429  	if [ -f "$tmp/checked" ]; then
   1.430  		rm -f $tmp/cooklist
   1.431 @@ -1805,6 +1880,14 @@
   1.432  			echo "Moving $PACKAGE..."
   1.433  			mv -f $INCOMING_REPOSITORY/$PACKAGE-$VERSION.tazpkg $PACKAGES_REPOSITORY
   1.434  			touch $PACKAGES_REPOSITORY/$PACKAGE-$VERSION.tazpkg
   1.435 +			previous_tarball=$(grep ^$PACKAGE:main $SOURCES_REPOSITORY/sources.list | cut -f2)
   1.436 +			sed -e "/^$PACKAGE:main/d" \
   1.437 +				-e "s/^$PACKAGE:incoming/$PACKAGE:main/"
   1.438 +				-i $SOURCES_REPOSITORY/sources.list
   1.439 +			if [ "$previous_tarball" ]; then
   1.440 +				grep -q $'\t'$previous_tarball$ $SOURCES_REPOSITORY/sources.list || \
   1.441 +					rm -f $SOURCES_REPOSITORY/$previous_tarball
   1.442 +			fi
   1.443  	done
   1.444  	report end-step
   1.445  	for file in packages.list packages.equiv packages.md5 packages.desc \
   1.446 @@ -2495,6 +2578,36 @@
   1.447  		done
   1.448  		echo "`ls -1 $WOK | wc -l` packages cleaned."
   1.449  	;;
   1.450 +	clean-src)
   1.451 +		# Remove tarball unrelated to wok receipts from src repo.
   1.452 +		check_root
   1.453 +		get_options_list="forced"
   1.454 +		get_tazwok_config
   1.455 +		cd $SOURCES_REPOSITORY
   1.456 +		echo -n "Checking $SOURCES_REPOSITORY..."	
   1.457 +		for TARBALL in *; do
   1.458 +		[ "$TARBALL" = sources.list ] && continue
   1.459 +		grep -q $'\t'$TARBALL$ $SOURCES_REPOSITORY/sources.list || \
   1.460 +			echo $TARBALL >> $tmp/obsolete
   1.461 +		done
   1.462 +		status
   1.463 +		echo ""	
   1.464 +		echo -e "\033[1mObsolete/unrelated-to-wok sourcess :\033[0m"
   1.465 +   		horizontal_line
   1.466 +		cat $tmp/obsolete
   1.467 +		horizontal_line
   1.468 +		echo "$(wc -l $tmp/obsolete | cut -f1 -d' ') tarballs to remove."
   1.469 +		echo ""
   1.470 +		echo -n "Please confirm removing (type uppercase YES): "
   1.471 +		read answer
   1.472 +		if [ "$answer" = YES ]; then
   1.473 +			echo -n "Removing old sources..."	
   1.474 +			cat $tmp/obsolete | while read i; do
   1.475 +				rm -f $SOURCES_REPOSITORY/$i
   1.476 +			done
   1.477 +			status
   1.478 +		fi
   1.479 +	;;
   1.480  	gen-list)
   1.481  		get_tazwok_config
   1.482  		if [ "$2" ]; then
     2.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     2.2 +++ b/update-repository	Sun Feb 13 23:38:35 2011 +0100
     2.3 @@ -0,0 +1,57 @@
     2.4 +#!/bin/sh
     2.5 +
     2.6 +if ! [ "$1" ]; then
     2.7 +	echo "Usage: update-repository LOCAL_REPOSITORY (i.e.: /home/slitaz/experimental)"
     2.8 +	exit
     2.9 +fi
    2.10 +
    2.11 +WOK=$1/wok
    2.12 +SOURCES_REPOSITORY=$1/src
    2.13 +LOG_DIR=$1/log
    2.14 +
    2.15 +if [ -d "$WOK" ] && [ -d "$SOURCES_REPOSITORY" ] && [ -d "$LOG_DIR" ]; then
    2.16 +	rm -f $SOURCES_REPOSITORY/sources.list
    2.17 +else
    2.18 +	echo "$1 doesn't looks like a LOCAL_REPOSITORY: it doesn't contains one or several of theses directories:
    2.19 +	* $WOK
    2.20 +	* $SOURCES_REPOSITORY
    2.21 +	* $LOG_DIR"
    2.22 +	exit
    2.23 +fi
    2.24 +
    2.25 +echo "Updating logs files..."
    2.26 +cd $LOG_DIR
    2.27 +for i in *.html; do
    2.28 +	sed 's~file:///usr/share/slitaz/web~web~' -i $i
    2.29 +done
    2.30 +[ -L web ] || ln -s /usr/share/slitaz/web web
    2.31 +echo "Update done: you can now use 'tazwok webserver on' to add you're repository to webinterface.
    2.32 +If you use the path by default, it will be available at: http://localhost/vhosts/bb
    2.33 +This command need lighttpd & php installed to be used."
    2.34 +
    2.35 +echo "
    2.36 +Changing sources pathes according new changes into tazwok-experimental and generating $SOURCES_REPOSITORY/sources.list."
    2.37 +cd $WOK
    2.38 +for i in *; do
    2.39 +	unset PACKAGE SOURCE VERSION WGET_URL TARBALL
    2.40 +	source $i/receipt
    2.41 +	[ "$WGET_URL" ] || continue
    2.42 +	# Check that source is at the good location; if not move it or remove it if it's a duplicate.
    2.43 +	if [ "$SOURCE" ]; then
    2.44 +		if [ -f "$SOURCES_REPOSITORY/$PACKAGE-$VERSION.tar.lzma" ]; then
    2.45 +			if [ -f "$SOURCES_REPOSITORY/$SOURCE-$VERSION.tar.lzma" ]; then
    2.46 +				rm $SOURCES_REPOSITORY/$PACKAGE-$VERSION.tar.lzma
    2.47 +			else
    2.48 +				mv $SOURCES_REPOSITORY/$PACKAGE-$VERSION.tar.lzma $SOURCES_REPOSITORY/$SOURCE-$VERSION.tar.lzma
    2.49 +			fi
    2.50 +		fi
    2.51 +	fi
    2.52 +	if [ -f $SOURCES_REPOSITORY/${SOURCE:-$PACKAGE}-$VERSION.tar.lzma ]; then
    2.53 +		echo -e "$PACKAGE:incoming\t${SOURCE:-$PACKAGE}-$VERSION.tar.lzma" >> $SOURCES_REPOSITORY/sources.list
    2.54 + 	elif [ -f "SOURCES_REPOSITORY/$TARBALL" ]; then
    2.55 +		echo -e "$PACKAGE:incoming\t$TARBALL" >> $SOURCES_REPOSITORY/sources.list
    2.56 +	fi
    2.57 +done
    2.58 +echo "Done."
    2.59 +echo "
    2.60 +You can check/purge old sources tarball and sources tarball unrelated to wok receipts using 'tazwok clean-src'"