You are not logged in.

#1 2020-02-15 08:07:50

E3LDDfrK
Member
Registered: 2019-10-24
Posts: 62

[SOLVED] Need help writing PKGBUILD for "chemfiles"

Hi,

I'd like to write a correct PKGBUILD for the library "chemfiles" from https://chemfiles.org.

This is my attempt:

pkgname="chemfiles"
pkgver=0.9.3
pkgrel=1
pkgdesc='Library written in modern C++ for reading and writing from and to molecular trajectory files.'
url='https://chemfiles.org/'
depends=()
makedepends=('cmake')
license=('BSD')
arch=('x86_64')
source=("$pkgname-$pkgver.tar.gz::https://github.com/chemfiles/chemfiles/archive/$pkgver.tar.gz")
md5sums=('801fc7e8c445e981348344d6a4836603')

check() {
  cd "$srcdir/$pkgname-$pkgver"
  #cd build
  #cd tests
  #ctest
}

build() {
  cd "$srcdir/$pkgname-$pkgver"
  mkdir -p build
  cd build
  cmake ..
  cmake --build .
}

package() {
  cd "$srcdir/$pkgname-$pkgver"
  cd build
  make DESTDIR="$pkgdir/" install
}

On its official website https://chemfiles.org/chemfiles/0.9.1/i … uild-steps, it has these instructions:

cd chemfiles
mkdir build
cd build
cmake .. # various options are allowed here
cmake --build .
# if you whant to run the tests before installing:
ctest
cmake --build . --target install

My attempted PKGBUILD only kinda works. Some problems I have:

  1. I couldn't make the tests work. Not sure where to put ctest/make test in the PKGBUILD

  2. I'm not sure if I need to actually create the "build" directory.

  3. "DESTDIR="$pkgdir/" cmake --build . --target install" didn't work. It complained "could not load cache". So I used "make install".

Any help is appreciated.

edit: Thanks for all of the comments, people.

Last edited by E3LDDfrK (2020-02-17 16:48:14)

Offline

#2 2020-02-15 10:18:13

a821
Member
Registered: 2012-10-31
Posts: 381

Re: [SOLVED] Need help writing PKGBUILD for "chemfiles"

Here you go. Your PKGBUILD was almost ready. I did not include the docs, but this should not be hard to do. It builds in a clean chroot.

pkgname="chemfiles"
pkgver=0.9.3
pkgrel=1
pkgdesc='Library written in modern C++ for reading and writing from and to molecular trajectory files.'
url='https://chemfiles.org/'
depends=('gcc-libs')
makedepends=('cmake' 'python')
license=('BSD')
arch=('x86_64')
source=("$pkgname-$pkgver.tar.gz::https://github.com/chemfiles/chemfiles/archive/$pkgver.tar.gz")
md5sums=('801fc7e8c445e981348344d6a4836603')

check() {
  cd "$pkgname-$pkgver/build"
  ctest
}

build() {
  cd "$pkgname-$pkgver"
  mkdir -p build && cd build
  cmake -DCMAKE_INSTALL_PREFIX=/usr \
        -DCMAKE_BUILD_TYPE=release \
        -DBUILD_SHARED_LIBS=ON \
        -DCHFL_BUILD_TESTS=ON \
        ..
  make
}

package() {
  cd "$pkgname-$pkgver"
  install -Dm644 LICENSE "$pkgdir/usr/share/licenses/${pkgname}/LICENSE"
  cd build
  make DESTDIR="$pkgdir" install
}

Offline

#3 2020-02-15 11:13:24

E3LDDfrK
Member
Registered: 2019-10-24
Posts: 62

Re: [SOLVED] Need help writing PKGBUILD for "chemfiles"

Wow, thanks a lot, @a821. It seems obvious now, but I needed "-DCHFL_BUILD_TESTS=ON" to run the tests.

Offline

#4 2020-02-15 19:31:00

aurelieng
Member
Registered: 2010-02-02
Posts: 104

Re: [SOLVED] Need help writing PKGBUILD for "chemfiles"

The molecular modeling community being often close to the HPC community, you might want to add `-j"$(nproc --all)"` to cmake/cmake to build the package with all your CPU cores :-)

Edit: or `-j"$(grep -c ^processor /proc/cpuinfo`)"` if you don't want to rely on nproc (coreutils).

Last edited by aurelieng (2020-02-15 19:35:59)

Offline

#5 2020-02-15 19:34:53

Slithery
Administrator
From: Norfolk, UK
Registered: 2013-12-01
Posts: 5,776

Re: [SOLVED] Need help writing PKGBUILD for "chemfiles"

aurelieng wrote:

The molecular modeling community being often close to the HPC community, you might want to add `-j"$(nprocs --all)"` to cmake/cmake to build the package with all your CPU cores :-)

No, you really shouldn't.

If a user wants to compile using multiple cores then they should set the option in their makepkg.conf. PKGFILES should never be used to override this.


No, it didn't "fix" anything. It just shifted the brokeness one space to the right. - jasonwryan
Closing -- for deletion; Banning -- for muppetry. - jasonwryan

aur - dotfiles

Offline

#6 2020-02-15 19:42:36

aurelieng
Member
Registered: 2010-02-02
Posts: 104

Re: [SOLVED] Need help writing PKGBUILD for "chemfiles"

Thanks, @Slithery, I did not know there was such an option.

Offline

#7 2020-02-16 02:53:32

eschwartz
Fellow
Registered: 2014-08-08
Posts: 4,097

Re: [SOLVED] Need help writing PKGBUILD for "chemfiles"

aurelieng wrote:

Thanks, @Slithery, I did not know there was such an option.

makepkg has a number of tuneable options in makepkg.conf, which are intended to be used for *all* customizations which some users might want, and some users might not want, and which can reasonably be expected to apply to all packages.

That means setting up C(XX)FLAGS, LDFLAGS, and debugging CFLAGS (which can then be opted into by defining OPTIONS+=(debug) or the PKGBUILD-specific equivalent), the compression type and options for the final .pkg.tar, and a bunch of other things. I strongly recommend you take a look at the things it lets you do. wink


Managing AUR repos The Right Way -- aurpublish (now a standalone tool)

Offline

Board footer

Powered by FluxBB