You are not logged in.

#1 2015-07-25 07:34:15

jamespharvey20
Member
Registered: 2015-06-09
Posts: 129

Configurable AUR PKGBUILDS - User can set variables, script uses if's

I just uploaded a new AUR repo, "sysbench-git".

Its PKGBUILD is below.  It can be built with no database package, mysql, and (I'm hoping) mariadb.  Its configure doesn't auto-detect which to use, and needs a "--without-mysql" prefix to build without support for it.

Every AUR PKGBUILD I've seen would either make one of them a depends, forcing some to install a database who don't need it, or would make them an optdepends... Which leaves the user needing to change the PKGBUILD's configure options.

Maybe this is done in other packages, and I just haven't seen it.

Is this OK to do, if it works as-is with defaults, so users don't HAVE to edit the PKGBUILD whatsoever, if I want to go the extra step, or does it make the Arch higher-ups cringe and say "Don't do that"?

One issue I do have with it is makepkg would produce identically named .pkg.tar.xz's that have different embedded dependencies.  I'm considering whether that's OK... Or, if the script should auto-rename pkgname to "sysbench-git-nodb", "sysbench-git-mariadb", or "sysbench-git-mysql" and use provides/conflicts... Or, if I should build all 3 ways and split them into a pkgbase / 3 subpackage PKGBUILD.  (But, this way could lead to a lot of permutations for packages with more configuration options.)

# Maintainer: James Harvey <james...@gmail.com>

# _use_mysql_package valid values:
#    none
#    mariadb
#    mysql
_use_mysql_package="none"

pkgname=sysbench-git
_pkgname=sysbench
pkgver=0.5.r212.0257f50
pkgrel=1
pkgdesc='Multi-threaded benchmark for evaluating OS parameters for database-loads (git)'
arch=('x86_64' 'i686')
license=('GPL2')
url='https://github.com/akopytov/sysbench'
depends=('glibc')
if [[ "${_use_mysql_package}" == "mariadb" ]]; then
   depends=('glibc' 'mariadb')
elif [[ "${_use_mysql_package}" == "mysql" ]]; then
   depends=('glibc' 'mysql')
elif [[ "${_use_mysql_package}" != "none" ]]; then
   echo "_use_mysql_package is \"${_use_mysql_package}\", but valid values are \"none\", \"mariadb\", or \"mysql\""
   exit
fi
optdepends=('mariadb' 'mysql')
makedepends=('git')
source=('git+https://github.com/akopytov/sysbench')
md5sums=('SKIP')

pkgver() {
  cd "${srcdir}/${_pkgname}"
  echo $(cat sysbench/sb_win.h | grep "define PACKAGE_VERSION" | sed 's|^#define PACKAGE_VERSION "||' | sed 's|"$||').r$(git rev-list --count HEAD).$(git rev-parse --short HEAD)
}

build() {
  cd "${srcdir}/${_pkgname}"
  ./autogen.sh

   if [[ "${_use_mysql_package}" == "mariadb" ]]; then
      ./configure --prefix=/usr
   elif [[ "${_use_mysql_package}" == "mysql" ]]; then
      ./configure --prefix=/usr
   elif [[ "${_use_mysql_package}" == "none" ]]; then
      ./configure --without-mysql --prefix=/usr
   else
      echo "_use_mysql_package is \"${_use_mysql_package}\", but valid values are \"none\", \"mariadb\", or \"mysql\""
     exit
   fi

   make
}

package() {
  cd "${srcdir}/${_pkgname}"
  make DESTDIR="${pkgdir}" install
  install -Dm644 COPYING "${pkgdir}/usr/share/licenses/${_pkgname}/COPYING"
  install -Dm644 README.md "${pkgdir}/usr/share/${_pkgname}/README.md"
}

Last edited by jasonwryan (2015-07-27 07:07:20)

Offline

#2 2015-07-25 13:05:53

Lone_Wolf
Administrator
From: Netherlands, Europe
Registered: 2005-10-04
Posts: 15,396

Re: Configurable AUR PKGBUILDS - User can set variables, script uses if's

I don't like PKGBUILDS that introduce new external variables.

https://aur4.archlinux.org/packages/mysql/   provides & conflicts mariadb .
mariadb also provides & conflicts mysql .

If you can verify this does work with both, then depending on mariadb should be enough.
If it doesn't work with one of them, you'll prob have to use additional testing code (like pacman -Qi mariadb output to verify which db is actually installed).


The different build options require 2 separate packages imo .

I'd go with sysbench-nodb-git & sysbench-git , providing and conflicting eachother.

Last edited by Lone_Wolf (2015-07-25 13:07:33)


Disliking systemd intensely, but not satisfied with alternatives so focusing on taming systemd.

clean chroot building not flexible enough ?
Try clean chroot manager by graysky

Offline

#3 2015-07-27 07:26:06

severach
Member
Registered: 2015-05-23
Posts: 198

Re: Configurable AUR PKGBUILDS - User can set variables, script uses if's

I've made bunches of packages with option variables. See the new office-2007-fonts (AUR). "They" don't like it. The trouble is that there isn't another way to enable the feature richness that PKGBUILD can provide. Debugging options are a prime example of something that must be an option because noone wants these except for PKGBUILD developers.

Split packages are wasteful as makepkg builds every version, including the dozen that they don't want. 'makepkg --pkg <package>' can build specified packges only but I think it's expecting too much for users to do this. It rapidly becomes intractable as each additional option doubles the number of packages to make. Certain option combinations may be dups or invalid.

makepkg accepts 'ENVVAR=value' on the command line. This seems to make things harder without making things better.

It is important for users other than yourself that the picked options not be clobbered by an upgrade. One way I've considered doing this is by creating the options file and immediately sourcing it.

[ ! -s 'PKGBUILD.local' ] && cat > 'PKGBUILD.local' << EOF
# Set foo to something important
_opt_FOO=1
# BAR is only a debugging option so leave it at 0 unless developing a PKGBUILD
_opt_BAR=0
EOF
source 'PKGBUILD.local'

Remember that as soon as the first option goes in your package isn't usable with one step package builders like yaourt and packer. I usually add a message somewhere as few one-steppers have any idea how the AUR works. 'Tis just another repository, right?

Offline

Board footer

Powered by FluxBB