You are not logged in.
Is there an easy method to have the output of makepkg -g written to a PKGBUILD file and at the same time have the existing sha256=... (and all lines) get replaced? I have been doing in a two step process where I:
1) manually delete all checksums in the PKGUBILD
2) run makepkg -g >> PKGBUILD
I'd like to have a script or one-liner that removes the current lines for the checksums and replaces them with the new ones.
Last edited by graysky (2011-12-09 18:28:54)
CPU-optimized Linux-ck packages @ Repo-ck • AUR packages • Zsh and other configs
Offline
I use this:
mg() {
if [ ! -f ./PKGBUILD ]; then
echo "No PKGBUILD in `pwd`"
return 1
fi
# removes md5sums
sed -i "/^.*'[a-z0-9]\{32\}'.*$/d" PKGBUILD
# removes sha1sums
sed -i "/^.*'[a-z0-9]\{64\}'.*$/d" PKGBUILD
makepkg -g >> PKGBUILD
echo "PKGBUILD updated"
}
Last edited by jjacky (2011-12-09 16:46:13)
Offline
@jjacky - I should have been more clear. I would like the script to replace the line/lines removed where they occur in the file. Your script is nice but it writes them to end of the PKGBUILD. I'd like to keep them as the last item before the build array.
CPU-optimized Linux-ck packages @ Repo-ck • AUR packages • Zsh and other configs
Offline
oh, I see. Something more like this then...
mg() {
if [ ! -f ./PKGBUILD ]; then
echo "No PKGBUILD in `pwd`"
return 1
fi
local sums
# calculate new md5sums
sums=$(makepkg -g)
# replace them in-place
sed -i "s/^md5sums=.*/%NEWSUMS%/;/'[a-z0-9]\{32\}'/d;s/%NEWSUMS%/$sums/" PKGBUILD
echo "PKGBUILD updated"
}
I'm not familiar with sed so there's probably a better way to do it, with or without sed actually. This doesn't feel like a good way to do this, but it does put the new sums where the old ones were...
Offline
I'd use awk for this.
#!/bin/bash
awk -v newsums="$(makepkg -g)" '
BEGIN {
if (!newsums) exit 1
}
/^[[:blank:]]*(md|sha)[[:digit:]]+sums=/,/\)[[:blank:]]*$/ {
if (!i) print newsums; i++
next
}
1
' PKGBUILD > PKGBUILD.new && mv PKGBUILD{.new,}
Offline
Nice! Thanks FI. Placed your script on the wiki:
https://wiki.archlinux.org/index.php/Ma … omatically
Last edited by graysky (2011-12-10 11:30:47)
CPU-optimized Linux-ck packages @ Repo-ck • AUR packages • Zsh and other configs
Offline
Native functionality in /usr/bin/makepkg would be killer.
EDIT: https://bugs.archlinux.org/task/27513
Last edited by graysky (2011-12-09 19:46:14)
CPU-optimized Linux-ck packages @ Repo-ck • AUR packages • Zsh and other configs
Offline