cookutils rev 899
Some important changes:
* cook: better die handling; cook can now mark packages as broken by itself; less chatty zip extracting; rename internal function copy() to scopy(); new copy() is the main tool to copy files from $install to $fs (docs to come); automatic patching (if patches are in $stuff/patches and patch list is $stuff/patches/series); better local packages handling; update packages.info database after each successful build, virtual packages are accessible immediately after build.
* doc/cookopts.txt: added "!perlz" and "!rmpod" options description.
* modules/compressor: strip Perl files.
* modules/pkgdb: calculate estimated time for cook:pkgdb too (as well as for cook:package).
* cook: better die handling; cook can now mark packages as broken by itself; less chatty zip extracting; rename internal function copy() to scopy(); new copy() is the main tool to copy files from $install to $fs (docs to come); automatic patching (if patches are in $stuff/patches and patch list is $stuff/patches/series); better local packages handling; update packages.info database after each successful build, virtual packages are accessible immediately after build.
* doc/cookopts.txt: added "!perlz" and "!rmpod" options description.
* modules/compressor: strip Perl files.
* modules/pkgdb: calculate estimated time for cook:pkgdb too (as well as for cook:package).
author | Aleksej Bobylev <al.bobylev@gmail.com> |
---|---|
date | Thu May 11 00:36:43 2017 +0300 (2017-05-11) |
parents | 2aaf73fe2cd4 |
children | e6e0957f3a48 |
files | cook doc/cookopts.txt modules/compressor modules/pkgdb |
line diff
1.1 --- a/cook Thu May 11 00:17:06 2017 +0300 1.2 +++ b/cook Thu May 11 00:36:43 2017 +0300 1.3 @@ -3,7 +3,7 @@ 1.4 # Cook - A tool to cook and generate SliTaz packages. Read the README 1.5 # before adding or modifying any code in cook! 1.6 # 1.7 -# Copyright (C) SliTaz GNU/Linux - GNU gpl v3 1.8 +# Copyright (C) SliTaz GNU/Linux - GNU GPL v3 1.9 # Author: Christophe Lincoln <pankso@slitaz.org> 1.10 # 1.11 1.12 @@ -285,12 +285,12 @@ 1.13 fi 1.14 mv $pkgsrc $pkgsrc-$BRANCH 1.15 pkgsrc="$pkgsrc-$BRANCH" 1.16 - create_tarball ;; 1.17 + create_tarball 1.18 + ;; 1.19 1.20 *) 1.21 - (newline; _ 'ERROR: Unable to handle "%s"' "$WGET_URL"; newline) | \ 1.22 - tee -a $LOGS/$PACKAGE.log 1.23 - exit 1 ;; 1.24 + broken; die 'ERROR: Unable to handle "%s"' "$WGET_URL" 1.25 + ;; 1.26 esac 1.27 } 1.28 1.29 @@ -313,7 +313,7 @@ 1.30 *.tar.lzma) tar -xaf $SRC/$TARBALL ;; 1.31 *.tar.lz|*.tlz) lzip -d < $SRC/$TARBALL | tar -xf - 2>/dev/null ;; 1.32 *.tar) tar -xf $SRC/$TARBALL ;; 1.33 - *.zip|*.xpi) unzip -o $SRC/$TARBALL ;; 1.34 + *.zip|*.xpi) unzip -o $SRC/$TARBALL 2>/dev/null ;; 1.35 *.xz) unxz -c $SRC/$TARBALL | tar -xf - || \ 1.36 tar -xf $SRC/$TARBALL 2>/dev/null;; 1.37 *.7z) 7zr x $SRC/$TARBALL 2>/dev/null >&2 ;; 1.38 @@ -402,9 +402,9 @@ 1.39 1.40 # A bit smarter function than the classic `cp` command 1.41 1.42 -copy() { 1.43 - if [ -d "$1" -o "$(stat -c %h -- "$1")" -eq 1 ]; then 1.44 - cp -a "$1" "$2" # copy folders and generic files 1.45 +scopy() { 1.46 + if [ "$(stat -c %h -- "$1")" -eq 1 ]; then 1.47 + cp -a "$1" "$2" # copy generic files 1.48 else 1.49 cp -al "$1" "$2" # copy hardlinks 1.50 fi 1.51 @@ -420,8 +420,8 @@ 1.52 if [ -d "$install/usr/share/locale" ]; then 1.53 mkdir -p $fs/usr/share/locale 1.54 for i in $LOCALE; do 1.55 - if [ -d "$install/usr/share/locale/$i" ]; then 1.56 - copy $install/usr/share/locale/$i $fs/usr/share/locale 1.57 + if [ -d "$install/usr/share/locale/$i" ]; then 1.58 + scopy $install/usr/share/locale/$i $fs/usr/share/locale 1.59 fi 1.60 done 1.61 fi 1.62 @@ -433,14 +433,14 @@ 1.63 mkdir -p $fs/usr/share/pixmaps 1.64 for i in png xpm; do 1.65 [ -f "$install/usr/share/pixmaps/$PACKAGE.$i" ] && 1.66 - copy $install/usr/share/pixmaps/$PACKAGE.$i $fs/usr/share/pixmaps 1.67 + scopy $install/usr/share/pixmaps/$PACKAGE.$i $fs/usr/share/pixmaps 1.68 done 1.69 fi 1.70 1.71 # Custom or homemade PNG pixmap can be in stuff. 1.72 if [ -f "$stuff/$PACKAGE.png" ]; then 1.73 mkdir -p $fs/usr/share/pixmaps 1.74 - copy $stuff/$PACKAGE.png $fs/usr/share/pixmaps 1.75 + scopy $stuff/$PACKAGE.png $fs/usr/share/pixmaps 1.76 fi 1.77 fi 1.78 1.79 @@ -449,24 +449,24 @@ 1.80 if [ "${COOKOPTS/!menus/}" == "$COOKOPTS" -a "$GENERIC_MENUS" != 'no' ]; then 1.81 if [ -d "$install/usr/share/applications" ] && [ -z "$WANTED" ]; then 1.82 mkdir -p $fs/usr/share 1.83 - copy $install/usr/share/applications $fs/usr/share 1.84 + scopy $install/usr/share/applications $fs/usr/share 1.85 fi 1.86 fi 1.87 1.88 # Homemade desktop file(s) can be in stuff. 1.89 if [ -d "$stuff/applications" ]; then 1.90 mkdir -p $fs/usr/share 1.91 - copy $stuff/applications $fs/usr/share 1.92 + scopy $stuff/applications $fs/usr/share 1.93 fi 1.94 if [ -f "$stuff/$PACKAGE.desktop" ]; then 1.95 mkdir -p $fs/usr/share/applications 1.96 - copy $stuff/$PACKAGE.desktop $fs/usr/share/applications 1.97 + scopy $stuff/$PACKAGE.desktop $fs/usr/share/applications 1.98 fi 1.99 1.100 # Add custom licenses 1.101 if [ -d "$stuff/licenses" ]; then 1.102 mkdir -p $fs/usr/share/licenses 1.103 - copy $stuff/licenses $fs/usr/share/licenses/$PACKAGE 1.104 + scopy $stuff/licenses $fs/usr/share/licenses/$PACKAGE 1.105 fi 1.106 } 1.107 1.108 @@ -510,11 +510,14 @@ 1.109 remove_deps() { 1.110 # Now remove installed build deps. 1.111 diff='/tmp/installed.cook.diff' 1.112 - if [ -s $diff ]; then 1.113 - deps=$(cat $diff | grep ^+[a-zA-Z0-9] | sed s/^+//) 1.114 - nb=$(cat $diff | grep ^+[a-zA-Z0-9] | wc -l) 1.115 - _n 'Build dependencies to remove:'; echo " $nb" 1.116 - [ -n "$root" ] && echo "root=\"$root\"" 1.117 + [ -s "$diff" ] || return 1.118 + 1.119 + deps=$(cat $diff | grep ^+[a-zA-Z0-9] | sed s/^+//) 1.120 + nb=$(cat $diff | grep ^+[a-zA-Z0-9] | wc -l) 1.121 + newline 1.122 + _n 'Build dependencies to remove:'; echo " $nb" 1.123 + [ -n "$root" ] && echo "root=\"$root\"" 1.124 + { 1.125 _n 'Removing:' 1.126 for dep in $deps; do 1.127 echo -n " $dep" 1.128 @@ -523,15 +526,27 @@ 1.129 newline; newline 1.130 # Keep the last diff for debug and info. 1.131 mv -f $diff $CACHE/installed.diff 1.132 - fi | fold -sw80 1.133 + } | fold -sw80 1.134 +} 1.135 + 1.136 + 1.137 +# Automatic patch the sources. 1.138 + 1.139 +patchit() { 1.140 + [ -f "$stuff/patches/series" ] || return 1.141 + 1.142 + while read i; do 1.143 + [ -f "$src/done.$i" ] && continue 1.144 + patch -p1 -i $stuff/patches/$i 1.145 + touch $src/done.$i 1.146 + done < $stuff/patches/series 1.147 } 1.148 1.149 1.150 # The main cook function. 1.151 1.152 cookit() { 1.153 - if [ -n "$SETUP_MD5" ] && [ "$SETUP_MD5" != "$(ls $root$INSTALLED | \ 1.154 - md5sum | cut -c1-32)" ]; then 1.155 + if [ -n "$SETUP_MD5" -a "$SETUP_MD5" != "$(ls $root$INSTALLED | md5sum | cut -c1-32)" ]; then 1.156 _ 'ERROR: Broken setup. Abort.' 1.157 return 1.158 fi 1.159 @@ -568,7 +583,8 @@ 1.160 export RANLIB="$HOST_SYSTEM-ranlib" 1.161 export LD="$HOST_SYSTEM-ld" 1.162 export STRIP="$HOST_SYSTEM-strip" 1.163 - export LIBTOOL="$HOST_SYSTEM-libtool" ;; 1.164 + export LIBTOOL="$HOST_SYSTEM-libtool" 1.165 + ;; 1.166 esac 1.167 1.168 [ -n "$QA" ] && receipt_quality 1.169 @@ -598,44 +614,34 @@ 1.170 [ -n "$BUILD_DEPENDS" ] && _ 'Checking build dependencies...' 1.171 [ -n "$root" ] && _ 'Using packages DB: %s' "$root$DB" 1.172 for dep in $BUILD_DEPENDS; do 1.173 - implicit="${dep%-dev}" 1.174 - # Don't add implicit dependency if it defined in DEPENDS 1.175 - # echo '' $DEPENDS '' | fgrep -q " $implicit " && implicit='' 1.176 + implicit="${dep%-dev}"; [ "$implicit" == "$dep" ] && implicit='' 1.177 for i in $dep $implicit; do 1.178 - if [ ! -f "$root$INSTALLED/$i/receipt" ]; then 1.179 - # Try local package first. In some cases implicit doesn't exist, ex: 1.180 - # libboost-dev exists but not libboost, so check if we got vers. 1.181 - unset vers 1.182 - vers=$(. $WOK/$i/receipt 2>/dev/null ; echo $VERSION) 1.183 - # We may have a local package. 1.184 - if [ -z "$vers" ]; then 1.185 - vers=$(awk -F$'\t' -vp="$i" '$1==p{print $2; quit}' $PKGS/packages.info 2> /dev/null) 1.186 - fi 1.187 - debug "bdep: $i version: $vers" 1.188 - if [ -f "$PKGS/$i-$vers$arch.tazpkg" ]; then 1.189 - echo $i-$vers$arch.tazpkg >> $CACHE/installed.local 1.190 - else 1.191 - # Priority to package version in wok (maybe more up-to-date) 1.192 - # than the mirrored one. 1.193 - if [ -n "$vers" ]; then 1.194 - if fgrep -q $i-$vers$arch $root$DB/packages.list; then 1.195 - echo $i >> $CACHE/installed.web 1.196 - else 1.197 - # So package exists in wok but not available. 1.198 - _ 'Missing dep (wok/pkg): %s' "$i $vers" 1.199 - echo $i >> $CACHE/missing.dep 1.200 - fi 1.201 - else 1.202 - # Package is not in wok but may be in online repo. 1.203 - if fgrep -q $i-$vers$arch $root$DB/packages.list; then 1.204 - echo $i >> $CACHE/installed.web 1.205 - else 1.206 - _ 'ERROR: unknown dep "%s"' "$i" 1.207 - exit 1 1.208 - fi 1.209 - fi 1.210 - fi 1.211 - fi 1.212 + [ -f "$root$INSTALLED/$i/receipt" ] && continue 1.213 + 1.214 + # Try local package first. 1.215 + namever=$(awk -F$'\t' -vpkg="$i" '{ 1.216 + # if package-name or provided-package-name matched 1.217 + if (index(" " $1 " " $10 " ", " " pkg " ")) { printf("%s-%s", $1, $2); quit; } 1.218 + }' "$PKGS/packages.info") # <namever> = <package_name>-<package_version> 1.219 + 1.220 + debug "bdep: $i name-version: $namever" 1.221 + 1.222 + # If local package available 1.223 + [ -f "$PKGS/$namever$arch.tazpkg" ] && 1.224 + echo "$namever$arch.tazpkg" >> $CACHE/installed.local && continue 1.225 + 1.226 + # If package exists in wok but not built 1.227 + [ -d "$WOK/$i" ] && 1.228 + _ 'Missing dep (wok/pkg): %s' "$i $vers" && 1.229 + echo $i >> $CACHE/missing.dep && continue 1.230 + 1.231 + # If package available on the mirror 1.232 + [ -n "$(awk -F$'\t' -vi="$i" '$1==i{print $1}' "$root$DB/packages.info")" ] && 1.233 + echo $i >> $CACHE/installed.web && continue 1.234 + 1.235 + # Give up; skip error for implicit dependency: in some cases 1.236 + # implicit doesn't exist, ex: libboost-dev exists but not libboost. 1.237 + [ "$i" == "$dep" ] && die 'ERROR: unknown dep "%s"' "$i" 1.238 done 1.239 done 1.240 1.241 @@ -666,9 +672,9 @@ 1.242 # missing dep in cached file. 1.243 lerror=$(_n 'ERROR') 1.244 if fgrep -q ^$lerror $LOGS/$pkg.log || [ -s "$CACHE/missing.dep" ]; then 1.245 - [ -s "$CACHE/missing.dep" ] && nb=$(cat $CACHE/missing.dep | wc -l) 1.246 + [ -s "$CACHE/missing.dep" ] && nb=$(wc -l < $CACHE/missing.dep) 1.247 _p 'ERROR: missing %d dependency' 'ERROR: missing %d dependencies' "$nb" "$nb" 1.248 - exit 1 1.249 + broken; exit 1 1.250 fi 1.251 1.252 # Install local packages: package-version$arch 1.253 @@ -695,14 +701,14 @@ 1.254 TARBALL="${SOURCE:-$PACKAGE}-$VERSION.tar.lzma" 1.255 LZMA_SRC='' 1.256 else 1.257 - get_source || exit 1 1.258 + get_source || { broken; exit 1; } 1.259 fi 1.260 fi 1.261 if [ -z "$WANTED" ] && [ -n "$TARBALL" ] && [ ! -d "$src" ]; then 1.262 mkdir -p $pkgdir/source/tmp; cd $pkgdir/source/tmp 1.263 if ! extract_source ; then 1.264 get_source 1.265 - extract_source || exit 1 1.266 + extract_source || { broken; exit 1; } 1.267 fi 1.268 if [ -n "$LZMA_SRC" ]; then 1.269 cd $pkgdir/source 1.270 @@ -736,7 +742,8 @@ 1.271 echo "CFLAGS : $CFLAGS" 1.272 #echo "LDFLAGS : $LDFLAGS" 1.273 [ -d "$src" ] && cd $src 1.274 - compile_rules $@ || exit 1 1.275 + patchit 1.276 + compile_rules $@ || { broken; exit 1; } 1.277 # Stay compatible with _pkg 1.278 [ -d "$src/_pkg" ] && mv $src/_pkg $install 1.279 # QA: compile_rules success so valid. 1.280 @@ -757,7 +764,7 @@ 1.281 # Execute testsuite. 1.282 if grep -q ^testsuite $receipt; then 1.283 title 'Running testsuite' 1.284 - testsuite $@ || exit 1 1.285 + testsuite $@ || { broken; exit 1; } 1.286 footer 1.287 fi 1.288 1.289 @@ -776,8 +783,9 @@ 1.290 if grep -Ev "(conftest|configtest)" $LOGS/$pkg.log | \ 1.291 grep -Eq "(^$lerror|undefined reference to)" ; then 1.292 debug_info | tee -a $LOGS/$pkg.log 1.293 + sed -i '$ s|$| [ Failed ]|' $activity 1.294 rm -f $command 1.295 - exit 1 1.296 + broken; exit 1 1.297 fi 1.298 } 1.299 1.300 @@ -882,7 +890,7 @@ 1.301 # First QA check to stop now if genpkg_rules failed. 1.302 lerror=$(_n 'ERROR') 1.303 if fgrep -q ^$lerror $LOGS/$pkg.log; then 1.304 - exit 1 1.305 + broken; exit 1 1.306 fi 1.307 1.308 cd $taz 1.309 @@ -974,36 +982,36 @@ 1.310 lerror=$(_n 'ERROR') 1.311 if fgrep -q ^$lerror $LOGS/$pkg.log; then 1.312 rm -f $command 1.313 - exit 1 1.314 + broken; exit 1 1.315 fi 1.316 1.317 action 'QA: checking for empty package...' 1.318 files=$(cat $WOK/$pkg/taz/$pkg-*/files.list | wc -l) 1.319 if [ "$files" -eq 0 -a "$CATEGORY" != 'meta' ]; then 1.320 - newline; _ 'ERROR: empty package' 1.321 + broken 1.322 rm -f $command 1.323 - exit 1 1.324 - else 1.325 - :; status 1.326 - # Find and remove old package(s) 1.327 - tempd="$(mktemp -d)"; cd "$tempd" 1.328 - for testpkg in $(ls $PKGS/$pkg-*.tazpkg 2> /dev/null); do 1.329 - # Extract receipt from each matched package 1.330 - cpio -F "$testpkg" -i receipt >/dev/null 2>&1 1.331 - name=$(. receipt; echo $PACKAGE) 1.332 - rm receipt 1.333 - if [ "$name" == "$pkg" ]; then 1.334 - action 'Removing old package "%s"' "$(basename "$testpkg")" 1.335 - rm -f "$testpkg" 1.336 - status 1.337 - fi 1.338 - done 1.339 - rm -r "$tempd" 1.340 - mv -f $pkgdir/taz/$pkg-*.tazpkg $PKGS 1.341 - sed -i /^${pkg}$/d $broken 1.342 - #action 'Removing source tree...' 1.343 - #rm -f $WOK/$pkg/source; status 1.344 + die 'ERROR: empty package' 1.345 fi 1.346 + 1.347 + :; status 1.348 + # Find and remove old package(s) 1.349 + tempd="$(mktemp -d)"; cd "$tempd" 1.350 + for testpkg in $(ls $PKGS/$pkg-*.tazpkg 2> /dev/null); do 1.351 + # Extract receipt from each matched package 1.352 + cpio -F "$testpkg" -i receipt >/dev/null 2>&1 1.353 + name=$(. receipt; echo $PACKAGE) 1.354 + rm receipt 1.355 + if [ "$name" == "$pkg" ]; then 1.356 + action 'Removing old package "%s"' "$(basename "$testpkg")" 1.357 + rm -f "$testpkg" 1.358 + status 1.359 + fi 1.360 + done 1.361 + rm -r "$tempd" 1.362 + mv -f $pkgdir/taz/$pkg-*.tazpkg $PKGS 1.363 + sed -i /^${pkg}$/d $broken 1.364 + #action 'Removing source tree...' 1.365 + #rm -f $WOK/$pkg/source; status 1.366 } 1.367 1.368 1.369 @@ -1030,8 +1038,8 @@ 1.370 cd $PKGS 1.371 tazpkg install $PACKAGE-$VERSION$EXTRAVERSION.tazpkg --forced 1.372 else 1.373 - _ 'Unable to install package, build has failed.'; newline 1.374 - exit 1 1.375 + broken 1.376 + die 'Unable to install package, build has failed.' 1.377 fi 1.378 fi 1.379 1.380 @@ -1118,7 +1126,7 @@ 1.381 cat > $FEEDS/$pkg.xml <<EOT 1.382 <item> 1.383 <title>$PACKAGE $VERSION$EXTRAVERSION</title> 1.384 - <link>${COOKER_URL}?pkg=$PACKAGE</link> 1.385 + <link>${COOKER_URL}?pkg=${PACKAGE//+/%2B}</link> 1.386 <guid>$PACKAGE-$VERSION$EXTRAVERSION</guid> 1.387 <pubDate>$pubdate</pubDate> 1.388 <description>$(echo -n "$SHORT_DESC" | xml_ent)</description> 1.389 @@ -1162,7 +1170,7 @@ 1.390 name=$(echo $i | sed 's|\.[gbx]z2*$||') 1.391 section=${name##*/}; section=${section##*.} 1.392 mkdir -p $install/usr/share/man/man$section 1.393 - copy $i $install/usr/share/man/man$section 1.394 + scopy $i $install/usr/share/man/man$section 1.395 done 1.396 status 1.397 } 1.398 @@ -1177,8 +1185,8 @@ 1.399 IFS=$'\n' 1.400 for i in $@; do 1.401 for j in $(find . -name $i ! -type d); do 1.402 - mkdir -p $fs$(dirname ${j#.}) 1.403 - copy $j $fs$(dirname ${j#.}) 1.404 + mkdir -p $fs$(dirname ${j#.}) 1.405 + scopy $j $fs$(dirname ${j#.}) 1.406 done 1.407 done 1.408 cd - >/dev/null 1.409 @@ -1195,8 +1203,8 @@ 1.410 IFS=$'\n' 1.411 for i in $@; do 1.412 for j in $(find . -name $i -type d); do 1.413 - mkdir -p $fs$(dirname ${j#.}) 1.414 - copy $j $fs$(dirname ${j#.}) 1.415 + mkdir -p $fs$(dirname ${j#.}) 1.416 + cp -a $j $fs$(dirname ${j#.}) 1.417 done 1.418 done 1.419 cd - >/dev/null 1.420 @@ -1204,6 +1212,60 @@ 1.421 } 1.422 1.423 1.424 +# Common function to copy files, folders and patterns 1.425 + 1.426 +copy() { 1.427 + action 'Copying folders and files...' 1.428 + cd $install 1.429 + local i j filelist=$(mktemp) tmplist=$(mktemp) 1.430 + IFS=$'\n' 1.431 + find ! -type d | sed 's|\.||' > $filelist 1.432 + for i in $@; do 1.433 + case $i in 1.434 + @std) 1.435 + # Copy "standard" files (all but "developer files", man pages, documentation, translations) 1.436 + sed '/\.h$/d; /\.hxx$/d; /\.a$/d; /\.la$/d; /\.pc$/d; /bin\/.*-config$/d; 1.437 + /\.m4$/d; /\.gir$/d; /\.typelib$/d; /\.vapi$/d; /\.deps$/d; 1.438 + /\/share\/man\//d; /\/share\/doc\//d; /\/share\/info\//d; /\/share\/locale\//d; 1.439 + /\/share\/bash-completion\//d; 1.440 + ' $filelist > $tmplist 1.441 + while read j; do 1.442 + mkdir -p $fs$(dirname $j) 1.443 + scopy $install$j $fs$(dirname $j) 1.444 + done < $tmplist 1.445 + ;; 1.446 + @dev) 1.447 + # Copy "developer files" 1.448 + sed -n '/\.h$/p; /\.hxx$/p; /\.a$/p; /\.la$/p; /\.pc$/p; /bin\/.*-config$/p; 1.449 + /\.m4$/p; /\.gir$/p; /\.typelib$/p; /\.vapi$/p; /\.deps$/p; 1.450 + ' $filelist | \ 1.451 + while read j; do 1.452 + mkdir -p $fs$(dirname $j) 1.453 + scopy $install$j $fs$(dirname $j) 1.454 + done 1.455 + ;; 1.456 + */) 1.457 + # Copy specified folders 1.458 + for j in $(find . -name ${i%/} -type d); do 1.459 + mkdir -p $fs$(dirname ${j#.}) 1.460 + cp -a $j $fs$(dirname ${j#.}) 1.461 + done 1.462 + ;; 1.463 + *) 1.464 + # Copy specified files 1.465 + for j in $(find . -name $i ! -type d); do 1.466 + mkdir -p $fs$(dirname ${j#.}) 1.467 + scopy $j $fs$(dirname ${j#.}) 1.468 + done 1.469 + ;; 1.470 + esac 1.471 + done 1.472 + cd - >/dev/null 1.473 + rm $filelist $tmplist 1.474 + status 1.475 +} 1.476 + 1.477 + 1.478 # Function to use in genpkg_rules() to copy hicolor icons in specified sizes 1.479 # (default: 16 and 48) from $install to $fs 1.480 1.481 @@ -1213,13 +1275,29 @@ 1.482 mkdir -p $fs/usr/share/icons/hicolor 1.483 for i in ${sizes:-16 48}; do 1.484 [ ! -e "$install/usr/share/icons/hicolor/${i}x$i" ] || 1.485 - copy $install/usr/share/icons/hicolor/${i}x$i \ 1.486 + scopy $install/usr/share/icons/hicolor/${i}x$i \ 1.487 $fs/usr/share/icons/hicolor 1.488 done 1.489 status 1.490 } 1.491 1.492 1.493 +# Update packages.info every time after successful build 1.494 + 1.495 +update_packages_info() { 1.496 + sed -i "/^$pkg\t/d" $PKGS/packages.info 1.497 + PACKAGE="$pkg"; set_paths 1.498 + unset_receipt; . $pack/receipt 1.499 + SIZES=$(echo $PACKED_SIZE $UNPACKED_SIZE | sed 's|\.0||g') 1.500 + DEPENDS=$(echo $DEPENDS) # remove newlines from some receipts 1.501 + MD5="$(md5sum "$PKGS/$PACKAGE-$VERSION$EXTRAVERSION.tazpkg" | awk '{print $1}')" 1.502 + cat >> $PKGS/packages.info <<EOT 1.503 +$PACKAGE $VERSION$EXTRAVERSION $CATEGORY $SHORT_DESC $WEB_SITE $TAGS $SIZES $DEPENDS $MD5 $PROVIDE 1.504 +EOT 1.505 + 1.506 +} 1.507 + 1.508 + 1.509 1.510 1.511 # 1.512 @@ -1272,10 +1350,7 @@ 1.513 # ARCH-setup or 'cross check' should be used before: cook setup 1.514 case "$ARCH" in 1.515 arm*|x86_64) 1.516 - if [ ! -x '/usr/bin/cross' ]; then 1.517 - _ 'ERROR: %s is not installed' 'cross' 1.518 - exit 1 1.519 - fi 1.520 + [ -x '/usr/bin/cross' ] || die 'ERROR: %s is not installed' 'cross' 1.521 _ 'Using config file: %s' '/etc/slitaz/cross.conf' 1.522 . /etc/slitaz/cross.conf ;; 1.523 esac 1.524 @@ -1388,10 +1463,7 @@ 1.525 pkg="$2" 1.526 [ -z "$pkg" ] && usage 1.527 newline 1.528 - if [ -d "$WOK/$pkg" ]; then 1.529 - _ 'Package "%s" already exists.' "$pkg" 1.530 - exit 1 1.531 - fi 1.532 + [ -d "$WOK/$pkg" ] && die 'Package "%s" already exists.' "$pkg" 1.533 1.534 action 'Creating folder "%s"' "$WOK/$pkg" 1.535 mkdir $WOK/$pkg; cd $WOK/$pkg; status 1.536 @@ -1455,14 +1527,8 @@ 1.537 # Cook a list of packages (better use the Cooker since it will order 1.538 # packages before executing cook). 1.539 check_root 1.540 - if [ -z "$2" ]; then 1.541 - newline; _ 'No list in argument.'; newline 1.542 - exit 1 1.543 - fi 1.544 - if [ ! -f "$2" ]; then 1.545 - newline; _ 'List "%s" not found.' "$2"; newline 1.546 - exit 1 1.547 - fi 1.548 + [ -z "$2" ] && die 'No list in argument.' 1.549 + [ -f "$2" ] || die 'List "%s" not found.' "$2" 1.550 1.551 _ 'Starting cooking the list "%s"' "$2" | log 1.552 1.553 @@ -1515,7 +1581,7 @@ 1.554 esac 1.555 done 1.556 1.557 - if [ "$count" -gt "0" ]; then 1.558 + if [ "$count" -gt 0 ]; then 1.559 footer "$(_p '%s uncooked package' '%s uncooked packages' "$count" "$(colorize 31 "$count")")" 1.560 else 1.561 _ 'All packages are cooked :-)' 1.562 @@ -1536,8 +1602,9 @@ 1.563 time=$(date +%s) 1.564 pkg="$1" 1.565 [ -z "$pkg" ] && usage 1.566 - lastcooktime=$(sed '/^Cook time/!d;s|.*: *\([0-9]*\)s.*|\1|' \ 1.567 - $LOGS/$pkg.log 2> /dev/null | sed '$!d') 1.568 + 1.569 + lastcooktime=$(sed '/^Cook time/!d; s|.*: *\([0-9]*\)s.*|\1|' \ 1.570 + $LOGS/$pkg.log 2>/dev/null | sed '$!d') 1.571 receipt="$WOK/$pkg/receipt" 1.572 check_pkg_in_wok 1.573 newline 1.574 @@ -1556,7 +1623,7 @@ 1.575 [ -n "$CROSS_BUGS" ] && _ 'bugs: %s' "$CROSS_BUGS" 1.576 _ 'Cook skip: %s' "$error" | log 1.577 newline 1.578 - exit 1 1.579 + broken; exit 1 1.580 fi ;; 1.581 esac 1.582 1.583 @@ -1576,18 +1643,17 @@ 1.584 fi 1.585 1.586 # Skip blocked, 3 lines also for the Cooker. 1.587 - if grep -q "^$pkg$" $blocked && [ "$2" != '--unblock' ]; then 1.588 - _ 'Package "%s" is blocked' "$pkg"; newline 1.589 - exit 0 1.590 - fi 1.591 + grep -q "^$pkg$" $blocked && [ "$2" != '--unblock' ] && 1.592 + die 'Package "%s" is blocked' "$pkg" 1.593 1.594 try_aufs_chroot "$@" 1.595 1.596 # Log and source receipt. 1.597 - _ 'Cook started for: %s' "<a href='cooker.cgi?pkg=$pkg'>$pkg</a>" | log 1.598 + _ 'Cook started for: %s' "<a href='cooker.cgi?pkg=${pkg//+/%2B}'>$pkg</a>" | log 1.599 echo "cook:$pkg" > $command 1.600 - [ "$lastcooktime" ] && 1.601 - echo "cook:$pkg $lastcooktime $(date +%s)" >> $cooktime 1.602 + 1.603 + [ -n "$lastcooktime" ] && echo "cook:$pkg $lastcooktime $(date +%s)" >> $cooktime 1.604 + 1.605 while read cmd duration start; do 1.606 [ $(($start + $duration)) -lt $(date +%s) ] && 1.607 echo "sed -i '/^$cmd $duration/d' $cooktime" 1.608 @@ -1628,15 +1694,12 @@ 1.609 exit 0 ;; 1.610 1.611 --pack) 1.612 - if [ -d $WOK/$pkg/taz ]; then 1.613 - rm -rf $WOK/$pkg/taz 1.614 - [ -f $LOGS/$pkg-pack.log ] && rm -rf $LOGS/$pkg-pack.log 1.615 - packit 2>&1 | tee -a $LOGS/$pkg-pack.log 1.616 - clean_log 1.617 - else 1.618 - _ 'Need to build "%s"' "$pkg" 1.619 - exit 0 1.620 - fi 1.621 + [ -d $WOK/$pkg/taz ] || die 'Need to build "%s"' "$pkg" 1.622 + rm -rf $WOK/$pkg/taz 1.623 + [ -f $LOGS/$pkg-pack.log ] && rm -rf $LOGS/$pkg-pack.log 1.624 + packit 2>&1 | tee -a $LOGS/$pkg-pack.log 1.625 + clean_log 1.626 + rm -f $command 1.627 exit 0 ;; 1.628 1.629 --cdeps) 1.630 @@ -1653,19 +1716,17 @@ 1.631 # Check if wanted is built now so we have separate log files. 1.632 for wanted in $WANTED ; do 1.633 if grep -q "^$wanted$" $blocked; then 1.634 - _ 'WANTED package "%s" is blocked' "$wanted" | tee $LOGS/$pkg.log 1.635 - newline 1.636 + broken 1.637 rm -f $command 1.638 - exit 1 1.639 + die 'WANTED package "%s" is blocked' "$wanted" 1.640 fi 1.641 if grep -q "^$wanted$" $broken; then 1.642 - _ 'WANTED package "%s" is broken' "$wanted" | tee $LOGS/$pkg.log 1.643 - newline 1.644 + broken 1.645 rm -f $command 1.646 - exit 1 1.647 + die 'WANTED package "%s" is broken' "$wanted" 1.648 fi 1.649 if [ ! -d "$WOK/$wanted/install" ]; then 1.650 - cook "$wanted" || exit 1 1.651 + cook "$wanted" || { broken; exit 1; } 1.652 fi 1.653 done 1.654 1.655 @@ -1681,8 +1742,9 @@ 1.656 if grep -Ev "(/root/.cvspass|conftest|df: /|rm: can't remove)" $LOGS/$pkg.log | \ 1.657 grep -Eq "(^$lerror|: No such file or directory|not remade because of errors|ake: \*\*\* .* Error)"; then 1.658 debug_info | tee -a $LOGS/$pkg.log 1.659 + sed -i '$ s|$| [ Failed ]|' $activity 1.660 rm -f $command 1.661 - exit 1 1.662 + broken; exit 1 1.663 fi 1.664 1.665 # Create an XML feed 1.666 @@ -1693,13 +1755,16 @@ 1.667 summary | tee -a $LOGS/$pkg.log 1.668 newline 1.669 1.670 - # We may want to install/update (outside aufs jail !). 1.671 - [ -s /aufs-umount.sh ] || 1.672 - install_package 1.673 + # We may want to install/update (outside aufs jail!). 1.674 + [ -s /aufs-umount.sh ] || install_package 1.675 + 1.676 + sed -i '$ s|$| [ Done ]|' $activity 1.677 + update_packages_info 1.678 1.679 # Finally we DON'T WANT to build the *-dev or packages with WANTED="$pkg" 1.680 - # You want automation: use the Cooker Build Bot. 1.681 - rm -f $command ;; 1.682 + # If you want automation, use the Cooker Build Bot. 1.683 + rm -f $command 1.684 + ;; 1.685 esac 1.686 1.687 exit 0
2.1 --- a/doc/cookopts.txt Thu May 11 00:17:06 2017 +0300 2.2 +++ b/doc/cookopts.txt Thu May 11 00:36:43 2017 +0300 2.3 @@ -58,6 +58,22 @@ 2.4 and libraries will not be stripped, and Python and Perl files will all be 2.5 left). 2.6 2.7 +!perlz 2.8 + Default action is to strip POD (plain old documentation) from the Perl 2.9 + modules (*.pm) and programs (*.pl) files. 2.10 + The presence of this option overrides the default action (Perl files will 2.11 + not be stripped). 2.12 + Note, if you disabled the cleaning by using the higher !strip option, Perl 2.13 + files also will not be stripped. 2.14 + 2.15 +!rmpod 2.16 + Default action is to remove Perl's POD (plain old documentation) (*.pod) 2.17 + files. 2.18 + The presence of this option overrides the default action (*.pod files will 2.19 + all be left). 2.20 + Note, if you disabled the cleaning by using the higher !strip option, *.pod 2.21 + files also will all be left. 2.22 + 2.23 !manz 2.24 Default action is to compress all man pages. 2.25 The presence of this option overrides the default action (all man pages will
3.1 --- a/modules/compressor Thu May 11 00:17:06 2017 +0300 3.2 +++ b/modules/compressor Thu May 11 00:36:43 2017 +0300 3.3 @@ -76,6 +76,8 @@ 3.4 loc) find $install/usr/share/i18n/locales -type f -exec ls -l \{\} \; ;; 3.5 mo2) find $fs/usr/share/locale -type f -name '*.mo' -exec ls -l \{\} \; ;; 3.6 gz) find $install -type f -name '*.gz' ! -path '*/share/man/*' -exec ls -l \{\} \; ;; 3.7 + str) find $fs -type f \( -name '*.so*' -o -name '*.a' -o -name '*.pyc' -o -name '*.pyo' \ 3.8 + -o -name '.packlist' -o -name '*.pm' -o -name '*.pl' -o -name '*.pod' \) -exec ls -l \{\} \; ;; 3.9 esac | awk '{s+=$5}END{print s}' 3.10 } 3.11 3.12 @@ -524,20 +526,29 @@ 3.13 fi 3.14 done 3.15 3.16 + oldsize=$(sizes str) 3.17 + 3.18 # Strip shared and static libraries 3.19 - # Remove Python *.pyc and *.pyo, Perl perllocal.pod and .packlist 3.20 - oldsize=$(find $fs -type f \( \ 3.21 - -name '*.so*' -o -name '*.a' -o \ 3.22 - -name '*.pyc' -o -name '*.pyo' -o \ 3.23 - -name 'perllocal.pod' -o -name '.packlist' \) -exec ls -l '{}' \; | awk '{s+=$5}END{print s}') 3.24 - 3.25 find $fs -name '*.so*' -exec $STRIP -s '{}' 2>/dev/null \; 3.26 find $fs -name '*.a' -exec $STRIP --strip-debug '{}' 2>/dev/null \; 3.27 + 3.28 + # Remove Python *.pyc and *.pyo 3.29 find $fs -type f \( -name '*.pyc' -o -name '*.pyo' \) -delete 2>/dev/null 3.30 - find $fs -type f \( -name 'perllocal.pod' -o -name '.packlist' \) -delete 2>/dev/null 3.31 3.32 - newsize=$(find $fs -type f \( \ 3.33 - -name '*.so*' -o -name '*.a' -o \) -exec ls -l '{}' \; | awk '{s+=$5}END{print s}') 3.34 + # Remove both with the empty subfolders: 3.35 + # 1. Perl perllocal.pod and .packlist (unconditionally) 3.36 + local perlfiles="$(find $fs -type f \( -name 'perllocal.pod' -o -name '.packlist' \))" 3.37 + # 2. Perl *.pod (if not disabled) 3.38 + [ "${COOKOPTS/!rmpod/}" == "$COOKOPTS" ] && 3.39 + perlfiles="$perlfiles $(find $fs -type f -name '*.pod')" 3.40 + echo "$perlfiles" | xargs rm -f 2>/dev/null 3.41 + echo "$perlfiles" | awk 'BEGIN{FS=OFS="/"}{$NF="";print}' | xargs rmdir -p 2>/dev/null 3.42 + 3.43 + # Strip Perl files (*.pm and *.pl) from documentation inside (if not disabled) 3.44 + [ "${COOKOPTS/!perlz/}" == "$COOKOPTS" ] && 3.45 + find $fs -type f \( -name '*.pm' -o -name '*.pl' \) -exec sed -i '/^=/,/^=cut/d' '{}' \; 3.46 + 3.47 + newsize=$(sizes str) 3.48 3.49 comp_summary "$time0" "$((size0 + oldsize))" "$((size1 + newsize))" 3.50 }
4.1 --- a/modules/pkgdb Thu May 11 00:17:06 2017 +0300 4.2 +++ b/modules/pkgdb Thu May 11 00:36:43 2017 +0300 4.3 @@ -27,6 +27,13 @@ 4.4 # as well as flavors files for TazLiTo. We don't need logs since we do it 4.5 # manually to ensure everything is fine before syncing the mirror. 4.6 4.7 +lastcooktime=$(sed '/Time:/!d; s|.*: *\([0-9]*\)s.*|\1|' $LOGS/pkgdb.log 2>/dev/null | sed '$!d') 4.8 +[ -n "$lastcooktime" ] && echo "cook:pkgdb $lastcooktime $(date +%s)" >> $cooktime 4.9 +while read cmd duration start; do 4.10 + [ $(($start + $duration)) -lt $(date +%s) ] && 4.11 + echo "sed -i '/^$cmd $duration/d' $cooktime" 4.12 +done < $cooktime | sh 4.13 + 4.14 rm $LOGS/pkgdb.log 2>/dev/null 4.15 4.16 case "$1" in 4.17 @@ -211,10 +218,11 @@ 4.18 # Create all flavors files at once. Do we really need code to monitor 4.19 # flavors changes? Let's just build them with packages lists before 4.20 # syncing the mirror. 4.21 -[ "$1" != '--flavors' ] && exit 1 4.22 +[ "$1" != '--flavors' ] && rm $command && exit 1 4.23 4.24 if [ ! -d "$flavors" ]; then 4.25 { _ 'Missing flavors folder "%s"' "$flavors"; newline; } | dblog 4.26 + rm $command 4.27 exit 1 4.28 fi 4.29 4.30 @@ -254,7 +262,7 @@ 4.31 separator | dblog 4.32 _ 'Cook pkgdb end: %s' "$(date "$(_ '+%%F %%R')")" | dblog 4.33 4.34 -> $command 4.35 +rm $command 4.36 4.37 4.38 exit 0