[Bug 283755] ports-mgmt/pkg: pkg-upgrade(8) - version comparison new kernel modules ("kmods") failure

From: <bugzilla-noreply_at_freebsd.org>
Date: Tue, 31 Dec 2024 08:40:57 UTC
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=283755

            Bug ID: 283755
           Summary: ports-mgmt/pkg: pkg-upgrade(8) - version comparison
                    new kernel modules ("kmods") failure
           Product: Ports & Packages
           Version: Latest
          Hardware: amd64
                OS: Any
            Status: New
          Severity: Affects Only Me
          Priority: ---
         Component: Individual Port(s)
          Assignee: pkg@FreeBSD.org
          Reporter: erichanskrs@gmail.com
             Flags: maintainer-feedback?(pkg@FreeBSD.org)
          Assignee: pkg@FreeBSD.org

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) #

-- 
You are receiving this mail because:
You are the assignee for the bug.