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