You are not logged in.

#1 2024-10-13 22:26:19

HeyCanIBorrowThat
Member
Registered: 2022-08-18
Posts: 7

Tips/recommendations for my first PKGBUILD

Hello,

I made my first PKGBUILD for a small, local-only service that I wrote, and I would greatly appreciate if I could get some feedback on it.

My current workflow is to:

1. run `make compress`, which cleans and makes the .tar.gz file for the PKGBUILD, and then
2. run `makepkg -cf` to test the PKGBUILD
3. run `makepkg -si` to install if (2) succeeds

My questions are:

1. Is there a better way to run this workflow? Is there a way to integrate the `make compress` step as part of the `makepkg` workflow?
2. In the PKGBUILD I set PKGDEST to keep the .tar.zst files from littering my working dir. Is there a recommended location for this? Currently using /dev/shm.
3. Could/should the `compress` step in the Makefile be moved to some function in the PKGBUILD?

Here are my files:

# Makefile

VERSION := 0.0.1

build_dir := myservice-$(VERSION)

myservice:
	gcc -g myservice.c -o myservice

clean:
	rm -rf $(build_dir) $(build_dir).tar.gz src pkg

install:
	install -Dm755 myservice /usr/bin/myservice

compress: clean
	mkdir $(build_dir)
	cp myservice.c $(build_dir)
	cp Makefile $(build_dir)
	tar czvf $(build_dir).tar.gz $(build_dir)/myservice.c $(build_dir)/Makefile
# PKGBUILD

pkgname=myservice
pkgver=0.0.1
pkgrel=1
pkgdesc="a daemon for system monitoring and notification purposes."
arch=('x86_64')
license=('GPL')
makedepends=('gcc')
source=("$pkgname-$pkgver.tar.gz")
sha256sums=('SKIP')

PKGDEST=/dev/shm/packages

build() {
  mkdir -p $PKGDEST
  cd "$pkgname-$pkgver"
  make
}

package() {
  cd "$pkgname-$pkgver"
  install -Dm755 myservice "$pkgdir/usr/bin/myservice"
}

Last edited by HeyCanIBorrowThat (2024-10-13 22:33:30)

Offline

#2 2024-10-13 22:43:54

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

Re: Tips/recommendations for my first PKGBUILD

Do you intend to only use the PKGBUILD yourself locally?  If so, why are you making a tarball at all?

There's also no need to run makepkg twice.  The -i command already will only install the package if it builds successfully.  But if you do keep those two commands separate, you'd want the -s flag on the first, not the second (though it really doesn't matter here as there are no dependencies).

Last edited by Trilby (2024-10-13 22:45:38)


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

Offline

#3 2024-10-14 00:20:26

HeyCanIBorrowThat
Member
Registered: 2022-08-18
Posts: 7

Re: Tips/recommendations for my first PKGBUILD

I was under the impression that the source array needs a tarball for the files to be extracted from by makepkg. Is there a way to avoid the source option? And yes I just intend to use this locally.

Offline

#4 2024-10-14 00:49:52

Scimmia
Fellow
Registered: 2012-09-01
Posts: 12,121

Re: Tips/recommendations for my first PKGBUILD

The source array can be files of any type, or VCS repos

In this case specifically where the PKGBUILD is in with the source files for a local-only build, I would probably just skip the source array and use $STARTDIR to access everything.

Last edited by Scimmia (2024-10-14 00:53:52)

Offline

Board footer

Powered by FluxBB