cookutils rev 924
A bunch of small improvements, incl.: cook: not touching main log when packing; find lastcooktime in other logs; summary for packing log; index.cgi: return back after changing the theme; show directories too among the files list, quick jump links; new download page (src & pkgs); new toolchain page; show packing log too.
author | Aleksej Bobylev <al.bobylev@gmail.com> |
---|---|
date | Sun Jun 11 21:39:35 2017 +0300 (2017-06-11) |
parents | 5d6cbb571217 |
children | 0b3395599e6f |
files | cook lighttpd/cooker.css lighttpd/cooker.js lighttpd/index.cgi |
line diff
1.1 --- a/cook Sun Jun 11 00:01:29 2017 +0300 1.2 +++ b/cook Sun Jun 11 21:39:35 2017 +0300 1.3 @@ -73,7 +73,7 @@ 1.4 1.5 clean_log() { 1.6 sed -i -e s'|\[70G\[ \[1;32m| |' \ 1.7 - -e s'|\[0;39m \]||' $LOGS/$pkg.log 1.8 + -e s'|\[0;39m \]||' $LOGS/${1:-$pkg}.log 1.9 } 1.10 1.11 1.12 @@ -1328,7 +1328,7 @@ 1.13 # Copy "standard" files (all but "developer files", man pages, documentation, translations) 1.14 sed '/\.h$/d; /\.hxx$/d; /\.a$/d; /\.la$/d; /\.pc$/d; /bin\/.*-config$/d; 1.15 /\.m4$/d; /\.gir$/d; /\.typelib$/d; /\.vapi$/d; /\.deps$/d; /\.cmake$/d; 1.16 - /\/Makefile.*/d; /\/include\//d; 1.17 + /\/Makefile.*/d; /\.inc$/d; /\/include\//d; 1.18 /\/share\/man\//d; /\/share\/doc\//d; /\/share\/gtk-doc\//d; /\/share\/info\//d; 1.19 /\/share\/devhelp\//d; /\/share\/locale\//d; 1.20 /\/share\/bash-completion\//d; /\/lib\/systemd\//d; 1.21 @@ -1338,7 +1338,7 @@ 1.22 # Copy "developer files" 1.23 sed -n '/\.h$/p; /\.hxx$/p; /\.a$/p; /\.la$/p; /\.pc$/p; /bin\/.*-config$/p; 1.24 /\.m4$/p; /\.gir$/p; /\.typelib$/p; /\.vapi$/p; /\.deps$/p; /\.cmake$/p; 1.25 - /\/Makefile.*/p; /\/include\//p; 1.26 + /\/Makefile.*/p; /\.inc$/p; /\/include\//p; 1.27 ' $filelist 1.28 ;; 1.29 */) 1.30 @@ -1720,8 +1720,14 @@ 1.31 pkg="$1" 1.32 [ -z "$pkg" ] && usage 1.33 1.34 - lastcooktime=$(sed '/^Cook time/!d; s|.*: *\([0-9]*\)s.*|\1|' \ 1.35 - $LOGS/$pkg.log 2>/dev/null | sed '$!d') 1.36 + # Search last successful cook time in all logs from newer to older 1.37 + for i in '' $(seq 0 9 | sed 's|^|.|'); do 1.38 + [ -f "$LOGS/$pkg.log$i" ] || break 1.39 + lastcooktime=$(sed '/^Cook time/!d; s|.*: *\([0-9]*\)s.*|\1|' \ 1.40 + $LOGS/$pkg.log$i 2>/dev/null | sed '$!d') 1.41 + [ -n "$lastcooktime" ] && break 1.42 + done 1.43 + 1.44 receipt="$WOK/$pkg/receipt" 1.45 check_pkg_in_wok 1.46 newline 1.47 @@ -1811,11 +1817,13 @@ 1.48 exit 0 ;; 1.49 1.50 --pack) 1.51 - [ -d $WOK/$pkg/taz ] || die 'Need to build "%s"' "$pkg" 1.52 - rm -rf $WOK/$pkg/taz 1.53 - [ -f $LOGS/$pkg-pack.log ] && rm -rf $LOGS/$pkg-pack.log 1.54 + [ -d "$WOK/$pkg/install" ] || die 'Need to build "%s"' "$pkg" 1.55 + [ ! -d "$WOK/$pkg/taz" ] || rm -rf "$WOK/$pkg/taz" 1.56 + [ ! -f "$LOGS/$pkg-pack.log" ] || rm -rf $LOGS/$pkg-pack.log 1.57 packall 2>&1 | tee -a $LOGS/$pkg-pack.log 1.58 - clean_log 1.59 + clean_log "$pkg-pack" 1.60 + time=$(($(date +%s) - $time)) 1.61 + summary | sed 's|^Cook |Pack |' | tee -a $LOGS/$pkg-pack.log 1.62 rm -f $command 1.63 exit 0 ;; 1.64
2.1 --- a/lighttpd/cooker.css Sun Jun 11 00:01:29 2017 +0300 2.2 +++ b/lighttpd/cooker.css Sun Jun 11 21:39:35 2017 +0300 2.3 @@ -314,7 +314,7 @@ 2.4 /* Table */ 2.5 2.6 table { width: 100%; box-sizing: border-box; border-collapse: collapse; /*box-shadow: 0 0 4px rgba(0,0,0,0.3);*/ } 2.7 -th { color: rgba(0,0,0,0.6); background-color: rgba(0,0,0,0.2); padding: 3px; } 2.8 +th { color: rgba(0,0,0,0.6); background-color: rgba(0,0,0,0.1); padding: 3px; } 2.9 td { padding: 2px; vertical-align: top; } 2.10 td:first-child { white-space: nowrap; width: 5rem; } 2.11 td+td, th+th { border-left: 1px solid rgba(0,0,0,0.1); }
3.1 --- a/lighttpd/cooker.js Sun Jun 11 00:01:29 2017 +0300 3.2 +++ b/lighttpd/cooker.js Sun Jun 11 21:39:35 2017 +0300 3.3 @@ -54,10 +54,13 @@ 3.4 // Calculate and show server date 3.5 3.6 function calcAndShowDate() { 3.7 - var serverDateNow = new Date() - deltaTime; 3.8 - var serverDateString = new Date(serverDateNow).toISOString(); 3.9 - // Format string in form 'YYYY-mm-dd HH:MM UTC' 3.10 - document.getElementById('date').innerHTML = serverDateString.substring(0, 10) + ' ' + serverDateString.substring(11, 16) + ' UTC'; 3.11 + var dateEl = document.getElementById('date'); 3.12 + if (dateEl !== null) { 3.13 + var serverDateNow = new Date() - deltaTime; 3.14 + var serverDateString = new Date(serverDateNow).toISOString(); 3.15 + // Format string in form 'YYYY-mm-dd HH:MM UTC' 3.16 + dateEl.innerHTML = serverDateString.substring(0, 10) + ' ' + serverDateString.substring(11, 16) + ' UTC'; 3.17 + } 3.18 } 3.19 3.20
4.1 --- a/lighttpd/index.cgi Sun Jun 11 00:01:29 2017 +0300 4.2 +++ b/lighttpd/index.cgi Sun Jun 11 21:39:35 2017 +0300 4.3 @@ -273,6 +273,7 @@ 4.4 4.5 if [ -n "$(GET theme)" ]; then 4.6 theme="$(GET theme)" 4.7 + ref="$(echo "$HTTP_REFERER" | sed 's|:|%3A|g; s|/|%2F|g; s|\?|%3F|g; s|\+|%2B|g;')" 4.8 case $theme in 4.9 theme) 4.10 current=$(COOKIE theme) 4.11 @@ -284,7 +285,7 @@ 4.12 <ul> 4.13 $( 4.14 for i in default emerald sky goldenrod midnight like2016 terminal; do 4.15 - [ "$i" == "${current:-default}" ] || echo "<li><a href="$base/?theme=$i">$i</a></li>" 4.16 + [ "$i" == "${current:-default}" ] || echo "<li><a href=\"$base/?theme=$i&ref=$ref\">$i</a></li>" 4.17 done 4.18 ) 4.19 </ul> 4.20 @@ -294,9 +295,11 @@ 4.21 exit 0 4.22 ;; 4.23 default|emerald|sky|goldenrod|midnight|like2016|terminal) 4.24 + ref="$(GET ref)" 4.25 + [ -n "$ref" ] || ref="$base/" 4.26 # Expires in a year 4.27 expires=$(date -uRd @$(($(date +%s)+31536000)) | sed 's|UTC|GMT|') 4.28 - echo -e "HTTP/1.1 302 Found\nLocation: $base/\nCache-Control: no-cache\nSet-Cookie: theme=$theme; expires=$expires\n\n" 4.29 + echo -e "HTTP/1.1 302 Found\nLocation: $ref\nCache-Control: no-cache\nSet-Cookie: theme=$theme; expires=$expires\n\n" 4.30 exit 0 4.31 ;; 4.32 esac 4.33 @@ -528,12 +531,14 @@ 4.34 if (part3 != "root ") part3 = "<span class=\"c11\">" part3 "</span>"; 4.35 print part1 part2 part3 part4; 4.36 }' | \ 4.37 - sed "s|\[\([01]\);3\([1-7]\)m|<a class='c\2\1'>|g; 4.38 + sed "s|\[0m/|/\[0m|g; 4.39 + s|\[\([01]\);3\([1-7]\)m|<a class='c\2\1'>|g; 4.40 s|\[\([01]\);0m|<a class='c0\1'>|g; 4.41 s|\[0m|</a>|g; 4.42 s|^\(lrwxrwxrwx\)|<span class='c61'>\1</span>|; 4.43 s|^\(-rwxr-xr-x\)|<span class='c21'>\1</span>|; 4.44 s|^\(-rw-r--r--\)|<span class='c31'>\1</span>|; 4.45 + s|^\(drwxr-xr-x\)|<span class='c41'>\1</span>|; 4.46 s|^\([lrwxs-]*\)|<span class='c11'>\1</span>|; 4.47 " 4.48 ;; 4.49 @@ -627,7 +632,7 @@ 4.50 local log active bpkg 4.51 log="$LOGS/$pkg.log" 4.52 4.53 - echo "<h2>Package “$pkg”</h2>" 4.54 + echo "<h2>$pkg</h2>" 4.55 echo '<div id="info">' 4.56 echo "<a class='button icon receipt$(active receipt stuff)' href='$base/$pkg/receipt'>receipt & stuff</a>" 4.57 4.58 @@ -643,18 +648,10 @@ 4.59 [ -n "$(ls $wok/$pkg/description*.txt)" ] && 4.60 echo "<a class='button icon desc$(active description)' href='$base/$pkg/description'>description</a>" 4.61 4.62 - unset EXTRAVERSION 4.63 - . $wok/$pkg/taz/$PACKAGE-$VERSION/receipt 4.64 - for filename in "$PACKAGE-$VERSION$EXTRAVERSION.tazpkg" "$PACKAGE-$VERSION$EXTRAVERSION-$ARCH.tazpkg"; do 4.65 - [ -f "$PKGS/$filename" ] && 4.66 - echo "<a class='button icon download' href='$base/get/$filename'>download</a>" 4.67 - done 4.68 - 4.69 + [ -n "$TARBALL" -a -s "$SRC/$TARBALL" -o -d "$wok/$pkg/taz" ] && 4.70 + echo "<a class='button icon download' href='$base/$pkg/download'>download</a>" 4.71 fi 4.72 4.73 - [ -n "$TARBALL" -a -s "$SRC/$TARBALL" ] && 4.74 - echo "<a class='button icon source' href='$base/src/$TARBALL'>source</a>" 4.75 - 4.76 echo "<a class='button icon browse' href='$base/$pkg/browse/'>browse</a>" 4.77 4.78 [ -x ./man2html -a -d "$wok/$pkg/install/usr/share/man" ] && 4.79 @@ -704,6 +701,40 @@ 4.80 } 4.81 4.82 4.83 +# Return all the names of packages bundled in this receipt 4.84 + 4.85 +all_names() { 4.86 + local split=" $SPLIT " 4.87 + if [ "${split/ $PACKAGE /}" != "$split" ]; then 4.88 + # $PACKAGE included somewhere in $SPLIT (probably in the end). 4.89 + # We should build packages in the order defined in the $SPLIT. 4.90 + echo $SPLIT 4.91 + else 4.92 + # We'll build the $PACKAGE, then all defined in the $SPLIT. 4.93 + echo $PACKAGE $SPLIT 4.94 + fi 4.95 +} 4.96 + 4.97 + 4.98 +toolchain_version() { 4.99 + echo "<tr><td><a href='$base/$1'>$1</a></td><td>" 4.100 + if [ -e "$WOK/$1/receipt" ]; then 4.101 + grep ^VERSION $WOK/$1/receipt | cut -d '"' -f2 4.102 + echo '</td><td>' 4.103 + grep ^SHORT_DESC $WOK/$1/receipt | cut -d '"' -f2 4.104 + else 4.105 + echo -n '---</td><td>---' 4.106 + fi 4.107 + echo "</td></tr>" 4.108 +} 4.109 + 4.110 + 4.111 +files_header() { 4.112 + echo '<section><h3>Available downloads:</h3>' 4.113 + echo '<table><thead><tr><th>File</th><th>Size</th><th>Description</th></tr></thead><tbody>' 4.114 +} 4.115 + 4.116 + 4.117 4.118 4.119 # 4.120 @@ -752,6 +783,34 @@ 4.121 show_note e "No log file: $log" 4.122 fi 4.123 ;; 4.124 + toolchain) 4.125 + cat <<EOT 4.126 +<div id="content2"> 4.127 +<section> 4.128 +<h2>SliTaz GNU/Linux toolchain</h2> 4.129 + 4.130 +<table> 4.131 +<tr><td>Build date</td> <td colspan="2">$(sed -n '/^Cook date/s|[^:]*: \(.*\)|\1|p' $LOGS/slitaz-toolchain.log)</td></tr> 4.132 +<tr><td>Build duration</td> <td colspan="2">$(sed -n '/^Cook time/s|[^:]*: \(.*\)|\1|p' $LOGS/slitaz-toolchain.log)</td></tr> 4.133 +<tr><td>Architecture</td> <td colspan="2">$ARCH</td></tr> 4.134 +<tr><td>Build system</td> <td colspan="2">$BUILD_SYSTEM</td></tr> 4.135 +<tr><td>Host system</td> <td colspan="2">$HOST_SYSTEM</td></tr> 4.136 +<tr><th>Package</th><th>Version</th><th>Description</th></tr> 4.137 +$(toolchain_version slitaz-toolchain) 4.138 +$(toolchain_version binutils) 4.139 +$(toolchain_version linux-api-headers) 4.140 +$(toolchain_version gcc) 4.141 +$(toolchain_version glibc) 4.142 +</table> 4.143 + 4.144 +<p>Toolchain documentation: <a target="_blank" rel="noopener noreferrer" 4.145 +href="http://doc.slitaz.org/en:cookbook:toolchain">http://doc.slitaz.org/en:cookbook:toolchain</a> 4.146 +</p> 4.147 + 4.148 +</section> 4.149 +</div> 4.150 +EOT 4.151 + ;; 4.152 esac 4.153 page_footer 4.154 exit 0 4.155 @@ -762,12 +821,12 @@ 4.156 if [ -f "toolchain.cgi" ]; then 4.157 toolchain="toolchain.cgi" 4.158 else 4.159 - toolchain="slitaz-toolchain/" 4.160 + toolchain="?toolchain" 4.161 fi 4.162 # Main page with summary. Count only packages included in ARCH, 4.163 # use 'cooker arch-db' to manually create arch.$ARCH files. 4.164 inwok=$(ls $WOK/*/arch.$ARCH | wc -l) 4.165 - cooked=$(ls $PKGS/*.tazpkg | wc -l) 4.166 + cooked=$(ls -d $WOK/*/taz | wc -l) 4.167 unbuilt=$(($inwok - $cooked)) 4.168 pct=0; [ $inwok -gt 0 ] && pct=$(( ($cooked * 100) / $inwok )) 4.169 cat <<EOT 4.170 @@ -813,7 +872,7 @@ 4.171 fi 4.172 4.173 cat <<EOT 4.174 -<p>Packages: $inwok in the wok · $cooked cooked · $unbuilt unbuilt</p> 4.175 +<p>Receipts in the wok: $inwok total · $cooked cooked · $unbuilt unbuilt</p> 4.176 4.177 <div class="meter"><progress max="100" value="$pct">${pct}%</progress><span>${pct}%</span></div> 4.178 4.179 @@ -1018,6 +1077,13 @@ 4.180 fi 4.181 ver=$(. $wok/$main/receipt; echo $VERSION$EXTRAVERSION) 4.182 4.183 + 4.184 + echo "<section><h3>Quick jump:</h3><ul>" 4.185 + echo "$split" | sed 'p' | xargs printf "<li><a href='#id-%s'>%s</a></li>\n" 4.186 + echo "<li><a href='#id-repeats'>repeatedly packaged files</a> (if any)</li>" 4.187 + echo "<li><a href='#id-orphans'>unpackaged files</a> (if any)</li>" 4.188 + echo "</ul></section>" 4.189 + 4.190 for p in $split; do 4.191 namever="$p-$ver" 4.192 if [ -d "$wok/$p/taz/$p-$ver" ]; then 4.193 @@ -1029,15 +1095,15 @@ 4.194 4.195 size=$(du -hs $dir | awk '{ sub(/\.0/, ""); print $1 }') 4.196 4.197 - echo "<section><h3>Files of package “$namever” (${size:-empty}):</h3>" 4.198 + echo "<section><h3 id='id-$p'>Content of package “$namever” (${size:-empty}):</h3>" 4.199 echo '<pre class="files">' 4.200 if [ -s "$wok/$indir/taz/$p-$ver/files.list" ]; then 4.201 echo -n '<span class="underline">permissions·lnk·user ·' 4.202 - echo -en 'group · size·date & time ·file name\n</span>' 4.203 + echo -en 'group · size·date & time ·name\n</span>' 4.204 cd $dir 4.205 - find . -not -type d -print0 | sort -z | xargs -0 ls -ld --color=always | \ 4.206 + find . -print0 | sort -z | xargs -0 ls -ldp --color=always | \ 4.207 syntax_highlighter files | \ 4.208 - sed "s|\([^>]*\)>\.\([^<]*\)\(<.*\)$|\1 href='$base/$indir/browse/taz/$p-$ver/fs\2'>\2\3|" | \ 4.209 + sed "s|\([^>]*\)>\.\([^<]*\)\(<.*\)$|\1 href='$base/$indir/browse/taz/$p-$ver/fs\2'>\2\3|;" | \ 4.210 awk 'BEGIN { FS="\""; } 4.211 { gsub("+", "%2B", $2); print; }' 4.212 else 4.213 @@ -1050,7 +1116,7 @@ 4.214 # find repeatedly packaged files 4.215 repeats="$(sort $packaged | uniq -d)" 4.216 if [ -n "$repeats" ]; then 4.217 - echo -n '<section><h3>Repeatedly packaged files:</h3><pre class="files">' 4.218 + echo -n '<section><h3 id="id-repeats">Repeatedly packaged files:</h3><pre class="files">' 4.219 echo "$repeats" | sed 's|^|<span class="c11">!!!</span> |' 4.220 echo "</pre></section>" 4.221 fi 4.222 @@ -1060,10 +1126,13 @@ 4.223 cd $wok/$main/install; find ! -type d | sed 's|\.||' > $all_files 4.224 orphans="$(sort $all_files $packaged | uniq -u)" 4.225 if [ -d "$wok/$main/install" -a -n "$orphans" ]; then 4.226 - echo '<section><h3>Unpackaged files:</h3>' 4.227 + echo '<section><h3 id="id-orphans">Unpackaged files:</h3>' 4.228 table=$(mktemp) 4.229 - echo "$orphans" | awk ' 4.230 - function tag(text, color) { printf("<span class=\"c%s1\">%s</span> %s\n", color, text, $0); } 4.231 + echo "$orphans" | awk -vi="$base/$indir/browse/install" ' 4.232 + function tag(text, color) { 4.233 + printf("<span class=\"c%s1\">%s</span> ", color, text); 4.234 + printf("<a class=\"c00\" href=\"%s\">%s</a>\n", i $0, $0); 4.235 + } 4.236 /\/perllocal.pod$/ || /\/\.packlist$/ || /\/share\/bash-completion\// || 4.237 /\/lib\/systemd\// || /\.pyc$/ || /\.pyo$/ { tag("---", 0); next } 4.238 /\.pod$/ { tag("pod", 5); next } 4.239 @@ -1072,7 +1141,8 @@ 4.240 /\/share\/devhelp\// { tag("doc", 5); next } 4.241 /\/share\/icons\// { tag("ico", 2); next } 4.242 /\/share\/locale\// { tag("loc", 4); next } 4.243 - /\.h$/ || /\.a$/ || /\.la$/ || /\.pc$/ || /\/bin\/.*-config$/ || /\/Makefile.*$/ { tag("dev", 3); next } 4.244 + /\.h$/ || /\.a$/ || /\.la$/ || /\.pc$/ || /\/bin\/.*-config$/ || 4.245 + /\/Makefile.*$/ { tag("dev", 3); next } 4.246 { tag("???", 1) } 4.247 ' > $table 4.248 4.249 @@ -1126,14 +1196,16 @@ 4.250 [ -z "$arg" ] && arg=$(stat -c %Y $LOGS/$pkg.log) 4.251 4.252 echo '<div class="btnList">' 4.253 - acc='l' 4.254 + acc='l' # access key for the latest log is 'L' 4.255 while read log; do 4.256 + # for all $pkg.log, $pkg.log.0 .. $pkg.log.9, $pkg-pack.log (if any) 4.257 timestamp=$(stat -c %Y $log) 4.258 class='' 4.259 if [ "$arg" == "$timestamp" ]; then 4.260 class=' log' 4.261 logfile="$log" 4.262 fi 4.263 + case $log in *-pack.log) acc='p';; esac # access key for the packing log is 'P' 4.264 echo -n "<a class='button$class' data-acc='$acc' accesskey='$acc' href='$base/$pkg/log/$timestamp'>" 4.265 echo "$(stat -c %y $log | cut -d: -f1,2)</a>" 4.266 case $acc in 4.267 @@ -1142,6 +1214,7 @@ 4.268 esac 4.269 done <<EOT 4.270 $(find $LOGS -name "$pkg.log*" | sort) 4.271 +$(find $LOGS -name "$pkg-pack.log") 4.272 EOT 4.273 echo '</div>' 4.274 4.275 @@ -1315,6 +1388,49 @@ 4.276 fi 4.277 ;; 4.278 4.279 + download) 4.280 + page_header 4.281 + pkg_info 4.282 + show=0 4.283 + 4.284 + . $wok/$pkg/receipt 4.285 + 4.286 + if [ -n "$TARBALL" -a -s "$SRC/$TARBALL" ]; then 4.287 + files_header 4.288 + echo "<tr><td><a href='$base/src/$TARBALL'>$TARBALL</a></td>" 4.289 + ls -lh "$SRC/$TARBALL" | awk '{printf("<td>%sB</td>", $5)}' 4.290 + echo "<td>Sources for building the package “$pkg”</td></tr>" 4.291 + show=1 4.292 + fi 4.293 + 4.294 + if [ -d "$wok/$pkg/taz" ]; then 4.295 + [ "$show" -eq 1 ] || files_header 4.296 + 4.297 + for i in $(all_names); do 4.298 + [ -e "$wok/$pkg/taz/$i-$VERSION$EXTRAVERSION/receipt" ] || continue 4.299 + . $wok/$pkg/taz/$i-$VERSION$EXTRAVERSION/receipt 4.300 + 4.301 + for filename in "$PACKAGE-$VERSION$EXTRAVERSION.tazpkg" "$PACKAGE-$VERSION$EXTRAVERSION-$ARCH.tazpkg"; do 4.302 + [ -f "$PKGS/$filename" ] && 4.303 + cat <<EOT 4.304 +<tr> 4.305 +<td><a href="$base/get/$filename">$filename</a></td> 4.306 +<td>$(ls -lh ./packages/$filename | awk '{printf("%sB", $5)}')</td> 4.307 +<td>$SHORT_DESC</td> 4.308 +</tr> 4.309 +EOT 4.310 + done 4.311 + done 4.312 + show=1 4.313 + fi 4.314 + 4.315 + if [ "$show" -eq 1 ]; then 4.316 + echo '</tbody></table></section>' 4.317 + else 4.318 + show_note w "Sorry, there's nothing to download…" 4.319 + fi 4.320 + ;; 4.321 + 4.322 esac 4.323 4.324