You are not logged in.

#1 2023-01-21 06:21:32

AltoXorg
Member
Registered: 2021-08-18
Posts: 7

getting other package versions for use in pkgver()

Hello I'm the maintainer of the soh packages (soh, soh-git, soh-otr-*). Someone commented about this particular problem in soh-otr-gc_mq_d:

webodan wrote:

Hey man, this package had a problem in pkgver() in my system, since I'm using spanish versions of packages, the line that grabbed the version of soh broke the package build, i fixed it by changing Version to Versión, then it worked, you might prefer to grep for "Ver" or something like that, so it doesn't break on tildes or foreign languages.

The soh-otr-exporter is a required tool that contains asset information and an exporter tool for the required rom provided by the user to generate this package. Some versions of it have changes that may break or not run by its main package. I want its package version to tie in with the exporter's version so that we can know what version of this package is generated, in order to prevent complications while troubleshooting.

Here's what the PKGBUILD pkgver() in question:

pacman -Qi soh-otr-exporter | grep Version | sed 's/.*: //;s/-.*$//'

So, is there any other methods to get other package's versions other than that I've showed?

Last edited by AltoXorg (2023-01-22 03:53:32)

Offline

#2 2023-01-21 08:28:53

mpan
Member
Registered: 2012-08-01
Posts: 983
Website

Re: getting other package versions for use in pkgver()

In general it is bad idea to parse output of commands that are meant to be only read by humans.

If possible, use expac to obtain the required information in a machine-readable format:

expac '%v' "$PKGNAME"

Otherwise, if parsing output meant for humans is unavoidable, force locale to C:

LANG=C pacman -Qi …

However, for this particular case, I see two more issues. The more important one: why a version of your package depends on a version of another package in the first place? The other: the `grep` invocation finds any line that contains substring “Version”, not the line that contains version information. The latter issue is less important, because with the line being tailored for a particular package breakage is unlikely. Still it is a code stink.


Sometimes I seem a bit harsh — don’t get offended too easily! PGP: 7C848198AE93D3BB

Offline

#3 2023-01-21 23:08:24

Allan
Pacman
From: Brisbane, AU
Registered: 2007-06-09
Posts: 11,243
Website

Re: getting other package versions for use in pkgver()

Just use "pacman -Q <pkg>".  No need for grepping.

Offline

#4 2023-01-22 03:49:36

AltoXorg
Member
Registered: 2021-08-18
Posts: 7

Re: getting other package versions for use in pkgver()

mpan wrote:

why a version of your package depends on a version of another package in the first place?

The soh-otr-* packages require a copyrighted ROM assumed to be legally obtained by a user, and won't put a link to any download sites. Each of them have different versions for a particular rom. It generates an .otr file for it to run the Soh program, as it depends on existing copyrighted assets. The soh-otr-exporter is a generator tool from the soh base package that is required to produce the otr file.

The current problem was that if some changes to the exporter package, like asset locations or additional custom material, it would crash the program. So, I have to add pkgver() to identify what version of the exporter and the program is generated from.

Offline

#5 2023-01-23 06:38:10

AltoXorg
Member
Registered: 2021-08-18
Posts: 7

Re: getting other package versions for use in pkgver()

Allan wrote:

Just use "pacman -Q <pkg>".  No need for grepping.

Thanks, that'll do...

Offline

Board footer

Powered by FluxBB