You are not logged in.

#1 2011-12-09 16:41:16

graysky
Wiki Maintainer
From: :wq
Registered: 2008-12-01
Posts: 10,597
Website

remove old checksums and replace with new in a PKGBUILD [SOLVED]

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 packagesZsh and other configs

Offline

#2 2011-12-09 16:44:44

jjacky
Member
Registered: 2011-11-09
Posts: 347
Website

Re: remove old checksums and replace with new in a PKGBUILD [SOLVED]

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

#3 2011-12-09 16:50:45

graysky
Wiki Maintainer
From: :wq
Registered: 2008-12-01
Posts: 10,597
Website

Re: remove old checksums and replace with new in a PKGBUILD [SOLVED]

@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 packagesZsh and other configs

Offline

#4 2011-12-09 17:57:50

jjacky
Member
Registered: 2011-11-09
Posts: 347
Website

Re: remove old checksums and replace with new in a PKGBUILD [SOLVED]

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

#5 2011-12-09 18:20:48

falconindy
Developer
From: New York, USA
Registered: 2009-10-22
Posts: 4,111
Website

Re: remove old checksums and replace with new in a PKGBUILD [SOLVED]

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

#6 2011-12-09 18:23:22

graysky
Wiki Maintainer
From: :wq
Registered: 2008-12-01
Posts: 10,597
Website

Re: remove old checksums and replace with new in a PKGBUILD [SOLVED]

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 packagesZsh and other configs

Offline

#7 2011-12-09 18:25:30

graysky
Wiki Maintainer
From: :wq
Registered: 2008-12-01
Posts: 10,597
Website

Re: remove old checksums and replace with new in a PKGBUILD [SOLVED]

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 packagesZsh and other configs

Offline

Board footer

Powered by FluxBB