You are not logged in.

#1 2024-09-06 06:18:25

refcherry
Member
Registered: 2024-09-06
Posts: 3

Can someone look over my first PKGBUILD?

Hi, first post here. I'm thinking of posting this to the AUR, but there's probably some noob mistake in there. Have tested inside a clean chroot and everything, but yeah. What do you guys think?

# Maintainer: Cherry <arch@sparklet.org>
_pkgname=windot
pkgname=$_pkgname-git
pkgver=0.2.1.58da11e
pkgrel=1
arch=(x86_64)
url="https://github.com/Lamby777/windot"
source=("$_pkgname::git+https://github.com/Lamby777/windot.git")
pkgdesc="A simple emoji picker."
md5sums=('SKIP')

depends=('gtk4')
makedepends=('gcc-libs' 'glibc' 'gcc' 'cargo' 'git' 'pkgconf' 'libadwaita')

# Fetch the current version using the latest commit hash
pkgver() {
    cd "$srcdir/$_pkgname"
    # get the crate version using grep and sed
    cargo_ver=$(grep '^version =' Cargo.toml | sed -E 's/version = "(.*)"/\1/')
    
    # use the latest commit hash
    git_hash=$(git rev-parse --short HEAD)
    
    echo "$cargo_ver.$git_hash"
}

build() {
    cd "$srcdir/$_pkgname"
    make 
}

package() {
    cd "$srcdir/$_pkgname"
    export RUSTUP_TOOLCHAIN=stable
    cargo fetch --locked --target "$(rustc -vV | sed -n 's/host: //p')"

    make install DESTDIR="$pkgdir/" prefix="/usr"
}

Thanks.

Last edited by refcherry (2024-09-06 06:34:23)

Offline

#2 2024-09-06 07:25:47

gromit
Administrator
From: Germany
Registered: 2024-02-10
Posts: 1,534
Website

Re: Can someone look over my first PKGBUILD?

You're missing provides and conflicts for the non-git package .. Also the pkgver() function is quite unusual, usually the version is derived from git for the git package.

Also makedepending on gcc is not needed as this is included in base-devel.

Did you try to build your package in a clean chroot by doing a "pkgctl build" already?

https://wiki.archlinux.org/title/VCS_package_guidelines

Offline

#3 2024-09-06 11:56:53

Scimmia
Fellow
Registered: 2012-09-01
Posts: 13,726

Re: Can someone look over my first PKGBUILD?

That pkgver function is a problem. While pulling a version from Cargo.toml is fine and in some cases preferred, the pkgver needs to increase with each commit. As it is, as the git hash changes, the pkgver will go up and down randomly. You need to add something that increases, like the git commit count, as shown on the page gromit linked.

To take what gromit said about the makedepends further, cargo, git, and libawaita are the only things there that should be in makedepends. libawaita is a very strange thing to have in makedepends, though, why is it needed at build time but not at run time?

You should not be running cargo fetch in package function, it should be in prepare. Doing it this late makes no sense at all.

Offline

#4 2024-09-06 15:54:28

refcherry
Member
Registered: 2024-09-06
Posts: 3

Re: Can someone look over my first PKGBUILD?

gromit wrote:

You're missing provides and conflicts for the non-git package .. Also the pkgver() function is quite unusual, usually the version is derived from git for the git package.

Also makedepending on gcc is not needed as this is included in base-devel.

Did you try to build your package in a clean chroot by doing a "pkgctl build" already?

https://wiki.archlinux.org/title/VCS_package_guidelines

Oh, thanks for the link! I tried looking for Git in that list but didn't see it, missed the VCS link lol

Do I need a `conflicts` if there's no non-git package released (yet)?

And no, I was using this command

makechrootpkg -c -r $CHROOT

from this guide. What's the difference? I'm trying `pkgctl` right now and it keeps throwing an error about certificates in the `extra` repo.

Scimmia wrote:

To take what gromit said about the makedepends further, cargo, git, and libawaita are the only things there that should be in makedepends. libawaita is a very strange thing to have in makedepends, though, why is it needed at build time but not at run time?

So I don't need the GCC/glibc ones? The Rust package guidelines page told me to put that. Or is it supposed to be in regular `depends`? And do I even need the `cargo fetch` at all if I'm running all my cargo commands via `make` anyway? I'm kinda confused here because my package falls under the Rust category but it provides a Makefile for doing the actual install (for icons and stuff).

Last edited by refcherry (2024-09-06 16:31:53)

Offline

#5 2024-09-06 16:24:51

Trilby
Inspector Parrot
Registered: 2011-11-29
Posts: 30,456
Website

Re: Can someone look over my first PKGBUILD?

refcherry wrote:

So I don't need the GCC/glibc ones? The Rust package guidelines page told me to put that.

What you link to notes including them in depends not makedepends: these are different lists with different rules.  Specifically, gcc can be assumed to be installed at build time but not at run time, so gcc (and other members of base-devel) do not need to be included in makedepends if they are only required at build time.  But anything required at runtime must be listed in depends, regardless of group memberships.

In practice, quite a few AUR packagers neglect to list packages in base or base-devel in depends, but this is incorrect.  If your package directly requires (i.e., links to) any libraries including glibc, they need to be listed in the depends array.  You do not, however, need to list transient dependencies (so you don't need to list glibc if it is only needed because some other dependency requires it already ... but note the emphasis on the word only there).


"UNIX is simple and coherent" - Dennis Ritchie; "GNU's Not Unix" - Richard Stallman

Offline

#6 2024-09-06 16:39:27

refcherry
Member
Registered: 2024-09-06
Posts: 3

Re: Can someone look over my first PKGBUILD?

Trilby wrote:

In practice, quite a few AUR packagers neglect to list packages in base or base-devel in depends, but this is incorrect.  If your package directly requires (i.e., links to) any libraries including glibc, they need to be listed in the depends array.  You do not, however, need to list transient dependencies (so you don't need to list glibc if it is only needed because some other dependency requires it already ... but note the emphasis on the word only there).


I checked `gtk4`'s dependencies and sure enough, glibc and gcc-libs are in the list. That makes more sense, thanks!

refcherry wrote:

and it keeps throwing an error about certificates in the `extra` repo

I ran the command with `-c` to rebuild the chroot and it works now, NVM.

Here's what I have so far, then.

# Maintainer: Cherry <arch@sparklet.org>
# shellcheck disable=SC2034,SC2154
_pkgname=windot
pkgname=$_pkgname-git
pkgver=0.2.1.r93
pkgrel=1
arch=(x86_64)
url="https://github.com/Lamby777/windot"
source=("$_pkgname::git+https://github.com/Lamby777/windot.git")
pkgdesc="A simple emoji picker."
md5sums=('SKIP')

depends=('gtk4' 'libadwaita')
makedepends=('cargo' 'git' 'pkgconf')
conflicts=('windot')
provides=("windot=${pkgver}")

# Fetch the current version using the latest commit hash
pkgver() {
    cd "$srcdir/$_pkgname"

    # get the crate version using grep and sed
    cargo_ver=$(grep '^version =' Cargo.toml | sed -E 's/version = "(.*)"/\1/')
    
    # use the latest commit's rev#
    git_rev=$(git rev-list --count HEAD)
    
    # requires the rev first for version sorting purposes
    echo "$cargo_ver.r$git_rev"
}

prepare() {
    cd "$srcdir/$_pkgname"

    export RUSTUP_TOOLCHAIN=stable
    cargo fetch --locked --target "$(rustc -vV | sed -n 's/host: //p')"
}

build() {
    cd "$srcdir/$_pkgname"
    make 
}

package() {
    cd "$srcdir/$_pkgname"
    export RUSTUP_TOOLCHAIN=stable

    make install DESTDIR="$pkgdir/" prefix="/usr"
}

Last edited by refcherry (2024-09-06 17:49:32)

Offline

Board footer

Powered by FluxBB