You are not logged in.
Been trying to find a way to do this. 'makepkg -g >> PKGBUILD' puts the md5sums at the end of the line and was hoping to find a way to put them after the source line. Been thinking about a way to do this but it's pretty ugly. Thinking something like this would do:
sed -e '1,/md5sum/d' PKGBUILD > PKGBUILD.tmp
sed -i '/md5sum/,/\t/d' PKGBUILD
makepkg -g PKGBUILD
cat PKGBUILD.tmp >> PKGBUILD
rm PKGBUILD.tmp
But thinking there's got to be a better way. Has anyone come up (or have any ideas on how to) put md5sums after source?
Last edited by Gen2ly (2009-10-25 16:54:32)
Setting Up a Scripting Environment | Proud donor to wikipedia - link
Offline
Something like this?
sed -i -e "s/^source.*$/&\n$(makepkg -g)/" PKGBUILD
Edit:
To also remove any pre-existing md5sum line,
sed -i -e '/^md5sum/d' -e "s/^source.*$/&\n$(makepkg -g)/" PKGBUILD
Last edited by Ramses de Norre (2009-10-16 18:16:16)
Offline
Does this handle a source split on multiple lines ?
Btw also check out http://bugs.archlinux.org/task/15051
We are still looking for THE way to update checksums
pacman roulette : pacman -S $(pacman -Slq | LANG=C sort -R | head -n $((RANDOM % 10)))
Offline
This will save me a good bit of time. I did make one small edit so the entire md5sum gets covered (i.e. spans over one line):
sed -i -e '/^md5sum/,/)/d' -e "s/^source.*$/&\n$(makepkg -g)/" PKGBUILD
Veeerrry nice, Ramses de Norre. Thanks for the help.
Edit:
Does this handle a source split on multiple lines ?
....
Last edited by Gen2ly (2009-10-16 18:55:25)
Setting Up a Scripting Environment | Proud donor to wikipedia - link
Offline
Heh, you guys are probably gonna get a good laugh out of this but I did find a way to get this to work. It ain't pretty, but heh...
# Remove trailing blank lines
while [ "$(tail -n 1 PKGBUILD)" == "" ]; do
sed -i '$d' PKGBUILD
done
# Delete previous md5sum entries
sed -i "/^.*'[a-z0-9]\{32\}'.*$/d" PKGBUILD
sed -i "/^md5sums/,/$/d" PKGBUILD
# Save then delete the build section
sed -e '/^build().*$/,$!d' PKGBUILD > /tmp/PKGBUILD.tmp
sed -i '/^build().*$/,$d' PKGBUILD
# Remove trailing blank lines
while [ "$(tail -n 1 PKGBUILD)" == "" ]; do
sed -i '$d' PKGBUILD
done
# Add md5sums
makepkg -g >> PKGBUILD
# Add two blank lines to seperate variable and build section
echo -e "\n" >> PKGBUILD
# Re-append build section
cat /tmp/PKGBUILD.tmp >> PKGBUILD
Setting Up a Scripting Environment | Proud donor to wikipedia - link
Offline
@Gen2ly:
nice
====* -- Joke
O
\|/ --- Me
/ \ Whooooosh
Offline
I got a couple guys to help me out with this. Awk it turns out is a much better way to do this. Ah... awk. Here's a more-awkward way of doing it:
awk 'BEGIN {
checkAt = 0
filesAt = 0
scanning = 0
}
/md5sums=\(/ {
checkAt = NR
scanning = 1
}
/source=\(/ {
filesAt = NR
scanning = 1
}
/)$/ {
if (scanning) {
if (checkAt > filesAt) {
checkEnd = NR
} else {
filesEnd = NR
}
scanning = 0
}
}
{
lines[NR] = $0
}
END {
for (i = 1; i <= NR; ++i) {
if (checkAt <= i && i <= checkEnd) {
continue
}
print lines[i]
if (i == filesEnd) {
for (j = checkAt; j <= checkEnd; ++j) {
print lines[j]
}
}
}
}' PKGBUILD > /tmp/PKGBUILD.tmp
mv /tmp/PKGBUILD.tmp PKGBUILD
This has the benefit of being able to put the md5sum after the source array even if it's before the source line. Yah!
Setting Up a Scripting Environment | Proud donor to wikipedia - link
Offline
Did you read the bug report comments ? There is a awk one-liner there which works.
But the questions were how to deal with multiple checksums, and how to integrate this with makepkg.
pacman roulette : pacman -S $(pacman -Slq | LANG=C sort -R | head -n $((RANDOM % 10)))
Offline
Actually, no I must have missed that awk one liner. Yeah, not bad, not bad. This, however does deal with multiple-checksums, though I'd admit would be very long one liner .
Setting Up a Scripting Environment | Proud donor to wikipedia - link
Offline
The awk script is really useful . Thanks Gen2ly.
Allan-Volunteer on the (topic being discussed) mailn lists. You never get the people who matters attention on the forums.
jasonwryan-Installing Arch is a measure of your literacy. Maintaining Arch is a measure of your diligence. Contributing to Arch is a measure of your competence.
Griemak-Bleeding edge, not bleeding flat. Edge denotes falls will occur from time to time. Bring your own parachute.
Offline
The awk script is really useful . Thanks Gen2ly.
Thanks ngoonee. Just FYI, now I'm using the sed one again because I forgot about the noextract array being after the sources array.
Setting Up a Scripting Environment | Proud donor to wikipedia - link
Offline