[pacman-dev] [PATCH] makepkg: Add a late check if package exists when using package functions
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 <git@nezmer.info> --- 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 ${pkgname[@]}; 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
On 26/05/10 02:00, Nezmer wrote:
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<git@nezmer.info>
I am not sure about this... I am of the opinion that if you have to override pkgver in every package function, then your default value is wrong. With a better default pkgver, the check should detect at least one of your packages is already built and abort. Also, I really do not like the erroring out after all the packages have been built (although "makepkg -R" would save all that work). I think these conditions should be an error out early or not at all. Allan
On Wed, May 26, 2010 at 11:30:38AM +1000, Allan McRae wrote:
On 26/05/10 02:00, Nezmer wrote:
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<git@nezmer.info>
I am not sure about this... I am of the opinion that if you have to override pkgver in every package function, then your default value is wrong. With a better default pkgver, the check should detect at least one of your packages is already built and abort.
I generally agree. I understand how this condition will probably never occur in arch. I discovered this when I decided to prefix or postfix pkgver and/or pkgrel with some values dynamically. As I'm not sure If this is possible in any other way, I wrote a function to do this and called it in package functions. I'm probably the only one who needs this. So, I edited the condition to respect FORCE and applied to my personal tree: (( (PKGFUNC || SPLITPKG) && !FORCE ))
Also, I really do not like the erroring out after all the packages have been built (although "makepkg -R" would save all that work). I think these conditions should be an error out early or not at all.
IMHO, silently deleting files (especially outside $startdir) is always bad. The rarity of this condition is a more compelling argument.
Allan
Thank you for your feedback. Nezmer
participants (2)
-
Allan McRae
-
Nezmer