This is in reference to http://bugs.archlinux.org/task/15051 and a somewhat-old http://mailman.archlinux.org/pipermail/pacman-dev/2008-March/005939.html :) The initial idea was actually not substantial enough and it also went on to continue the build, so here is another one updated with Allan's suggestion. * Do not resume (maybe a separate switch for that..and for another person another day) * Consider all supported checksums from buildscript (regardless of user's config) * Do not support buildscripts with checksums for more than one architecture The last one is something I had hoped I wouldn't end up with. It's technically possible, but visually ugly. Firstly, to override $CARCH one needs to do something before generate_checksums, and this doesn't appear to be as trivial as I'd thought. Then, there is simply no way to redirect a properly-formatted multi-arch checksum output. Echo'ing along with the function produces a huge number of white spaces (or tabs), though nothing harmful. Any deeper trick is simply not going to be worth it. Obviously may not be the best way to do this, so adapt as you like if it's worth implementing. Against current git. diff --git a/scripts/makepkg.sh.in b/scripts/makepkg.sh.in index 2941a5d..d3d0d61 100644 --- a/scripts/makepkg.sh.in +++ b/scripts/makepkg.sh.in @@ -504,7 +504,6 @@ download_sources() { generate_checksums() { msg "$(gettext "Generating checksums for source files...")" - plain "" if [ ! $(type -p openssl) ]; then error "$(gettext "Cannot find openssl.")" @@ -523,6 +522,7 @@ generate_checksums() { local ct=0 local numsrc=${#source[@]} + echo echo -n "${integ}sums=(" local i=0; @@ -557,6 +557,45 @@ generate_checksums() { done } +update_checksums() { + local file="$startdir/$BUILDSCRIPT" + local integ + + # necessary override for --geninteg + unset INTEGRITY_CHECK + + for integ in md5 sha1 sha256 sha384 sha512; do + grep "${integ}sums=(" $file &> /dev/null && \ + INTEGRITY_CHECK=(${INTEGRITY_CHECK[@]} $integ) + done + + integ=${INTEGRITY_CHECK[0]} + if grep "&& ${integ}sums=(" "$file" | grep '$CARCH' &> /dev/null; then + error "$(gettext "Multi-arch checksum update not supported. Exiting...")" + exit 1 + else + for integ in ${INTEGRITY_CHECK[@]}; do + sed -i "/${integ}sums=(/,/)$/d" "$file" + done + + if grep "# vim: set" "$file" &> /dev/null; then + sed -i '/# vim: set/d' "$file" + sed -i -e :a -e '/^\n*$/{$d;N;ba' -e '}' "$file" + local vimset=1 + fi + + generate_checksums >> "$file" + + if [ $vimset -eq 1 ]; then + echo >> "$file" + echo "# vim: set ts=2 sw=2 et:" >> "$file" + fi + fi + + msg "$(gettext "Updated checksums in %s")" "$BUILDSCRIPT" + return 0 +} + check_checksums() { [ ${#source[@]} -eq 0 ] && return 0 @@ -1431,6 +1470,7 @@ usage() { echo "$(gettext " -e, --noextract Do not extract source files (use existing src/ dir)")" echo "$(gettext " -f, --force Overwrite existing package")" echo "$(gettext " -g, --geninteg Generate integrity checks for source files")" + printf "$(gettext " -G, --getinteg Update integrity checks in %s")\n" "$BUILDSCRIPT" echo "$(gettext " -h, --help This help")" echo "$(gettext " -i, --install Install package after successful build")" echo "$(gettext " -L, --log Log package build process")" @@ -1477,9 +1517,9 @@ fi ARGLIST=$@ # Parse Command Line Options. -OPT_SHORT="AcCdefFghiLmop:rRsV" +OPT_SHORT="AcCdefFgGhiLmop:rRsV" OPT_LONG="allsource,asroot,ignorearch,clean,cleancache,nodeps" -OPT_LONG="$OPT_LONG,noextract,force,forcever:,geninteg,help,holdver" +OPT_LONG="$OPT_LONG,noextract,force,forcever:,geninteg,getinteg,help,holdver" OPT_LONG="$OPT_LONG,install,log,nocolor,nobuild,rmdeps,repackage,skipinteg" OPT_LONG="$OPT_LONG,source,syncdeps,version,config:" # Pacman Options @@ -1512,6 +1552,7 @@ while true; do --forcever) shift; FORCE_VER=$1;; -F) INFAKEROOT=1 ;; -g|--geninteg) GENINTEG=1 ;; + -G| --getinteg) GETINTEG=1 ;; --holdver) HOLDVER=1 ;; -i|--install) INSTALL=1 ;; -L|--log) LOGGING=1 ;; @@ -1680,6 +1721,15 @@ if [ "$GENINTEG" -eq 1 ]; then exit 0 # $E_OK fi +if [ "$GETINTEG" -eq 1 ]; then + mkdir -p "$srcdir" + cd "$srcdir" + download_sources + update_checksums + cd "$startdir" + exit 0 +fi + if [ "$(type -t package)" = "function" ]; then PKGFUNC=1 fi