Bug 283755 - ports-mgmt/pkg: pkg-upgrade(8) - version comparison new kernel modules ("kmods") failure
Summary: ports-mgmt/pkg: pkg-upgrade(8) - version comparison new kernel modules ("kmod...
Status: New
Alias: None
Product: Ports & Packages
Classification: Unclassified
Component: Individual Port(s) (show other bugs)
Version: Latest
Hardware: amd64 Any
: --- Affects Some People
Assignee: freebsd-pkg (Nobody)
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2024-12-31 08:40 UTC by Eric
Modified: 2025-05-15 10:29 UTC (History)
4 users (show)

See Also:
bugzilla: maintainer-feedback? (pkg)


Attachments
debug output from pkg upgrade drm-61-kmod (27.20 KB, text/plain)
2025-01-03 17:10 UTC, Eric
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Eric 2024-12-31 08:40:57 UTC
Forum reference starting at:
https://forums.freebsd.org/threads/possible-solution-to-the-drm-kmod-kernel-mismatch-after-upgrade-from-bapt.96058/page-2#post-684474

On 14.2-RELEASE version number comparison by pkg-upgrade(8) 
does not work as expected with graphics/drm-61-kmod.

It is unclear if this version comparison issue reaches beyond 
this drm-61-kmod example but, IMO, this is probable, especially 
for the kernel modules where this is intended for.

This issue occurs when upgrading from 14.1-RELEASE to 
14.2-RELEASE and applying the changes to the pkg .conf file 
as mentioned in the anouncement on the ports mailinglist 
"CFT: repository for kernel modules" 
https://lists.freebsd.org/archives/freebsd-ports/2024-December/006997.html

However, this issue can also be shown to occur on 
14.2-RELEASE (irrespective of upgrading) as is shown 
in the command sequence below.

Furthermore "CFT: repository for kernel modules" states:
   The goal of this change is that the kernel module for 
   14.2 is at a higher version from the kernel module 
   from 14.1 which means will force reinstalling 
   considering this is an upgrade.
   
Necessary for this was an extension to the version numbering as announced in
"kmod: append osversion to the portversion":
https://github.com/freebsd/freebsd-ports/commit/a5fc087131e66513d1c74f8427c924afff580a15

The aforementioned "will force reinstalling" is inline with the 
documented comparison semantics as detailed in 
"5.2.2. Versions, DISTVERSION or PORTVERSION"
https://docs.freebsd.org/en/books/porters-handbook/book/#makefile-versions

For example for drm-61-kmod version numbers:
   # pkg version -t 6.1.92.1401000_3  6.1.92.1402000_3 
   <


The command sequence below details the unexpected failure to 
upgrade the package drm-61-kmod on 14.2-RELEASE after applying 
the advised changes to the pkg .conf file.

[1](0) # uname -a
FreeBSD q210 14.2-RELEASE FreeBSD 14.2-RELEASE releng/14.2-n269506-c8918d6c7412 GENERIC amd64
[2](0) # pkg -v
1.21.3
[3](0) # pkg info drm-61-kmod
pkg: No package(s) matching drm-61-kmod
[4](1) # cd /usr/local/etc/pkg/repos/
[5](0) # grep -v '^#' FreeBSD.conf

FreeBSD: {
        url: pkg+https://pkg.freebsd.org/${ABI}/latest,
}

FreeBSD-kmods: {
        enabled: no,
        url: pkg+https://pkg.freebsd.org/${ABI}/kmods_latest_${VERSION_MINOR},
        signature_type: "fingerprints",
        fingerprints: "/usr/share/keys/pkg",
        mirror_type: "srv",
}
[6](0) # pkg -vv | sed -n '/^Repositories:/,$ p'      <-- start with scan for "kmods" repository disabled
Repositories:
  FreeBSD: {
    url             : "pkg+https://pkg.freebsd.org/FreeBSD:14:amd64/latest",
    enabled         : yes,
    priority        : 0,
    mirror_type     : "SRV",
    signature_type  : "FINGERPRINTS",
    fingerprints    : "/usr/share/keys/pkg"
  }
  FreeBSD-kmods: {
    url             : "pkg+https://pkg.freebsd.org/FreeBSD:14:amd64/kmods_latest_2",
    enabled         : no,
    priority        : 0,
    mirror_type     : "SRV",
    signature_type  : "FINGERPRINTS",
    fingerprints    : "/usr/share/keys/pkg"
  }
[7](0) # pkg install drm-61-kmod
Updating FreeBSD repository catalogue...
FreeBSD repository is up to date.
All repositories are up to date.
Checking integrity... done (0 conflicting)
The following 1 package(s) will be affected (of 0 checked):

New packages to be INSTALLED:
        drm-61-kmod: 6.1.92.1401000_3 [FreeBSD]

Number of packages to be installed: 1

The process will require 17 MiB more space.

Proceed with this action? [y/N]: y
[1/1] Installing drm-61-kmod-6.1.92.1401000_3...
[1/1] Extracting drm-61-kmod-6.1.92.1401000_3: 100%
=====
Message from drm-61-kmod-6.1.92.1401000_3:

--
The drm-61-kmod port can be enabled for amdgpu (for AMD
GPUs starting with the HD7000 series / Tahiti) or i915kms (for Intel
APUs starting with HD3000 / Sandy Bridge) through kld_list in
/etc/rc.conf. radeonkms for older AMD GPUs can be loaded and there are
some positive reports if EFI boot is NOT enabled.

For amdgpu: kld_list="amdgpu"
For Intel: kld_list="i915kms"
For radeonkms: kld_list="radeonkms"

Please ensure that all users requiring graphics are members of the
"video" group.

Please note that this package was built for FreeBSD 14.1.
If this is not your current running version, please rebuild
it from ports to prevent panics when loading the module.
[8](0) # pkg info drm-61-kmod | grep  Version        <-- the version specific to 14.1-RELEASE is installed
Version        : 6.1.92.1401000_3
[9](0) # sed -i.org '/FreeBSD-kmods:/,$ s/enabled:*.no,/enabled: yes,/' FreeBSD.conf   <-- a ".org" backup of the original FreeBSD.conf is made
[10](0) # pkg -vv | sed -n '/^Repositories:/,$ p'    <-- "kmods" repository is enabled
Repositories:
  FreeBSD: {
    url             : "pkg+https://pkg.freebsd.org/FreeBSD:14:amd64/latest",
    enabled         : yes,
    priority        : 0,
    mirror_type     : "SRV",
    signature_type  : "FINGERPRINTS",
    fingerprints    : "/usr/share/keys/pkg"
  }
  FreeBSD-kmods: {
    url             : "pkg+https://pkg.freebsd.org/FreeBSD:14:amd64/kmods_latest_2",
    enabled         : yes,
    priority        : 0,
    mirror_type     : "SRV",
    signature_type  : "FINGERPRINTS",
    fingerprints    : "/usr/share/keys/pkg"
  }
[11](0) # pkg update
Updating FreeBSD repository catalogue...
FreeBSD repository is up to date.
Updating FreeBSD-kmods repository catalogue...
FreeBSD-kmods repository is up to date.
All repositories are up to date.
[12](0) # pkg upgrade
Updating FreeBSD repository catalogue...
FreeBSD repository is up to date.
Updating FreeBSD-kmods repository catalogue...
FreeBSD-kmods repository is up to date.
All repositories are up to date.
Checking for upgrades (15 candidates): 100%
Processing candidates (15 candidates): 100%
Checking integrity... done (0 conflicting)
Your packages are up to date.
[13](0) # pkg version -vRL=                <-- attempts to recognise an upgrade fail
Updating FreeBSD repository catalogue...
FreeBSD repository is up to date.
Updating FreeBSD-kmods repository catalogue...
FreeBSD-kmods repository is up to date.
All repositories are up to date.
[14](0) # pkg delete drm-61-kmod        <-- delete the "14.1 version"
Checking integrity... done (0 conflicting)
Deinstallation has been requested for the following 1 packages (of 0 packages in the universe):

Installed packages to be REMOVED:
        drm-61-kmod: 6.1.92.1401000_3

Number of packages to be removed: 1

The operation will free 17 MiB.

Proceed with deinstalling packages? [y/N]: y
[1/1] Deinstalling drm-61-kmod-6.1.92.1401000_3...
[1/1] Deleting files for drm-61-kmod-6.1.92.1401000_3: 100%
[15](0) # pkg install drm-61-kmod
Updating FreeBSD repository catalogue...
FreeBSD repository is up to date.
Updating FreeBSD-kmods repository catalogue...
FreeBSD-kmods repository is up to date.
All repositories are up to date.
Checking integrity... done (0 conflicting)
The following 1 package(s) will be affected (of 0 checked):

New packages to be INSTALLED:
        drm-61-kmod: 6.1.92.1402000_3 [FreeBSD-kmods]

Number of packages to be installed: 1

The process will require 17 MiB more space.

Proceed with this action? [y/N]: y
[1/1] Installing drm-61-kmod-6.1.92.1402000_3...
[1/1] Extracting drm-61-kmod-6.1.92.1402000_3: 100%
=====
Message from drm-61-kmod-6.1.92.1402000_3:

--
The drm-61-kmod port can be enabled for amdgpu (for AMD
GPUs starting with the HD7000 series / Tahiti) or i915kms (for Intel
APUs starting with HD3000 / Sandy Bridge) through kld_list in
/etc/rc.conf. radeonkms for older AMD GPUs can be loaded and there are
some positive reports if EFI boot is NOT enabled.

For amdgpu: kld_list="amdgpu"
For Intel: kld_list="i915kms"
For radeonkms: kld_list="radeonkms"

Please ensure that all users requiring graphics are members of the
"video" group.

Please note that this package was built for FreeBSD 14.2.
If this is not your current running version, please rebuild
it from ports to prevent panics when loading the module.
[16](0) # pkg info drm-61-kmod | grep  Version    <-- drm-61-kmod version specific to 14.2-RELEASE is installed
Version        : 6.1.92.1402000_3
[17](0) # pkg version -t 6.1.92.1401000_3  6.1.92.1402000_3     <-- this shows how pkg-upgrade should compare version numbers
<
[18](0) #
Comment 1 devnull freebsd_committer freebsd_triage 2025-01-01 07:50:33 UTC
Importance: affects some people.

From <https://mail-archive.freebsd.org/cgi/mid.cgi?be9146d1-a895-4e52-91c1-85186bb86cbe> | <https://lists.freebsd.org/archives/freebsd-ports/2024-December/007016.html> (2024-12-15): 

> CFT: repository for kernel modules: from .1401000 to .1402000 with kmods_latest_2

> … In both cases, an upgrade without specifying '-r FreeBSD-kmods' did 
> not gain packages from the repo: …

For users of FreeBSD Discord: some discussion at and around <https://discord.com/channels/727023752348434432/760416312676712519/1322841404623294585> (2024-12-29), and I have created a thread at <https://discord.com/channels/727023752348434432/1322832644442165259> with reference to this bug 283755.
Comment 2 Eric 2025-01-02 15:24:30 UTC
(in reply to comment #1)

Thanks. With the suggested settings, it seems the following sequence 
of two commands is a practicle work-around at the moment:
   pkg upgrade -r FreeBSD
   pkg upgrade -r FreeBSD-kmods

As mentioned, and contrary to what is documented in pkg-upgrade(8)
and pkg.conf(5), I haven't been able to deploy PRIORITY in FreeBSD.conf
or CONSERVATIVE_UPGRADE in /usr/local/etc/pkg.conf in such a way 
that it enables the use of
   pkg upgrade
(without the -r option) spanning both repositories.
Comment 3 Eric 2025-01-03 17:10:33 UTC
Created attachment 256383 [details]
debug output from pkg upgrade drm-61-kmod
Comment 4 Eric 2025-01-03 17:13:52 UTC
(in reply to comment #3 )

As shown in the attached debug out, it seems there is definitely a problem with version comparison:
   drm-61-kmod-6.1.92.1402000_3
is recognised but rejected.
Comment 5 Mark Millard 2025-01-03 17:35:32 UTC
Just for reference, to avoid needing to search in the overall
debug output:

DBG(2)[3037]> universe: add new local pkg: drm-61-kmod, (drm-61-kmod-6.1.92.1401000_3:. . .)
DBG(2)[3037]> universe: add new remote pkg: drm-61-kmod, (drm-61-kmod-6.1.92.1402000_3:. . .)
DBG(2)[3037]> universe: add new remote pkg: drm-61-kmod, (drm-61-kmod-6.1.92.1401000_3:. . .)
DBG(1)[3037]> removing drm-61-kmod from the request as it is the same as local

Note the 2 "remote" examples, just one of which is a match
to the "local" one. The mismatch is larger:

drm-61-kmod-6.1.92.1401000_3 < drm-61-kmod-6.1.92.1402000_3
Comment 6 Vedran Miletic 2025-05-15 10:29:37 UTC
(In reply to Graham Perrin from comment #1)
I am glad to confirm that

pkg upgrade -r FreeBSD-kmods

also solves the issue for 14.3-BETA2. Thanks for providing the information.