If destarch is added to a PKGBUILD, makepkg sets the architecture of the resulting package to $destarch instead of $CARCH. This is useful if you want to cross-create packages for one architecture on the other. Using arch=('i686') destarch='x86_64' makes it possible to build multilib packages and to build grub without the export CARCH="x86_64" hack. --- scripts/makepkg.sh.in | 32 ++++++++++++++++++-------------- 1 files changed, 18 insertions(+), 14 deletions(-) diff --git a/scripts/makepkg.sh.in b/scripts/makepkg.sh.in index bce2e6c..c45d7e8 100644 --- a/scripts/makepkg.sh.in +++ b/scripts/makepkg.sh.in @@ -152,7 +152,7 @@ clean_up() { rm -rf pkg src if [ "$pkgname" != "" ]; then # Can't do this unless the BUILDSCRIPT has been sourced. - rm -f "${pkgname}-${pkgver}-${pkgrel}-${CARCH}.log*" + rm -f "${pkgname}-${pkgver}-${pkgrel}-${destarch}.log*" fi fi @@ -662,7 +662,7 @@ run_build() { local ret=0 if [ "$LOGGING" = "1" ]; then - BUILDLOG="${startdir}/${pkgname}-${pkgver}-${pkgrel}-${CARCH}.log" + BUILDLOG="${startdir}/${pkgname}-${pkgver}-${pkgrel}-${destarch}.log" if [ -f "$BUILDLOG" ]; then local i=1 while true; do @@ -792,8 +792,8 @@ create_package() { echo "builddate = $builddate" >>.PKGINFO echo "packager = $packager" >>.PKGINFO echo "size = $size" >>.PKGINFO - if [ "$CARCH" != "" ]; then - echo "arch = $CARCH" >>.PKGINFO + if [ "$destarch" != "" ]; then + echo "arch = $destarch" >>.PKGINFO fi if [ "$(check_option force)" = "y" ]; then echo "force = true" >> .PKGINFO @@ -851,7 +851,7 @@ create_package() { # tar it up msg2 "$(gettext "Compressing package...")" - local pkg_file="$PKGDEST/${pkgname}-${pkgver}-${pkgrel}-${CARCH}${PKGEXT}" + local pkg_file="$PKGDEST/${pkgname}-${pkgver}-${pkgrel}-${destarch}${PKGEXT}" if ! bsdtar -czf "$pkg_file" $comp_files *; then error "$(gettext "Failed to create package file.")" @@ -872,11 +872,11 @@ create_xdelta() { local pkginfo="$(mktemp "$startdir"/xdelta-pkginfo.XXXXXXXXX)" local old_file old_version - for old_file in $(ls {"$cache_dir","$PKGDEST"}/${pkgname}-*-*{,-$CARCH}$PKGEXT 2>/dev/null); do + for old_file in $(ls {"$cache_dir","$PKGDEST"}/${pkgname}-*-*{,-$destarch}$PKGEXT 2>/dev/null); do bsdtar -xOf "$old_file" .PKGINFO > "$pkginfo" || continue if [ "$(cat "$pkginfo" | grep '^pkgname = ')" != "pkgname = $pkgname" ]; then continue # Package name does not match. - elif [ "$(cat "$pkginfo" | grep '^arch = ')" != "arch = $CARCH" ] ; then + elif [ "$(cat "$pkginfo" | grep '^arch = ')" != "arch = $destarch" ] ; then continue # Not same arch. fi @@ -894,7 +894,7 @@ create_xdelta() { if [ "$base_file" != "" ]; then msg "$(gettext "Making delta from version %s...")" "$latest_version" - local delta_file="$PKGDEST/$pkgname-${latest_version}_to_$pkgver-$pkgrel-$CARCH.delta" + local delta_file="$PKGDEST/$pkgname-${latest_version}_to_$pkgver-$pkgrel-$destarch.delta" local ret=0 # xdelta will decompress base_file & pkg_file into TMP_DIR (or /tmp if @@ -984,9 +984,9 @@ install_package() { [ "$INSTALL" = "0" ] && return msg "$(gettext "Installing package ${pkgname} with pacman -U...")" if [ "$ASROOT" = "0" ]; then - sudo pacman $PACMAN_OPTS -U $PKGDEST/${pkgname}-${pkgver}-${pkgrel}-${CARCH}${PKGEXT} || exit $? + sudo pacman $PACMAN_OPTS -U $PKGDEST/${pkgname}-${pkgver}-${pkgrel}-${destarch}${PKGEXT} || exit $? else - pacman $PACMAN_OPTS -U $PKGDEST/${pkgname}-${pkgver}-${pkgrel}-${CARCH}${PKGEXT} || exit $? + pacman $PACMAN_OPTS -U $PKGDEST/${pkgname}-${pkgver}-${pkgrel}-${destarch}${PKGEXT} || exit $? fi } @@ -1330,6 +1330,10 @@ if [ "$arch" = 'any' ]; then CARCH='any' fi +if [ -z "$destarch" ]; then + destarch="$CARCH" +fi + if ! in_array $CARCH ${arch[@]}; then if [ "$IGNOREARCH" = "0" ]; then error "$(gettext "%s is not available for the '%s' architecture.")" "$pkgname" "$CARCH" @@ -1374,7 +1378,7 @@ unset valid_options opt known kopt devel_check devel_update -if [ -f "$PKGDEST/${pkgname}-${pkgver}-${pkgrel}-${CARCH}${PKGEXT}" \ +if [ -f "$PKGDEST/${pkgname}-${pkgver}-${pkgrel}-${destarch}${PKGEXT}" \ -a "$FORCE" = "0" -a "$SOURCEONLY" = "0" -a "$NOBUILD" = "0" ]; then if [ "$INSTALL" = "1" ]; then warning "$(gettext "A package has already been built, installing existing package...")" @@ -1402,7 +1406,7 @@ if [ "$INFAKEROOT" = "1" ]; then exit 0 # $E_OK fi -msg "$(gettext "Making package: %s")" "$pkgname $pkgver-$pkgrel $CARCH ($(date))" +msg "$(gettext "Making package: %s")" "$pkgname $pkgver-$pkgrel $destarch ($(date))" if [ $EUID -eq 0 ]; then warning "$(gettext "Running makepkg as root...")" @@ -1504,10 +1508,10 @@ else fi fi - create_xdelta "$PKGDEST/${pkgname}-${pkgver}-${pkgrel}-${CARCH}${PKGEXT}" + create_xdelta "$PKGDEST/${pkgname}-${pkgver}-${pkgrel}-${destarch}${PKGEXT}" fi -msg "$(gettext "Finished making: %s")" "$pkgname $pkgver-$pkgrel $CARCH ($(date))" +msg "$(gettext "Finished making: %s")" "$pkgname $pkgver-$pkgrel $destarch ($(date))" install_package -- 1.5.6