You are not logged in.

#1 2021-02-09 13:04:04

probackup-nl
Member
From: Delft
Registered: 2017-11-15
Posts: 54
Website

[solved] My first PKGBUILD review request: influxdb2-bin

Hi,

I made my first package. That is for the distribution of influxdb version 2(.0.3) binaries. It was created by adapting influxdb PKGBUILD and reading github shell scripts for influxdb release 2.

It contains some mistakes where I would like guidance. I think that user creation in influxdb.install is redundant because of influxdb.sysusers content. I also think that group creation should be moved from .install to sysusers. What to do with the Maintainer line?

I can't figure out which location to choose as the influxdb user home directory: /etc/influxdb or /var/lib/influxdb or somewhere else?

Since influxdb v.2.0.3 the default path locations according to https://github.com/influxdata/influxdb/ … grade.sh#4 seem:
/etc/influxdb/config.toml, /var/lib/influxdb/influxd.bolt, /var/lib/influxdb/engine

Namcap -i output is:

influxdb2-bin W: ELF file ('usr/bin/influx') lacks FULL RELRO, check LDFLAGS.
influxdb2-bin W: ELF file ('usr/bin/influxd') lacks FULL RELRO, check LDFLAGS.
influxdb2-bin W: ELF file ('usr/bin/influx') lacks PIE.
influxdb2-bin W: ELF file ('usr/bin/influxd') lacks PIE.
influxdb2-bin W: .INSTALL file runs a command provided by hooks.
influxdb2-bin I: .INSTALL file runs a command (systemd-sysusers) provided by hooks.
influxdb2-bin I: .INSTALL file runs a command (systemd-tmpfiles) provided by hooks.
influxdb2-bin W: Dependency included and not needed ('glibc')
influxdb2-bin I: Depends as namcap sees them: depends=()

There are 5 files:

# Maintainer: Bartłomiej Piotrowski <bpiotrowski@archlinux.org>
# Contributor: Ceriel Jacobs <2010 at probackup dot nl>

pkgname=influxdb2-bin
pkgver=2.0.3
pkgrel=1
pkgdesc='Scalable datastore for metrics, events, and real-time analytics; Binary release;'
arch=('x86_64' 'aarch64')
url="https://github.com/InfluxData/influxdb"
license=('MIT')
depends=('glibc')
conflicts=('influxdb' 'influxdb-bin')
#v1 backup=('etc/influxdb/influxdb.conf')
#backup=('etc/influxdb/config.toml' 'var/lib/influxdb/influxd.bolt')
install=influxdb.install

# see https://portal.influxdata.com/downloads/
source_x86_64=(influxdb.tar.gz::"https://dl.influxdata.com/influxdb/releases/influxdb2-${pkgver}_linux_amd64.tar.gz")
sha256sums_x86_64=('d01f0b6d634406e0be1829f884ebf93423cc0c920743fa293a03b1533ffac4af')
source_aarch64=(influxdb.tar.gz::"https://dl.influxdata.com/influxdb/releases/influxdb2-${pkgver}_linux_arm64.tar.gz")
sha256sums_aarch64=('0c67b0282cefc9b1052633008f5713d24f6d18f669d8f92abb2004e2541947b4')

source=('influxdb.sysusers' 'influxdb.tmpfiles')
sha256sums=('a5ffcdb6db92ed33eccd14a93f1243c18d0d64724de641730af451c99642d6d6' 'e2aa59413a6204737383b86cedefd866d7073f56ace5b89aad38c530cc86e60c')

package() {
  # declare system users and groups
  install -Dm644 ../influxdb.sysusers "$pkgdir/usr/lib/sysusers.d/influxdb.conf"
  install -Dm644 ../influxdb.tmpfiles "$pkgdir/usr/lib/tmpfiles.d/influxdb.conf"

  install -Dm644 ../influxdb.service.d "$pkgdir/usr/lib/systemd/system/influxdb.service"

  if [[ $CARCH = 'aarch64' ]]; then
    cd "$srcdir/influxdb2-${pkgver}_linux_arm64"
  elif [[ $CARCH == 'x86_64' ]]; then
    cd "$srcdir/influxdb2-${pkgver}_linux_amd64"
  fi
  install -d "${pkgdir}/usr/bin/"
  install -Dm755 influx "${pkgdir}/usr/bin/influx"
  install -Dm755 influxd "${pkgdir}/usr/bin/influxd"
  install -Dm644 LICENSE "${pkgdir}/usr/share/licenses/${pkgname}/LICENSE"
  install -Dm644 README.md "${pkgdir}/usr/share/doc/${pkgname}/README.md"

  #install -Dm644 etc/logrotate.d/influxdb "$pkgdir/etc/logrotate.d/influxdb"
  #sudo cp /root/.influxdbv2/configs /var/lib/influxdb
  #sudo chown influxdb:influxdb /var/lib/influxdb/influxd.bolt /var/lib/influxdb/configs
  #sudo chown -R influxdb:influxdb /var/lib/influxdb/engine
}

$ cat influxdb.install

## arg 1:  the new package version
post_install() {
  systemd-sysusers /usr/lib/sysusers.d/influxdb.conf
  systemd-tmpfiles --create /usr/lib/tmpfiles.d/influxdb.conf

  groupadd -r influxdb &>/dev/null
  useradd -r -g influxdb -d /var/lib/influxdb -s /bin/false influxdb &>/dev/null

  #/var/lib/influxdb is already created by useradd
  #install -dm700 -o influxdb -g influxdb /var/lib/influxdb
  install -dm755 -o influxdb -g influxdb /var/log/influxdb
  #install -dm700 -o influxdb -g influxdb /home/influxdb
}

$ cat influxdb.sysusers

u influxdb - - /etc/influxdb

$ cat influxdb.service.d

# https://raw.githubusercontent.com/influxdata/influxdb/279bf1bf13bb391ac5635bbcccfe8d7524dadb92/scripts/influxdb.service
[Unit]
Description=InfluxDB 2.x is an open-source, distributed, time series database
Documentation=https://v2.docs.influxdata.com/v2.0/get-started/
After=network-online.target

[Service]
User=influxdb
Group=influxdb
LimitNOFILE=65536
#ExecStart=
ExecStart=/usr/bin/influxd --reporting-disabled
KillMode=control-group
Restart=on-failure

[Install]
WantedBy=multi-user.target
Alias=influxd.service

$ cat influxdb.tmpfiles

d /var/lib/influxdb   0755 influxdb influxdb
d /etc/influxdb       0755 influxdb influxdb
x /var/lib/influxdb/*
x /etc/influxdb/*

Any feedback will be appreciated.

PS I don't want to compile from source code because cargo/webpack crashes with 2GB of RAM (RPi).

Last edited by probackup-nl (2021-02-10 09:44:38)

Offline

#2 2021-02-09 13:17:52

Scimmia
Fellow
Registered: 2012-09-01
Posts: 8,671

Re: [solved] My first PKGBUILD review request: influxdb2-bin

The big, glaring problems that jump out at me right away:

1. Get rid of that .install file completely. You shouldn't be doing any of that. It should all be being done either in package(), or by hooks which automatically run when you install files for systemd-tmpfiles or systemd-sysusers.
2. Functions start in $pkgdir. You then use ../, but there's no guarantee what's one level up from $pkgdir. You can't use that.
3. Where does influxdb.service.d come from? It's not in the source array.

As for the maintainer tag, when you become maintainer, previous maintainers become contributors.

Edit:
4. Don't rename the source tarballs like that. Without a version, makepkg will try to use the cached tarball on every update, causing checksum errors and requiring the user manually delete it.
5. Why isn't this just influxdb-bin?

Last edited by Scimmia (2021-02-09 13:49:00)

Offline

#3 2021-02-09 14:53:42

probackup-nl
Member
From: Delft
Registered: 2017-11-15
Posts: 54
Website

Re: [solved] My first PKGBUILD review request: influxdb2-bin

@Scimmia
1. Thanks, I'll fix that.
2. Here I am most confused. $pkgdir is a subdirectory of the directory where PKGBUILD is. ../ is the folder where PKGBUILD is. On the test machine

install ../xyz $pkgdir

works as expected. But my guess is that you are trying to tell me that this is not the case on other machines, aren't you?
3. I don't understand what you mean. influxdb.service.d is a file in the same directory as PKGBUILD is. And is copied in the package with the 3th install command of function package().
4. I think that these lines are faulty:

source_x86_64=(influxdb.tar.gz::"https://dl.influxdata.com/influxdb/releases/influxdb2-${pkgver}_linux_amd64.tar.gz")
source_aarch64=(influxdb.tar.gz::"https://dl.influxdata.com/influxdb/releases/influxdb2-${pkgver}_linux_arm64.tar.gz")

and should be replaced with:

source_x86_64=("https://dl.influxdata.com/influxdb/releases/influxdb2-${pkgver}_linux_amd64.tar.gz")
source_aarch64=("https://dl.influxdata.com/influxdb/releases/influxdb2-${pkgver}_linux_arm64.tar.gz")

5. Upstream uses "influx2" instead of "influx" in their package naming since version release 2.0.3 (see https://github.com/influxdata/influxdb/releases).
I think that it is wise to follow upstream package naming.

Offline

#4 2021-02-09 15:09:28

Scimmia
Fellow
Registered: 2012-09-01
Posts: 8,671

Re: [solved] My first PKGBUILD review request: influxdb2-bin

probackup-nl wrote:

@Scimmia
1. Thanks, I'll fix that.
2. Here I am most confused. $pkgdir is a subdirectory of the directory where PKGBUILD is. ../ is the folder where PKGBUILD is. On the test machine

install ../xyz $pkgdir

works as expected. But my guess is that you are trying to tell me that this is not the case on other machines, aren't you?

It's $startdir/src by default, but that doesn't mean that it always is. Set BUILDDIR in makepkg.conf and see what happens.

I'll also correct myself here, I said $pkgdir when I meant $srcdir.

probackup-nl wrote:

3. I don't understand what you mean. influxdb.service.d is a file in the same directory as PKGBUILD is. And is copied in the package with the 3th install command of function package().

Since it's not in the source array, it's unusable. It is not included in the release tarball?

probackup-nl wrote:

4. I think that these lines are faulty:

source_x86_64=(influxdb.tar.gz::"https://dl.influxdata.com/influxdb/releases/influxdb2-${pkgver}_linux_amd64.tar.gz")
source_aarch64=(influxdb.tar.gz::"https://dl.influxdata.com/influxdb/releases/influxdb2-${pkgver}_linux_arm64.tar.gz")

and should be replaced with:

source_x86_64=("https://dl.influxdata.com/influxdb/releases/influxdb2-${pkgver}_linux_amd64.tar.gz")
source_aarch64=("https://dl.influxdata.com/influxdb/releases/influxdb2-${pkgver}_linux_arm64.tar.gz")

Correct.

probackup-nl wrote:

5. Upstream uses "influx2" instead of "influx" in their package naming since version release 2.0.3 (see https://github.com/influxdata/influxdb/releases).
I think that it is wise to follow upstream package naming.

Generally the latest version is the unversioned package. They apparently changed it after complaints from Debian users. We don't care about Debian.

Last edited by Scimmia (2021-02-09 15:35:38)

Offline

#5 2021-02-09 17:54:07

probackup-nl
Member
From: Delft
Registered: 2017-11-15
Posts: 54
Website

Re: [solved] My first PKGBUILD review request: influxdb2-bin

Scimmia wrote:

2.
It's $startdir/src by default, but that doesn't mean that it always is. Set BUILDDIR in makepkg.conf and see what happens.

What happens is:

==> Starting package()...
install: cannot stat '../influxdb.sysusers': No such file or directory
==> ERROR: A failure occurred in package().

Thanks for that catch.

After trial and error I figured out that I should not try to

cd

into any directory, neither prefix the files, just use their name. And that throws issue #3 for the service.d file:

==> Starting package()...
install: cannot stat 'influxdb.service.d': No such file or directory
==> ERROR: A failure occurred in package().

The service.d file is not included in the release tarball. Though it is available on https://github.com/influxdata/influxdb/ … db.service

5. Upgrading from version 1 to version 2 is not handled in this PKGBUILD. Therefore I (still) don't dare to name the package influxdb-bin

An issue is that the systemd service isn't started after installation:

* influxdb.service - InfluxDB 2.x is an open-source, distributed, time series database
     Loaded: loaded (/usr/lib/systemd/system/influxdb.service; disabled; vendor preset: disabled)
     Active: inactive (dead)

Last edited by probackup-nl (2021-02-09 19:47:33)

Offline

#6 2021-02-10 11:29:53

Lone_Wolf
Member
From: Netherlands, Europe
Registered: 2005-10-04
Posts: 9,496

Re: [solved] My first PKGBUILD review request: influxdb2-bin

probackup-nl wrote:
Scimmia wrote:

2.
It's $startdir/src by default, but that doesn't mean that it always is. Set BUILDDIR in makepkg.conf and see what happens.

What happens is:

==> Starting package()...
install: cannot stat '../influxdb.sysusers': No such file or directory
==> ERROR: A failure occurred in package().

Thanks for that catch.

The typical solution for using such files is to prepend such filepaths with the appropriate variable to ensure the files are found .
example :

 install -m644 -Dt "${pkgdir}/usr/share/licenses/${pkgname}" "${srcdir}/LICENSE"
probackup-n wrote:

An issue is that the systemd service isn't started after installation:

Nope, having it enabled / started by default would be an issue .

archlinux tries to minimize things started by default and expects users to arrange such things themselves.
(Other distros may do things differently).


Disliking systemd intensely, but not satisfied with alternatives so focusing on taming systemd.
Did you use the guided installer ? If yes, I can't help you.

(A works at time B)  && (time C > time B ) ≠  (A works at time C)

Offline

#7 2021-02-10 17:36:51

probackup-nl
Member
From: Delft
Registered: 2017-11-15
Posts: 54
Website

Re: [solved] My first PKGBUILD review request: influxdb2-bin

Lone_Wolf wrote:
probackup-n wrote:

An issue is that the systemd service isn't started after installation:

Nope, having it enabled / started by default would be an issue .

archlinux tries to minimize things started by default and expects users to arrange such things themselves.
(Other distros may do things differently).

I understand that users should enable and start the .service file. I can live with that as long as it is allowed to echo such instructions in the .install file. Is such allowed?

Does that policy to leave such things to the users themselves also limit from bundling a preset file that enables this service?

Offline

#8 2021-02-10 20:37:29

a821
Member
Registered: 2012-10-31
Posts: 282

Re: [solved] My first PKGBUILD review request: influxdb2-bin

probackup-nl wrote:

I understand that users should enable and start the .service file. I can live with that as long as it is allowed to echo such instructions in the .install file. Is such allowed?

Does that policy to leave such things to the users themselves also limit from bundling a preset file that enables this service?

1) Instructions in the .install file are allowed and in fact they are quite common. I don't think this is really necessary in this case though.

2) Not sure what you mean with "a preset file that enables this service". If you mean the .service file then of course you can include it. If a configuration file with default settings (so the software works out-of-the-box), then it is also OK, but remember to include it in the "backup" array so package updates don't overwrite user's settings.

Offline

#9 2021-02-11 00:02:03

probackup-nl
Member
From: Delft
Registered: 2017-11-15
Posts: 54
Website

Re: [solved] My first PKGBUILD review request: influxdb2-bin

a821 wrote:

2) Not sure what you mean with "a preset file that enables this service".

With .preset file, I meant the systemd preset file like:

$ cat 50-influxdb.preset 
enable influxdb.service

which will be installed at "/usr/lib/systemd/system-preset/"

Offline

#10 2021-02-11 00:59:25

loqs
Member
Registered: 2014-03-06
Posts: 13,935

Re: [solved] My first PKGBUILD review request: influxdb2-bin

That would be overridden by /usr/lib/systemd/system-preset/99-default.preset so would have no effect unless 99-default.preset has been overridden.

Offline

#11 2021-02-11 12:08:00

probackup-nl
Member
From: Delft
Registered: 2017-11-15
Posts: 54
Website

Re: [solved] My first PKGBUILD review request: influxdb2-bin

@loqs After installation the status is:

* influxdb.service - InfluxDB 2.x is an open-source, distributed, time series database
     Loaded: loaded (/usr/lib/systemd/system/influxdb.service; disabled; vendor preset: enabled)
     Active: inactive (dead)
       Docs: https://v2.docs.influxdata.com/v2.0/get-started/

And after a "systemctl preset-all" the status is:

* influxdb.service - InfluxDB 2.x is an open-source, distributed, time series database
     Loaded: loaded (/usr/lib/systemd/system/influxdb.service; enabled; vendor preset: enabled)
     Active: inactive (dead)
       Docs: https://v2.docs.influxdata.com/v2.0/get-started/

In my opinion the 99-default.preset does not override the "50-influxdb.preset" file. Or do I misunderstand your remark?
---

When installing the created package, there is an "n/a" at the "Creating user" line. Is that an issue?

(1/4) Creating system user accounts...
Creating group influxdb with gid 976.
Creating user influxdb (n/a) with uid 976 and gid 976.

Offline

#12 2021-02-11 13:32:17

loqs
Member
Registered: 2014-03-06
Posts: 13,935

Re: [solved] My first PKGBUILD review request: influxdb2-bin

I misread the man-page systemd.preset as 50-influxdb.preset is ordered lexicographically before 99-default.preset is has priority.

Offline

#13 2021-02-11 14:58:06

Scimmia
Fellow
Registered: 2012-09-01
Posts: 8,671

Re: [solved] My first PKGBUILD review request: influxdb2-bin

Please don't do that. This isn't Ubuntu, things like this should not be started automatically just because they're installed.

Offline

Board footer

Powered by FluxBB