Bug 278631 - pkg update fails when explicitly providing ABI (since 1.21.2)
Summary: pkg update fails when explicitly providing ABI (since 1.21.2)
Status: New
Alias: None
Product: Base System
Classification: Unclassified
Component: bin (show other bugs)
Version: 14.0-RELEASE
Hardware: amd64 Any
: --- Affects Only Me
Assignee: freebsd-pkg (Nobody)
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2024-04-28 08:58 UTC by Markus Stoff
Modified: 2024-04-30 14:42 UTC (History)
3 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Markus Stoff 2024-04-28 08:58:47 UTC
Since upgrading pkg to version 1.21.2, the following error occurs (it was fine up to and including 1.21.1):

# pkg -o ABI="$(pkg config abi)" update -f
# ABI="$(pkg config abi)" pkg update -f
Updating FreeBSD repository catalogue...
Fetching meta.conf: 100%    178 B   0.2kB/s    00:01    
Fetching data.pkg: 100%    7 MiB   7.3MB/s    00:01    
Processing entries:   0%
pkg: Newer FreeBSD version for package zxfer:
To ignore this error set IGNORE_OSVERSION=yes
- package: 1400097
- running kernel: 0

pkg: repository FreeBSD contains packages for wrong OS version: FreeBSD:14:amd64
Processing entries:   0%
Unable to update repository FreeBSD
Error updating repositories!

# echo $?
1


Without setting the ABI explicitly:

# pkg update -f
Updating FreeBSD repository catalogue...
Fetching meta.conf: 100%    178 B   0.2kB/s    00:01    
Fetching data.pkg: 100%    7 MiB   7.3MB/s    00:01    
Processing entries: 100%
FreeBSD repository update completed. 34056 packages processed.
All repositories are up to date.

# echo $?
0
Comment 1 crest 2024-04-29 01:05:26 UTC
Please try the command with a `env OSVERSION=$(sysctl -n kern.osreldate)` prefix to check if it makes a difference.
Comment 2 Baptiste Daroussin freebsd_committer freebsd_triage 2024-04-29 06:47:32 UTC
Can you please explain your use case when you need to specify the ABI in command line?
The change in 1.21.2 exposes an issue people where silently having before.

I need to understand your use case to make sure either the explanation of what should be done, is correct, and/or improve pkg so it covers in a more userfriendly way your use case.
Comment 3 crest 2024-04-29 10:32:48 UTC
I can't speak for Markus, but my use-case isn't that I explicitly set the ABI. Instead I invoke `make packages` on a releng/14.0 tree and Makefile.inc1 sets the ABI which triggers the changed behaviour in pkg-1.21.2 resulting broken repos with the kernel packages annotated as FreeBSD_version="0". When `pkg update -r local_base` tries to update from the corrupted it detects the corruption and refuses to update the local database for the repo. To me this a regression that should be fixed: `make packages` used to generate a valid repo and now it doesn't.

What's the motivation behind the change in pkg version 1.21.[0-2]? Was it just a cleanup attempt with unforeseen fallout or is it required to solve a more important problem and the Makefiles have to change to set either all or nothing? Is there some mail/issue/documentation I can read to learn more?
Comment 4 crest 2024-04-29 17:45:35 UTC
The same problem (and its resolution) has been discussed on the FreeBSD package base mailing list. The the thread starts here: https://lists.freebsd.org/archives/freebsd-pkgbase/2024-April/000386.html. A solution committed to 14-stable and 15-current is discussed here: https://lists.freebsd.org/archives/freebsd-pkgbase/2024-April/000398.html.
Comment 5 Baptiste Daroussin freebsd_committer freebsd_triage 2024-04-30 09:00:02 UTC
yes I already stated, the before this change it was working by accident, and the change in 1.2 just make the issue obvious. never the less there is no way for pkg to guess what will be the target OSVERSION if nothing provides it and when one manually sets ABI pkg cannot know what is the OSVERSION which is being targetted and has 0 way to guess it, using kern.osreldate is wrong as this the the OSVERSION of the host building the packages and not the OSVERSION of the target
Comment 6 Markus Stoff 2024-04-30 13:50:36 UTC
I'm using this feature to provision jails, which may run a different FreeBSD release (i.e. running 13-RELEASE jails on a 14-RELEASE host).

To avoid fetching the package database for each and every jail separately, I'm using a distinct package database, set via PKG_DBDIR, for every ABI used in jails.

Essentially I'm running

  pkg -o ABI='FreeBSD:14:amd64' -o PKG_DBDIR='/path/to/FreeBSD:14:amd64/db' update

to update the package database, and

  pkg -o ABI='FreeBSD:14:amd64' -o PKG_DBDIR='/path/to/FreeBSD:14:amd64/db' -o PKG_CACHEDIR='/path/to/FreeBSD:14:amd64/db/cache' -r '/path/to/jail' install some packages

to install packages into /path/to/jail.

Please let me know if you need further details.
Comment 7 Markus Stoff 2024-04-30 13:54:31 UTC
@crest@rlwinm.de

Yes, running it like this works:

OSVERSION=$(sysctl -n kern.osreldate) pkg -o ABI="$(pkg config abi)" update -f
Comment 8 Baptiste Daroussin freebsd_committer freebsd_triage 2024-04-30 14:42:44 UTC
to provision a jail the best way is to run pkg -o ABI="FreeBSD:13:amd64 -o IGNORE_OSVERSION=yes -r /myjail install

once the uname is present inside the jail your don't need anymore to specify the ABI or OSVERSION, pkg will autodetermine it.