cookutils rev 481 slitaz-tank

cooker: Updated fully to what slitaz-tank needs.
author Christopher Rogers <slaxemulator@gmail.com>
date Mon Jun 11 15:49:54 2012 +0000 (2012-06-11)
parents ff51df709a1c
children 42b6c399a30f
files cooker
line diff
     1.1 --- a/cooker	Mon Jun 11 12:13:37 2012 +0000
     1.2 +++ b/cooker	Mon Jun 11 15:49:54 2012 +0000
     1.3 @@ -7,13 +7,14 @@
     1.4  # at least understand basic English.
     1.5  #
     1.6  . /usr/lib/slitaz/libcook.sh
     1.7 +. /usr/lib/slitaz/libcookorder.sh
     1.8  
     1.9  # Set pkg name and use same wok as cook.
    1.10  pkg="$2"
    1.11 -wok="$WOK"
    1.12  
    1.13  # PID file.
    1.14  pidfile='/var/run/cooker.pid'
    1.15 +COMMAND="$1"
    1.16  
    1.17  #
    1.18  # Functions
    1.19 @@ -25,20 +26,20 @@
    1.20  Usage: cooker [command] [pkg|list|note|hours]
    1.21  
    1.22  Options:
    1.23 -  usage|-u        Display this short usage.
    1.24 -  setup|-s        Setup the Cooker environment.
    1.25 -  setup-cron      Setup a cron job for the Cooker.
    1.26 -  arch-db         Create host arch packages DB.
    1.27 -  note|-n         Add a note to the cooknotes.
    1.28 -  notes|-ns       Display all the cooknotes.
    1.29 -  block|-b        Block a package so cook will skip it.
    1.30 -  unblock|-ub     Unblock a blocked package.
    1.31 -  pkg|-p          Same as 'cook pkg' but with cooker log.
    1.32 -  flavor|-f       Cook all packages of a flavor.
    1.33 -  list|-l         Cook all packages in the given list.
    1.34 -  cat|-c          Cook all packages of a category.
    1.35 -  rev|-r          Cook packages of a specific revision.
    1.36 -  all|-a          Find and cook all unbuilt packages.
    1.37 +  usage|-u        $(gettext "Display this short usage.")
    1.38 +  setup|-s        $(gettext "Setup the Cooker environment.")
    1.39 +  setup-cron      $(gettext "Setup a cron job for the Cooker.")
    1.40 +  arch-db         $(gettext "Create host arch packages DB.")
    1.41 +  note|-n         $(gettext "Add a note to the cooknotes.")
    1.42 +  notes|-ns       $(gettext "Display all the cooknotes.")
    1.43 +  block|-b        $(gettext "Block a package so cook will skip it.")
    1.44 +  unblock|-ub     $(gettext "Unblock a blocked package.")
    1.45 +  pkg|-p          $(gettext "Same as 'cook pkg' but with cooker log.")
    1.46 +  flavor|-f       $(gettext "Cook all packages of a flavor.")
    1.47 +  list|-l         $(gettext "Cook all packages in the given list.")
    1.48 +  cat|-c          $(gettext "Cook all packages of a category.")
    1.49 +  rev|-r          $(gettext "Cook packages of a specific revision.")
    1.50 +  all|-a          $(gettext "Find and cook all unbuilt packages.")
    1.51  
    1.52  EOT
    1.53  	exit 0
    1.54 @@ -75,11 +76,17 @@
    1.55  	touch $cookorder
    1.56  	for pkg in $(cat $cooklist)
    1.57  	do
    1.58 -		unset WANTED BUILD_DEPENDS
    1.59 -		. $wok/$pkg/receipt
    1.60 +		unset WANTED BUILD_DEPENDS BDEPS
    1.61 +		. $WOK/$pkg/receipt
    1.62  		# The :: is for web interface color.
    1.63 -		[ "$WANTED$BUILD_DEPENDS" ] && echo "$pkg :: $WANTED $BUILD_DEPENDS"
    1.64 -		for dep in $WANTED $BUILD_DEPENDS
    1.65 +		if [ "$AUTO_DEP" -a ! "$WANTED" ]; then
    1.66 +			BDEPS=$(scan $PACKAGE --look_for=bdep --with_dev | \
    1.67 +				grep -v $(for i in $(look_for_rwanted) $PACKAGE; do echo " -e ^$i$"; done))
    1.68 +		else
    1.69 +			BDEPS="$BUILD_DEPENDS"
    1.70 +		fi
    1.71 +		[ "$WANTED$BDEPS" ] && echo "$pkg :: $WANTED $BDEPS"
    1.72 +		for dep in $BDEPS
    1.73  		do
    1.74  			if grep -q "^$dep$" $cooklist; then
    1.75  				if ! grep -q "^$dep$" $cookorder; then
    1.76 @@ -108,6 +115,15 @@
    1.77  	echo "cookorder" > $command
    1.78  	echo -e "\nInitial Cooker order scan"
    1.79  	separator
    1.80 +	
    1.81 +	if [ "$COMMAND" = "pkg" ]; then
    1.82 +		if ! grep -q "^$pkg$" $cooklist; then
    1.83 +			if [ -f "$WOK/$pkg/receipt" ]; then
    1.84 +				echo "$pkg" > $cooklist
    1.85 +			fi
    1.86 +		fi
    1.87 +	fi
    1.88 +	
    1.89  	cook_order_scan
    1.90  
    1.91  	# Diff between the cooklist and new ordered list ? So copy the last
    1.92 @@ -126,6 +142,15 @@
    1.93  		fi
    1.94  	done
    1.95  
    1.96 +	if [ "$COOK_WANTED" ]; then
    1.97 +		PACKAGE=$pkg
    1.98 +		for i in $PACKAGE $(look_for_rwanted); do
    1.99 +			if ! grep -q "^${i}$" $cooklist; then
   1.100 +				echo $i >> $cooklist
   1.101 +			fi
   1.102 +		done
   1.103 +	fi
   1.104 +
   1.105  	# Keep a diff between submited cooklist and the ordered.
   1.106  	diff $cooklist.0 $cooklist > $cooklist.diff
   1.107  	rm -f $cookorder $cookorder.diff $cooklist.0
   1.108 @@ -137,15 +162,14 @@
   1.109  	for pkg in $(cat $cooklist)
   1.110  	do
   1.111  		unset WANTED
   1.112 -		. $wok/$pkg/receipt
   1.113 -		for wanted in $WANTED
   1.114 -		do
   1.115 -			echo "$pkg :: $wanted"
   1.116 -			if grep -q ^${wanted}$ $cooklist; then
   1.117 +		. $WOK/$pkg/receipt
   1.118 +		if [ "$WANTED" ]; then
   1.119 +			echo "$pkg :: $WANTED"
   1.120 +			if grep -q ^${WANTED}$ $cooklist; then
   1.121  				sed -i -e "/^$pkg$/"d  \
   1.122 -					-e "/^$wanted$/ a $pkg" $cooklist
   1.123 +					-e "/^$WANTED$/ a $pkg" $cooklist
   1.124  			fi
   1.125 -		done
   1.126 +		fi
   1.127  	done
   1.128  
   1.129  	# Show ordered cooklist
   1.130 @@ -165,14 +189,6 @@
   1.131  	separator && rm -f $command
   1.132  }
   1.133  
   1.134 -# Remove blocked (faster this way than grepping before).
   1.135 -strip_blocked() {
   1.136 -	for pkg in $(cat $blocked)
   1.137 -	do
   1.138 -		sed -i /^${pkg}$/d $cooklist
   1.139 -	done && sed -i /^$/d $cooklist
   1.140 -}
   1.141 -
   1.142  # Use in default mode and with all cmd.
   1.143  cook_commits() {
   1.144  	if [ -s "$commits" ]; then
   1.145 @@ -181,6 +197,16 @@
   1.146  			echo "cook:$pkg" > $command
   1.147  			cook $pkg || broken
   1.148  			sed -i /^${pkg}$/d $commits
   1.149 +			if [ "$COOK_WANTED" ]; then
   1.150 +				PACKAGE=$pkg
   1.151 +				for pkg in $(look_for_rwanted); do
   1.152 +					if ! grep -q "^$pkg$" $commits; then
   1.153 +						[ -f "$WOK/$pkg/receipt" ] || continue
   1.154 +						echo "cook:$pkg" > $command
   1.155 +						cook $pkg
   1.156 +					fi
   1.157 +				done
   1.158 +			fi
   1.159  		done
   1.160  	fi
   1.161  }
   1.162 @@ -191,9 +217,46 @@
   1.163  	do
   1.164  		cook $pkg || broken
   1.165  		sed -i /^${pkg}$/d $cooklist
   1.166 +		if [ "$COOK_WANTED" ]; then
   1.167 +			PACKAGE=$pkg
   1.168 +			for wpkg in $(look_for_rwanted); do
   1.169 +				if ! grep -q "^$wpkg$" $cooklist; then
   1.170 +					if [ -f "$WOK/$wpkg/receipt" ]; then
   1.171 +						cook $wpkg
   1.172 +						sed -i /^${wpkg}$/d $cooklist
   1.173 +					fi
   1.174 +				fi
   1.175 +			done
   1.176 +		fi
   1.177 +		if [ "$1" = "--list" ]; then
   1.178 +			pkgdb incoming
   1.179 +		fi
   1.180  	done
   1.181  }
   1.182  
   1.183 +# reverse pkg build when doing a big update to 
   1.184 +# rebuild all packages that depends on it
   1.185 +reverse_cook_list() {
   1.186 +	local pkg="$1"
   1.187 +	[ ! -f "$WOK/$pkg/receipt" ] && echo -e "\nNo package $pkg found.\n" && exit 0
   1.188 +	cp -a $cooklist $cooklist.bak
   1.189 +	rm -f $cooklist && touch $cooklist
   1.190 +	echo -e "\nReverse cooklist for: $pkg"
   1.191 +	separator && cd $WOK
   1.192 +	for rev in *
   1.193 +	do
   1.194 +		[ -f $WOK/$rev/receipt ] || continue
   1.195 +		unset DEPENDS BUILD_DEPENDS && . $WOK/$rev/receipt
   1.196 +		if echo "$DEPENDS $BUILD_DEPENDS" | fgrep -q $pkg; then
   1.197 +			echo "$rev" | tee -a $cooklist
   1.198 +		fi
   1.199 +	done && separator
   1.200 +	echo -e "Reverse dependencies found: $(cat $cooklist | wc -l)\n"
   1.201 +	strip_blocked
   1.202 +	cook_order | tee $LOGS/cookorder.log
   1.203 +	cook_list
   1.204 +}
   1.205 +
   1.206  # Create a arch.$ARCH file for each package cooked for the target host
   1.207  # architecture
   1.208  #
   1.209 @@ -221,37 +284,38 @@
   1.210  	echo "Packages for $ARCH : $count"
   1.211  }
   1.212  
   1.213 +
   1.214  #
   1.215  # Commands
   1.216  #
   1.217 -case "$1" in
   1.218 +case "$COMMAND" in
   1.219  	usage|help|-u|-h)
   1.220  		usage ;;
   1.221  	setup|-s)
   1.222  		# Setup the Cooker environment.
   1.223  		echo -e "\nSetting up the Cooker"
   1.224 -		mkdir -p $CACHE
   1.225  		echo "Cooker setup using: $SLITAZ" | log
   1.226  		separator
   1.227 -		for pkg in $SETUP_PKGS mercurial rsync tazlito
   1.228 +		echo "$PKGS" > $LOCALSTATE/mirror
   1.229 +		mkdir -p $LOCALSTATE/undigest/incoming
   1.230 +		echo "$INCOMING" > $LOCALSTATE/undigest/incoming/mirror
   1.231 +		echo "incoming" > $LOCALSTATE/priority
   1.232 +		tazpkg recharge
   1.233 +		for pkg in $INSTALL_PKGS
   1.234  		do
   1.235 -			[ ! -d "$INSTALLED/$pkg" ] && tazpkg get-install $pkg
   1.236 +			[ ! -f "$INSTALLED/$pkg/receipt" ] && tazpkg get-install $pkg
   1.237  		done
   1.238 +		ls -1 "$INSTALLED" > $CACHE/chroot-pkgs
   1.239  		mkdir -p $SLITAZ && cd $SLITAZ
   1.240 -		[ -d "${wok}-hg" ] && echo -e "Hg wok already exists.\n" && exit 1
   1.241 -		[ -d "$wok" ] && echo -e "Build wok already exists.\n" && exit 1
   1.242 -
   1.243 -		# Directories and files
   1.244 -		echo "mkdir's and touch files in: $SLITAZ"
   1.245 -		mkdir -p $PKGS $LOGS $FEEDS $CACHE $SRC
   1.246 -		for f in $activity $blocked $broken $commits $cooklist $command
   1.247 -		do
   1.248 -			touch $f
   1.249 -		done
   1.250 -		hg clone $WOK_URL ${wok}-hg || exit 1
   1.251 -		[ -d "$flavors" ] || hg clone $FLAVORS_URL flavors
   1.252 -		cp -a ${wok}-hg $wok
   1.253 -		separator && echo "" ;;
   1.254 +		[ -d "$WOKHG" ] || hg clone $WOK_URL $WOKHG
   1.255 +		rsync_wok
   1.256 +		init_db_files
   1.257 +		cook gen-wok-db
   1.258 +		echo "Make unbuild list"
   1.259 +		cook unbuild --full
   1.260 +		[ "$AUTO_PURGE_SRC" ] && cook gen-src $SRC
   1.261 +		#[ -d "$FLAVORS" ] || hg clone $FLAVORS_URL flavors
   1.262 +		separator && newline ;;
   1.263  	arch-db)
   1.264  		# Manually create arch packages DB.
   1.265  		arch_db ;;
   1.266 @@ -267,6 +331,8 @@
   1.267  			killall crond 2>/dev/null && /etc/init.d/crond start
   1.268  		fi ;;
   1.269  	check-cron)
   1.270 +		[ -f "$crontabs" ] || \
   1.271 +			echo "There is no $crontabs here. Use setup-cron option." && exit 1
   1.272  		fgrep /usr/bin/cooker $crontabs ;;
   1.273  	note|-n)
   1.274  		# Blocked a pkg and want others to know why ? Post a note!
   1.275 @@ -278,7 +344,7 @@
   1.276  		echo -e "\nCooknotes"
   1.277  		separator
   1.278  		cat $cooknotes
   1.279 -		separator && echo "" ;;
   1.280 +		separator && newline ;;
   1.281  	block|-b)
   1.282  		# Block a package.
   1.283  		[ "$pkg" ] && cook $pkg --block ;;
   1.284 @@ -291,29 +357,67 @@
   1.285  		#
   1.286  		# Use hg commit ? Ex: hg commit -m "Message bla bla | cooker:reverse"
   1.287  		#
   1.288 -		[ ! -d "$wok/$pkg" ] && echo -e "\nNo package $2 found.\n" && exit 0
   1.289 -		rm -f $cooklist && touch $cooklist && cd $wok
   1.290 -		echo -e "\nReverse cooklist for: $pkg"
   1.291 -		separator && cd $wok
   1.292 -		for rev in *
   1.293 +		reverse_cook_list $pkg ;;
   1.294 +	chroot)
   1.295 +		[ -d $SLITAZ/chroot ] || tazdev gen-chroot $2
   1.296 +		[ -d $SLITAZ/chroot ] && tazdev chroot $2
   1.297 +		;;
   1.298 +	toolchain)
   1.299 +		toolchain=$CACHE/toolchain
   1.300 +		[ -f $PKGS/fullco.txt ] || cook gen-wok-db
   1.301 +		cook gen-cooklist toolchain > $toolchain
   1.302 +		newline > $cooklist
   1.303 +		echo "cooker:toolchain" > $command
   1.304 +		echo "First build slitaz-toolchain"
   1.305 +		[ -f $blocked ] && rm -f $blocked
   1.306 +		touch $blocked
   1.307 +		cook slitaz-toolchain
   1.308 +		SKIP="glibc gcc binutils linux-api-headers slitaz-toolchain cookutils"
   1.309 +		for i in $SKIP; do
   1.310 +			echo "$i" >> $blocked
   1.311 +		done
   1.312 +		for pkg in $(cat $blocked)
   1.313  		do
   1.314 -			unset WANTED DEPENDS BUILD_DEPENDS && . $wok/$rev/receipt
   1.315 -			if echo "$WANTED $DEPENDS $BUILD_DEPENDS" | fgrep -q $pkg; then
   1.316 -				echo "$rev" | tee -a $cooklist
   1.317 +			sed -i /^${pkg}$/d $toolchain
   1.318 +		done && sed -i /^$/d $toolchain
   1.319 +		for pkg in $(cat $toolchain)
   1.320 +		do
   1.321 +			[ -f "$WOK/$pkg/receipt" ] || continue
   1.322 +			cook $pkg
   1.323 +			sed -i /^${pkg}$/d $toolchain
   1.324 +			if [ "$COOK_WANTED" ]; then
   1.325 +				PACKAGE=$pkg
   1.326 +				for pkg in $(look_for_rwanted); do
   1.327 +					if ! grep -q "^$pkg$" $toolchain; then
   1.328 +						[ -f "$WOK/$pkg/receipt" ] || continue
   1.329 +						cook $pkg
   1.330 +					fi
   1.331 +				done
   1.332  			fi
   1.333 -		done && separator
   1.334 -		echo -e "Reverse dependencies found: $(cat $cooklist | wc -l)\n"
   1.335 -		strip_blocked
   1.336 -		cook_order | tee $LOGS/cookorder.log
   1.337 -		cook_list ;;
   1.338 +			cook pkgdb incoming
   1.339 +		done
   1.340 +		[ -f $toolchain ] && rm -f $toolchain
   1.341 +		clean_exit ;;
   1.342  	pkg|-p)
   1.343  		# Same as 'cook pkg' but with log for web interface.
   1.344 -		cook $pkg || broken
   1.345 +		[ ! -f "$WOK/$pkg/receipt" ] && echo "$pkg doesn't exist in wok" && exit 1
   1.346 +		if [ "$COOK_WANTED" ]; then
   1.347 +			PACKAGE=$pkg
   1.348 +			strip_blocked
   1.349 +			cook_order | tee $LOGS/cookorder.log
   1.350 +			cook_list
   1.351 +			if [ "$AUTO_UPDATE_DB" ]; then
   1.352 +				cook pkgdb $INCOMING
   1.353 +			fi
   1.354 +		else
   1.355 +			cook $pkg
   1.356 +		fi
   1.357  		clean_exit ;;
   1.358  	cat|-c)
   1.359  		# Cook all packages of a category.
   1.360  		cat="$2"
   1.361 -		rm -f $cooklist && touch $cooklist && cd $wok
   1.362 +		cp -a $cooklist $cooklist.bak
   1.363 +		rm -f $cooklist && touch $cooklist && cd $WOK
   1.364  		for pkg in *
   1.365  		do
   1.366  			unset CATEGORY && . $pkg/receipt
   1.367 @@ -321,32 +425,41 @@
   1.368  		done
   1.369  		strip_blocked
   1.370  		cook_order | tee $LOGS/cookorder.log
   1.371 -		cook_list ;;
   1.372 +		cook_list --list ;;
   1.373  	flavor|-f)
   1.374  		# Cook all packages of a flavor.
   1.375  		name="$2"
   1.376 -		[ ! -d "$flavors/$name" ] && \
   1.377 +		[ ! -d "$FLAVORS/$name" ] && \
   1.378  			echo -e "\nSpecified flavor does not exist: $name\n" && exit 1
   1.379 -		[ -d "$flavors/.hg" ] && cd $flavors && hg pull -u
   1.380 -		list=$flavors/$name/packages.list
   1.381 +		[ -d "$FLAVORS/.hg" ] && cd $FLAVORS && hg pull -u
   1.382 +		list=$FLAVORS/$name/packages.list
   1.383  		cp -a $list $cooklist
   1.384  		strip_blocked
   1.385  		cook_order | tee $LOGS/cookorder.log
   1.386  		cook_list ;;
   1.387  	list|-l)
   1.388  		# Cook a list of packages given in argument.
   1.389 -		list="$2"
   1.390 -		[ ! -f "$list" ] && \
   1.391 -			echo -e "\nSpecified list does not exist: $list\n" && exit 1
   1.392 -		cp -a $list $cooklist
   1.393 +		list="$cooklist"
   1.394 +		[ "$2" ] && list="$2"
   1.395 +		[ -f "$list" ] || $(gettext -e "$list doesn't exist." && exit 1)
   1.396 +		if [ "$list" != "$cooklist" ]; then
   1.397 +			cp -a $list $cooklist
   1.398 +		fi
   1.399 +		unset pkg
   1.400  		strip_blocked
   1.401 -		cook_order | tee $LOGS/cookorder.log
   1.402 -		cook_list ;;
   1.403 +		if [ "$UPCOOKLIST" ]; then
   1.404 +			gen_cook_list
   1.405 +		else
   1.406 +			cook_order | tee $LOGS/cookorder.log
   1.407 +		fi
   1.408 +		cook_list --list
   1.409 +		cook pkgdb $INCOMING ;;
   1.410  	rev|-r)
   1.411  		# Cook or recook a specific Hg revision.
   1.412  		rev="$2"
   1.413  		[ "$rev" ] || exit 0
   1.414 -		cd $wok
   1.415 +		cd $WOK
   1.416 +		cp -a $cooklist $cooklist.bak
   1.417  		rm -f $cooklist && touch $cooklist
   1.418  		for pkg in $(hg log --rev=$rev --template "{files}")
   1.419  		do
   1.420 @@ -358,35 +471,25 @@
   1.421  	all|-a)
   1.422  		# Try to build all unbuilt packages except blocked's.
   1.423  		echo "cooker:all" > $command
   1.424 +		cp -a $cooklist $cooklist.bak
   1.425  		rm -f $cooklist && touch $cooklist
   1.426 -		echo "" && cd $wok
   1.427 +		newline && cd $WOK
   1.428  		echo "Cooker cooklist"
   1.429  		separator
   1.430 -
   1.431 -		# Find all unbuilt packages. Get EXTRAVERSION from packed receipt
   1.432 -		# if it exists since extra version is added when packing the package.
   1.433 -		echo "Searching for all unbuilt packages" | log
   1.434 -		for pkg in *
   1.435 -		do
   1.436 -			unset EXTRAVERSION
   1.437 -			. $pkg/receipt
   1.438 -			[ -f "$pkg/taz/$PACKAGE-$VERSION/receipt" ] && \
   1.439 -				. $pkg/taz/$PACKAGE-$VERSION/receipt
   1.440 -			if [ ! -f "$PKGS/$PACKAGE-${VERSION}${EXTRAVERSION}.tazpkg" ]
   1.441 -			then
   1.442 -				echo $pkg && echo $pkg >> $cooklist
   1.443 -			fi
   1.444 -		done
   1.445 +		
   1.446 +		cook unbuild
   1.447 +		cp -a $unbuild $cooklist
   1.448  		strip_blocked
   1.449 -		cook_order | tee $LOGS/cookorder.log
   1.450  		echo "Packages to cook: $(cat $cooklist | wc -l)" | log
   1.451  		cook_list ;;
   1.452 +	new|pkgdb|get-src|check-incoming|gen-wok-db|upwok)
   1.453 +		cook "$COMMAND" "$2" "$3" "$4" "$5" ;;
   1.454  	*)
   1.455  		# Default is to cook all commits if not yet running.
   1.456 -		[ "$1" ] && usage
   1.457 -		cooklist=$CACHE/commits
   1.458 +		[ "$COMMAND" ] && usage
   1.459 +		cooklist=$commits
   1.460  		if [ -f "$pidfile" ]; then
   1.461 -			pid=$(cat /var/run/cooker.pid)
   1.462 +			pid=$(cat $pidfile)
   1.463  			if [ -s /proc/$pid/status ]; then
   1.464  				gettext -e "\nStill cooking latest commits with pid:"
   1.465  				echo -e " $pid\n" && exit 0
   1.466 @@ -396,7 +499,7 @@
   1.467  
   1.468  		# Start and get a PID file.
   1.469  		rm -f $LOGS/commits.log
   1.470 -		echo ""
   1.471 +		newline
   1.472  		echo "Checking for commits" | log_commits
   1.473  		separator | tee -a $LOGS/commits.log
   1.474  
   1.475 @@ -409,32 +512,33 @@
   1.476  
   1.477  		# Get revisions. Here we have 2 echoes since we want a msg on screen,
   1.478  		# in commits log and activity DB without a space before.
   1.479 -		cd $wok || exit 1
   1.480 -		cur=$(hg head --template '{rev}\n')
   1.481 -		echo "Updating wok : ${wok}-hg (rev $cur)" | log_commits
   1.482 -		echo "Updating wok: ${wok}-hg" | log
   1.483 +		cd $WOK || exit 1
   1.484 +		branch=$(cat /etc/slitaz-release)
   1.485 +		cur=$(hg head $branch --template '{rev}\n')
   1.486 +		echo "Updating wok : $WOKHG (rev $cur)" | log_commits
   1.487 +		echo "Updating wok: $WOKHG" | log
   1.488  		echo "hg:pull" > $command
   1.489 -		cd ${wok}-hg && hg pull -u | log_commits
   1.490 -		new=$(hg head --template '{rev}\n')
   1.491 +		cd $WOKHG && hg pull -u | log_commits
   1.492 +		new=$(hg head $branch --template '{rev}\n')
   1.493  		# Store last rev to be used by CGI so it doesn't need to call hg head
   1.494  		# on each load.
   1.495 -		echo "$new" > $CACHE/wokrev
   1.496 +		echo "$new" > $wokrev
   1.497  
   1.498  		# Sync build wok with rsync so we don't take care about removing old
   1.499  		# files as before.
   1.500  		if [ "$new" -gt "$cur" ]; then
   1.501  			echo "Changes found from: $cur to $new" | log
   1.502  			echo "Syncing build wok with Hg wok..." | log_commits
   1.503 -			rsync -r -t -c -l -u -v -D -E ${wok}-hg/ $wok/ | \
   1.504 +			rsync -r -t -c -l -u -v -D -E $WOKHG/ $WOK/ | \
   1.505  				sed '/^$/'d | log_commits
   1.506  		else
   1.507  			echo "No revision changes: $cur vs $new" | log
   1.508  			separator | log_commits
   1.509 -			clean_exit && echo "" && exit 0
   1.510 +			clean_exit && newline && exit 0
   1.511  		fi
   1.512  
   1.513  		# Get and display modifications.
   1.514 -		cd ${wok}-hg
   1.515 +		cd $WOKHG
   1.516  		commits_summary | log_commits
   1.517  		cur=$(($cur + 1))
   1.518  		rm -f $commits.tmp && touch $commits.tmp
   1.519 @@ -444,21 +548,27 @@
   1.520  			do
   1.521  				pkg=$(echo $file | cut -d "/" -f 1)
   1.522  				desc=$(hg log --rev=$rev --template "{desc}" $file)
   1.523 -				echo "Committed package : $pkg - $desc" | log_commits
   1.524 +				echo "Commited package : $pkg - $desc" | log_commits
   1.525  				echo $pkg >> $commits.tmp
   1.526  			done
   1.527  		done
   1.528  
   1.529  		# We may have deleted packages and files in stuff/. Remove it and
   1.530  		# clean DB as well as log file.
   1.531 -		cd $wok
   1.532 +		cd $WOK
   1.533  		for pkg in *
   1.534  		do
   1.535 -			if [ ! -d "${wok}-hg/$pkg" ]; then
   1.536 +			if [ ! -d "$WOKHG/$pkg" ]; then
   1.537  				echo "Removing package: $pkg" | log_commits
   1.538 -				. $wok/$pkg/receipt
   1.539 -				rm -rf $PKGS/$PACKAGE-$VERSION* $wok/$pkg $LOGS/$pkg.log
   1.540 -				sed -i "/^${pkg}$/"d $CACHE/blocked $CACHE/broken $commits.tmp
   1.541 +				. $WOK/$pkg/receipt
   1.542 +				if [ -f "$INCOMING/$PACKAGE-$VERSION*" ]; then
   1.543 +					rm -rf $INCOMING/$PACKAGE-$VERSION*
   1.544 +				fi
   1.545 +				if [ -f "$PKGS/$PACKAGE-$VERSION*" ]; then
   1.546 +					rm -rf $PKGS/$PACKAGE-$VERSION*
   1.547 +				fi
   1.548 +				rm -rf $WOK/$pkg $LOGS/$pkg.log
   1.549 +				sed -i "/^${pkg}$/"d $blocked $broken $commits.tmp
   1.550  			fi
   1.551  		done
   1.552  
   1.553 @@ -490,10 +600,11 @@
   1.554  		echo "Packages to cook: $pkgs" | log
   1.555  		echo "Packages to cook : $pkgs" | log_commits
   1.556  		separator | log_commits
   1.557 -		echo ""
   1.558 +		newline
   1.559  		strip_blocked
   1.560  		cook_order | tee $LOGS/cookorder.log
   1.561  		cook_commits
   1.562 +		pkgdb $INCOMING
   1.563  		clean_exit ;;
   1.564  esac
   1.565