pkg icon indicating copy to clipboard operation
pkg copied to clipboard

negative repository priority is allowed but does not work

Open ronaldklop opened this issue 11 months ago • 2 comments

As the default priority of /etc/pkg/FreeBSD.conf is 0, I added my repository with a lower priority. The only use case for me is to overrule the official repo by my local poudriere build by doing: pkg install -r ronald .

So I configured this.

# cat /usr/local/etc/pkg/repos/ronald.conf
ronald: {
  # /usr/local/poudriere/data/packages/ contains symlinks to link MAJOR to a specific minor
  url: "https://pkg.thuis.klop.ws/packages/freebsd${VERSION_MAJOR}-custom",
  enabled: yes,
  priority: -10
}

But it didn't work as expected and lately I found this command which shows that a negative priority is interpreted as a very high unsigned priority.

# pkg repositories
FreeBSD: { 
    url             : "pkg+https://pkg.FreeBSD.org/FreeBSD:14:aarch64/quarterly",
    enabled         : yes,
    priority        : 0,
    mirror_type     : "SRV",
    signature_type  : "FINGERPRINTS",
    fingerprints    : "/usr/share/keys/pkg"
  }
ronald: { 
    url             : "https://pkg.thuis.klop.ws/packages/freebsd14-custom",
    enabled         : yes,
    priority        : 4294967286
  }

I now about how this works in binary, so as a technical person it makes me happy. But as a user of my computer I was surprised that it is not possible to configure a lower priority than the default. And in a follow up that if the choice is to not support negatives that I think it would be nice to have this raise an error.

ronaldklop avatar Jun 04 '25 16:06 ronaldklop

please test with pkg-devel lots have changed regarding priorities

bapt avatar Jun 04 '25 19:06 bapt

[root@rpi /usr/local/etc/pkg/repos]# pkg -v
2.1.99.5

[root@rpi /usr/local/etc/pkg/repos]# pkg repositories
FreeBSD: { 
...
  }
ronald: { 
    url             : "https://X.Y.Z/packages/freebsd14-custom",
    enabled         : yes,
    priority        : 4294967286
  }

[root@rpi /usr/local/etc/pkg/repos]# cat ronald.conf 
ronald: {
  url: "https://X.Y.Z/packages/freebsd${VERSION_MAJOR}-custom",
  enabled: yes,
  priority: -10
}

Same issue with pkg-devel. The code silently changes priority -10 to MAX_INT-10.

ronaldklop avatar Jun 10 '25 14:06 ronaldklop