Cal, Pawel, Baho, all,
For the arch master build script I have the script update the tree and then
create tarballs on the fly. (easier that mount --bind of local git tree into
chroot to use the git tree directly). One of the things I had to do was to
automate the update of the md5sum in the PKGBUILD. I have come up with a rather
wonky 2-function approach that I want to get comment on. May be OK as it (it
works fine), but I welcome thoughts for improvement. The only limitation is that
the tarball must be the first md5sum listed in the md5sum array. The functions I
use are:
## function getsum(): get the new md5sum (getsum filename)
getsum() {
[[ -r "$1" ]] || { echo "ERROR: file not found '$1' in function
getsum";
return 1; }
_tmp=$(md5sum "$1")
echo "${_tmp//\ *}"
}
## function updtsum(): update the md5sum in pkgbuild (updtsum file newmd5sum)
updtsum() {
sed -i -e "s/md5sums=('.*'/md5sums=('$2'/" "$1"
}
Then they are called in the script as follows:
## update the md5sum
_newsum=$(getsum "${tgzdir}/${tgzfn}")
echo " updating PKGBUILD md5sum -> $_newsum"
updtsum "${pbpkgd}/${pbpkg}/PKGBUILD" $_newsum
Any areas you see that could be improved? The script isn't ready for
distribution yet, but it is getting close.
--
David C. Rankin, J.D.,P.E.
Show replies by date