You are not logged in.

#1 2017-01-30 13:38:38

starfry
Member
From: Surrey, UK
Registered: 2010-08-18
Posts: 230

PKGBUILD in source package (pkgver, startdir, happy namcap)

I have an application that I am working on. I have packaged it for my own internal use using a PKGBUILD in the root of my source tree (i.e. it won't ever be sent to AUR in this form). What I have works fine for my needs but I have a few questions about the right way to do this. Here is the gist my PKGBUILD:

pkgname=example
pkgver=$(git describe --always)
pkgrel=1
pkgdesc="example"
arch=(any)
url=https://example.com
license=(mit)
source=()
options=(!strip)

prepare() {
    ln -snf "$startdir" "$srcdir/$pkgname"
}

package() {
    cd "$pkgname"

    install -Dm755 ... yadda yadda yadda
}

If I run namcap on it. I get an error for the "pkgver" line:

Error: PKGBUILD: line 4: git: command not found

I can't put the absolute path to git in there because I would get "restricted: cannot specify `/' in command names". I can work around the problem by using a pkgver() function. However, the problem that I then get is that the PKGBUILD changes on every run because the "pkgver=" entry is updated. So, I prefer the command-line - which works - despite namcap complaining.

I wondered if there is a right way to use a package-time pkgver without it modifying the pkgbuild on every run.

The second issue that I have is that namcap complains about my use of "startdir".

PKGBUILD (example) E: File referenced in $startdir

(this error occurs if the word '$startdir' is in the PKGBUILD - even if it is in a comment)

I have read that using startdir is discouraged, so found that I can use "$src/.." as a replacement for "$startdir" which stops namcap from complaining. I'd like to know if there is a more approved alternative ?

(I did read the packaging standards, man pkgbuild and an old thread, since closed, also about pkgbuild in source tree but I am still unclear about the right way to create this kind of package.)

Offline

#2 2017-01-30 13:46:54

mis
Member
Registered: 2016-03-16
Posts: 234

Re: PKGBUILD in source package (pkgver, startdir, happy namcap)

starfry wrote:
Error: PKGBUILD: line 4: git: command not found

Looks like you don't have git installed..

man pkgbuild wrote:

startdir
This contains the absolute path to the directory where the PKGBUILD is located, which is usually the output of $(pwd) when makepkg is started. Use of this variable is deprecated and strongly discouraged.

Offline

#3 2017-01-30 13:52:20

starfry
Member
From: Surrey, UK
Registered: 2010-08-18
Posts: 230

Re: PKGBUILD in source package (pkgver, startdir, happy namcap)

re git: I do have git installed. Makepkg works without any problems, it's only namcap that complains about my pkgver line.
re startdir: I said that in my question - I'd like to learn what the approved alternative is.

Offline

#4 2017-01-30 14:17:39

mis
Member
Registered: 2016-03-16
Posts: 234

Re: PKGBUILD in source package (pkgver, startdir, happy namcap)

Sorry I missed: If I run namcap on it
I think the right way is using a pkgver() function, like you already did but don't want to use, or hardcode a pkgver.

You could cd into the right directory directly (without creating a link) in the package() function.
edit: Sorry again, just seen you did that already too (cd $srcdir/..). I should read more carefully. wink

Last edited by mis (2017-01-30 14:32:55)

Offline

Board footer

Powered by FluxBB