5f6732f5c04c1c13e199cf646948c3268eac32ac
[mirrors/Programs.git] / bash / pacman-doctor / makepkg-update-checksums.sh
1 #!/bin/bash
2 pkgbuild='PKGBUILD'
3 echo "==> Sourcing $pkgbuild ..."
4 unset pkgname pkgver pkgrel license url options md5sums sha1sums sha256sums sha384sums sha512sums
5 . PKGBUILD
6 echo "==> Package: $pkgname ($pkgver-$pkgrel)"
7 echo " License: $license, Homepage: $url"
8
9 option='updatesums'
10 proceed=false;
11
12 echo "${options[*]}" | grep "!$option" >/dev/null && {
13 echo "==> ERROR: $pkgbuild prevents checksum updating using: options=(!$option)"
14 echo "==> Aborted!"
15 exit
16 }
17 echo "${options[*]}" | grep "[^!]*$option" >/dev/null && {
18 echo "==> $pkgbuild forces checksum updating using: options=($option)"
19 proceed=true;
20 }
21 echo "==> Old checksums:"
22 echo "md5sums=(${md5sums[*]})"
23
24 checksums="$(makepkg -p "$pkgbuild" -g)" 2>/dev/null
25 echo "==> New checksums:"
26 echo "$checksums";
27
28
29
30
31
32 exit
33
34 update_hashes() {
35 sed -ne '1h;1!H;${;g;s/md5sums=([^)]*)/'$(makepkg -p "$1" -g 2>/dev/null)'/g;p;}' "$1" > "$1.new"
36 #maybe this code should be changed to replace only first occurence of md5sums array...
37 mv -f "$1" "$1.bak"
38 mv -f "$1.new" "$1"
39 }
40
41 update_hashes() {
42 #sed -ne '1h;1!H;${;g;s/md5sums=([^)]*)/'$(makepkg -p "$1" -g 2>/dev/null)'/g;p;}' "$1" > "$1.new"
43 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"
44 mv -f "$1" "$1.bak"
45 mv -f "$1.new" "$1"
46 }
47
48
49 sed -i '/^md5sums=([^)]*)/d' PKGBUILD && makepkg -g >> PKGBUILD && makepkg
50
51 sed -ne '1h;1!H;${;g;s/md5sums=([^)]*)/'$(makepkg -g 2>/dev/null)'/g;p;}' PKGBUILD
52
53
54 { rm PKGBUILD; awk '$0 ~ /^md5sums/ {i = 1; system("makepkg -g 2>/dev/null")}; !i {print}; $0 ~ /\)/ {i = 0}' > PKGBUILD; } < PKGBUILD
This page took 1.183805 seconds and 5 git commands to generate.