cookutils rev 383

cooker: add some support for cross compilation. We use a arch.$ARCH file to check id package must be build for the host arch or not
author Christophe Lincoln <pankso@slitaz.org>
date Sat May 12 23:26:36 2012 +0200 (2012-05-12)
parents 95ba9a892bb4
children 3fd578a80412
files cooker web/cooker.cgi web/style.css
line diff
     1.1 --- a/cooker	Sat May 12 22:03:46 2012 +0100
     1.2 +++ b/cooker	Sat May 12 23:26:36 2012 +0200
     1.3 @@ -1,7 +1,7 @@
     1.4  #!/bin/sh
     1.5  #
     1.6 -# SliTaz Build Bot. The Cooker is a tool to automate and test SliTaz package 
     1.7 -# building. Please read the Cookbook documentation for more information 
     1.8 +# SliTaz Build Bot. The Cooker is a tool to automate and test SliTaz package
     1.9 +# building. Please read the Cookbook documentation for more information
    1.10  # and discuss with the AUTHORS before adding anything here. PS: no translations
    1.11  # here since it's not an end user tool and it's not useful, all devs should
    1.12  # at least understand basic English.
    1.13 @@ -42,6 +42,7 @@
    1.14    usage|-u        Display this short usage.
    1.15    setup|-s        Setup the Cooker environment.
    1.16    setup-cron      Setup a cron job for the Cooker.
    1.17 +  arch-db         Create host arch packages DB.
    1.18    note|-n         Add a note to the cooknotes.
    1.19    notes|-ns       Display all the cooknotes.
    1.20    block|-b        Block a package so cook will skip it.
    1.21 @@ -106,6 +107,7 @@
    1.22  # Scan packages build deps and fill up cookorder list.
    1.23  cook_order_scan() {
    1.24  	rm -f $cookorder
    1.25 +	touch $cookorder
    1.26  	for pkg in $(cat $cooklist)
    1.27  	do
    1.28  		unset WANTED BUILD_DEPENDS
    1.29 @@ -121,7 +123,7 @@
    1.30  			fi
    1.31  		done
    1.32  	done
    1.33 -	
    1.34 +
    1.35  	# Append unordered packages to cookorder.
    1.36  	for pkg in $(cat $cooklist)
    1.37  	do
    1.38 @@ -142,7 +144,7 @@
    1.39  	echo -e "\nInitial Cooker order scan"
    1.40  	separator
    1.41  	cook_order_scan
    1.42 -	
    1.43 +
    1.44  	# Diff between the cooklist and new ordered list ? So copy the last
    1.45  	# cookorder to cooklist and rescan it.
    1.46  	while /bin/true
    1.47 @@ -227,6 +229,32 @@
    1.48  	done
    1.49  }
    1.50  
    1.51 +# Create a arch.$ARCH file for each packages cooked for the target host
    1.52 +# architecture
    1.53 +#
    1.54 +# The deal: we dont want all packages handled by cooker commands and stats,
    1.55 +# since we dont cross compile all packages for each arch but only a set of
    1.56 +# packages to provide one full featured desktop, servers and goodies usefull
    1.57 +# for the host system.
    1.58 +#
    1.59 +arch_db() {
    1.60 +	count=0
    1.61 +	echo "Cleaning packages DB: arch.$ARCH"
    1.62 +	rm -f $wok/*/arch.$ARCH
    1.63 +	echo "Creating $ARCH packages DB..."
    1.64 +	for pkg in $wok/*
    1.65 +	do
    1.66 +		unset HOST_ARCH
    1.67 +		. $pkg/receipt
    1.68 +		if $(echo "$HOST_ARCH" | fgrep -q $ARCH); then
    1.69 +			count=$(($count + 1))
    1.70 +			echo "Including: $pkg"
    1.71 +			touch $wok/$pkg/arch.$ARCH
    1.72 +		fi
    1.73 +	done
    1.74 +	echo "Included packages for $ARCH: $count"
    1.75 +}
    1.76 +
    1.77  #
    1.78  # Commands
    1.79  #
    1.80 @@ -258,6 +286,9 @@
    1.81  		[ -d "$flavors" ] || hg clone $FLAVORS_URL flavors
    1.82  		cp -a ${wok}-hg $wok
    1.83  		separator && echo "" ;;
    1.84 +	arch-db)
    1.85 +		# Manually create arch packages DB.
    1.86 +		arch_db ;;
    1.87  	setup-cron)
    1.88  		# Create cron job for the cooker.
    1.89  		[ "$2" ] || hours=2
    1.90 @@ -368,7 +399,7 @@
    1.91  		echo "" && cd $wok
    1.92  		echo "Cooker cooklist"
    1.93  		separator
    1.94 -		
    1.95 +
    1.96  		# Find all unbuilt packages. Get EXTRAVERSION from packed receipt
    1.97  		# if it exists since extra version is added when packing the package.
    1.98  		echo "Searching for all unbuilt packages" | log
    1.99 @@ -405,14 +436,14 @@
   1.100  		echo ""
   1.101  		echo "Checking for commits" | log_commits
   1.102  		separator | tee -a $LOGS/commits.log
   1.103 -		
   1.104 +
   1.105  		echo $$ > $pidfile
   1.106  		trap 'echo -e "\nCooker stopped: PID $$\n" && \
   1.107  			rm -f $pidfile $command && exit 1' INT TERM
   1.108 -		
   1.109 +
   1.110  		echo "Cooker PID   : $$" | log_commits
   1.111  		echo "Cooker date  : $(date '+%Y-%m-%d %H:%M:%S')" | log_commits
   1.112 -		
   1.113 +
   1.114  		# Get revisions. Here we have 2 echoes since we want a msg on screen,
   1.115  		# in commits log and activity DB without a space before.
   1.116  		cd $wok || exit 1
   1.117 @@ -425,7 +456,7 @@
   1.118  		# Store last rev to be used by CGI so it doesn't need to call hg head
   1.119  		# on each load.
   1.120  		echo "$new" > $CACHE/wokrev
   1.121 -		
   1.122 +
   1.123  		# Sync build wok with rsync so we don't take care about removing old
   1.124  		# files as before.
   1.125  		if [ "$new" -gt "$cur" ]; then
   1.126 @@ -438,7 +469,7 @@
   1.127  			separator | log_commits
   1.128  			clean_exit && echo "" && exit 0
   1.129  		fi
   1.130 -		
   1.131 +
   1.132  		# Get and display modifications.
   1.133  		cd ${wok}-hg
   1.134  		commits_summary | log_commits
   1.135 @@ -467,10 +498,31 @@
   1.136  				sed -i "/^${pkg}$/"d $CACHE/blocked $CACHE/broken $commits.tmp
   1.137  			fi
   1.138  		done
   1.139 -		
   1.140 +
   1.141  		# Keep previous commit and discard duplicate lines
   1.142  		cat $commits $commits.tmp | sed /"^$"/d > $commits.new
   1.143  		uniq $commits.new > $commits && rm $commits.*
   1.144 +
   1.145 +		# Handle cross compilation. Creat arch packages DB and remove pkgs
   1.146 +		# not cooked for this arch from the commits list.
   1.147 +		case "$ARCH" in
   1.148 +			arm)
   1.149 +				arch_db | log_commits
   1.150 +				for pkg in $(cat $commits)
   1.151 +				do
   1.152 +					if [ ! -f "$wok/$pkg/arch.$ARCH" ]; then
   1.153 +						echo "Cooker arch : skip $pkg (not include in: $ARCH)" | \
   1.154 +							log_commits
   1.155 +						sed -i "/^${pkg}$/"d $commits
   1.156 +					fi
   1.157 +				done ;;
   1.158 +			i486)
   1.159 +				echo "Cooker arch : $ARCH (default)" | log_commits ;;
   1.160 +			*)
   1.161 +				echo "Cooker arch : $ARCH" | log_commits ;;
   1.162 +		esac
   1.163 +
   1.164 +		# Stats
   1.165  		pkgs=$(cat $commits | wc -l)
   1.166  		echo "Packages to cook: $pkgs" | log
   1.167  		echo "Packages to cook : $pkgs" | log_commits
     2.1 --- a/web/cooker.cgi	Sat May 12 22:03:46 2012 +0100
     2.2 +++ b/web/cooker.cgi	Sat May 12 23:26:36 2012 +0200
     2.3 @@ -256,8 +256,19 @@
     2.4  			echo "<pre>No files list for: $pkg</pre>"
     2.5  		fi ;;
     2.6  	*)
     2.7 -		# Main page with summary.
     2.8 -		inwok=$(ls $WOK | wc -l)
     2.9 +		# We may have a toolchain.cgi script for cross cooker's
    2.10 +		if [ -f "toolchain.cgi" ]; then
    2.11 +			toolchain='toolchain.cgi'
    2.12 +		else
    2.13 +			toolchain='cooker.cgi?pkg=slitaz-toolchain'
    2.14 +		fi
    2.15 +		# Main page with summary. Count only package include in ARCH,
    2.16 +		# use 'cooker arch' to manually create arch.$ARCH files.
    2.17 +		# We may have arm only packages, use arch.i486 ?
    2.18 +		case "$ARCH" in
    2.19 +			arm) inwok=$(ls $WOK/*/arch.$ARCH | wc -l) ;;
    2.20 +			*) inwok=$(ls $WOK | wc -l) ;;
    2.21 +		esac
    2.22  		cooked=$(ls $PKGS/*.tazpkg | wc -l)
    2.23  		unbuilt=$(($inwok - $cooked))
    2.24  		pct=0
    2.25 @@ -281,7 +292,7 @@
    2.26  Blocked packages : $(cat $blocked | wc -l)
    2.27  </pre>
    2.28  
    2.29 -<p>
    2.30 +<p class="info">
    2.31  	Packages: $inwok in the wok - $cooked cooked - $unbuilt unbuilt -
    2.32  	Server date: $(date '+%Y-%m-%d %H:%M')
    2.33  </p>
    2.34 @@ -295,7 +306,7 @@
    2.35  	<a href="cooker.cgi?file=commits.log">commits.log</a>
    2.36  	<a href="cooker.cgi?file=installed.diff">installed.diff</a>
    2.37  	- Architecture $ARCH:
    2.38 -	<a href="cooker.cgi?pkg=slitaz-toolchain">toolchain.log</a>
    2.39 +	<a href="$toolchain">toolchain</a>
    2.40  </p>
    2.41  
    2.42  <a name="activity"></a>
     3.1 --- a/web/style.css	Sat May 12 22:03:46 2012 +0100
     3.2 +++ b/web/style.css	Sat May 12 23:26:36 2012 +0200
     3.3 @@ -28,28 +28,28 @@
     3.4  	width: 250px;
     3.5  }
     3.6  
     3.7 -#header h1 a { 
     3.8 -	color: white; 
     3.9 +#header h1 a {
    3.10 +	color: white;
    3.11  	text-decoration: none;
    3.12  	font-size: 20px;
    3.13  	font-style: italic;
    3.14  }
    3.15  
    3.16 -#header h1 a:hover, #network a:hover { 
    3.17 +#header h1 a:hover, #network a:hover {
    3.18  	color: #d66018;
    3.19  }
    3.20  
    3.21  /* Header links */
    3.22  
    3.23 -#network { 
    3.24 -	float: right; 
    3.25 -	padding: 10px 5px 0; 
    3.26 +#network {
    3.27 +	float: right;
    3.28 +	padding: 10px 5px 0;
    3.29  	font-size: 12px;
    3.30  }
    3.31  
    3.32  #network a {
    3.33  	padding: 0 6px;
    3.34 -	color: #fff; 
    3.35 +	color: #fff;
    3.36  	font-weight: bold;
    3.37  	text-decoration: none;
    3.38  }
    3.39 @@ -73,38 +73,31 @@
    3.40  /* Buttons */
    3.41  
    3.42  .button {
    3.43 -	padding: 2px 4px;
    3.44  	cursor: pointer;
    3.45 -	color: #000;
    3.46 +	padding: 4px;
    3.47 +	margin: 4px 0px;
    3.48  }
    3.49  
    3.50 -a.button  {
    3.51 +a.button, .pctbar  {
    3.52  	text-decoration: none;
    3.53  	color: #666;
    3.54  }
    3.55  
    3.56  .button:hover {
    3.57 -	background-color: #ddd;
    3.58  	border: 1px solid #999;
    3.59  }
    3.60  
    3.61 -.button {
    3.62 -	margin: 0;
    3.63 -	background: #f1f1f1;
    3.64 -	border: 1px solid #ddd;
    3.65 -}
    3.66 -
    3.67 -/* Progress bar */
    3.68 -
    3.69  .pct { background: #9dff4a; padding: 2px 4px; }
    3.70  
    3.71 -.pctbar {
    3.72 -	margin: 0;
    3.73 -	color: #666;
    3.74 -	background: #f1f1f1;
    3.75 -	border: 1px solid #ddd;
    3.76 -	overflow: hidden;
    3.77 -	clear: both;
    3.78 +.button, .pctbar {
    3.79 +	border: 1px solid #cccccc;
    3.80 +	font-size: 14px;
    3.81 +	line-height: 1.2em;
    3.82 +	background-image: -webkit-linear-gradient(#FAFAFA, #F4F4F4 40%, #E5E5E5);
    3.83 +	background-image: -moz-linear-gradient(#FAFAFA, #F4F4F4 40%, #E5E5E5);
    3.84 +	-webkit-box-shadow: 0px 1px 3px rgba(0, 0, 0, 0.1);
    3.85 +	-moz-box-shadow: 0px 1px 3px rgba(0, 0, 0, 0.1);
    3.86 +	box-shadow: 0px 1px 3px rgba(0, 0, 0, 0.1);
    3.87  }
    3.88  
    3.89  /* Round corner */