You are not logged in.

#1 2007-09-22 18:27:35

IsSuE
Member
Registered: 2006-04-29
Posts: 309

PKGBUILD for multiple arches

I recently made a PKGBUILD for Teewars http://aur.archlinux.org/packages.php?d … 1&ID=13040
but how do I enable this pkgbuild for both architectures? there are 2 different binaries for x86 and x86_64 so how to make the pkgbuild choose the right download?

thx

Offline

#2 2007-09-22 20:44:16

[vEX]
Member
From: Sweden
Registered: 2006-11-23
Posts: 450

Re: PKGBUILD for multiple arches

Cheat and look at another PKGBUILD that does the same: http://cvs.archlinux.org/cgi-bin/viewcv … cvs-markup.

Or if the filenames are completely different, then do something like this:

source=(i686_src)
[ "$CARCH" = "x86_64" ] && md5sums=(x86_64_src)
md5sums=(i686_md5sum)
[ "$CARCH" = "x86_64" ] && md5sums=(x86_64_md5sum)

You might have to do additional changes to your PKGBUILD incase they extract to different destinations.

I didn't know teewars was released, I'll sure give your PKGBUILD a go after it's been modified for 64-bit compilation.

Last edited by [vEX] (2007-09-22 20:45:39)


PC: Antec P182B | Asus P8Z77-V PRO | Intel i5 3570k | 16GB DDR3 | GeForce 450GTS | 4TB HDD | Pioneer BDR-207D | Asus Xonar DX | Altec Lansing CS21 | Eizo EV2736W-BK | Arch Linux x86_64
HTPC: Antec NSK2480 | ASUS M3A78-EM (AMD 780G) | AMD Athlon X3 425 | 8GB DDR2 | GeForce G210 | 2TB HDD | Arch Linux x86_64
Server: Raspberry Pi (model B) | 512MB RAM | 750GB HDD | Arch Linux ARM

Offline

#3 2007-09-22 22:10:05

IsSuE
Member
Registered: 2006-04-29
Posts: 309

Re: PKGBUILD for multiple arches

how can i test it if it works if i have not got an 64bit machine?

current PKGBUILD looks like this

pkgname=teewars
pkgver=0.2.3
pkgrel=2
pkgdesc="Teewars is a multiplayer 2D shooter"
arch=('i686' x86_64)
[ "$CARCH" = "i686"   ] && ARCH=x86
[ "$CARCH" = "x86_64" ] && ARCH=x86_64
url="http://teewars.com"
license=('none')
[ "$CARCH" = "i686" ] && source=(teewars.desktop http://teewars.com/files/$pkgname-$pkgver-linux86.tar.gz)
[ "$CARCH" = "i686" ] && md5sums=('6af26d99a92d11202db8f08ee293e3b7')
[ "$CARCH" = "x86_64" ] && source=(teewars.desktop http://teewars.com/files/$pkgname-$pkgver-linux86_64.tar.gz)

build() {
  cd $startdir/src/$pkgname-$pkgver-linux86
  mkdir -p $startdir/pkg/opt/$pkgname
  mkdir -p $startdir/pkg/usr/bin
  cp -r * $startdir/pkg/opt/$pkgname
  chmod -R 777 $startdir/pkg/opt/$pkgname
 
  echo '#!/bin/bash
  cd /opt/teewars
  ./teewars' > teewars

  chmod +x teewars
  mv teewars $startdir/pkg/usr/bin

  install -D -m 644 $startdir/src/teewars.desktop \
      $startdir/pkg/usr/share/applications/teewars.desktop

}

Last edited by IsSuE (2016-01-30 10:08:23)

Offline

#4 2007-09-23 04:07:59

Cerebral
Forum Fellow
From: Waterloo, ON, CA
Registered: 2005-04-08
Posts: 3,108
Website

Re: PKGBUILD for multiple arches

A couple comments.

1) You don't need to set the ARCH variable as near as I can tell.  It's not used anywhere.
2) The license isn't 'none' - the readme.txt provides a very small license.  The license should be listed as "custom" and the text file installed into $startdir/pkg/usr/share/licenses/$pkgname/

It looks ok - if you want to ensure it'll work on x86_64 you'll need to get someone with that arch to test it for you.  You can find out the md5sum for those people beforehand by downloading the file and running md5sum on it. smile

-edit- A couple more comments:

3) Your md5sum array should also contain the md5sum of the desktop file you've listed in the sources array.  BTW - cool stuff including a desktop file - lots of people forget that.
4) You need a depends line like so:

depends=('alsa-lib' 'mesa' 'libgl')

- run namcap on the resulting package to find these dependencies.
5) It's generally a really bad idea to make an entire directory world-writable (chmod 777 $startdir/pkg/opt/$pkgname) - instead, chown the directory to the 'games' group (group 50), and make it writable to that group. Then set the group of the executables to 'games', and set the sticky-bit for groups (chmod g+s $binname) - this will give the binary access to that folder (and anyone else in the games group, but users should NOT be placed in the games group - that's not its purpose)

Last edited by Cerebral (2007-09-23 04:16:55)

Offline

#5 2007-09-23 07:45:45

[vEX]
Member
From: Sweden
Registered: 2006-11-23
Posts: 450

Re: PKGBUILD for multiple arches

I fixed it up for you, still missing the license field though, I'll leave that for you to take care off. Builds and starts fine on my 64-bit Arch.

teewars.install (will add the games group if missing):

# arg 1:  the new package version
pre_install() {
  getent group games > /dev/null || /usr/sbin/groupadd -g 50 games
}

# arg 1:  the new package version
post_install() {
  /bin/true
}

# arg 1:  the new package version
# arg 2:  the old package version
pre_upgrade() {
  /bin/true
}

# arg 1:  the new package version
# arg 2:  the old package version
post_upgrade() {
  /bin/true
}

# arg 1:  the old package version
pre_remove() {
  /bin/true
}

# arg 1:  the old package version
post_remove() {
  /bin/true
}

op=$1
shift
$op $*

PKGBUILD:

# Contributor: Armin 'IsSuE' Praher [issue.at.gmx.dot.at]
pkgname=teewars
pkgver=0.2.3
pkgrel=2
pkgdesc="Teewars is a multiplayer 2D shooter"
arch=('i686' 'x86_64')
url="http://teewars.com"
license=('none')
depends=('alsa-lib' 'mesa' 'libgl')
install="teewars.install"
[ "$CARCH" = "i686"   ] && ARCH=86
[ "$CARCH" = "x86_64" ] && ARCH=86_64
source=(teewars.desktop http://teewars.com/files/${pkgname}-${pkgver}-linux${ARCH}.tar.gz)
md5sums=('fbbd40871b615e34835741b00aa2c3f1' '6af26d99a92d11202db8f08ee293e3b7')
[ "$CARCH" = "x86_64" ] && md5sums=('fbbd40871b615e34835741b00aa2c3f1' '1849b96c4dcfe667c9d59e3eba14c352')

build() {
  cd $startdir/src/$pkgname-$pkgver-linux${ARCH}
  mkdir --parents --mode=775 $startdir/pkg/opt/$pkgname
  chgrp games $startdir/pkg/opt/$pkgname
  cp -r * $startdir/pkg/opt/$pkgname

  chmod g+s $startdir/pkg/opt/teewars/teewars
  chgrp games $startdir/pkg/opt/teewars/teewars

  echo '#!/bin/bash
  cd /opt/teewars
  ./teewars' > $startdir/src/$pkgname-$pkgver-linux${ARCH}/teewars

  install -D --mode=755 --group=games $startdir/src/$pkgname-$pkgver-linux${ARCH}/teewars $startdir/pkg/usr/bin/teewars
  install -D --mode=644 $startdir/src/teewars.desktop $startdir/pkg/usr/share/applications/teewars.desktop
}

EDIT: The config will be saved on a per-user basis from 0.3.0, ie: ~/.teewars according to this http://ix.teewars.com/trac/ticket/135 so the PKGBUILD can be simplified some then.

Last edited by [vEX] (2007-09-23 21:09:51)


PC: Antec P182B | Asus P8Z77-V PRO | Intel i5 3570k | 16GB DDR3 | GeForce 450GTS | 4TB HDD | Pioneer BDR-207D | Asus Xonar DX | Altec Lansing CS21 | Eizo EV2736W-BK | Arch Linux x86_64
HTPC: Antec NSK2480 | ASUS M3A78-EM (AMD 780G) | AMD Athlon X3 425 | 8GB DDR2 | GeForce G210 | 2TB HDD | Arch Linux x86_64
Server: Raspberry Pi (model B) | 512MB RAM | 750GB HDD | Arch Linux ARM

Offline

#6 2007-09-25 13:57:59

[vEX]
Member
From: Sweden
Registered: 2006-11-23
Posts: 450

Re: PKGBUILD for multiple arches

Updated the PKGBUILD to include the license as well, also separated the shell script out into a file off it's own. The desktop file was also updated according to comments on AUR about it not being valid.

EDIT: Noticed that the package was orphaned, adopted it and updated it accordingly to this post.

teewars.sh:

#!/bin/sh
cd /opt/teewars
./teewars

teewars.desktop:

[Desktop Entry]
Version=1.0
Type=Application
Icon=/opt/teewars/data/gui_tee.png
Exec=teewars
Terminal=false
StartupNotify=false

Name=TeeWars
GenericName=Arcade Game
Comment=is a multiplayer 2D FPS shooter
Comment[pl_PL]=wieloosobowa strzelanka FTP w 2D

Categories=Game;ArcadeGame;

teewars.install:

# arg 1:  the new package version
pre_install() {
  getent group games > /dev/null || /usr/sbin/groupadd -g 50 games
}

# arg 1:  the new package version
post_install() {
  /bin/true
}

# arg 1:  the new package version
# arg 2:  the old package version
pre_upgrade() {
  /bin/true
}

# arg 1:  the new package version
# arg 2:  the old package version
post_upgrade() {
  /bin/true
}

# arg 1:  the old package version
pre_remove() {
  /bin/true
}

# arg 1:  the old package version
post_remove() {
  /bin/true
}

op=$1
shift
$op $*

PKGBUILD:

pkgname=teewars
pkgver=0.2.3
pkgrel=3
pkgdesc="Teewars is a multiplayer 2D shooter"
arch=('i686' 'x86_64')
url="http://teewars.com"
license=('custom')
depends=('alsa-lib' 'mesa' 'libgl')
install="teewars.install"
[ "$CARCH" = "i686"   ] && ARCH=86
[ "$CARCH" = "x86_64" ] && ARCH=86_64
source=(teewars.desktop teewars.sh http://teewars.com/files/${pkgname}-${pkgver}-linux${ARCH}.tar.gz)
md5sums=('ed4ba763c8752800013f1e9defc45978' '8281c1f8b4f7d8836e0ae4211989bcb6' '6af26d99a92d11202db8f08ee293e3b7')
[ "$CARCH" = "x86_64" ] && md5sums=('ed4ba763c8752800013f1e9defc45978' '8281c1f8b4f7d8836e0ae4211989bcb6' '1849b96c4dcfe667c9d59e3eba14c352')

build() {
  cd $startdir/src/$pkgname-$pkgver-linux${ARCH}
  mkdir --parents --mode=775 $startdir/pkg/opt/$pkgname
  chgrp games $startdir/pkg/opt/$pkgname
  cp -r * $startdir/pkg/opt/$pkgname

  chmod g+s $startdir/pkg/opt/teewars/teewars
  chgrp games $startdir/pkg/opt/teewars/teewars

  install -D --mode=755 --group=games $startdir/src/teewars.sh $startdir/pkg/usr/bin/teewars
  install -D --mode=644 $startdir/src/teewars.desktop $startdir/pkg/usr/share/applications/teewars.desktop
  install -D --mode=644 $startdir/src/$pkgname-$pkgver-linux${ARCH}/readme.txt $startdir/pkg/usr/share/licenses/$pkgname/readme.txt
}

Last edited by [vEX] (2007-09-25 14:05:05)


PC: Antec P182B | Asus P8Z77-V PRO | Intel i5 3570k | 16GB DDR3 | GeForce 450GTS | 4TB HDD | Pioneer BDR-207D | Asus Xonar DX | Altec Lansing CS21 | Eizo EV2736W-BK | Arch Linux x86_64
HTPC: Antec NSK2480 | ASUS M3A78-EM (AMD 780G) | AMD Athlon X3 425 | 8GB DDR2 | GeForce G210 | 2TB HDD | Arch Linux x86_64
Server: Raspberry Pi (model B) | 512MB RAM | 750GB HDD | Arch Linux ARM

Offline

#7 2007-09-25 14:12:51

Cerebral
Forum Fellow
From: Waterloo, ON, CA
Registered: 2005-04-08
Posts: 3,108
Website

Re: PKGBUILD for multiple arches

one further comment - chgrp games should really be 'chgrp 50' so that people who don't have the games group on their systems can still build the pkg properly. wink

Otherwise looks great.

Offline

#8 2007-09-25 18:00:07

[vEX]
Member
From: Sweden
Registered: 2006-11-23
Posts: 450

Re: PKGBUILD for multiple arches

Well, the teewars.install file checks for, and creates if needed, the games group before starting the install. Or am I wrong in assuming pre_install() makepkg gets to build()?


PC: Antec P182B | Asus P8Z77-V PRO | Intel i5 3570k | 16GB DDR3 | GeForce 450GTS | 4TB HDD | Pioneer BDR-207D | Asus Xonar DX | Altec Lansing CS21 | Eizo EV2736W-BK | Arch Linux x86_64
HTPC: Antec NSK2480 | ASUS M3A78-EM (AMD 780G) | AMD Athlon X3 425 | 8GB DDR2 | GeForce G210 | 2TB HDD | Arch Linux x86_64
Server: Raspberry Pi (model B) | 512MB RAM | 750GB HDD | Arch Linux ARM

Offline

#9 2007-09-25 18:20:50

Cerebral
Forum Fellow
From: Waterloo, ON, CA
Registered: 2005-04-08
Posts: 3,108
Website

Re: PKGBUILD for multiple arches

[vEX] wrote:

Well, the teewars.install file checks for, and creates if needed, the games group before starting the install. Or am I wrong in assuming pre_install() makepkg gets to build()?

pre_install happens before the install of the ACTUAL package.  None of the functions in the .install file are executed while building the package.

Order of functions:

You run makepkg:

build()

(user runs pacman -U to install the package for the first time)

pre_install()
post_install()

(user runs pacman -U or pacman -S to upgrade the package already on their system)

pre_upgrade()
post_upgrade()

(user runs pacman -R)

pre_remove()
post_remove()

Offline

#10 2007-09-25 19:08:48

[vEX]
Member
From: Sweden
Registered: 2006-11-23
Posts: 450

Re: PKGBUILD for multiple arches

Ah, so it's really necessary to have it as chgrp 50, I see, I will change the PKGBUILD.


PC: Antec P182B | Asus P8Z77-V PRO | Intel i5 3570k | 16GB DDR3 | GeForce 450GTS | 4TB HDD | Pioneer BDR-207D | Asus Xonar DX | Altec Lansing CS21 | Eizo EV2736W-BK | Arch Linux x86_64
HTPC: Antec NSK2480 | ASUS M3A78-EM (AMD 780G) | AMD Athlon X3 425 | 8GB DDR2 | GeForce G210 | 2TB HDD | Arch Linux x86_64
Server: Raspberry Pi (model B) | 512MB RAM | 750GB HDD | Arch Linux ARM

Offline

Board footer

Powered by FluxBB