cookutils rev 484 slitaz-tank

cooker.cgi: Updated.
author Christopher Rogers <slaxemulator@gmail.com>
date Mon Jun 11 16:27:12 2012 +0000 (2012-06-11)
parents ee10b96cd87b
children 4b1f207c4058
files web/cooker.cgi
line diff
     1.1 --- a/web/cooker.cgi	Mon Jun 11 16:26:15 2012 +0000
     1.2 +++ b/web/cooker.cgi	Mon Jun 11 16:27:12 2012 +0000
     1.3 @@ -3,22 +3,7 @@
     1.4  # SliTaz Cooker CGI/web interface.
     1.5  #
     1.6  
     1.7 -[ -f "/etc/slitaz/cook.conf" ] && . /etc/slitaz/cook.conf
     1.8 -[ -f "cook.conf" ] && . ./cook.conf
     1.9 -
    1.10 -# The same wok as cook.
    1.11 -wok="$WOK"
    1.12 -
    1.13 -# Cooker DB files.
    1.14 -activity="$CACHE/activity"
    1.15 -commits="$CACHE/commits"
    1.16 -cooklist="$CACHE/cooklist"
    1.17 -cookorder="$CACHE/cookorder"
    1.18 -command="$CACHE/command"
    1.19 -blocked="$CACHE/blocked"
    1.20 -broken="$CACHE/broken"
    1.21 -cooknotes="$CACHE/cooknotes"
    1.22 -wokrev="$CACHE/wokrev"
    1.23 +. /usr/lib/slitaz/libcook.sh
    1.24  
    1.25  # We're not logged and want time zone to display correct server date.
    1.26  export TZ=$(cat /etc/TZ)
    1.27 @@ -106,11 +91,21 @@
    1.28  	done
    1.29  }
    1.30  
    1.31 +list_incoming() {
    1.32 +	cd $INCOMING
    1.33 +	ls -1t *.tazpkg | head -20 | \
    1.34 +	while read file
    1.35 +	do
    1.36 +		echo -n $(stat -c '%y' $INCOMING/$file | cut -d . -f 1 | sed s/:[0-9]*$//)
    1.37 +		echo " : $file"
    1.38 +	done
    1.39 +}
    1.40 +
    1.41  # xHTML header. Pages can be customized with a separated html.header file.
    1.42  if [ -f "header.html" ]; then
    1.43  	cat header.html
    1.44  else
    1.45 -	cat << EOT
    1.46 +cat << EOT
    1.47  <!DOCTYPE html>
    1.48  <html xmlns="http://www.w3.org/1999/xhtml">
    1.49  <head>
    1.50 @@ -123,6 +118,13 @@
    1.51  
    1.52  <div id="header">
    1.53  	<div id="logo"></div>
    1.54 +	<div id="network">
    1.55 +			<a href="http://pkgs.slitaz.org/cooking/">Database</a>
    1.56 +			<a href="http://tank.slitaz.org/graphs.php#cpu">Cpu</a>
    1.57 +			<a href="http://hg.slitaz.org/wok/">Hg</a>
    1.58 +			<a href="packages/">Packages</a>
    1.59 +			<a href="incoming/">Incoming</a>
    1.60 +	</div>
    1.61  	<h1><a href="cooker.cgi">SliTaz Cooker</a></h1>
    1.62  </div>
    1.63  
    1.64 @@ -143,26 +145,38 @@
    1.65  
    1.66  		# Package info.
    1.67  		echo '<div id="info">'
    1.68 -		if [ -f "$wok/$pkg/receipt" ]; then
    1.69 +		if [ -f "$WOK/$pkg/receipt" ]; then
    1.70  			echo "<a href='cooker.cgi?receipt=$pkg'>receipt</a>"
    1.71  			unset WEB_SITE
    1.72 -			. $wok/$pkg/receipt
    1.73 -			[ -n "$WEB_SITE" ] && # busybox wget -s $WEB_SITE &&
    1.74 +			. $WOK/$pkg/receipt
    1.75 +			[ -n "$WEB_SITE" ] && busybox wget -s $WEB_SITE &&
    1.76  			echo "<a href='$WEB_SITE'>home</a>"
    1.77 -			if [ -f "$wok/$pkg/taz/$PACKAGE-$VERSION/receipt" ]; then
    1.78 +			if [ -f "$WOK/$pkg/taz/$PACKAGE-$VERSION/receipt" ]; then
    1.79  				echo "<a href='cooker.cgi?files=$pkg'>files</a>"
    1.80  				unset EXTRAVERSION
    1.81 -				. $wok/$pkg/taz/$PACKAGE-$VERSION/receipt
    1.82 -				if [ -f $PKGS/$PACKAGE-$VERSION$EXTRAVERSION.tazpkg ]; then
    1.83 +				. $WOK/$pkg/taz/$PACKAGE-$VERSION/receipt
    1.84 +				if [ -f $PKGS/$PACKAGE-$VERSION$EXTRAVERSION-$ARCH.tazpkg ]; then
    1.85 +					echo "<a href='cooker.cgi?download=$PACKAGE-$VERSION$EXTRAVERSION-$ARCH.tazpkg'>download</a>"
    1.86 +				elif [ -f $PKGS/$PACKAGE-$VERSION$EXTRAVERSION.tazpkg ]; then
    1.87  					echo "<a href='cooker.cgi?download=$PACKAGE-$VERSION$EXTRAVERSION.tazpkg'>download</a>"
    1.88  				fi
    1.89 -				if [ -f $PKGS/$PACKAGE-$VERSION$EXTRAVERSION-$ARCH.tazpkg ]; then
    1.90 -					echo "<a href='cooker.cgi?download=$PACKAGE-$VERSION$EXTRAVERSION-$ARCH.tazpkg'>download</a>"
    1.91 +				
    1.92 +				if [ -f $SRC/$TARBALL ]; then
    1.93 +					echo "<a href='cooker.cgi?download=$TARBALL'>src tarball</a>"
    1.94 +				elif [ -f $SRC/$SOURCE-${KBASEVER:-$VERSION}.tar.lzma ]; then
    1.95 +					echo "<a href='cooker.cgi?download=$SOURCE-${KBASEVER:-$VERSION}.tar.lzma'>src tarball</a>"
    1.96 +				elif [ -f $SRC/$PACKAGE-${KBASEVER:-$VERSION}.tar.lzma ]; then
    1.97 +					echo "<a href='cooker.cgi?download=$PACKAGE-${KBASEVER:-$VERSION}.tar.lzma'>src tarball</a>"
    1.98  				fi
    1.99  			fi
   1.100  		else
   1.101  			echo "No package named: $pkg"
   1.102  		fi
   1.103 +		if [ -f $WOK/$pkg/taz/*/library.list ]; then
   1.104 +			echo "<a href='cooker.cgi?library=$pkg'>library</a>"
   1.105 +		else
   1.106 +			echo "No library: $pkg"
   1.107 +		fi
   1.108  		echo '</div>'
   1.109  
   1.110  		# Check for a log file and display summary if it exists.
   1.111 @@ -173,7 +187,7 @@
   1.112  			if fgrep -q "Summary for:" $LOGS/$pkg.log; then
   1.113  				echo "<h3>Cook summary</h3>"
   1.114  				echo '<pre>'
   1.115 -				grep -A 9 "^Summary for:" $LOGS/$pkg.log | sed /^$/d | \
   1.116 +				grep -A 10 "^Summary for:" $LOGS/$pkg.log | sed /^$/d | \
   1.117  					syntax_highlighter log
   1.118  				echo '</pre>'
   1.119  			fi
   1.120 @@ -209,6 +223,14 @@
   1.121  				cat $CACHE/$file | sort | \
   1.122  					sed s"#^[^']*#<a href='cooker.cgi?pkg=\0'>\0</a>#"g
   1.123  				echo '</pre>' ;;
   1.124 +			unbuild)
   1.125 +				# Main page with summary.
   1.126 +				nb=$(cat $unbuild | wc -l)
   1.127 +				echo "<h2>DB: unbuild - Packages: $nb</h2>"
   1.128 +				echo '<pre>'
   1.129 +				cat $CACHE/$file | sort | \
   1.130 +					sed s"#^[^']*#<a href='cooker.cgi?pkg=\0'>\0</a>#"g
   1.131 +				echo '</pre>' ;;
   1.132  			*.diff)
   1.133  				diff=$CACHE/$file
   1.134  				echo "<h2>Diff for: ${file%.diff}</h2>"
   1.135 @@ -239,9 +261,9 @@
   1.136  	receipt=*)
   1.137  		pkg=${QUERY_STRING#receipt=}
   1.138  		echo "<h2>Receipt for: $pkg</h2>"
   1.139 -		if [ -f "$wok/$pkg/receipt" ]; then
   1.140 +		if [ -f "$WOK/$pkg/receipt" ]; then
   1.141  			echo '<pre>'
   1.142 -			cat $wok/$pkg/receipt | syntax_highlighter receipt
   1.143 +			cat $WOK/$pkg/receipt | syntax_highlighter receipt
   1.144  			echo '</pre>'
   1.145  		else
   1.146  			echo "<pre>No receipt for: $pkg</pre>"
   1.147 @@ -258,6 +280,14 @@
   1.148  		else
   1.149  			echo "<pre>No files list for: $pkg</pre>"
   1.150  		fi ;;
   1.151 +	library=*)
   1.152 +		pkg=${QUERY_STRING#library=}
   1.153 +		echo "<h2>Library for: $pkg</h2>"
   1.154 +		if [ -f $WOK/$pkg/taz/*/library.list ]; then
   1.155 +			echo '<pre>'
   1.156 +			cat $WOK/$pkg/taz/*/library.list | sed "s|$pkg	||g" | sed 's| |\n|g' | sed '/^$/d'
   1.157 +			echo '</pre>'
   1.158 +		fi ;;
   1.159  	*)
   1.160  		# We may have a toolchain.cgi script for cross cooker's
   1.161  		if [ -f "toolchain.cgi" ]; then
   1.162 @@ -272,10 +302,14 @@
   1.163  			arm|x86_64) inwok=$(ls $WOK/*/arch.$ARCH | wc -l) ;;
   1.164  			*) inwok=$(ls $WOK | wc -l) ;;
   1.165  		esac
   1.166 -		cooked=$(ls $PKGS/*.tazpkg | wc -l)
   1.167 -		unbuilt=$(($inwok - $cooked))
   1.168 -		pct=0
   1.169 -		[ $inwok -gt 0 ] && pct=$(( ($cooked * 100) / $inwok ))
   1.170 +		pkg_cooked=$(ls $PKGS/*.tazpkg | wc -l)
   1.171 +		incoming_cooked=$(ls $INCOMING/*.tazpkg | wc -l)
   1.172 +		pkg_unbuilt=$(($inwok - $pkg_cooked))
   1.173 +		incoming_unbuilt=$(($inwok -$incoming_cooked))
   1.174 +		pkg_pct=0
   1.175 +		[ $inwok -gt 0 ] && pkg_pct=$(( ($pkg_cooked * 100) / $inwok ))
   1.176 +		incoming_pct=0
   1.177 +		[ $inwok -gt 0 ] && incoming_pct=$(( ($incoming_cooked * 100) / $inwok ))
   1.178  		cat << EOT
   1.179  <div style="float: right;">
   1.180  	<form method="get" action="$SCRIPT_NAME">
   1.181 @@ -293,14 +327,21 @@
   1.182  Current cooklist : $(cat $cooklist | wc -l)
   1.183  Broken packages  : $(cat $broken | wc -l)
   1.184  Blocked packages : $(cat $blocked | wc -l)
   1.185 +Unbuild packages : $(cat $unbuild | wc -l)
   1.186  </pre>
   1.187  
   1.188 -<p class="info">
   1.189 -	Packages: $inwok in the wok - $cooked cooked - $unbuilt unbuilt -
   1.190 -	Server date: $(date '+%Y-%m-%d %H:%M')
   1.191 +<p>
   1.192 +	Packages: $inwok in the wok - Server date: $(date '+%Y-%m-%d %H:%M')
   1.193  </p>
   1.194 +
   1.195 +	$pkg_cooked packages cooked - $pkg_unbuilt unbuilt
   1.196  <div class="pctbar">
   1.197 -	<div class="pct" style="width: ${pct}%;">${pct}%</div>
   1.198 +	<div class="pct" style="width: ${pkg_pct}%;">${pkg_pct}%</div>
   1.199 +</div>
   1.200 +
   1.201 +	$incoming_cooked incoming packages cooked - $incoming_unbuilt unbuilt
   1.202 +<div class="pctbar">
   1.203 +	<div class="pct" style="width: ${incoming_pct}%;">${incoming_pct}%</div>
   1.204  </div>
   1.205  
   1.206  <p>
   1.207 @@ -315,7 +356,7 @@
   1.208  <a name="activity"></a>
   1.209  <h2>Activity</h2>
   1.210  <pre>
   1.211 -$(tac $CACHE/activity | head -n 12 | syntax_highlighter activity)
   1.212 +$(tac $activity | head -n 12 | syntax_highlighter activity)
   1.213  </pre>
   1.214  <a class="button" href="cooker.cgi?file=activity">More activity</a>
   1.215  
   1.216 @@ -352,15 +393,30 @@
   1.217  $(cat $blocked | sed s"#^[^']*#<a href='cooker.cgi?pkg=\0'>\0</a>#"g)
   1.218  </pre>
   1.219  
   1.220 +<a name="unbuild"></a>
   1.221 +<h2>Unbuild</h2>
   1.222 +<pre>
   1.223 +$(cat $unbuild | head -n 20)
   1.224 +</pre>
   1.225 +<a class="button" href="cooker.cgi?file=unbuild">Unbuild</a>
   1.226 +
   1.227  <a name="lastcook"></a>
   1.228  <h2>Latest cook</h2>
   1.229  <pre>
   1.230 +$(list_incoming | sed s"#^\([^']*\).* : #<span class='log-date'>\0</span>#"g)
   1.231 +</pre>
   1.232 +
   1.233 +<h2>Latest packages for mirror</h2>
   1.234 +<pre>
   1.235  $(list_packages | sed s"#^\([^']*\).* : #<span class='log-date'>\0</span>#"g)
   1.236  </pre>
   1.237  EOT
   1.238  	;;
   1.239  esac
   1.240  
   1.241 +if [ -f "footer.html" ]; then
   1.242 +	cat footer.html
   1.243 +else
   1.244  # Close xHTML page
   1.245  cat << EOT
   1.246  </div>
   1.247 @@ -375,5 +431,6 @@
   1.248  </body>
   1.249  </html>
   1.250  EOT
   1.251 +fi
   1.252  
   1.253  exit 0