cookutils rev 940
cook: improve patchit() and all_names(); modules/deps: change the cases upside down, show update stats (it not hangs); lighttpd/index.cgi: use split.db to make search datalist, and to search packages (no need to `ls` ~ 5000 dirs, just one file); lighttpd/cooker.css: style the matches in search page.
author | Aleksej Bobylev <al.bobylev@gmail.com> |
---|---|
date | Thu Jun 22 20:18:08 2017 +0300 (2017-06-22) |
parents | 9c470f60d0d0 |
children | adda5217f721 |
files | cook lighttpd/cooker.css lighttpd/index.cgi modules/deps |
line diff
1.1 --- a/cook Tue Jun 20 19:02:35 2017 +0100 1.2 +++ b/cook Thu Jun 22 20:18:08 2017 +0300 1.3 @@ -545,7 +545,7 @@ 1.4 1.5 IFS=$'\n' 1.6 while read i; do 1.7 - patchname=$(echo $i | cut -d' ' -f1) # allow comments (anything after the space) 1.8 + patchname=$(echo ${i%%#*} | cut -d' ' -f1) # allow comments (anything after the # or space) 1.9 [ -n "$patchname" ] || continue # allow empty lines 1.10 [ -f "$src/done.$patchname" ] && continue # already applied (useful with `cook --continue`) 1.11 newline 1.12 @@ -1093,7 +1093,11 @@ 1.13 1.14 all_names() { 1.15 local split=" $SPLIT " 1.16 - if [ "${split/ $PACKAGE /}" != "$split" ]; then 1.17 + if ! head -n1 $WOK/$pkg/receipt | fgrep -q 'v2'; then 1.18 + # For receipts v1: $SPLIT may present in the $WANTED package, 1.19 + # but split packages have their own receipts 1.20 + echo $PACKAGE 1.21 + elif [ "${split/ $PACKAGE /}" != "$split" ]; then 1.22 # $PACKAGE included somewhere in $SPLIT (probably in the end). 1.23 # We should build packages in the order defined in the $SPLIT. 1.24 echo $SPLIT 1.25 @@ -1451,10 +1455,10 @@ 1.26 > $db 1.27 1.28 cd $WOK 1.29 - for i in *; do 1.30 - [ -f "$WOK/$i/receipt" ] || continue 1.31 + for pkg in *; do 1.32 + [ -f "$WOK/$pkg/receipt" ] || continue 1.33 unset PACKAGE SPLIT 1.34 - . $WOK/$i/receipt 1.35 + . $WOK/$pkg/receipt 1.36 echo -e "$PACKAGE\t$(all_names)" >> $db 1.37 done 1.38 }
2.1 --- a/lighttpd/cooker.css Tue Jun 20 19:02:35 2017 +0100 2.2 +++ b/lighttpd/cooker.css Thu Jun 22 20:18:08 2017 +0300 2.3 @@ -158,6 +158,12 @@ 2.4 margin: auto; 2.5 padding: 0.5em; 2.6 } 2.7 +mark { 2.8 + background: #FF8; 2.9 + border: solid #EB7; 2.10 + border-radius: 4px; 2.11 + border-width: 1px 0; 2.12 +} 2.13 2.14 2.15 .span-ok { color: #0a0; }
3.1 --- a/lighttpd/index.cgi Tue Jun 20 19:02:35 2017 +0100 3.2 +++ b/lighttpd/index.cgi Thu Jun 22 20:18:08 2017 +0300 3.3 @@ -31,6 +31,7 @@ 3.4 cooktime="$CACHE/cooktime" 3.5 wokrev="$CACHE/wokrev" 3.6 webstat="$CACHE/webstat" 3.7 +splitdb="$CACHE/split.db" 3.8 3.9 # Path to markdown to html convertor 3.10 cmark_opts='--smart -e table -e strikethrough -e autolink -e tagfilter' 3.11 @@ -555,15 +556,11 @@ 3.12 3.13 3.14 datalist() { 3.15 - ( 3.16 - cd $wok 3.17 - 3.18 - ls | awk ' 3.19 + cut -d$'\t' -f2 $splitdb | tr ' ' '\n' | sort -u | awk ' 3.20 BEGIN{printf("<datalist id=\"packages\">")} 3.21 - {printf("<option>%s</option>",$1)} 3.22 + {printf("<option>%s",$1)} 3.23 END {printf("</datalist>")} 3.24 ' 3.25 - ) 3.26 } 3.27 3.28 3.29 @@ -740,6 +737,7 @@ 3.30 3.31 # Update statistics used in web interface. 3.32 # There is no need to recalculate the statistics every time the page is displayed. 3.33 +# Note, $webstat file must be owned by www, otherwise this function will not be able to do the job. 3.34 3.35 update_webstat() { 3.36 echo '<div id="waitme">' 3.37 @@ -975,33 +973,53 @@ 3.38 case "$cmd" in 3.39 '') 3.40 page_header 3.41 - log=$LOGS/$pkg.log 3.42 3.43 # Package info. 3.44 - if [ -f "$wok/$pkg/receipt" ]; then 3.45 - pkg_info 3.46 - else 3.47 - if [ $(ls $wok/*$pkg*/receipt 2>/dev/null | wc -l) -eq 0 ]; then 3.48 - echo "<h2>Not Found</h2>" 3.49 - show_note e "The requested package <b>$pkg</b> was not found on this server." 3.50 - else 3.51 - # Search page 3.52 + if [ ! -f "$wok/$pkg/receipt" ]; then 3.53 + # Let's look at the cases when the package was not found 3.54 + 3.55 + # Maybe query is the exact name of split package? -> proceed to main package 3.56 + mainpkg=$(awk -F$'\t' -vpkg=" $pkg " '{ 3.57 + if (index(" " $2 " ", pkg)) {print $1; exit} 3.58 + }' $splitdb) 3.59 + 3.60 + # No, so let's find any matches among packages names (both main and split) 3.61 + if [ -z "$mainpkg" ]; then 3.62 + pkgs=$(cut -d$'\t' -f2 $splitdb | tr ' ' '\n' | fgrep "$pkg") 3.63 + # Nothing matched 3.64 + if [ -z "$pkgs" ]; then 3.65 + echo "<h2>Not Found</h2>" 3.66 + show_note e "The requested package <b>$pkg</b> was not found on this server." 3.67 + page_footer; exit 0 3.68 + fi 3.69 + # Search results page 3.70 echo "<section><h2>Package names matching “$pkg”</h2>" 3.71 echo "<table><thead><tr><th>Name</th><th>Description</th><th>Category</th></tr></thead><tbody>" 3.72 - for i in $(cd $wok; ls *$pkg*/receipt); do 3.73 - pkg=$(dirname $i) 3.74 + query="$pkg" 3.75 + for pkg in $pkgs; do 3.76 + # Find main package 3.77 + mainpkg=$(awk -F$'\t' -vpkg=" $pkg " '{ 3.78 + if (index(" " $2 " ", pkg)) {print $1; exit} 3.79 + }' $splitdb) 3.80 + unset SHORT_DESC CATEGORY; . $wok/$mainpkg/receipt 3.81 + 3.82 unset SHORT_DESC CATEGORY 3.83 - . $wok/$pkg/receipt 3.84 - echo -n "<tr><td><a href="$base/$pkg">$pkg</a></td>" 3.85 - echo -n "<td>$SHORT_DESC</td><td>$CATEGORY</td></tr>" 3.86 + [ -e "$wok/$mainpkg/taz/$PACKAGE-$VERSION/receipt" ] && 3.87 + . $wok/$mainpkg/taz/$PACKAGE-$VERSION/receipt 3.88 + 3.89 + echo -n "<tr><td><a href="$base/$pkg">${pkg//$query/<mark>$query</mark>}</a>" 3.90 + [ "$pkg" == "$mainpkg" ] || echo -n " (${mainpkg//$query/<mark>$query</mark>})" 3.91 + echo -n "</td><td>$SHORT_DESC</td><td>$CATEGORY</td></tr>" 3.92 done 3.93 echo '</tbody></table></section>' 3.94 - unset pkg 3.95 + page_footer; exit 0 3.96 fi 3.97 - page_footer 3.98 - exit 0 3.99 + pkg="$mainpkg" 3.100 fi 3.101 3.102 + log=$LOGS/$pkg.log 3.103 + pkg_info 3.104 + 3.105 # Check for a log file and display summary if it exists. 3.106 summary "$log" 3.107 3.108 @@ -1128,9 +1146,9 @@ 3.109 3.110 3.111 echo "<section><h3>Quick jump:</h3><ul>" 3.112 - echo "$split" | sed 'p' | xargs printf "<li><a href='#id-%s'>%s</a></li>\n" 3.113 - echo "<li id='li-repeats' style='display:none'><a href='#id-repeats'>repeatedly packaged files</a></li>" 3.114 - echo "<li id='li-orphans' style='display:none'><a href='#id-orphans'>unpackaged files</a></li>" 3.115 + echo "$split" | sed 'p' | xargs printf "<li><a href='#%s'>%s</a></li>\n" 3.116 + echo "<li id='li-repeats' style='display:none'><a href='#repeats'>repeatedly packaged files</a></li>" 3.117 + echo "<li id='li-orphans' style='display:none'><a href='#orphans'>unpackaged files</a></li>" 3.118 echo "</ul></section>" 3.119 3.120 for p in $split; do 3.121 @@ -1144,7 +1162,7 @@ 3.122 3.123 size=$(du -hs $dir | awk '{ sub(/\.0/, ""); print $1 }') 3.124 3.125 - echo "<section><h3 id='id-$p'>Contents of package “$namever” (${size:-empty}):</h3>" 3.126 + echo "<section><h3 id='$p'>Contents of package “$namever” (${size:-empty}):</h3>" 3.127 echo '<pre class="files">' 3.128 if [ -s "$wok/$indir/taz/$p-$ver/files.list" ]; then 3.129 echo -n '<span class="underline">permissions·lnk·user ·' 3.130 @@ -1166,7 +1184,7 @@ 3.131 repeats="$(sort $packaged | uniq -d)" 3.132 if [ -n "$repeats" ]; then 3.133 echo '<script>document.getElementById("li-repeats").style.display = "list-item"</script>' 3.134 - echo -n '<section><h3 id="id-repeats">Repeatedly packaged files:</h3><pre class="files">' 3.135 + echo -n '<section><h3 id="repeats">Repeatedly packaged files:</h3><pre class="files">' 3.136 echo "$repeats" | sed 's|^|<span class="c11">!!!</span> |' 3.137 echo "</pre></section>" 3.138 fi 3.139 @@ -1177,7 +1195,7 @@ 3.140 orphans="$(sort $all_files $packaged | uniq -u)" 3.141 if [ -d "$wok/$main/install" -a -n "$orphans" ]; then 3.142 echo '<script>document.getElementById("li-orphans").style.display = "list-item"</script>' 3.143 - echo '<section><h3 id="id-orphans">Unpackaged files:</h3>' 3.144 + echo '<section><h3 id="orphans">Unpackaged files:</h3>' 3.145 table=$(mktemp) 3.146 echo "$orphans" | awk -vi="$base/$indir/browse/install" ' 3.147 function tag(text, color) {
4.1 --- a/modules/deps Tue Jun 20 19:02:35 2017 +0100 4.2 +++ b/modules/deps Thu Jun 22 20:18:08 2017 +0300 4.3 @@ -28,7 +28,11 @@ 4.4 # It's useful on casual development on local host, but useless on cooker server 4.5 # (and slows down list creation a lot). 4.6 tank) 4.7 + [ ! -s $fl -o $fl_local -nt $fl ] && cp $fl_local $fl 4.8 + ;; 4.9 + *) 4.10 if [ ! -s $fl -o $fl_mirrorz -nt $fl -o $fl_local -nt $fl ]; then 4.11 + action 'Updating %s...' "$(basename $fl)" 4.12 # unpack mirror files list 4.13 fl_mirror="$(mktemp)" 4.14 lzcat $fl_mirrorz > $fl_mirror 4.15 @@ -44,11 +48,9 @@ 4.16 4.17 # clean 4.18 rm $fl_mirror 4.19 + status 4.20 fi 4.21 ;; 4.22 - *) 4.23 - [ ! -s $fl -o $fl_local -nt $fl ] && cp $fl_local $fl 4.24 - ;; 4.25 esac 4.26 4.27 # recreate "database with *.so files" in the cases: 4.28 @@ -56,10 +58,12 @@ 4.29 # * combined list of all files has been updated 4.30 4.31 if [ ! -s $db_so -o $fl -nt $db_so ]; then 4.32 + action 'Updating %s...' "$(basename $db_so)" 4.33 fgrep '/lib/' $fl | fgrep '.so' | \ 4.34 sed 's|^\([^:]*\):.*/\([^/]*\)$|\2\t\1|' | \ 4.35 awk -F$'\t' '{if ($2 !~ "uclibc") print}' | \ 4.36 sort > $db_so 4.37 + status 4.38 fi 4.39 4.40 # recreate "database with *.a files" in the cases: 4.41 @@ -67,9 +71,11 @@ 4.42 # * combined list of all files has been updated 4.43 4.44 if [ ! -s $db_a -o $fl -nt $db_a ]; then 4.45 + action 'Updating %s...' "$(basename $db_a)" 4.46 fgrep '/usr/lib/lib' $fl | fgrep '.a' | \ 4.47 sed 's|^\([^:]*\):.*/\([^/]*\)$|\2\t\1|' | \ 4.48 sort > $db_a 4.49 + status 4.50 fi 4.51 4.52 # recreate "database with *.la files" in the cases: 4.53 @@ -77,9 +83,11 @@ 4.54 # * combined list of all files has been updated 4.55 4.56 if [ ! -s $db_la -o $fl -nt $db_la ]; then 4.57 + action 'Updating %s...' "$(basename $db_la)" 4.58 fgrep '/usr/lib/' $fl | fgrep '.la' | \ 4.59 sed 's|^\([^:]*\): \(.*\)$|\2\t\1|' | \ 4.60 sort > $db_la 4.61 + status 4.62 fi 4.63 4.64 # recreate "database with *.pc files" in the cases: 4.65 @@ -87,9 +95,11 @@ 4.66 # * combined list of all files has been updated 4.67 4.68 if [ ! -s $db_pc -o $fl -nt $db_pc ]; then 4.69 + action 'Updating %s...' "$(basename $db_pc)" 4.70 grep '\.pc$' $fl | \ 4.71 sed -e 's|^\([^:]*\):.*/\([^/]*\)$|\2\t\1|' -e '/\tbuildroot$/d' | \ 4.72 sort > $db_pc 4.73 + status 4.74 fi 4.75 4.76