[pacman-dev] [PATCH] makepkg: allow overriding arch in split packages
Allan McRae
allan at archlinux.org
Sun Oct 11 10:18:31 EDT 2009
This allows building a mixture of binary and arch=any packages.
Fixes FS#15955.
The value of CARCH is no longer overridden to "any" in when arch=any
is used and the assigning of the "any" arch is delayed to during the
packaging stage. Adjustments were required to fix installing and
checking for pre-built packages of varing arches.
Signed-off-by: Allan McRae <allan at archlinux.org>
---
PKGBUILD-split.proto | 1 +
doc/PKGBUILD.5.txt | 2 +-
scripts/makepkg.sh.in | 49 +++++++++++++++++++++++++++++--------------------
3 files changed, 31 insertions(+), 21 deletions(-)
diff --git a/PKGBUILD-split.proto b/PKGBUILD-split.proto
index 2d772d5..68a8cc4 100644
--- a/PKGBUILD-split.proto
+++ b/PKGBUILD-split.proto
@@ -37,6 +37,7 @@ package_pkg1() {
pkgver=
pkgrel=
pkgdesc=""
+ arch=()
license=()
groups=()
depends=()
diff --git a/doc/PKGBUILD.5.txt b/doc/PKGBUILD.5.txt
index 611a314..17288d7 100644
--- a/doc/PKGBUILD.5.txt
+++ b/doc/PKGBUILD.5.txt
@@ -276,7 +276,7 @@ name of the split package.
All options and directives for the split packages default to the global values given
within the PKGBUILD. However, some of these can be overridden within each split
package's packaging function. The following variables can be overridden: `pkgver`,
-`pkgrel`, `pkgdesc`, `license`, `groups`, `depends`, `optdepends`,
+`pkgrel`, `pkgdesc`, `arch`, `license`, `groups`, `depends`, `optdepends`,
`provides`, `conflicts`, `replaces`, `backup`, `options`, `install` and `changelog`.
An optional global directive is available when building a split package:
diff --git a/scripts/makepkg.sh.in b/scripts/makepkg.sh.in
index 2500638..3472f7c 100644
--- a/scripts/makepkg.sh.in
+++ b/scripts/makepkg.sh.in
@@ -46,7 +46,7 @@ pkgdir="$startdir/pkg"
packaging_options=('strip' 'docs' 'libtool' 'emptydirs' 'zipman' 'purge')
other_options=('ccache' 'distcc' 'makeflags' 'force')
-splitpkg_overrides=('pkgver' 'pkgrel' 'pkgdesc' 'license' 'groups' \
+splitpkg_overrides=('pkgver' 'pkgrel' 'pkgdesc' 'arch' 'license' 'groups' \
'depends' 'optdepends' 'provides' 'conflicts' 'replaces' \
'backup' 'options' 'install' 'changelog')
readonly -a packaging_options other_options splitpkg_overrides
@@ -895,9 +895,7 @@ write_pkginfo() {
echo "builddate = $builddate" >>.PKGINFO
echo "packager = $packager" >>.PKGINFO
echo "size = $size" >>.PKGINFO
- if [ -n "$CARCH" ]; then
- echo "arch = $CARCH" >>.PKGINFO
- fi
+ echo "arch = $PKGARCH" >>.PKGINFO
if [ "$(check_option force)" = "y" ]; then
echo "force = true" >> .PKGINFO
fi
@@ -976,6 +974,12 @@ create_package() {
nameofpkg="$1"
fi
+ if [ "$arch" = "any" ]; then
+ PKGARCH="any"
+ else
+ PKGARCH=$CARCH
+ fi
+
write_pkginfo $nameofpkg
local comp_files=".PKGINFO"
@@ -1004,7 +1008,7 @@ create_package() {
*) warning "$(gettext "'%s' is not a valid archive extension.")" \
"$PKGEXT" ; EXT=$PKGEXT ;;
esac
- local pkg_file="$PKGDEST/${nameofpkg}-${pkgver}-${pkgrel}-${CARCH}${EXT}"
+ local pkg_file="$PKGDEST/${nameofpkg}-${pkgver}-${pkgrel}-${PKGARCH}${EXT}"
local ret=0
@@ -1116,7 +1120,11 @@ install_package() {
local pkglist
for pkg in ${pkgname[@]}; do
- pkglist="${pkglist} $PKGDEST/${pkg}-${pkgver}-${pkgrel}-${CARCH}${PKGEXT}"
+ if [ -f $PKGDEST/${pkg}-${pkgver}-${pkgrel}-${CARCH}${PKGEXT} ]; then
+ pkglist="${pkglist} $PKGDEST/${pkg}-${pkgver}-${pkgrel}-${CARCH}${PKGEXT}"
+ else
+ pkglist="${pkglist} $PKGDEST/${pkg}-${pkgver}-${pkgrel}-any${PKGEXT}"
+ fi
done
local ret=0
@@ -1159,15 +1167,14 @@ check_sanity() {
return 1
fi
- if [ "$arch" = 'any' ]; then
- CARCH='any'
- fi
- if ! in_array $CARCH ${arch[@]}; then
- if [ "$IGNOREARCH" -eq 0 ]; then
- error "$(gettext "%s is not available for the '%s' architecture.")" "$pkgbase" "$CARCH"
- plain "$(gettext "Note that many packages may need a line added to their %s")" "$BUILDSCRIPT"
- plain "$(gettext "such as arch=('%s').")" "$CARCH"
- return 1
+ if [ "$arch" != 'any' ]; then
+ if ! in_array $CARCH ${arch[@]}; then
+ if [ "$IGNOREARCH" -eq 0 ]; then
+ error "$(gettext "%s is not available for the '%s' architecture.")" "$pkgbase" "$CARCH"
+ plain "$(gettext "Note that many packages may need a line added to their %s")" "$BUILDSCRIPT"
+ plain "$(gettext "such as arch=('%s').")" "$CARCH"
+ return 1
+ fi
fi
fi
@@ -1713,8 +1720,9 @@ fi
pkgbase=${pkgbase:-${pkgname[0]}}
if [ "$SPLITPKG" -eq 0 ]; then
- if [ -f "$PKGDEST/${pkgname}-${pkgver}-${pkgrel}-${CARCH}${PKGEXT}" \
- -a "$FORCE" -eq 0 -a "$SOURCEONLY" -eq 0 -a "$NOBUILD" -eq 0 ]; then
+ if [ \( -f "$PKGDEST/${pkgname}-${pkgver}-${pkgrel}-${CARCH}${PKGEXT}" \
+ -f "$PKGDEST/${pkgname}-${pkgver}-${pkgrel}-any${PKGEXT}" \) \
+ -a "$FORCE" -eq 0 -a "$SOURCEONLY" -eq 0 -a "$NOBUILD" -eq 0 ]; then
if [ "$INSTALL" -eq 1 ]; then
warning "$(gettext "A package has already been built, installing existing package...")"
install_package
@@ -1728,7 +1736,8 @@ else
allpkgbuilt=1
somepkgbuilt=0
for pkg in ${pkgname[@]}; do
- if [ -f "$PKGDEST/${pkg}-${pkgver}-${pkgrel}-${CARCH}${PKGEXT}" ]; then
+ if [ \( -f "$PKGDEST/${pkg}-${pkgver}-${pkgrel}-${CARCH}${PKGEXT}" \
+ -f "$PKGDEST/${pkg}-${pkgver}-${pkgrel}-any${PKGEXT}" \) ]; then
somepkgbuilt=1
else
allpkgbuilt=0
@@ -1783,7 +1792,7 @@ if [ "$INFAKEROOT" -eq 1 ]; then
exit 0 # $E_OK
fi
-msg "$(gettext "Making package: %s")" "$pkgbase $pkgver-$pkgrel $CARCH ($(date))"
+msg "$(gettext "Making package: %s")" "$pkgbase $pkgver-$pkgrel ($(date))"
# if we are creating a source-only package, go no further
if [ "$SOURCEONLY" -ne 0 ]; then
@@ -1911,7 +1920,7 @@ else
fi
fi
-msg "$(gettext "Finished making: %s")" "$pkgbase $pkgver-$pkgrel $CARCH ($(date))"
+msg "$(gettext "Finished making: %s")" "$pkgbase $pkgver-$pkgrel ($(date))"
install_package
--
1.6.4.4
More information about the pacman-dev
mailing list