You are not logged in.
Heya everyone and anyone reading this.
I'm following the AUR submission guide to build an AUR package for termsonic.
Here is the PKGBUILD i've come up with. It builds just fine locally, and follows general guidelines for Go software packages.
# Maintainer: chaotic_cilliac <theophile.gm(at)happyngreen.fr>
pkgname=termsonic-git
pkgver=v0.2.r1.g0fa73fe
pkgrel=1
pkgdesc='A terminal-based (TUI) client for any Subsonic-compatibl
e server.'
arch=('x86_64')
url='https://git.sixfoisneuf.fr/termsonic'
license=('GPL-3.0-only')
depends=('alsa-lib')
makedepends=('git' 'go>=1.19' 'gcc')
source=("${pkgname}::git+https://git.sixfoisneuf.fr/termsonic")
sha256sums=('SKIP')
provides=('termsonic')
pkgver() {
cd "${srcdir}/${pkgname}"
# If there are no tags, use commit count and hash
local version=$(git describe --long --tags 2>/dev/null || echo
"0.0.0-$(git rev-list --count HEAD)-g$(git rev-parse --short HEAD
)")
printf "%s" "$(echo "$version" | sed 's/\([^-]*-g\)/r\1/;s/-/./
g')"
}
prepare() {
cd "${srcdir}/${pkgname}"
# Ensure dependencies are downloaded
go mod download
}
build() {
cd "${srcdir}/${pkgname}"
export CGO_CFLAGS="${CFLAGS}"
export CGO_CPPFLAGS="${CPPFLAGS}"
export CGO_CXXFLAGS="${CXXFLAGS}"
export CGO_LDFLAGS="${LDFLAGS}"
export GOFLAGS="-buildmode=pie -trimpath -ldflags=-linkmode=ext
ernal -mod=readonly -modcacherw"
msg2 'Building...'
go build -o termsonic ./cmd/termsonic/
}
package() {
cd "${srcdir}/${pkgname}"
install -Dm755 termsonic -t "${pkgdir}/usr/bin/"
}
If anyone with experience making AUR packages would be kind enough to have a look, that would be great.
Also, if the PKGBUILD file is good, I'm wondering if I need any approval before making the remote repo in the AUR and pushing my PKGBUILD.
Last edited by chaotic_cilliac (2025-01-04 18:52:48)
Offline
I'm going to assume the wrapping issues are just from copy/paste.
You should remove the 'v' from the front of the pkgver (as part of the sed).
You should not have members of base-devel as part of the makedepends (gcc).
Why are you renaming the dir git is cloning the source repo into? You generally shouldn't do that.
You need to conflict with the regular package in addition to providing it.
msg2 is an internal makepkg function, you should not use it and there's no reason to print that anyway
I didn't try to build it and I'm not a go expert, so there may be things I missed.
Offline
Thank you Scimmia for taking the time to review my PKGBUILD file. I've adjusted the few easy fixable issues you mentioned. Formating should be better too (I copy pasted the cat output directly ...)
Why are you renaming the dir git is cloning the source repo into? You generally shouldn't do that.
The thing is that $pkgname is termsonic-git, while the upstream repo is termsonic. So either I rename or I cd in "$srcdir"/termsonic instead of what I have now. I've removed it for now, but if anyone has a better solution, I'm very curious.
New PKGBUILD
# Maintainer: chaotic_cilliac <theophile.gm(at)happyngreen.fr>
pkgname=termsonic-git
pkgver=0.2.r2.gf6f61fd
pkgrel=1
pkgdesc='A terminal-based (TUI) client for any Subsonic-compatible server.'
arch=('x86_64')
url='https://git.sixfoisneuf.fr/termsonic'
license=('GPL-3.0-only')
depends=('alsa-lib')
makedepends=('git' 'go>=1.19')
# source=("${pkgname}::git+https://git.sixfoisneuf.fr/termsonic")
source=("git+https://git.sixfoisneuf.fr/termsonic")
sha256sums=('SKIP')
provides=('termsonic')
conflict=('termsonic')
pkgver() {
cd "${srcdir}/termsonic"
# If there are no tags, use commit count and hash
local version=$(git describe --long --tags 2>/dev/null || echo "0.0.0-$(git rev-list --count HEAD)-g$(git rev-parse --short HEAD)")
printf "%s" "$(echo "$version" | sed 's/^v//;s/\([^-]*-g\)/r\1/;s/-/./g')"
}
prepare() {
cd "${srcdir}/termsonic"
go mod download
}
build() {
cd "${srcdir}/termsonic"
export CGO_CPPFLAGS="${CPPFLAGS}"
export CGO_CFLAGS="${CFLAGS}"
export CGO_CXXFLAGS="${CXXFLAGS}"
export CGO_LDFLAGS="${LDFLAGS}"
export GOFLAGS="-buildmode=pie -trimpath -ldflags=-linkmode=external -mod=readonly -modcacherw"
go build -o termsonic ./cmd/termsonic/
}
package() {
cd "${srcdir}/termsonic"
install -Dm755 termsonic -t "${pkgdir}/usr/bin/"
}
Last edited by chaotic_cilliac (2025-01-04 20:05:20)
Offline
Also, once I'm sure it's good, do I just create a aur repo with the pckname and push to it ?
I'm following this part of the wiki : AUR submission guidelines: Creating Package Repositories
Offline
conflict=('termsonic')
Missing s from the end of conflicts.
cd "${srcdir}/termsonic"
Not a bug just to note $srcdir can be skipped as makepkg will always set the working directory to $srcdir before it calls prepare() etc.
Offline
conflict=('termsonic')
Missing s from the end of conflicts.
Good catch
cd "${srcdir}/termsonic"
Not a bug just to note $srcdir can be skipped as makepkg will always set the working directory to $srcdir before it calls prepare() etc.
So if I understand correctly, I can just use
cd termsonic
instead ?
Offline
So if I understand correctly, I can just use
cd termsonic
instead ?
Yes.
Offline
chaotic_cilliac wrote:So if I understand correctly, I can just use
cd termsonic
instead ?
Yes.
Here is something I don't understand: when I run makepkg -si --noconfirm --needed
I end up with :
- a termsonic folder next to pkg and src. It contains source code but is not a git folder
- in src, I have a termsonic folder, this one git repos containing the makepkg branch.
Is this normal ?
Offline
Yes this is normal. For git repos makepkg will mirror the repo producing the directory without the .git subdirectory in the same directory as the PKGBUILD. makepkg on extract clones that mirror into $srcdir (src) producing the directory with the .git subdirectory. makepkg also sets the branch to makepkg on that clone.
Last edited by loqs (2025-01-05 15:24:43)
Offline
Thank you both Scimmia and loqs for your time and help.
I've published the termsonic-git package to the AUR.
Last edited by chaotic_cilliac (2025-01-06 13:19:40)
Offline