# HG changeset patch # User Aleksej Bobylev # Date 1498151888 -10800 # Node ID 81f33cdb5a66991a335b8ca2befba486e9dda0b0 # Parent 9c470f60d0d008659cb6f96ecb7ccc6580b34963 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. diff -r 9c470f60d0d0 -r 81f33cdb5a66 cook --- a/cook Tue Jun 20 19:02:35 2017 +0100 +++ b/cook Thu Jun 22 20:18:08 2017 +0300 @@ -545,7 +545,7 @@ IFS=$'\n' while read i; do - patchname=$(echo $i | cut -d' ' -f1) # allow comments (anything after the space) + patchname=$(echo ${i%%#*} | cut -d' ' -f1) # allow comments (anything after the # or space) [ -n "$patchname" ] || continue # allow empty lines [ -f "$src/done.$patchname" ] && continue # already applied (useful with `cook --continue`) newline @@ -1093,7 +1093,11 @@ all_names() { local split=" $SPLIT " - if [ "${split/ $PACKAGE /}" != "$split" ]; then + if ! head -n1 $WOK/$pkg/receipt | fgrep -q 'v2'; then + # For receipts v1: $SPLIT may present in the $WANTED package, + # but split packages have their own receipts + echo $PACKAGE + elif [ "${split/ $PACKAGE /}" != "$split" ]; then # $PACKAGE included somewhere in $SPLIT (probably in the end). # We should build packages in the order defined in the $SPLIT. echo $SPLIT @@ -1451,10 +1455,10 @@ > $db cd $WOK - for i in *; do - [ -f "$WOK/$i/receipt" ] || continue + for pkg in *; do + [ -f "$WOK/$pkg/receipt" ] || continue unset PACKAGE SPLIT - . $WOK/$i/receipt + . $WOK/$pkg/receipt echo -e "$PACKAGE\t$(all_names)" >> $db done } diff -r 9c470f60d0d0 -r 81f33cdb5a66 lighttpd/cooker.css --- a/lighttpd/cooker.css Tue Jun 20 19:02:35 2017 +0100 +++ b/lighttpd/cooker.css Thu Jun 22 20:18:08 2017 +0300 @@ -158,6 +158,12 @@ margin: auto; padding: 0.5em; } +mark { + background: #FF8; + border: solid #EB7; + border-radius: 4px; + border-width: 1px 0; +} .span-ok { color: #0a0; } diff -r 9c470f60d0d0 -r 81f33cdb5a66 lighttpd/index.cgi --- a/lighttpd/index.cgi Tue Jun 20 19:02:35 2017 +0100 +++ b/lighttpd/index.cgi Thu Jun 22 20:18:08 2017 +0300 @@ -31,6 +31,7 @@ cooktime="$CACHE/cooktime" wokrev="$CACHE/wokrev" webstat="$CACHE/webstat" +splitdb="$CACHE/split.db" # Path to markdown to html convertor cmark_opts='--smart -e table -e strikethrough -e autolink -e tagfilter' @@ -555,15 +556,11 @@ datalist() { - ( - cd $wok - - ls | awk ' + cut -d$'\t' -f2 $splitdb | tr ' ' '\n' | sort -u | awk ' BEGIN{printf("")} - {printf("",$1)} + {printf("")} ' - ) } @@ -740,6 +737,7 @@ # Update statistics used in web interface. # There is no need to recalculate the statistics every time the page is displayed. +# Note, $webstat file must be owned by www, otherwise this function will not be able to do the job. update_webstat() { echo '
' @@ -975,33 +973,53 @@ case "$cmd" in '') page_header - log=$LOGS/$pkg.log # Package info. - if [ -f "$wok/$pkg/receipt" ]; then - pkg_info - else - if [ $(ls $wok/*$pkg*/receipt 2>/dev/null | wc -l) -eq 0 ]; then - echo "

Not Found

" - show_note e "The requested package $pkg was not found on this server." - else - # Search page + if [ ! -f "$wok/$pkg/receipt" ]; then + # Let's look at the cases when the package was not found + + # Maybe query is the exact name of split package? -> proceed to main package + mainpkg=$(awk -F$'\t' -vpkg=" $pkg " '{ + if (index(" " $2 " ", pkg)) {print $1; exit} + }' $splitdb) + + # No, so let's find any matches among packages names (both main and split) + if [ -z "$mainpkg" ]; then + pkgs=$(cut -d$'\t' -f2 $splitdb | tr ' ' '\n' | fgrep "$pkg") + # Nothing matched + if [ -z "$pkgs" ]; then + echo "

Not Found

" + show_note e "The requested package $pkg was not found on this server." + page_footer; exit 0 + fi + # Search results page echo "

Package names matching “$pkg”

" echo "" - for i in $(cd $wok; ls *$pkg*/receipt); do - pkg=$(dirname $i) + query="$pkg" + for pkg in $pkgs; do + # Find main package + mainpkg=$(awk -F$'\t' -vpkg=" $pkg " '{ + if (index(" " $2 " ", pkg)) {print $1; exit} + }' $splitdb) + unset SHORT_DESC CATEGORY; . $wok/$mainpkg/receipt + unset SHORT_DESC CATEGORY - . $wok/$pkg/receipt - echo -n "" - echo -n "" + [ -e "$wok/$mainpkg/taz/$PACKAGE-$VERSION/receipt" ] && + . $wok/$mainpkg/taz/$PACKAGE-$VERSION/receipt + + echo -n "" done echo '
NameDescriptionCategory
$pkg$SHORT_DESC$CATEGORY
${pkg//$query/$query}" + [ "$pkg" == "$mainpkg" ] || echo -n " (${mainpkg//$query/$query})" + echo -n "$SHORT_DESC$CATEGORY
' - unset pkg + page_footer; exit 0 fi - page_footer - exit 0 + pkg="$mainpkg" fi + log=$LOGS/$pkg.log + pkg_info + # Check for a log file and display summary if it exists. summary "$log" @@ -1128,9 +1146,9 @@ echo "

Quick jump:

" for p in $split; do @@ -1144,7 +1162,7 @@ size=$(du -hs $dir | awk '{ sub(/\.0/, ""); print $1 }') - echo "

Contents of package “$namever” (${size:-empty}):

" + echo "

Contents of package “$namever” (${size:-empty}):

" echo '
'
 			if [ -s "$wok/$indir/taz/$p-$ver/files.list" ]; then
 				echo -n 'permissions·lnk·user    ·'
@@ -1166,7 +1184,7 @@
 		repeats="$(sort $packaged | uniq -d)"
 		if [ -n "$repeats" ]; then
 			echo ''
-			echo -n '

Repeatedly packaged files:

'
+			echo -n '

Repeatedly packaged files:

'
 			echo "$repeats" | sed 's|^|!!! |'
 			echo "
" fi @@ -1177,7 +1195,7 @@ orphans="$(sort $all_files $packaged | uniq -u)" if [ -d "$wok/$main/install" -a -n "$orphans" ]; then echo '' - echo '

Unpackaged files:

' + echo '

Unpackaged files:

' table=$(mktemp) echo "$orphans" | awk -vi="$base/$indir/browse/install" ' function tag(text, color) { diff -r 9c470f60d0d0 -r 81f33cdb5a66 modules/deps --- a/modules/deps Tue Jun 20 19:02:35 2017 +0100 +++ b/modules/deps Thu Jun 22 20:18:08 2017 +0300 @@ -28,7 +28,11 @@ # It's useful on casual development on local host, but useless on cooker server # (and slows down list creation a lot). tank) + [ ! -s $fl -o $fl_local -nt $fl ] && cp $fl_local $fl + ;; + *) if [ ! -s $fl -o $fl_mirrorz -nt $fl -o $fl_local -nt $fl ]; then + action 'Updating %s...' "$(basename $fl)" # unpack mirror files list fl_mirror="$(mktemp)" lzcat $fl_mirrorz > $fl_mirror @@ -44,11 +48,9 @@ # clean rm $fl_mirror + status fi ;; - *) - [ ! -s $fl -o $fl_local -nt $fl ] && cp $fl_local $fl - ;; esac # recreate "database with *.so files" in the cases: @@ -56,10 +58,12 @@ # * combined list of all files has been updated if [ ! -s $db_so -o $fl -nt $db_so ]; then + action 'Updating %s...' "$(basename $db_so)" fgrep '/lib/' $fl | fgrep '.so' | \ sed 's|^\([^:]*\):.*/\([^/]*\)$|\2\t\1|' | \ awk -F$'\t' '{if ($2 !~ "uclibc") print}' | \ sort > $db_so + status fi # recreate "database with *.a files" in the cases: @@ -67,9 +71,11 @@ # * combined list of all files has been updated if [ ! -s $db_a -o $fl -nt $db_a ]; then + action 'Updating %s...' "$(basename $db_a)" fgrep '/usr/lib/lib' $fl | fgrep '.a' | \ sed 's|^\([^:]*\):.*/\([^/]*\)$|\2\t\1|' | \ sort > $db_a + status fi # recreate "database with *.la files" in the cases: @@ -77,9 +83,11 @@ # * combined list of all files has been updated if [ ! -s $db_la -o $fl -nt $db_la ]; then + action 'Updating %s...' "$(basename $db_la)" fgrep '/usr/lib/' $fl | fgrep '.la' | \ sed 's|^\([^:]*\): \(.*\)$|\2\t\1|' | \ sort > $db_la + status fi # recreate "database with *.pc files" in the cases: @@ -87,9 +95,11 @@ # * combined list of all files has been updated if [ ! -s $db_pc -o $fl -nt $db_pc ]; then + action 'Updating %s...' "$(basename $db_pc)" grep '\.pc$' $fl | \ sed -e 's|^\([^:]*\):.*/\([^/]*\)$|\2\t\1|' -e '/\tbuildroot$/d' | \ sort > $db_pc + status fi