# HG changeset patch # User Aleksej Bobylev # Date 1531207536 -10800 # Node ID 64c16be1dda472c22ec008134cde90d5301cecb0 # Parent 1463d32f6f90b0c1d3fb0d471a7bc82e790fdadf Improve work with sets: - keep natural order of the sets described in $SPLIT, - provide new mode (COOKOPTS="instant-pack"): compile the set and then immediately pack all it's packages, so they will be available for the next set. Allow to change $CATEGORY. diff -r 1463d32f6f90 -r 64c16be1dda4 cook --- a/cook Thu Jun 21 12:57:52 2018 +0300 +++ b/cook Tue Jul 10 10:25:36 2018 +0300 @@ -86,6 +86,16 @@ } +# Find the package, return the receipt name where it was found +# for example, libpcreposix -> pcre + +find_pkg_in_wok() { + awk -F$'\t' -vi="$1" '{ + if (index(" " $2 " ", i)) {print $1; exit} + }' $cache/split.db +} + + # Initialize files used in $CACHE init_db_files() { @@ -629,6 +639,68 @@ } +# Internal function to cook specified SET + +cook_set() { + # Switch to the specified source set + set_paths + local suffix='' + [ -n "$SET" ] && suffix="-$SET" + export src="$WOK/$pkg/source/$PACKAGE-$VERSION$suffix" + export install="$WOK/$pkg/install$suffix" + export DESTDIR="$install" + + if [ -n "$SETS" ]; then + if [ -n "$SET" ]; then + title "Switching to the set '$SET'" + else + title "Switching to the default set" + fi + echo "src : $src" + echo "install: $install" + fi + [ -d "$src" ] && cd $src # packages without sources exists + echo + + [ -d "$install" ] && rm -r $install + #mkdir -p $install + + compile_rules $@ || { broken; exit 1; } + + # Stay compatible with _pkg + [ -d "$src/_pkg" ] && mv $src/_pkg $install + + copy_generic_stuff + + timestamp job$job_counter # compiling (set '$SET') + + # Actions to do after compiling the package + # Skip all for split packages (already done in main package) + if [ -z "$WANTED" ]; then + footer + export COOKOPTS ARCH install + @@PREFIX@@/libexec/cookutils/compressor install + timestamp job$(($job_counter + 1)) # compressing (set '$SET') + fi + + # Activate "instant-pack" mode + if [ "${COOKOPTS/instant-pack/}" != "$COOKOPTS" ]; then + echo " $SPLIT " | fgrep -q " $PACKAGE " || SPLIT="$PACKAGE $SPLIT" + # determine the list of the packages belongs to the current SET... + echo -n $SPLIT \ + | awk -vset="$SET" ' + BEGIN { RS = " "; FS = ":"; } + { if ($2 == set) print $1; }' \ + | while read SET_PKG; do + # ... and then pack them + packit $SET_PKG + done + fi + + job_counter=$(($job_counter + 2)) +} + + # The main cook function. cookit() { @@ -806,13 +878,14 @@ timestamp job4 # patching # Get set names from $SPLIT variable, format ex. 'pkg1 pkg2:set1 pkg3:set2' - SETS=$(echo $SPLIT \ + # Keep natural order of the sets, don't sort them alphabetically + SETS=$(echo -n $SPLIT \ | awk ' BEGIN { RS = " "; FS = ":"; } - { print $2; }' \ - | sort -u \ - | tr '\n' ' ') - SETS=${SETS% } # normalize space + { + if ($2 && ! set[$2]) { printf("%s ", $2); set[$2] = "1"; } + }' \ + | sed 's| $||') # Prepare specified source sets using patched sources [ -n "$SETS" -a -d "$src" ] && for set in $SETS; do @@ -824,49 +897,19 @@ timestamp sets "$SETS" job_counter='6' - for SET in '' $SETS; do - # Switch to the specified source set - set_paths - local suffix='' - [ -n "$SET" ] && suffix="-$SET" - export src="$WOK/$pkg/source/$PACKAGE-$VERSION$suffix" - export install="$WOK/$pkg/install$suffix" - export DESTDIR="$install" - if [ -n "$SETS" ]; then - if [ -n "$SET" ]; then - title "Switching to the set '$SET'" - else - title "Switching to the default set" - fi - echo "src : $src" - echo "install: $install" - fi - [ -d "$src" ] && cd $src # packages without sources exists - echo + SET='' cook_set # first run for empty SET - [ -d "$install" ] && rm -r $install - #mkdir -p $install - - compile_rules $@ || { broken; exit 1; } - - # Stay compatible with _pkg - [ -d "$src/_pkg" ] && mv $src/_pkg $install - - copy_generic_stuff - - timestamp job$job_counter # compiling (set '$SET') - - # Actions to do after compiling the package - # Skip all for split packages (already done in main package) - if [ -z "$WANTED" ]; then - footer - export COOKOPTS ARCH install - @@PREFIX@@/libexec/cookutils/compressor install - timestamp job$(($job_counter + 1)) # compressing (set '$SET') - fi - - job_counter=$(($job_counter + 2)) + # Allow to change SETS after the first run, follow the changes + SETS=$(. $receipt; echo -n $SPLIT \ + | awk ' + BEGIN { RS = " "; FS = ":"; } + { + if ($2 && ! set[$2]) { printf("%s ", $2); set[$2] = "1"; } + }' \ + | sed 's| $||') + for SET in $SETS; do + cook_set done else mkdir -p $install # allow receipts without `compile_rules()` @@ -982,7 +1025,7 @@ cd $taz action 'Copying "%s"...' 'receipt' - export PACKAGE VERSION SHORT_DESC WEB_SITE DEPENDS PROVIDE SUGGESTED TAZPANEL_DAEMON TAGS CAT CONFIG_FILES + export PACKAGE VERSION CATEGORY SHORT_DESC WEB_SITE DEPENDS PROVIDE SUGGESTED TAZPANEL_DAEMON TAGS CAT CONFIG_FILES @@PREFIX@@/libexec/cookutils/mk_pkg_receipt "$(realpath ../receipt)" > $pack/receipt chown 0.0 $pack/receipt; status @@ -1182,7 +1225,7 @@ all_names() { # Get package names from $SPLIT variable - local split=$(echo $SPLIT \ + local split=$(echo -n $SPLIT \ | awk ' BEGIN { RS = " "; FS = ":"; } { print $1; }' \ @@ -2137,6 +2180,8 @@ fi # Proceed only if `cookit` return code is zero-OK + # If instant-pack if specified, then packages already packed in the cookit() + [ "${COOKOPTS/instant-pack/}" == "$COOKOPTS" ] && packall 2>&1 | loglimit 5 >> $LOGS/$pkg.log timestamp job29 # packing diff -r 1463d32f6f90 -r 64c16be1dda4 doc/cookopts.txt --- a/doc/cookopts.txt Thu Jun 21 12:57:52 2018 +0300 +++ b/doc/cookopts.txt Tue Jul 10 10:25:36 2018 +0300 @@ -164,3 +164,13 @@ Default behaviour is to end work with error message when package contains no files (exception is made for packages belonging to the "meta" category). Presence of this option allows the package not to contain files. + +instant-pack + Usual behaviour is to make the sources (when sources in the $src became + files in the $install) and then pack the package (when files from $install + split to one or another $fs, and then became the *.tazpkg archives). + When multiple SETs used in the receipt, the default behaviour is to make + all the sources for all the sets, and only then to pack all the packages. + Presence of this option will pack the SET packages instantly before + to switch to another SET. So, packages created in the first SET will be + immediately available to use in the second SET, and so on. diff -r 1463d32f6f90 -r 64c16be1dda4 lighttpd/index.cgi --- a/lighttpd/index.cgi Thu Jun 21 12:57:52 2018 +0300 +++ b/lighttpd/index.cgi Tue Jul 10 10:25:36 2018 +0300 @@ -571,7 +571,7 @@ -e "s#^====\([^']*\).#\0#g" \ -e "s#^[a-zA-Z0-9]\([^']*\) :: #\0#g" \ -e "s#[fh]tt*ps*://[^ '\"]*#\0#g" \ - -e 's|^Switching to the set.*|‣‣‣ \0|' \ + -e 's|^Switching to the .*|‣‣‣ \0|' \ \ -e 's|^\(.*libtool: warning: relinking.*\)|\1|' \ -e 's|^\(.*libtool: warning: .* has not been installed in .*\)|\1|' \ diff -r 1463d32f6f90 -r 64c16be1dda4 modules/mk_pkg_receipt --- a/modules/mk_pkg_receipt Thu Jun 21 12:57:52 2018 +0300 +++ b/modules/mk_pkg_receipt Tue Jul 10 10:25:36 2018 +0300 @@ -39,7 +39,7 @@ PACKAGE="$PACKAGE"; DEPENDS="$(echo $DEPENDS)"; PROVIDE="$(echo $PROVIDE)" SUGGESTED="$(echo $SUGGESTED)"; TAZPANEL_DAEMON="$TAZPANEL_DAEMON" TAGS="$(echo $TAGS)"; VERSION="$VERSION"; SHORT_DESC="$SHORT_DESC" -WEB_SITE="$WEB_SITE" +WEB_SITE="$WEB_SITE"; CATEGORY="$CATEGORY" EOT unset_receipt . "$orig_receipt"