cookutils diff cook @ rev 904
Introduce SliTaz packages receipts v2. Tune 'cook' and 'lighttpd/index.cgi' for it. Small improvements to CSS styles.
author | Aleksej Bobylev <al.bobylev@gmail.com> |
---|---|
date | Fri May 26 16:22:26 2017 +0300 (2017-05-26) |
parents | b03ac1e1213d |
children | c711ef2e51a9 |
line diff
1.1 --- a/cook Fri May 12 17:15:15 2017 +0300 1.2 +++ b/cook Fri May 26 16:22:26 2017 +0300 1.3 @@ -84,12 +84,6 @@ 1.4 } 1.5 1.6 1.7 -if_empty_value() { 1.8 - # L10n: QA is quality assurance 1.9 - [ -n "$value" ] || die 'QA: empty variable: %s' "$var=\"\"" 1.10 -} 1.11 - 1.12 - 1.13 # Initialize files used in $CACHE 1.14 1.15 init_db_files() { 1.16 @@ -104,19 +98,15 @@ 1.17 1.18 receipt_quality() { 1.19 _ 'QA: checking package receipt...' 1.20 - unset online 1.21 - if ifconfig | grep -q -A 1 "^[a-z]*[0-9]" | fgrep 'addr:'; then 1.22 - online='online' 1.23 - fi 1.24 + 1.25 for var in PACKAGE VERSION CATEGORY SHORT_DESC MAINTAINER WEB_SITE; do 1.26 unset value 1.27 value="$(. $receipt; eval echo \$$var)" 1.28 + # L10n: QA is quality assurance 1.29 + [ -n "$value" ] || die 'QA: empty variable: %s' "$var=\"\"" 1.30 + 1.31 case "$var" in 1.32 - PACKAGE|VERSION|SHORT_DESC) 1.33 - if_empty_value 1.34 - ;; 1.35 CATEGORY) 1.36 - value="${value:-empty}" 1.37 valid="$(echo $PKGS_CATEGORIES)" # avoid newlines 1.38 if ! echo " $valid " | grep -q " $value "; then 1.39 _ 'QA: unknown category "%s"' "$value" 1.40 @@ -126,9 +116,8 @@ 1.41 WEB_SITE) 1.42 # We don't check WGET_URL since if dl is needed it will fail. 1.43 # Break also if we're not online. Here error is not fatal. 1.44 - if_empty_value 1.45 - [ -z "$online" ] && break 1.46 - if ! busybox wget -T 12 -s $value 2>/dev/null; then 1.47 + if ifconfig | grep -A1 '^[a-z]*[0-9]' | fgrep -q 'addr:' && \ 1.48 + ! busybox wget -T 12 --spider $value 2>/dev/null; then 1.49 _ 'QA: unable to reach "%s"' "$value" 1.50 fi 1.51 ;; 1.52 @@ -140,46 +129,45 @@ 1.53 # Paths used in receipt and by cook itself. 1.54 1.55 set_paths() { 1.56 - pkgdir="$WOK/$PACKAGE" 1.57 + pkgdir="$WOK/$pkg" 1.58 . "$pkgdir/receipt" 1.59 basesrc="$pkgdir/source" 1.60 tmpsrc="$basesrc/tmp" 1.61 src="$basesrc/$PACKAGE-$VERSION" 1.62 taz="$pkgdir/taz" 1.63 - pack="$taz/$PACKAGE-$VERSION$EXTRAVERSION" 1.64 + pack="$taz/${1:-$PACKAGE}-$VERSION$EXTRAVERSION" # v2: multiple taz/* folders 1.65 fs="$pack/fs" 1.66 stuff="$pkgdir/stuff" 1.67 install="$pkgdir/install" 1.68 + 1.69 pkgsrc="${SOURCE:-$PACKAGE}-${KBASEVER:-$VERSION}" 1.70 lzma_tarball="$pkgsrc.tar.lzma" 1.71 - if [ -n "$PATCH" ]; then 1.72 - [ -z "$PTARBALL" ] && PTARBALL="$(basename $PATCH)" 1.73 - fi 1.74 + 1.75 + [ -n "$PATCH" -a -z "$PTARBALL" ] && PTARBALL="$(basename $PATCH)" 1.76 + 1.77 if [ -n "$WANTED" ]; then 1.78 basesrc="$WOK/$WANTED/source" 1.79 src="$basesrc/$WANTED-$VERSION" 1.80 install="$WOK/$WANTED/install" 1.81 wanted_stuff="$WOK/$WANTED/stuff" 1.82 fi 1.83 - if [ -n "$SOURCE" ]; then 1.84 - source_stuff="$WOK/$SOURCE/stuff" 1.85 - fi 1.86 + 1.87 + [ -n "$SOURCE" ] && source_stuff="$WOK/$SOURCE/stuff" 1.88 + 1.89 # Kernel version is set from wok/linux or installed/linux-api-headers(wok-undigest) 1.90 if [ -f "$WOK/linux/receipt" ]; then 1.91 - kvers=$(grep ^VERSION= $WOK/linux/receipt | cut -d\" -f2) 1.92 - kbasevers=${kvers:0:3} 1.93 + kvers=$(. $WOK/linux/receipt; echo $VERSION) 1.94 + kbasevers=$(echo $kvers | cut -d. -f1,2) 1.95 elif [ -f "$INSTALLED/linux-api-headers/receipt" ]; then 1.96 - kvers=$(grep ^VERSION= $INSTALLED/linux-api-headers/receipt | cut -d\" -f2) 1.97 - kbasevers=${kvers:0:3} 1.98 + kvers=$(. $INSTALLED/linux-api-headers/receipt; echo $VERSION) 1.99 + kbasevers=$(echo $kvers | cut -d. -f1,2) 1.100 fi 1.101 + 1.102 # Python version 1.103 - if [ -f "$WOK/python/receipt" ]; then 1.104 - pyvers=$(grep ^VERSION= $WOK/python/receipt | cut -d\" -f2) 1.105 - fi 1.106 + [ -f "$WOK/python/receipt" ] && pyvers=$(. $WOK/python/receipt; echo $VERSION) 1.107 # Perl version for some packages needed it 1.108 - if [ -f "$WOK/perl/receipt" ]; then 1.109 - perlvers=$(grep ^VERSION= $WOK/perl/receipt | cut -d\" -f2) 1.110 - fi 1.111 + [ -f "$WOK/perl/receipt" ] && perlvers=$(. $WOK/perl/receipt; echo $VERSION) 1.112 + 1.113 # Old way compatibility. 1.114 _pkg="$install" 1.115 } 1.116 @@ -349,25 +337,32 @@ 1.117 cd $WOK/$pkg 1.118 [ -d $WOK/$pkg/install ] && prod=$(du -sh $WOK/$pkg/install | awk '{print $1}' 2>/dev/null) 1.119 [ -d $WOK/$pkg/source ] && srcdir=$(du -sh $WOK/$pkg/source | awk '{print $1}' 2>/dev/null) 1.120 - fs=$(du -sh $WOK/$pkg/taz/* | awk '{print $1}') 1.121 - size=$(ls -lh $PKGS/$pkg-${VERSION}*.tazpkg | awk '{print $5}') 1.122 - files=$(cat $WOK/$pkg/taz/$pkg-*/files.list | wc -l) # please keep cat here, otherwise it'll not work 1.123 [ -n "$TARBALL" ] && srcsize=$(du -sh $SRC/$TARBALL | awk '{print $1}') 1.124 1.125 _ 'Summary for: %s' "$PACKAGE $VERSION" 1.126 separator 1.127 1.128 # L10n: keep the same width of translations to get a consistent view 1.129 - [ -n "$srcdir" ] && _ 'Source dir : %s' "$srcdir" 1.130 [ -n "$TARBALL" ] && _ 'Src file : %s' "$TARBALL" 1.131 [ -n "$srcsize" ] && _ 'Src size : %s' "$srcsize" 1.132 + [ -n "$srcdir" ] && _ 'Source dir : %s' "$srcdir" 1.133 [ -n "$prod" ] && _ 'Produced : %s' "$prod" 1.134 - _ 'Packed : %s' "$fs" 1.135 - _ 'Compressed : %s' "$size" 1.136 - _ 'Files : %s' "$files" 1.137 _ 'Cook time : %s' "$(disp_time "$time")" 1.138 _ 'Cook date : %s' "$(date "$(_ '+%%F %%R')")" 1.139 _ 'Host arch : %s' "$ARCH" 1.140 + 1.141 + separator - 1.142 + _ ' # : Packed : Compressed : Files : Package name' 1.143 + separator - 1.144 + pkgi=1 1.145 + for i in $PACKAGE $SPLIT; do 1.146 + fs=$(du -sh $WOK/$pkg/taz/$i-$VERSION | awk '{print $1}') 1.147 + pkgname="$i-$VERSION.tazpkg" 1.148 + size=$(ls -lh $PKGS/$pkgname | awk '{print $5}') 1.149 + files=$(wc -l < $WOK/$pkg/taz/$i-$VERSION/files.list) 1.150 + printf "%2d : %6s : %10s : %5s : %s\n" "$pkgi" "$fs" "$size" "$files" "$pkgname" 1.151 + pkgi=$((pkgi + 1)) 1.152 + done 1.153 separator 1.154 } 1.155 1.156 @@ -381,7 +376,7 @@ 1.157 _ 'Cook date: %s' "$(date "$(_ '+%%F %%R')")" 1.158 if [ -n "$time" ]; then 1.159 times="$(($(date +%s) - $time))" 1.160 - _ 'Cook time : %s' "$(disp_time "$times")" 1.161 + _ 'Wasted time : %s' "$(disp_time "$times")" 1.162 fi 1.163 for error in \ 1.164 ERROR 'No package' "cp: can't" "can't open" "can't cd" \ 1.165 @@ -588,6 +583,7 @@ 1.166 esac 1.167 1.168 [ -n "$QA" ] && receipt_quality 1.169 + 1.170 cd $pkgdir 1.171 [ -z "$continue" ] && rm -rf source 2>/dev/null 1.172 rm -rf install taz 2>/dev/null 1.173 @@ -607,6 +603,12 @@ 1.174 export DESTDIR MAKEFLAGS CFLAGS CXXFLAGS CONFIG_SITE LC_ALL=C LANG=C 1.175 #LDFLAGS 1.176 1.177 + # BUILD_DEPENDS may vary depending on the ARCH 1.178 + case "$ARCH" in 1.179 + arm*) [ -n "$BUILD_DEPENDS_arm" ] && BUILD_DEPENDS=$BUILD_DEPENDS_arm ;; 1.180 + x86_64) [ -n "$BUILD_DEPENDS_x86_64" ] && BUILD_DEPENDS=$BUILD_DEPENDS_x86_64 ;; 1.181 + esac 1.182 + 1.183 # Check for build deps and handle implicit depends of *-dev packages 1.184 # (ex: libusb-dev :: libusb). 1.185 rm -f $CACHE/installed.local $CACHE/installed.web $CACHE/missing.dep 1.186 @@ -616,6 +618,8 @@ 1.187 for dep in $BUILD_DEPENDS; do 1.188 implicit="${dep%-dev}"; [ "$implicit" == "$dep" ] && implicit='' 1.189 for i in $dep $implicit; do 1.190 +# echo "i='$i'" 1.191 + # Check if package already installed 1.192 [ -f "$root$INSTALLED/$i/receipt" ] && continue 1.193 1.194 # Try local package first. 1.195 @@ -688,7 +692,7 @@ 1.196 # use local packages). 1.197 for i in $(uniq $CACHE/installed.web); do 1.198 # _ 'Installing dep (web/cache): %s' "$i" 1.199 - tazpkg get-install $i --root=$root --quiet --cookmode 1.200 + tazpkg get-install $i --root=$root --local --quiet --cookmode 1.201 done 1.202 1.203 update_installed_cook_diff 1.204 @@ -796,29 +800,29 @@ 1.205 1.206 mk_pkg_receipt() { 1.207 orig_receipt="$1" 1.208 - # $pkg is package name 1.209 1.210 # Receipt's signature is important, although some receipts may miss it 1.211 signature=$(head -n1 "$orig_receipt") 1.212 [ "${signature:0:1}" == '#' ] || signature='# SliTaz package receipt.' 1.213 1.214 + save_PACKAGE="$PACKAGE"; save_DEPENDS="$DEPENDS"; save_PROVIDE="$PROVIDE" 1.215 + unset_receipt 1.216 . "$orig_receipt" 1.217 - 1.218 - # Is package split one? 1.219 - [ -n "$SPLIT" -a "${SPLIT/$pkg/}" != "$SPLIT" ]; splitted=$? 1.220 + PACKAGE="$save_PACKAGE"; DEPENDS="$save_DEPENDS"; PROVIDE="$save_PROVIDE" 1.221 1.222 # Manage split packages 1.223 - if $splitted; then 1.224 + SPLIT=" $SPLIT " 1.225 + if [ "$SPLIT" != ' ' -a "${SPLIT/ $PACKAGE /}" != "$SPLIT" ]; then 1.226 # For packages with empty $DEPENDS 1.227 - [ -n "$DEPENDS" ] || DEPENDS="$PACKAGE" 1.228 + [ -n "$DEPENDS" ] || DEPENDS="$pkg" 1.229 1.230 # Default $CAT 1.231 [ -z "$CAT" ] && 1.232 - case $pkg in 1.233 + case $PACKAGE in 1.234 *-dev) CAT="development|development files" ;; 1.235 esac 1.236 1.237 - # Manage $CAT 1.238 + # Manage two-in-one $CAT="$CATEGORY|$SHORT_DESC_ADDITION" 1.239 CATEGORY="${CAT%|*}" 1.240 SHORT_DESC="$SHORT_DESC (${CAT#*|})" 1.241 fi 1.242 @@ -838,12 +842,13 @@ 1.243 1.244 # Optional variables 1.245 [ -n "$TAGS" ] && echo "TAGS=\"$TAGS\"" 1.246 - [ -n "$DEPENDS" ] && echo "DEPENDS=\"$DEPENDS\"" 1.247 + [ -n "$DEPENDS" ] && echo "DEPENDS=\"$DEPENDS\"" | tr -ds '\t' ' ' 1.248 + [ -n "$PROVIDE" ] && echo "PROVIDE=\"$PROVIDE\"" 1.249 1.250 # Extract {pre,post}_{install,remove} functions 1.251 for i in pre post; do 1.252 for j in install remove; do 1.253 - if grep -q "^${i}_$j()"; then 1.254 + if grep -q "^${i}_$j()" "$orig_receipt"; then 1.255 echo 1.256 sed "/^${i}_$j()/,/}/!d" "$orig_receipt" 1.257 fi 1.258 @@ -856,7 +861,8 @@ 1.259 # but it doesn't handle EXTRAVERSION. 1.260 1.261 packit() { 1.262 - set_paths 1.263 + set_paths "$1" 1.264 + PACKAGE="${1:-$PACKAGE}" 1.265 1.266 # Handle cross compilation 1.267 case "$ARCH" in 1.268 @@ -894,11 +900,18 @@ 1.269 fi 1.270 1.271 cd $taz 1.272 - for file in receipt description.txt; do 1.273 - [ ! -f "../$file" ] && continue 1.274 - action 'Copying "%s"...' "$file" 1.275 - cp -f ../$file $pack; chown 0.0 $pack/$file; status 1.276 - done 1.277 + action 'Copying "%s"...' 'receipt' 1.278 + mk_pkg_receipt ../receipt > $pack/receipt 1.279 + chown 0.0 $pack/receipt; status 1.280 + 1.281 + unset desc 1.282 + [ "$pkg" == "$PACKAGE" -a -f "../description.txt" ] && desc="../description.txt" 1.283 + [ -f "../description.$PACKAGE.txt" ] && desc="../description.$PACKAGE.txt" 1.284 + if [ -n "$desc" ]; then 1.285 + action 'Copying "%s"...' "$(basename "$desc")" 1.286 + cp -f $desc $pack/description.txt; chown 0.0 $pack/description.txt; status 1.287 + fi 1.288 + 1.289 copy_generic_files 1.290 1.291 # Strip and stuff files. 1.292 @@ -927,11 +940,11 @@ 1.293 UNPACKED_SIZE=$(du -chs fs receipt files.list md5sum description.txt \ 1.294 2>/dev/null | awk 'END{ print $1 }') 1.295 1.296 - # Build cpio archives. 1.297 + # Build cpio archive. 1.298 action 'Compressing the FS...' 1.299 - find fs -newer $receipt -exec touch -hr $receipt {} \; 1.300 + find fs -newer $receipt -exec touch -hr $receipt '{}' \; 1.301 find fs | cpio -o -H newc --quiet | lzma e fs.cpio.lzma -si 1.302 - rm -rf fs 1.303 + mv fs ../ 1.304 status 1.305 1.306 PACKED_SIZE=$(du -chs fs.cpio.lzma receipt files.list md5sum description.txt \ 1.307 @@ -953,12 +966,12 @@ 1.308 1.309 # Compress. 1.310 action 'Creating full cpio archive...' 1.311 - find . -print | cpio -o -H newc --quiet > \ 1.312 - ../$PACKAGE-$VERSION$EXTRAVERSION$arch.tazpkg 1.313 + find . -newer $receipt -exec touch -hr $receipt '{}' \; 1.314 + find . | cpio -o -H newc --quiet > ../$PACKAGE-$VERSION$EXTRAVERSION$arch.tazpkg 1.315 status 1.316 1.317 action 'Restoring original package tree...' 1.318 - unlzma -c fs.cpio.lzma | cpio -idm --quiet 1.319 + mv ../fs . 1.320 status 1.321 1.322 rm fs.cpio.lzma; cd .. 1.323 @@ -967,6 +980,7 @@ 1.324 tazpkg=$(ls *.tazpkg) 1.325 packit_quality 1.326 footer "$(_ 'Package "%s" created' "$tazpkg")" 1.327 + update_packages_info 1.328 } 1.329 1.330 1.331 @@ -986,7 +1000,7 @@ 1.332 fi 1.333 1.334 action 'QA: checking for empty package...' 1.335 - files=$(cat $WOK/$pkg/taz/$pkg-*/files.list | wc -l) 1.336 + files=$(cat $WOK/$pkg/taz/$PACKAGE-$VERSION/files.list | wc -l) 1.337 if [ "$files" -eq 0 -a "$CATEGORY" != 'meta' ]; then 1.338 broken 1.339 rm -f $command 1.340 @@ -996,25 +1010,40 @@ 1.341 :; status 1.342 # Find and remove old package(s) 1.343 tempd="$(mktemp -d)"; cd "$tempd" 1.344 - for testpkg in $(ls $PKGS/$pkg-*.tazpkg 2> /dev/null); do 1.345 + for testpkg in $(ls $PKGS/$PACKAGE-*.tazpkg 2> /dev/null); do 1.346 # Extract receipt from each matched package 1.347 cpio -F "$testpkg" -i receipt >/dev/null 2>&1 1.348 name=$(. receipt; echo $PACKAGE) 1.349 rm receipt 1.350 - if [ "$name" == "$pkg" ]; then 1.351 + if [ "$name" == "$PACKAGE" ]; then 1.352 action 'Removing old package "%s"' "$(basename "$testpkg")" 1.353 rm -f "$testpkg" 1.354 status 1.355 fi 1.356 done 1.357 rm -r "$tempd" 1.358 - mv -f $pkgdir/taz/$pkg-*.tazpkg $PKGS 1.359 + mv -f $pkgdir/taz/$PACKAGE-$VERSION.tazpkg $PKGS 1.360 sed -i /^${pkg}$/d $broken 1.361 #action 'Removing source tree...' 1.362 #rm -f $WOK/$pkg/source; status 1.363 } 1.364 1.365 1.366 +# v2: pack all packages using compiled files 1.367 + 1.368 +packall() { 1.369 + set_paths 1.370 + if head -n1 "$pkgdir/receipt" | fgrep -q 'v2'; then 1.371 + for i in $PACKAGE $SPLIT; do 1.372 + unset DEPENDS CAT 1.373 + packit $i 1.374 + done 1.375 + else 1.376 + packit 1.377 + fi 1.378 +} 1.379 + 1.380 + 1.381 # Reverse "cat" command: prints input lines in the reverse order 1.382 1.383 tac() { 1.384 @@ -1227,8 +1256,9 @@ 1.385 sed '/\.h$/d; /\.hxx$/d; /\.a$/d; /\.la$/d; /\.pc$/d; /bin\/.*-config$/d; 1.386 /\.m4$/d; /\.gir$/d; /\.typelib$/d; /\.vapi$/d; /\.deps$/d; 1.387 /\/include\//d; 1.388 - /\/share\/man\//d; /\/share\/doc\//d; /\/share\/info\//d; /\/share\/locale\//d; 1.389 - /\/share\/bash-completion\//d; 1.390 + /\/share\/man\//d; /\/share\/doc\//d; /\/share\/gtk-doc\//d; /\/share\/info\//d; 1.391 + /\/share\/devhelp\//d; /\/share\/locale\//d; 1.392 + /\/share\/bash-completion\//d; /\/lib\/systemd\//d; 1.393 ' $filelist > $tmplist 1.394 while read j; do 1.395 mkdir -p $fs$(dirname $j) 1.396 @@ -1287,11 +1317,10 @@ 1.397 # Update packages.info every time after successful build 1.398 1.399 update_packages_info() { 1.400 - sed -i "/^$pkg\t/d" $PKGS/packages.info 1.401 - PACKAGE="$pkg"; set_paths 1.402 + sed -i "/^$PACKAGE\t/d" $PKGS/packages.info 1.403 unset_receipt; . $pack/receipt 1.404 SIZES=$(echo $PACKED_SIZE $UNPACKED_SIZE | sed 's|\.0||g') 1.405 - DEPENDS=$(echo $DEPENDS) # remove newlines from some receipts 1.406 + DEPENDS=$(echo $DEPENDS) # remove newlines, tabs and multiple spaces from variable 1.407 MD5="$(md5sum "$PKGS/$PACKAGE-$VERSION$EXTRAVERSION.tazpkg" | awk '{print $1}')" 1.408 cat >> $PKGS/packages.info <<EOT 1.409 $PACKAGE $VERSION$EXTRAVERSION $CATEGORY $SHORT_DESC $WEB_SITE $TAGS $SIZES $DEPENDS $MD5 $PROVIDE 1.410 @@ -1736,7 +1765,7 @@ 1.411 cookit $@ 2>&1 | loglimit 50 > $LOGS/$pkg.log 1.412 remove_deps | tee -a $LOGS/$pkg.log 1.413 cookit_quality 1.414 - packit 2>&1 | loglimit 5 >> $LOGS/$pkg.log 1.415 + packall 2>&1 | loglimit 5 >> $LOGS/$pkg.log 1.416 clean_log 1.417 1.418 # Exit if any error in packing. 1.419 @@ -1761,7 +1790,6 @@ 1.420 [ -s /aufs-umount.sh ] || install_package 1.421 1.422 sed -i '$ s|$| [ Done ]|' $activity 1.423 - update_packages_info 1.424 1.425 # Finally we DON'T WANT to build the *-dev or packages with WANTED="$pkg" 1.426 # If you want automation, use the Cooker Build Bot.