index : pacman | |
Archlinux32 fork of pacman | gitolite user |
summaryrefslogtreecommitdiff |
author | Allan McRae <allan@archlinux.org> | 2012-06-05 13:30:08 +1000 |
---|---|---|
committer | Allan McRae <allan@archlinux.org> | 2012-08-04 00:16:38 +1000 |
commit | 888020de9068218fafe820e631222bc85c47b453 (patch) | |
tree | 20c2e8b0562310830f1ca1367527b6cd1a0805bc /scripts/makepkg.sh.in | |
parent | cca9849fc25012845b08ce877f9450e45c9d207d (diff) |
-rw-r--r-- | scripts/makepkg.sh.in | 21 |
diff --git a/scripts/makepkg.sh.in b/scripts/makepkg.sh.in index d6f314ac..5ff4bb6d 100644 --- a/scripts/makepkg.sh.in +++ b/scripts/makepkg.sh.in @@ -473,9 +473,30 @@ download_sources() { esac done + if declare -f pkgver >/dev/null; then + update_pkgver + fi + popd &>/dev/null } +# Automatically update pkgver variable if a pkgver() function is provided +# Re-sources the PKGBUILD afterwards to allow for other variables that use $pkgver +update_pkgver() { + newpkgver=$(run_function_safe pkgver) + + if [[ -n $newpkgver && $newpkgver != "$pkgver" ]]; then + if [[ -f $BUILDFILE && -w $BUILDFILE ]]; then + @SEDINPLACE@ "s/^pkgver=[^ ]*/pkgver=$newpkgver/" "$BUILDFILE" + @SEDINPLACE@ "s/^pkgrel=[^ ]*/pkgrel=1/" "$BUILDFILE" + source "$BUILDFILE" + else + warning "$(gettext "%s is not writeable -- pkgver will not be updated")" \ + "$BUILDFILE" + fi + fi +} + # Print 'source not found' error message and exit makepkg missing_source_file() { error "$(gettext "Unable to find source file %s.")" "$(get_filename "$1")" |