You are not logged in.

#1 2016-01-06 18:23:09

fturco
Member
Registered: 2010-07-12
Posts: 40

Review my PKGBUILD for The Linux Counter Project update script

My goal is to create a package for the update script of The Linux Counter Project and then upload it to the AUR. This is my first PKGBUILD.

PKGBUILD:

# Maintainer: Francesco Turco <fturco@fastmail.fm>
# Contributor: Max Roder <maxroder@web.de>
# Contributor: Mathias Buren <mathias.buren@gmail.com>
pkgname='linux-counter'
pkgver='git'
pkgrel='1'
pkgdesc="Update script for The Linux Counter Project"
url="https://www.linuxcounter.net/download"
arch=('any')
license=('GPL3')
depends=('bash')
source=("https://github.com/christinloehner/linuxcounter-update-examples/raw/master/_official/lico-update.sh"
        linux-counter.service
	linux-counter.timer)
sha256sums=('19e1d08ee30843f17a65652b69332cec127fa69803203b47d3f1930490bf1e59'
            '3b5d0f1a8e24fb9596c5fa6718a606510a30d461819c6b90209468fb74903df1'
            'daf2649bb460e7e755eba8287716d18101509b0eb21ac5a961a094c70602b903')
package() {
	install -D -m755 ${srcdir}/lico-update.sh ${pkgdir}/usr/bin/lico-update
	install -D -m644 ${srcdir}/${pkgname}.service ${pkgdir}/usr/lib/systemd/system/${pkgname}.service
	install -D -m644 ${srcdir}/${pkgname}.timer ${pkgdir}/usr/lib/systemd/system/${pkgname}.timer
}

linux-counter.service:

[Unit]
Description=Update script for The Linux Counter Project
Documentation=https://www.linuxcounter.net/

[Service]
ExecStart=/usr/bin/lico-update -m
User=root
Group=root
Type=oneshot

linux-counter.timer:

[Unit]
Description=Linux Counter daily update

[Timer]
OnCalendar=daily

Probably this package can be improved by dropping root privileges and running the script by a dedicated user, but I don't know how to do that. What do you think?

Offline

#2 2016-01-06 22:02:11

The Infinity
Member
Registered: 2014-07-05
Posts: 91
Website

Re: Review my PKGBUILD for The Linux Counter Project update script

If the package contains the latest Git version its name should have "-git" suffix and should provide and conflict ${pkgname%-git}. Checksums should be skiped. The pkgver should be set dynamically, see: https://wiki.archlinux.org/index.php/VC … 9_function

Offline

#3 2016-01-06 22:41:54

fturco
Member
Registered: 2010-07-12
Posts: 40

Re: Review my PKGBUILD for The Linux Counter Project update script

Thank you for the answer, I'll look at the link. Anyway I'm not even sure my package is a real -git package because I don't clone the whole repository. I just download a single file from the git repository. There's even a version number inside that file (0.0.4).

Offline

#4 2016-01-06 22:46:55

Scimmia
Fellow
Registered: 2012-09-01
Posts: 11,461

Re: Review my PKGBUILD for The Linux Counter Project update script

If you're downloading from master, it should definitely be a -git package.

Offline

#5 2016-01-06 23:13:33

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

Re: Review my PKGBUILD for The Linux Counter Project update script

fturco wrote:

I just download a single file from the git repository. There's even a version number inside that file (0.0.4).

Yes, but that version number can and will change without any indication to the users of the AUR package.

So your options as I see them:

1) keep the source as is, append -git to the package name, and write a pkgver function that parses the script file to get that version number you just mentioned.

2) clone the git repo properly, append -git to the package name, and make this just like countless other good git PKGBUILDs.

3) change the source url to point to the file for a specific git commit or tag.  Then put the version number of this commit/tag into the version field of the PKGBUILD and keep the package name as is.

Number 2 seems best to me, but 3 would be resonable enough - 1 just seems very awkward to me.

FWIW, number 2 will also make this easiest for you: you (almost never) need to worry about updating the PKGBUILD when upstream makes changes.  They'll (almost) always 'just work'.


"UNIX is simple and coherent..." - Dennis Ritchie, "GNU's Not UNIX" -  Richard Stallman

Offline

#6 2016-01-07 19:09:25

fturco
Member
Registered: 2010-07-12
Posts: 40

Re: Review my PKGBUILD for The Linux Counter Project update script

I chose option number 2. Here you are the updated PKGBUILD:

# Maintainer: Francesco Turco <fturco@fastmail.fm>
# Contributor: Max Roder <maxroder@web.de>
# Contributor: Mathias Buren <mathias.buren@gmail.com>
_name=linux-counter
pkgname=${_name}-git
pkgver=r34.6cd6ff2
pkgrel=1
pkgdesc="Update script for The Linux Counter Project"
url="https://www.linuxcounter.net/download"
arch=('any')
license=('GPL3')
depends=('bash')
source=("git://github.com/christinloehner/linuxcounter-update-examples/"
        ${pkgname}.service
	${pkgname}.timer)
sha256sums=('SKIP'
            '3b5d0f1a8e24fb9596c5fa6718a606510a30d461819c6b90209468fb74903df1'
            'daf2649bb460e7e755eba8287716d18101509b0eb21ac5a961a094c70602b903')
package() {
  install -D -m755 ${srcdir}/lico-update.sh ${pkgdir}/usr/bin/lico-update
  install -D -m644 ${srcdir}/${pkgname}.service ${pkgdir}/usr/lib/systemd/system/${_name}.service
  install -D -m644 ${srcdir}/${pkgname}.timer ${pkgdir}/usr/lib/systemd/system/${_name}.timer
}
pkgver() {
  cd linuxcounter-update-examples
  printf "r%s.%s" "$(git rev-list --count HEAD)" "$(git rev-parse --short HEAD)"
}

What do you think? Can I upload it to the AUR?

Offline

#7 2016-01-08 08:29:37

severach
Member
Registered: 2015-05-23
Posts: 192

Re: Review my PKGBUILD for The Linux Counter Project update script

Take -git out of the systemd files. Those would be the same whether you use the git version or not.

Offline

#8 2016-01-08 13:00:28

fturco
Member
Registered: 2010-07-12
Posts: 40

Re: Review my PKGBUILD for The Linux Counter Project update script

Yeah, you're right. Fixed. Latest version:

# Maintainer: Francesco Turco <fturco@fastmail.fm>
# Contributor: Max Roder <maxroder@web.de>
# Contributor: Mathias Buren <mathias.buren@gmail.com>
_name=linux-counter
pkgname=${_name}-git
pkgver=r34.6cd6ff2
pkgrel=1
pkgdesc="Update script for The Linux Counter Project"
url="https://www.linuxcounter.net/download"
arch=('any')
license=('GPL3')
depends=('bash')
source=("git://github.com/christinloehner/linuxcounter-update-examples/"
        ${_name}.service
	${_name}.timer)
sha256sums=('SKIP'
            '3b5d0f1a8e24fb9596c5fa6718a606510a30d461819c6b90209468fb74903df1'
            'daf2649bb460e7e755eba8287716d18101509b0eb21ac5a961a094c70602b903')
package() {
  install -D -m755 ${srcdir}/linuxcounter-update-examples/_official/lico-update.sh ${pkgdir}/usr/bin/lico-update
  install -D -m644 ${srcdir}/${_name}.service ${pkgdir}/usr/lib/systemd/system/${_name}.service
  install -D -m644 ${srcdir}/${_name}.timer ${pkgdir}/usr/lib/systemd/system/${_name}.timer
}
pkgver() {
  cd linuxcounter-update-examples
  printf "r%s.%s" "$(git rev-list --count HEAD)" "$(git rev-parse --short HEAD)"
}

Offline

Board footer

Powered by FluxBB