[pacman-dev] add contrib/pkgdigest.sh: bash script that replaces md5sums in most PKGBUILDs
I'd like to see support for split packages, too, maybe I'll add it some time. Using it locally, while improving my dwm patches. Different approaches include playing around with $PATH, use absolute start paths for testing, but once I got used to this way, I just can't resist it any more... :) cheers! mar77i --- contrib/pkgdigest.sh | 39 +++++++++++++++++++++++++++++++++++++++ 1 files changed, 39 insertions(+), 0 deletions(-) create mode 100755 contrib/pkgdigest.sh diff --git a/contrib/pkgdigest.sh b/contrib/pkgdigest.sh new file mode 100755 index 0000000..278a838 --- /dev/null +++ b/contrib/pkgdigest.sh @@ -0,0 +1,39 @@ +#!/bin/bash + +if ! [[ -w PKGBUILD ]]; then + echo "Error: no PKGBUILD found." >&2 + exit 1 +fi + +cp PKGBUILD PKGBUILD~ +i=0 +lines=() +marker= +contexts=0 +md5context=0 +while read -r; do + if [[ "$REPLY" =~ (build|check|package)(_.*)?\(\) ]]; then + (( ${#marker} )) || marker=$i + fi + # only ever replace one sum + [[ "${REPLY,,}" == "md5sums="* ]] && (( md5context=1, contexts+= 1 )) + if (( md5context && contexts < 2 )); then + # no one ever would do parameter expansion in md5sums + # comments however that contain parens are possible + [[ "$REPLY" =~ [^#]*\) ]] && md5context=0 + else + lines+=("$REPLY") && (( i++ )) + fi +done < PKGBUILD + +while [[ "${lines[marker - 1]}" == '' ]]; do + (( marker -= 1 )) +done + +for (( i=0; i < marker; i++ )); do + echo "${lines[i]}" +done > PKGBUILD +echo "$(makepkg -g)" >> PKGBUILD +for (( i=marker; i < ${#lines[@]}; i++ )); do + echo "${lines[i]}" +done >> PKGBUILD -- 1.7.7.1
On 02/11/11 22:49, Martti Kühne wrote:
I'd like to see support for split packages, too, maybe I'll add it some time. Using it locally, while improving my dwm patches. Different approaches include playing around with $PATH, use absolute start paths for testing, but once I got used to this way, I just can't resist it any more... :)
I do not understand the comment about split packages? How do they change anything to do with extracting and replacing the checksum arrays? Also the comment about $PATH confuses me... I have not looked at your script in detail, but there is quite a lot of discussion about various approaches to doing this in the following bug report: https://bugs.archlinux.org/task/15051 . Any script being added to contrib should support updating the variety of checksums makepkg accepts. Allan
On 07.11.2011 06:35, Allan McRae wrote:
On 02/11/11 22:49, Martti Kühne wrote:
I'd like to see support for split packages, too, maybe I'll add it some time. Using it locally, while improving my dwm patches. Different approaches include playing around with $PATH, use absolute start paths for testing, but once I got used to this way, I just can't resist it any more... :)
I do not understand the comment about split packages? How do they change anything to do with extracting and replacing the checksum arrays?
Also the comment about $PATH confuses me...
I have not looked at your script in detail, but there is quite a lot of discussion about various approaches to doing this in the following bug report: https://bugs.archlinux.org/task/15051 . Any script being added to contrib should support updating the variety of checksums makepkg accepts.
I once created something similar [1]. If you want, I can create a patch. [1]: http://git.server-speed.net/bin/tree/upgpkg -- Florian Pritz
On Mon, Nov 07, 2011 at 03:35:27PM +1000, Allan McRae wrote:
On 02/11/11 22:49, Martti Kühne wrote:
I'd like to see support for split packages, too, maybe I'll add it some time. Using it locally, while improving my dwm patches. Different approaches include playing around with $PATH, use absolute start paths for testing, but once I got used to this way, I just can't resist it any more... :)
I do not understand the comment about split packages? How do they change anything to do with extracting and replacing the checksum arrays?
Well, the script does not extract any checksum from a PKGBUILD and does currently not care about *sums assignments within functions, as may be the case with split packages. However I'd like to add that in a later version.
Also the comment about $PATH confuses me...
Testing a package one is working on can be done in several ways, one could add the source directory to PATH or create symlinks, or use ./blah... In case of a window manager the latter isn't comfortable, since it includes modifying ~/.xinitrc, hence my seemingly far-fetched mentioning of $PATH.
I have not looked at your script in detail, but there is quite a lot of discussion about various approaches to doing this in the following bug report: https://bugs.archlinux.org/task/15051 . Any script being added to contrib should support updating the variety of checksums makepkg accepts.
Good point. The way I'm doing it is pretty generic, although for now I'm literally muting any /^md5sums=\(/ assignment. Insertion of a sum is done by simply redirecting the output of `makepkg -g`. Afaict checksums arrays can be identified uniquely because they exclusively contain the string "sums=("? The script is based on the fact that the checksums array of a package is placed before any empty line before the first of the /(build|check|package)/ function definitions, in a current version also skipping /^_.*/ lines to work with VCS packages ("_blahurl" and "_blahrepo" and the like). cheers! mar77i
On 08/11/11 05:10, Martti Kühne wrote:
On Mon, Nov 07, 2011 at 03:35:27PM +1000, Allan McRae wrote:
On 02/11/11 22:49, Martti Kühne wrote:
I'd like to see support for split packages, too, maybe I'll add it some time. Using it locally, while improving my dwm patches. Different approaches include playing around with $PATH, use absolute start paths for testing, but once I got used to this way, I just can't resist it any more... :)
I do not understand the comment about split packages? How do they change anything to do with extracting and replacing the checksum arrays?
Well, the script does not extract any checksum from a PKGBUILD and does currently not care about *sums assignments within functions, as may be the case with split packages. However I'd like to add that in a later version.
There should be no *sum assignment within functions of a PKGBUILD as that is not a variable that can be overridden within a split package. In fact, it would make no sense at all...
Also the comment about $PATH confuses me...
Testing a package one is working on can be done in several ways, one could add the source directory to PATH or create symlinks, or use ./blah... In case of a window manager the latter isn't comfortable, since it includes modifying ~/.xinitrc, hence my seemingly far-fetched mentioning of $PATH.
What? How is this relevant to updating checksums?
I have not looked at your script in detail, but there is quite a lot of discussion about various approaches to doing this in the following bug report: https://bugs.archlinux.org/task/15051 . Any script being added to contrib should support updating the variety of checksums makepkg accepts.
Good point. The way I'm doing it is pretty generic, although for now I'm literally muting any /^md5sums=\(/ assignment. Insertion of a sum is done by simply redirecting the output of `makepkg -g`. Afaict checksums arrays can be identified uniquely because they exclusively contain the string "sums=("?
The script is based on the fact that the checksums array of a package is placed before any empty line before the first of the /(build|check|package)/ function definitions, in a current version also skipping /^_.*/ lines to work with VCS packages ("_blahurl" and "_blahrepo" and the like).
cheers! mar77i
On Tue, Nov 08, 2011 at 05:52:36AM +1000, Allan McRae wrote:
On 08/11/11 05:10, Martti Kühne wrote:
On Mon, Nov 07, 2011 at 03:35:27PM +1000, Allan McRae wrote:
On 02/11/11 22:49, Martti Kühne wrote:
I'd like to see support for split packages, too, maybe I'll add it some time. Using it locally, while improving my dwm patches. Different approaches include playing around with $PATH, use absolute start paths for testing, but once I got used to this way, I just can't resist it any more... :)
I do not understand the comment about split packages? How do they change anything to do with extracting and replacing the checksum arrays?
Well, the script does not extract any checksum from a PKGBUILD and does currently not care about *sums assignments within functions, as may be the case with split packages. However I'd like to add that in a later version.
There should be no *sum assignment within functions of a PKGBUILD as that is not a variable that can be overridden within a split package. In fact, it would make no sense at all...
Of course. That means as far as I can tell, the only remaining problems are about $CARCH conditionals? Those aren't impossible to do, as they always seem in LR-context, too, they just need to be done right. I can look into that.
Also the comment about $PATH confuses me...
Testing a package one is working on can be done in several ways, one could add the source directory to PATH or create symlinks, or use ./blah... In case of a window manager the latter isn't comfortable, since it includes modifying ~/.xinitrc, hence my seemingly far-fetched mentioning of $PATH.
What? How is this relevant to updating checksums?
No, it's not relevant. Sorry for the noise, I thought I was supposed to emphasize. The bugreport someone has linked was talking about makepkg integration by "-G" flag? cheers! mar77i
participants (3)
-
Allan McRae
-
Florian Pritz
-
Martti Kühne