cookutils diff cook @ rev 952
cook: do not replace package in $PKGS if release checksum has not changed -> mirror package will not change if nothing was changed after rebuilding.
author | Aleksej Bobylev <al.bobylev@gmail.com> |
---|---|
date | Sat Jul 29 14:50:36 2017 +0300 (2017-07-29) |
parents | 4e8c86306ce2 |
children | 160d8c595c75 |
line diff
1.1 --- a/cook Thu Jul 27 13:36:30 2017 +0300 1.2 +++ b/cook Sat Jul 29 14:50:36 2017 +0300 1.3 @@ -1044,6 +1044,33 @@ 1.4 } 1.5 1.6 1.7 +# Calculate release checksum: usually it does not change on "just recook". 1.8 +# Release checksum is md5sum of file containing md5sums of: 1.9 +# a) all files, b) receipt, and c) description.txt. 1.10 +# Md5sum of the package file will change every time because of embedded timestamps; 1.11 +# release checksum based only on files content, and will change only when files change. 1.12 +# (Pitfall: ownership and permissions...) 1.13 + 1.14 +release_checksum() { 1.15 + local pack=$1 1.16 + local rsum_file=$(mktemp) 1.17 + 1.18 + cp $pack/md5sum $rsum_file 1.19 + md5sum $pack/receipt | sed 's| [^ ]*/| |' >> $rsum_file 1.20 + [ -e "$pack/description.txt" ] && 1.21 + md5sum $pack/description.txt | sed 's| [^ ]*/| |' >> $rsum_file 1.22 + 1.23 + local rsum=$(md5sum $rsum_file | awk '{print $1}') 1.24 + rm $rsum_file 1.25 + local rsumold=$(awk -F$'\t' -vpkg="$PACKAGE" ' 1.26 + {if ($1 == pkg) { print $9; exit; }}' $PKGS/packages.info) 1.27 + 1.28 + [ "$rsum" == "$rsumold" ] && rsum='' 1.29 + 1.30 + echo $rsum 1.31 +} 1.32 + 1.33 + 1.34 # Verify package quality and consistency. 1.35 1.36 packit_quality() { 1.37 @@ -1060,29 +1087,28 @@ 1.38 fi 1.39 1.40 action 'QA: checking for empty package...' 1.41 - files=$(wc -l < $WOK/$pkg/taz/$PACKAGE-$VERSION$EXTRAVERSION/files.list) 1.42 - if [ "$files" -eq 0 -a "$CATEGORY" != 'meta' ]; then 1.43 + if [ ! -s "$pack/files.list" -a "$CATEGORY" != 'meta' ]; then 1.44 broken 1.45 rm -f $command 1.46 die 'ERROR: empty package' 1.47 fi 1.48 1.49 :; status 1.50 - # Find and remove old package(s) 1.51 - tempd="$(mktemp -d)"; cd "$tempd" 1.52 - for testpkg in $(ls $PKGS/$PACKAGE-*.tazpkg 2>/dev/null); do 1.53 - # Extract receipt from each matched package 1.54 - cpio -F "$testpkg" -i receipt >/dev/null 2>&1 1.55 - name=$(. ./receipt; echo $PACKAGE) 1.56 - rm receipt 1.57 - if [ "$name" == "$PACKAGE" ]; then 1.58 - action 'Removing old package "%s"' "$(basename "$testpkg")" 1.59 - rm -f "$testpkg" 1.60 + 1.61 + # Find and remove old package(s) only if "release checksum" has changed 1.62 + rsum=$(release_checksum $pack) 1.63 + if [ -n "$rsum" ]; then 1.64 + old_file=$(awk -F$'\t' -vname="$PACKAGE" '{ 1.65 + if ($1 == name) printf("%s-%s.tazpkg", $1, $2); 1.66 + }' $PKGS/packages.info) 1.67 + if [ -f "$PKGS/$old_file" ]; then 1.68 + action 'Removing old package "%s"' "$old_file" 1.69 + rm -f "$PKGS/$old_file" 1.70 status 1.71 fi 1.72 - done 1.73 - rm -r "$tempd" 1.74 - mv -f $pkgdir/taz/$PACKAGE-$VERSION$EXTRAVERSION.tazpkg $PKGS 1.75 + mv -f $pkgdir/taz/$PACKAGE-$VERSION$EXTRAVERSION.tazpkg $PKGS 1.76 + fi 1.77 + 1.78 sed -i "/^${pkg}$/d" $broken 1.79 #action 'Removing source tree...' 1.80 #rm -f $WOK/$pkg/source; status 1.81 @@ -1425,37 +1451,23 @@ 1.82 1.83 DEPENDS=$(echo $DEPENDS) # remove newlines, tabs and multiple spaces from variable 1.84 1.85 - # Calculate release checksum: usually it does not change on "just recook". 1.86 - # Release checksum is md5sum of file containing md5sums of: 1.87 - # a) all files, b) receipt, and c) description.txt. 1.88 - # Md5sum of the package file will change every time because of embedded timestamps; 1.89 - # release checksum based only on files content, and will change only when files change. 1.90 - # (Pitfall: ownership and permissions...) 1.91 - rsumf=$(mktemp) 1.92 - cp $pack/md5sum $rsumf 1.93 - md5sum $pack/receipt | sed 's| [^ ]*/| |' >> $rsumf 1.94 - [ -e "$pack/description.txt" ] && md5sum $pack/description.txt | sed 's| [^ ]*/| |' >> $rsumf 1.95 - rsum=$(md5sum $rsumf | awk '{print $1}') 1.96 - rm $rsumf 1.97 -# MD5="$(md5sum "$PKGS/$PACKAGE-$VERSION$EXTRAVERSION.tazpkg" | awk '{print $1}')" 1.98 - rsumold=$(awk -F$'\t' -vpkg="$PACKAGE" '{if ($1 == pkg) { print $9; exit; }}' $pi) 1.99 + rsum=$(release_checksum $pack) 1.100 + if [ -n "$rsum" ]; then 1.101 + _ 'The release checksum has changed.\n' 1.102 1.103 - if [ "$rsum" == "$rsumold" ]; then 1.104 - _ 'The release checksum has not changed.\n' 1.105 - else 1.106 - _ 'The release checksum has changed.\n' 1.107 - fi 1.108 - 1.109 - sed -i "/^$PACKAGE\t/d" $pi # remove old entry 1.110 - cat >> $pi <<EOT 1.111 + sed -i "/^$PACKAGE\t/d" $pi # remove old entry 1.112 + cat >> $pi <<EOT 1.113 $PACKAGE $VERSION$EXTRAVERSION $CATEGORY $SHORT_DESC $WEB_SITE $TAGS $SIZES $DEPENDS $rsum $PROVIDE 1.114 EOT 1.115 1.116 - # files.list (uncompressed, unsorted, located in $cache) 1.117 - local fl="$cache/files.list" 1.118 - touch $fl 1.119 - sed -i "/^$PACKAGE: /d" $fl 1.120 - sed "s/^/$PACKAGE: \0/" $pack/files.list >> $fl 1.121 + # files.list (uncompressed, unsorted, located in $cache) 1.122 + local fl="$cache/files.list" 1.123 + touch $fl 1.124 + sed -i "/^$PACKAGE: /d" $fl 1.125 + sed "s/^/$PACKAGE: \0/" $pack/files.list >> $fl 1.126 + else 1.127 + _ 'The release checksum has not changed.\n' 1.128 + fi 1.129 } 1.130 1.131