dnf/libsolv vs. package feed with commit hashes in version strings
Hi,
I noticed a strange behavior of dnf not updating a package from the package feed, and when I told it to explicitly install that newest package version it went "Downgrading: ...." as if the newest version were a older one.
The "competing" packages were:
foo-bar-1.0.0+git0+93a939c4-r0.24
foo-bar-1.0.0+git0+f95bf929-r0.26
So we have a system where foo-bar-1.0.0+git0+93a939c4-r0.24 is installed, and a package feed which offers foo-bar-1.0.0+git0+f95bf929-r0.26, dnf is convinced that f95bf929-r0.26 is older than 93a939c4-r0.24 - which is not as expected, IMHO.
BitBake has the "Package version for package XYZ went backwards which would break package feeds" error message, but it wouldn't even trigger in this case, since after a lexical comparison, f95bf929 is "higher" than 93a939c4. But turns out that libsolv implements a whole different algorithm for comparing version strings [1] which splits them into 'tokens' of either only numerical or only alpha characters, and compares the length of each. In above example it arrives at the commit hash after everything preceding it is equal, then it processes "93" for the 93a939c4 (delimited by "a") and "" for f95bf929 (delimited by "f"). Comparing "93" and "" the former is 2 characters longer, so the 93a939c4 version is considered more recent.
I think this behavior is counter-intuitive and there are lots of upstream recipes that append "git0+<hash>" to their PV; is the general consensus that you *must never* change the Git revision of such a package without incrementing the PV preceding the "git0" part? (Incrementing the PR doesn't help here, since dnf/libsolv never considers the PR if a PV is found to be newer).
I patched libsolv on our systems now to ignore everything following a "git0" in a PV, since we absolutely need to be able to update packages between version bumps.
Would be interested to learn if this behavior of dnf/libsolv is already known and what is the commonly accepted "best practice" dealing with it.
Thanks,
Patrick
[1]: https://github.com/openSUSE/libsolv/blob/7b0788fb7ee937b7d38829bcec47760e42779a66/src/evr.c#L74-L155
Welcome to PR service which you need to run and use during yocto builds:
https://wiki.yoctoproject.org/wiki/PR_Service
Alex
Quoted 32 lines · On Wed, 28 Feb 2024 at 12:56, <[email protected]> wrote:
Hi,
I noticed a strange behavior of dnf not updating a package from the package feed, and when I told it to explicitly install that newest package version it went "Downgrading: ...." as if the newest version were a older one.
The "competing" packages were:
foo-bar-1.0.0+git0+93a939c4-r0.24
foo-bar-1.0.0+git0+f95bf929-r0.26So we have a system where foo-bar-1.0.0+git0+93a939c4-r0.24 is installed, and a package feed which offers foo-bar-1.0.0+git0+f95bf929-r0.26, dnf is convinced that f95bf929-r0.26 is older than 93a939c4-r0.24 - which is not as expected, IMHO.
BitBake has the "Package version for package XYZ went backwards which would break package feeds" error message, but it wouldn't even trigger in this case, since after a lexical comparison,
f95bf929is "higher" than93a939c4. But turns out that libsolv implements a whole different algorithm for comparing version strings [1] which splits them into 'tokens' of either only numerical or only alpha characters, and compares the length of each. In above example it arrives at the commit hash after everything preceding it is equal, then it processes "93" for the93a939c4(delimited by "a") and "" forf95bf929(delimited by "f"). Comparing "93" and "" the former is 2 characters longer, so the93a939c4version is considered more recent.I think this behavior is counter-intuitive and there are lots of upstream recipes that append "git0+<hash>" to their PV; is the general consensus that you *must never* change the Git revision of such a package without incrementing the PV preceding the "git0" part? (Incrementing the PR doesn't help here, since dnf/libsolv never considers the PR if a PV is found to be newer).
I patched libsolv on our systems now to ignore everything following a "git0" in a PV, since we absolutely need to be able to update packages between version bumps.
Would be interested to learn if this behavior of dnf/libsolv is already known and what is the commonly accepted "best practice" dealing with it.
Thanks,
Patrick[1]: https://github.com/openSUSE/libsolv/blob/7b0788fb7ee937b7d38829bcec47760e42779a66/src/evr.c#L74-L155
-=-=-=-=-=-=-=-=-=-=-=-
Links: You receive all messages sent to this group.
View/Reply Online (#62629): https://lists.yoctoproject.org/g/yocto/message/62629
Mute This Topic: https://lists.yoctoproject.org/mt/104621339/1686489
Group Owner: [email protected]
Unsubscribe: https://lists.yoctoproject.org/g/yocto/unsub [[email protected]]
-=-=-=-=-=-=-=-=-=-=-=-
Hi Alex,
I'm using PRSERV and the PR is also incrementing in the example I've shown; this doesn't help as the PV of the older version is considered newer due to the commit hash - in this case the PR is never evaluated.
Patrick
PRserv isn't only for incrementing EXTENDPRAUTO, but it should also increment the LOCALCOUNT (the "0" in "+git0") whenever git sha is changed to new value not yet recorded in PRserv db.
If this doesn't work, then something isn't configured correctly or there is a bug.
Cheers,
Quoted 14 lines · On Wed, Feb 28, 2024 at 1:25 PM <[email protected]> wrote:
Hi Alex,
I'm using PRSERV and the PR is also incrementing in the example I've shown; this doesn't help as the PV of the older version is considered newer due to the commit hash - in this case the PR is never evaluated.
Patrick
-=-=-=-=-=-=-=-=-=-=-=-
Links: You receive all messages sent to this group.
View/Reply Online (#62631): https://lists.yoctoproject.org/g/yocto/message/62631
Mute This Topic: https://lists.yoctoproject.org/mt/104621339/3617156
Group Owner: [email protected]
Unsubscribe: https://lists.yoctoproject.org/g/yocto/unsub [[email protected]]
-=-=-=-=-=-=-=-=-=-=-=-
Note that the package version has 'git0' in it. That zero is supposed to be filled in by PR server, and if this doesn't happen, something is misconfigured, or there's a bug.
You can find the code that does this in meta/classes-global/package.bbclass, particularly look for PKGV manipulations in package_setup_pkgv() and subsequent substitution of PRSERV_PV_AUTOINC in package_get_auto_pr().
Alex
Quoted 6 lines · On Wed, 28 Feb 2024 at 13:25, <[email protected]> wrote:
Hi Alex,
I'm using PRSERV and the PR is also incrementing in the example I've shown; this doesn't help as the PV of the older version is considered newer due to the commit hash - in this case the PR is never evaluated.
Patrick
Great! This was exactly the bit of information I was missing.
The recipe in question puts a hardcoded "git0" there; I have to make it interact with PRSERV somehow.
Thanks,
Patrick
You can check if existing recipes in oe-core get correct PKGV into package files, there's plenty of them, e.g. xinput-calibrator, or any other that adds +git to PV (without zero at the end).
Alex
Quoted 7 lines · On Wed, 28 Feb 2024 at 14:17, <[email protected]> wrote:
Great! This was exactly the bit of information I was missing.
The recipe in question puts a hardcoded "git0" there; I have to make it interact with PRSERV somehow.
Thanks,
Patrick
As far as I can see, the SRCPV / AUTOINC logic works on a per recipe basis (not per package), right?
So when my recipe is divided into subpackages with a dedicated source revision for each, my only choice is to either split it into multiple recipes or use SRCREV_FORMAT to build a summarized SRCREV from the subpackages revisions ... correct?
At this point you need to show the recipe. Because I don't understand how packages can have dedicated source revision, if source revision is set by the recipe, and is the same for all packages it makes... where is the problem here?
Alex
Quoted 4 lines · On Wed, 28 Feb 2024 at 16:15, <[email protected]> wrote:
As far as I can see, the SRCPV / AUTOINC logic works on a per recipe basis (not per package), right?
So when my recipe is divided into subpackages with a dedicated source revision for each, my only choice is to either split it into multiple recipes or use
SRCREV_FORMATto build a summarized SRCREV from the subpackages revisions ... correct?
Hi Alex,
We have Yocto running on FPGA boards; the Linux images and package feeds include bitstream files to download into the FPGA. These bitstreams cannot be built within the Yocto/BitBake system, because they require special (closed source) build tools, take ages to build, etc.
So they are built somewhere outside BitBake (either on the local machine or on a build server) and provided as binaries via file:// or http://. But there are a bunch of complications:
- The version information (version string, git hash) has to be extracted from the filename. The files are named like "foobar_1.2.3-g12345678.xsa" and from that we derive the version 1.2.3 and SRCREV 12345678. The recipe doesn't know the filename in advance; in case of the local filesystem it is globbed and in case of the build server it is retrieved via Jenkins REST API.
- For some systems we need to bundle multiple bitstreams (variants), then at runtime an application specific script chooses one of them based on CPU ID, EEPROM contents, config files, etc. Hence the sub-packages.
- Some metadata (file basenames, versions, etc.) has to be passed to dependent recipes that extract further stuff from the original files.
See our bbappend and the original bb (from Xilinx) below.
This has already grown into quite a monstrosity, so I wouldn't be averse to rewrite/refactor it, especially if you happen to have a better idea how to implement it.
Thanks!
Patrick
https://github.com/MicroTCA-Tech-Lab/meta-techlab-utils/blob/rel-v2021.2/recipes-bsp/device-tree-from-bd/external-hdf.bbappend
https://github.com/Xilinx/meta-xilinx-tools/blob/rel-v2021.2/recipes-bsp/hdf/external-hdf.bb
Oh mercy me. Yocto isn't designed for this; everything is assuming that SRCREV, SRC_URI and PV are static and set in the recipe.
So I would rather implement the logic to determine what they are in an external script, and run that prior to bitbake. The script would write the dynamic values into an .inc file, which in turn is included into the recipe. You can place the .inc into a layer, and make automated git commits/pushes every time the content changes.
Alex
Quoted 23 lines · On Wed, 28 Feb 2024 at 18:37, <[email protected]> wrote:
Hi Alex,
We have Yocto running on FPGA boards; the Linux images and package feeds include bitstream files to download into the FPGA. These bitstreams cannot be built within the Yocto/BitBake system, because they require special (closed source) build tools, take ages to build, etc.
So they are built somewhere outside BitBake (either on the local machine or on a build server) and provided as binaries via file:// or http://. But there are a bunch of complications:
- The version information (version string, git hash) has to be extracted from the filename. The files are named like "foobar_1.2.3-g12345678.xsa" and from that we derive the version 1.2.3 and SRCREV 12345678. The recipe doesn't know the filename in advance; in case of the local filesystem it is globbed and in case of the build server it is retrieved via Jenkins REST API.
- For some systems we need to bundle multiple bitstreams (variants), then at runtime an application specific script chooses one of them based on CPU ID, EEPROM contents, config files, etc. Hence the sub-packages.
- Some metadata (file basenames, versions, etc.) has to be passed to dependent recipes that extract further stuff from the original files.
See our bbappend and the original bb (from Xilinx) below.
This has already grown into quite a monstrosity, so I wouldn't be averse to rewrite/refactor it, especially if you happen to have a better idea how to implement it.
Thanks!
Patrickhttps://github.com/MicroTCA-Tech-Lab/meta-techlab-utils/blob/rel-v2021.2/recipes-bsp/device-tree-from-bd/external-hdf.bbappend
https://github.com/Xilinx/meta-xilinx-tools/blob/rel-v2021.2/recipes-bsp/hdf/external-hdf.bb
Thank you, Alex!
Your suggestion will probably get rid of a lot of complexity in our recipe that tried to work around bitbake's limitations. But I'm still not sure how to tackle the original problem (AUTOINC from PRSERV for file:// and http:// resources), even if I have SRCREV as static data before running bitbake.
If I understand correctly, bb.fetch2.get_srcrev() requires that the fetcher's supports_srcrev() is set, so it wouldn't support file and http fetchers.
So what would be the recommended way to implement this functionality? Should I write and somehow inject my own fetcher module, or reimplement package_get_auto_pr() for my recipe (talking to PRSERV directly)?
Thanks again,
Patrick
Quoted 5 lines · Patrick Huesmann
Your suggestion will probably get rid of a lot of complexity in our recipe that tried to work around bitbake's limitations. But I'm still not sure how to tackle the original problem (AUTOINC from PRSERV for file:// and http:// resources), even if I have SRCREV as static data before running bitbake.
If I understand correctly,
bb.fetch2.get_srcrev()requires that the fetcher'ssupports_srcrev()is set, so it wouldn't support file and http fetchers.So what would be the recommended way to implement this functionality? Should I write and somehow inject my own fetcher module, or reimplement
package_get_auto_pr()for my recipe (talking to PRSERV directly)?
I know as much about this as you do. I don't have time to run experiments, and it's hard to tell from reading the code if there's a possible code path that would inject a value from pr server into PKGV for non-git resources.
Maybe the easiest is to have self-contained logic in the script that ensures PV always increases before it's set, and not try to involve pr server in that. Writing a new fetcher is... far-fetched :)
Alex