From aca0bc7454c7763f928cc89c9ab37db305c879b8 Mon Sep 17 00:00:00 2001 From: Harvie Date: Tue, 24 Aug 2010 00:55:01 +0200 Subject: [PATCH] Added experimental makepkg-update-checksums.sh --- .../pacman-doctor/makepkg-update-checksums.sh | 54 +++++++++++++++++++ 1 file changed, 54 insertions(+) create mode 100755 bash/pacman-doctor/makepkg-update-checksums.sh diff --git a/bash/pacman-doctor/makepkg-update-checksums.sh b/bash/pacman-doctor/makepkg-update-checksums.sh new file mode 100755 index 0000000..5f6732f --- /dev/null +++ b/bash/pacman-doctor/makepkg-update-checksums.sh @@ -0,0 +1,54 @@ +#!/bin/bash +pkgbuild='PKGBUILD' +echo "==> Sourcing $pkgbuild ..." +unset pkgname pkgver pkgrel license url options md5sums sha1sums sha256sums sha384sums sha512sums +. PKGBUILD +echo "==> Package: $pkgname ($pkgver-$pkgrel)" +echo " License: $license, Homepage: $url" + +option='updatesums' +proceed=false; + +echo "${options[*]}" | grep "!$option" >/dev/null && { + echo "==> ERROR: $pkgbuild prevents checksum updating using: options=(!$option)" + echo "==> Aborted!" + exit +} +echo "${options[*]}" | grep "[^!]*$option" >/dev/null && { + echo "==> $pkgbuild forces checksum updating using: options=($option)" + proceed=true; +} +echo "==> Old checksums:" +echo "md5sums=(${md5sums[*]})" + +checksums="$(makepkg -p "$pkgbuild" -g)" 2>/dev/null +echo "==> New checksums:" +echo "$checksums"; + + + + + +exit + +update_hashes() { +sed -ne '1h;1!H;${;g;s/md5sums=([^)]*)/'$(makepkg -p "$1" -g 2>/dev/null)'/g;p;}' "$1" > "$1.new" +#maybe this code should be changed to replace only first occurence of md5sums array... +mv -f "$1" "$1.bak" +mv -f "$1.new" "$1" +} + +update_hashes() { +#sed -ne '1h;1!H;${;g;s/md5sums=([^)]*)/'$(makepkg -p "$1" -g 2>/dev/null)'/g;p;}' "$1" > "$1.new" +sed -ne '1h;1!H;${;g;s/\(md5\|sha\|sha1\|sha224\|sha256\|sha384\|sha512\)sums=([^)]*)/'$(makepkg -p "$1" -g 2>/dev/null)'/1;p;}' "$1" > "$1.new" +mv -f "$1" "$1.bak" +mv -f "$1.new" "$1" +} + + +sed -i '/^md5sums=([^)]*)/d' PKGBUILD && makepkg -g >> PKGBUILD && makepkg + +sed -ne '1h;1!H;${;g;s/md5sums=([^)]*)/'$(makepkg -g 2>/dev/null)'/g;p;}' PKGBUILD + + +{ rm PKGBUILD; awk '$0 ~ /^md5sums/ {i = 1; system("makepkg -g 2>/dev/null")}; !i {print}; $0 ~ /\)/ {i = 0}' > PKGBUILD; } < PKGBUILD -- 2.30.2