pkgver and pkgrel can be overridden in package functions. makepkg can't
use the overridden values when doing the early check if a package file
already exists. That means makepkg will silently delete the existing
package file and generate a new one.

pkgbase=N
pkgname=(N1 N2)
pkgver=1
pkgrel=1
arch=(any)

package_N1() {
  pkgver=v1
}

package_N2() {
  pkgver=v2
}

Signed-off-by: Nezmer <[email protected]>
---

This is just a quick fix I needed. There is probably better ways to do
this.

 scripts/makepkg.sh.in |   11 +++++++++++
 1 files changed, 11 insertions(+), 0 deletions(-)

diff --git a/scripts/makepkg.sh.in b/scripts/makepkg.sh.in
index 8c0da8b..c2953b4 100644
--- a/scripts/makepkg.sh.in
+++ b/scripts/makepkg.sh.in
@@ -979,6 +979,17 @@ check_package() {
        if grep -R "${srcdir}" "${pkgdir}" &>/dev/null; then
                warning "$(gettext "Package contains reference to %s")" 
"\$srcdir"
        fi
+
+       # Check again if package already exists in case pkgver or pkgrel was 
overridden
+       if (( PKGFUNC || SPLITPKG )); then
+               for pkg in ${pkgna...@]}; do
+                       if [[ -f 
$PKGDEST/${pkg}-${pkgver}-${pkgrel}-${CARCH}${PKGEXT} \
+                               || -f 
$PKGDEST/${pkg}-${pkgver}-${pkgrel}-any${PKGEXT} ]]; then
+                               error "$(gettext "A package already exists.")"
+                               exit 1
+                       fi
+               done
+       fi
 }
 
 create_package() {
-- 
1.7.1


Reply via email to