You are not logged in.

#1 2025-08-09 23:10:19

WayfarerCodes
Member
Registered: 2025-05-30
Posts: 9

[SOLVED] How can I improve my PKGBUILD?

It's my first one and it feels a little clunky to me. Specifically, the number of times I use the mkdir and cp commands, and the fact that it leaves behind a leftover folder in the user's home directory after the install finishes. Here's the AUR link to it. I'm also not sure if there's a better way to handle mime type registration for the .gamebook file type. I'll take any pointers you have.

Last edited by WayfarerCodes (2025-08-13 18:23:59)

Offline

#2 2025-08-10 01:06:18

yochananmarqos
Member
Registered: 2020-02-05
Posts: 217

Re: [SOLVED] How can I improve my PKGBUILD?

You don't need to use mkdir or cp at all as 'install -D' creates the leading directory. All the files except for the Python script can be installed with 'install -Dm644'.

Offline

#3 2025-08-10 11:47:46

Lone_Wolf
Administrator
From: Netherlands, Europe
Registered: 2005-10-04
Posts: 14,565

Re: [SOLVED] How can I improve my PKGBUILD?

If you do prefer to create directories before using them, you can combine the commands on 1 line .

Something like

mkdir -p "${pkgdir}"/usr/share/{appplications,icons,mime/packages,doc/Wayfarer/StoryFork/Examples}

Note that https://wiki.archlinux.org/title/Arch_p … irectories recommends /usr/share/doc/pkg so no grouping in /usr/share/doc .


source=("$url/archive/v$pkgver.zip")
sha512sums=("SKIP")

You must using a unique name in the source array, also skipping checksum generation for archives is a bad idea.
Check https://wiki.archlinux.org/title/Arch_p … ge_sources


Disliking systemd intensely, but not satisfied with alternatives so focusing on taming systemd.

clean chroot building not flexible enough ?
Try clean chroot manager by graysky

Offline

#4 2025-08-10 20:48:12

WayfarerCodes
Member
Registered: 2025-05-30
Posts: 9

Re: [SOLVED] How can I improve my PKGBUILD?

How would I go about generating a checksum for the archive? Also, is there a way to clean up the files left behind in the user's home after install,  or is that generally up to the user to do?

Here's my updated PKGBUILD so far. I've tested it and it seems to be working.

pkgname="storyfork"
pkgver="1.1.0"
pkgrel="2"
pkgdesc="A tool for reading CYOA stories written in text files"
arch=("x86_64")
url="https://codeberg.org/wayfarer/StoryFork"
license=("GPL-3.0-only")
groups=("wayfarer")
depends=("python-pyqt6" "python3")
source=("${pkgname}-${pkgver}.zip::${url}/archive/v${pkgver}.zip")
sha512sums=("SKIP")

package() {
	install -Dm755 "${srcdir}/storyfork/src/storyfork.py" "${pkgdir}/usr/bin/storyfork"

	install -Dm644 "${srcdir}/storyfork/build/StoryFork.desktop" "${pkgdir}/usr/share/applications/StoryFork.desktop"
	install -Dm644 "${srcdir}/storyfork/icons/storyfork-logo.png" "${pkgdir}/usr/share/icons/storyfork.png"
	install -Dm644 "${srcdir}/storyfork/build/mime-type.xml" "${pkgdir}/usr/share/mime/packages/wayfarer-storyfork.xml"

	install -Dm644 "${srcdir}/storyfork/templates/Simple.gamebook" "${pkgdir}/usr/share/doc/StoryFork/Examples/Simple.gamebook"
	install -Dm644 "${srcdir}/storyfork/templates/Advanced.gamebook" "${pkgdir}/usr/share/doc/StoryFork/Examples/Advanced.gamebook"
}

Offline

#5 2025-08-10 21:08:56

Lone_Wolf
Administrator
From: Netherlands, Europe
Registered: 2005-10-04
Posts: 14,565

Re: [SOLVED] How can I improve my PKGBUILD?

How would I go about generating a checksum for the archive?

- manually calculate the checksum using the sha512sum command on the archive and c/p it in the PKGBUILD
- run makepkg -g
and my preferred method:
- run updpkgsums (comes with pacman-contrib)

Also, is there a way to clean up the files left behind in the user's home after install,  or is that generally up to the user to do?

If you're referring to the build folder where the PKGBUILD (and other files needed for build) reside, that's up to the user.
(many prefer to keep those for future rebuils)


Disliking systemd intensely, but not satisfied with alternatives so focusing on taming systemd.

clean chroot building not flexible enough ?
Try clean chroot manager by graysky

Offline

#6 2025-08-13 18:23:24

WayfarerCodes
Member
Registered: 2025-05-30
Posts: 9

Re: [SOLVED] How can I improve my PKGBUILD?

Okay, I've added the checksum and pushed the updated PKGBUILD to the AUR. Thanks for all your help with this.

Offline

Board footer

Powered by FluxBB