You are not logged in.

#1 2022-01-07 22:40:44

restore
Member
Registered: 2015-03-26
Posts: 19

[SOLVED] gsl-lite: public PKGBUILD review

Please review my PKGBUILD file (maintainer headline omitted) for the package gsl-lite:

pkgname=gsl-lite
pkgver=v0.40.0.r1.g4b5e9ab
pkgrel=1
pkgdesc="Guidelines Support Library for C++98, C++11 up"
arch=('any')
url="https://github.com/gsl-lite/gsl-lite"
license=('MIT')
makedepends=('cmake' 'git')
source=("$pkgname::git+https://github.com/gsl-lite/gsl-lite.git")
md5sums=('SKIP')

pkgver() {
  cd "$srcdir/$pkgname"
  git describe --long --tags | sed 's/\([^-]*-g\)/r\1/;s/-/./g'
}

prepare() {
  cd "$srcdir/$pkgname"
  mkdir -p build
}

# header only library, no build step needed
#build() {}

package() {
  cd "$srcdir/$pkgname/build"
  cmake -DCMAKE_INSTALL_PREFIX=/usr ..
  make DESTDIR="$pkgdir" install
  install -D -t $pkgdir/usr/share/licenses/$pkgname/ ../LICENSE
}
What I read
What I checked and did

(“It” is referring to the library as well as the package)

  • ✅ It is in no official repo

  • ✅ It is not found by

    pacman -Ss
  • ✅ It is not part of the AUR

  • ✅ It was not posted in this forum

  • ✅ It is in none of the unofficial user repositories

  • ✅ Created the PKGBUILD file (see above)

  • ✅ Successfully build the PKGBUILD file with

    makepkg
  • ✅ Found no errors or warnings wih

    namcap PKGBUILD gsl-lite-v0.40.0.r1.g4b5e9ab-1-any.pkg.tar.xz
  • ✅ Successfully installed the package with

    sudo pacman -U gsl-lite-v0.40.0.r1.g4b5e9ab-1-any.pkg.tar.xz
  • ✅ Successfully compiled an example C++ file including this library

  • ✅ Checked that it does not collide with any of the files of the package extra/gsl by using

    pacman -Ql gsl
  • ✅ Build it in a clean CHROOT with

    makechrootpkg -c -r $CHROOT

Thank you! I'm eager to learn from my own request big_smile

Last edited by restore (2022-01-08 19:04:28)

Offline

#2 2022-01-07 23:06:44

loqs
Member
Registered: 2014-03-06
Posts: 14,426

Re: [SOLVED] gsl-lite: public PKGBUILD review

The package does not use the -git suffix but is not pinned to a commit or tag.

Minor nits.

source=("$pkgname::git+https://github.com/gsl-lite/gsl-lite.git")

The git repo is renamed to the same name?

You could drop prepare() and shorten package to the following,  in which cmake creates the build directory as required.

package() {
  cmake -S $pkgname -B build -DCMAKE_INSTALL_PREFIX=/usr
  DESTDIR="$pkgdir" cmake --install build
  install -D -t $pkgdir/usr/share/licenses/$pkgname/ $pkgname/LICENSE
}

Edit:
See also https://github.com/archlinux/svntogit-p … k/PKGBUILD

Last edited by loqs (2022-01-07 23:17:01)

Offline

#3 2022-01-07 23:37:40

yochananmarqos
Member
Registered: 2020-02-05
Posts: 51
Website

Re: [SOLVED] gsl-lite: public PKGBUILD review

If no build step is needed, then why are you creating a build folder? There are separate build() and package() functions for a reason. Building should not be done in the fakeroot environment.

You missed a few things reviewing Arch package guidelines:

  • As @loqs mentioned, if you want to pull directly from master it needs to be a VCS package with a -git suffix in the pkgname

  • No need for specifying a folder name in the source() array, the git repo name will be used

  • remove the leading v in the pkgver: VCS package guidelines

  • no need for the prepare() function at all, the build folder can be created using Cmake commands: Cmake package guidelines

  • do not use relative paths, either change directory or specify the folder where the file is located

Example PKGBULD:

pkgname=gsl-lite-git
pkgver=0.40.0.r1.g4b5e9ab
pkgrel=1
pkgdesc="Guidelines Support Library for C++98, C++11 up"
arch=('any')
url="https://github.com/gsl-lite/gsl-lite"
license=('MIT')
makedepends=('cmake' 'git')
provides=("${pkgname%-git}")
conflicts=("${pkgname%-git}")
source=('git+https://github.com/gsl-lite/gsl-lite.git')
sha256sums=('SKIP')

pkgver() {
  cd "$srcdir/${pkgname%-git}"
  git describe --long --tags | sed 's/^v//;s/\([^-]*-g\)/r\1/;s/-/./g'
}

build() {
  cmake -B build -S "${pkgname%-git}" \
    -DCMAKE_BUILD_TYPE='None' \
    -DCMAKE_INSTALL_PREFIX='/usr' \
    -Wno-dev
    cmake --build build
}

package() {
  DESTDIR="$pkgdir" cmake --install build

  cd "$srcdir/${pkgname%-git}"
  install -Dm644 -t "$pkgdir/usr/share/licenses/${pkgname%-git}/" LICENSE
}

Last edited by yochananmarqos (2022-01-07 23:38:59)

Offline

#4 2022-01-07 23:51:14

loqs
Member
Registered: 2014-03-06
Posts: 14,426

Re: [SOLVED] gsl-lite: public PKGBUILD review

yochananmarqos wrote:
  • do not use relative paths, either change directory or specify the folder where the file is located

Why would that be an issue as the resolved path is still under $srcdir ?

Offline

#5 2022-01-08 10:42:56

restore
Member
Registered: 2015-03-26
Posts: 19

Re: [SOLVED] gsl-lite: public PKGBUILD review

Thank you both for your extensive answers! I'll incorporate your suggestions.

VCS - yes or no
loqs wrote:

The package does not use the -git suffix but is not pinned to a commit or tag.

One thing I do not understand – and I did not found anywhere – is when to use a package as VCS package. I had the impression – and I'm fully aware that this is vague – that VCS packages are more “for development” and therefore “fluid”, hence the 'SKIP' option for the checksum. The VCS package guidelines say:

Wiki wrote:

Suffix pkgname with -cvs, -svn, -hg, -darcs, -bzr, -git etc. unless the package fetches a specific release.

But I do want to use a specific release, namely the “pinned commit” which @loqs suggests. I don't want to “live on the head” but update the package only when there’s a new release/tag. I therefore did not choose to append the suffix -git.

yochananmarqos wrote:

As @loqs mentioned, if you want to pull directly from master it needs to be a VCS package with a -git suffix in the pkgname

Okay, but is software not always pulled from a repository? Isn’t the master branch, as the name suggests, the main source for the software as stable as it can get (in contrast to the dev branch, for instance)? What is the alternative?
Given the maybe wrong assumptions I made above I would prefer a non-VCS package – but the 'SKIP' checksum option clashes with that,  doesn't it?

Build folder
yochananmarqos wrote:

If no build step is needed, then why are you creating a build folder?

Because I just followed the steps in the installation and use guide of the libraries README. I am no cmake expert and did not know there are other ways like those you both showed.

Path
loqs wrote:

Why would that be an issue as the resolved path is still under $srcdir?

I think just because it is cleaner.

Offline

#6 2022-01-08 11:25:29

Stefan Husmann
Member
From: Germany
Registered: 2007-08-07
Posts: 1,232

Re: [SOLVED] gsl-lite: public PKGBUILD review

But I do want to use a specific release, namely the “pinned commit” which @loqs suggests. I don't want to “live on the head” but update the package only when there’s a new release/tag. I therefore did not choose to append the suffix -git.

You can do so by using a the #-syntax at the end of your source-url.

E.g. you can use #commit=<the specific commit you want to use> or #tag=<tag> if upstream provides tags. it is described in the Wiki.

Offline

#7 2022-01-08 11:40:47

progandy
Member
Registered: 2012-05-17
Posts: 4,762

Re: [SOLVED] gsl-lite: public PKGBUILD review

Stefan Husmann wrote:

E.g. you can use #commit=<the specific commit you want to use> or #tag=<tag> if upstream provides tags. it is described in the Wiki.

#commit= is preferred so upstream cannot replace the tag with something different.


| alias CUTF='LANG=en_XX.UTF-8@POSIX ' |

Offline

#8 2022-01-08 19:03:40

restore
Member
Registered: 2015-03-26
Posts: 19

Re: [SOLVED] gsl-lite: public PKGBUILD review

Thank you all for your answers! Your improvements are now part of the PKGBUILD. Set to [Solved].

Offline

Board footer

Powered by FluxBB