-
Notifications
You must be signed in to change notification settings - Fork 681
feat: Enable libsolv to expose file time to dnf plugins #17972
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: 4.0
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,152 @@ | ||
| diff --git a/ext/repo_rpmmd.c b/ext/repo_rpmmd.c | ||
| index 42b7c73..2d3281c 100644 | ||
| --- a/ext/repo_rpmmd.c | ||
| +++ b/ext/repo_rpmmd.c | ||
| @@ -842,6 +842,9 @@ startElement(struct solv_xmlparser *xmlp, int state, const char *name, const cha | ||
| str = solv_xmlparser_find_attr("build", atts); | ||
| if (str && (ti = strtoull(str, 0, 10)) != 0) | ||
| repodata_set_num(pd->data, handle, SOLVABLE_BUILDTIME, ti); | ||
| + str = solv_xmlparser_find_attr("file", atts); | ||
| + if (str && (ti = strtoull(str, 0, 10)) != 0) | ||
| + repodata_set_num(pd->data, handle, SOLVABLE_FILETIME, ti); | ||
|
mbearup marked this conversation as resolved.
|
||
| break; | ||
| } | ||
| case STATE_SIZE: | ||
| diff --git a/src/knownid.h b/src/knownid.h | ||
| index 3d558af..abad692 100644 | ||
| --- a/src/knownid.h | ||
| +++ b/src/knownid.h | ||
| @@ -274,6 +274,7 @@ KNOWNID(UPDATE_COLLECTIONLIST, "update:collectionlist"), /* list of UPDATE_COLL | ||
| KNOWNID(SOLVABLE_MULTIARCH, "solvable:multiarch"), /* debian multi-arch field */ | ||
| KNOWNID(SOLVABLE_SIGNATUREDATA, "solvable:signaturedata"), /* conda */ | ||
| KNOWNID(SOLVABLE_ORDERWITHREQUIRES, "solvable:orderwithrequires"), /* rpm */ | ||
| +KNOWNID(SOLVABLE_FILETIME, "solvable:filetime"), /* file publish time from rpm-md <time file="..."> */ | ||
|
|
||
| KNOWNID(ID_NUM_INTERNAL, 0) | ||
|
|
||
| diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt | ||
| index 8a5cd8a..9fda423 100644 | ||
| --- a/test/CMakeLists.txt | ||
| +++ b/test/CMakeLists.txt | ||
| @@ -18,4 +18,12 @@ FOREACH(tcdir testcases libsolv-zypptestcases) | ||
| ENDIF () | ||
| ENDFOREACH () | ||
| ENDIF () | ||
| -ENDFOREACH () | ||
| \ No newline at end of file | ||
| +ENDFOREACH () | ||
| + | ||
| +# Standalone regression test: verify the rpm-md <time file="..."/> attribute | ||
| +# is retained as solvable:filetime. repo_add_rpmmd is only built with RPMMD. | ||
| +IF (ENABLE_RPMMD) | ||
| + ADD_EXECUTABLE (test_rpmmd_filetime test_rpmmd_filetime.c) | ||
| + TARGET_LINK_LIBRARIES (test_rpmmd_filetime libsolvext libsolv ${SYSTEM_LIBRARIES}) | ||
| + ADD_TEST (rpmmd_filetime ${CMAKE_CURRENT_BINARY_DIR}/test_rpmmd_filetime) | ||
| +ENDIF (ENABLE_RPMMD) | ||
| diff --git a/test/test_rpmmd_filetime.c b/test/test_rpmmd_filetime.c | ||
| new file mode 100644 | ||
| index 0000000..5a9df21 | ||
| --- /dev/null | ||
| +++ b/test/test_rpmmd_filetime.c | ||
| @@ -0,0 +1,100 @@ | ||
| +/* | ||
| + * test_rpmmd_filetime.c | ||
| + * | ||
| + * Regression test for the rpm-md primary.xml parser (ext/repo_rpmmd.c): | ||
| + * the package <time file="..."/> attribute must be recorded as | ||
| + * solvable:filetime. This value is a prerequisite for the DNF | ||
| + * virtual-snapshot plugins. | ||
| + * | ||
| + * If the parsing regresses, filetime is no longer stored and this test | ||
| + * fails, even while the rest of the ctest suite stays green. | ||
| + */ | ||
| + | ||
| +#include <stdio.h> | ||
| + | ||
| +#include "pool.h" | ||
| +#include "repo.h" | ||
| +#include "repo_rpmmd.h" | ||
| +#include "solv_xfopen.h" | ||
| +#include "knownid.h" | ||
| + | ||
| +/* Minimal rpm-md primary.xml with a single package that carries both a | ||
| + * build time and, crucially, a file publish time (<time file="123">). */ | ||
| +static const char primary_xml[] = | ||
| +"<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" | ||
| +"<metadata xmlns=\"http://linux.duke.edu/metadata/common\"" | ||
| +" xmlns:rpm=\"http://linux.duke.edu/metadata/rpm\" packages=\"1\">\n" | ||
| +" <package type=\"rpm\">\n" | ||
| +" <name>filetime-test</name>\n" | ||
| +" <arch>x86_64</arch>\n" | ||
| +" <version epoch=\"0\" ver=\"1.0\" rel=\"1\"/>\n" | ||
| +" <time file=\"123\" build=\"456\"/>\n" | ||
| +" </package>\n" | ||
| +"</metadata>\n"; | ||
| + | ||
| +int | ||
| +main(int argc, char **argv) | ||
| +{ | ||
| + Pool *pool; | ||
| + Repo *repo; | ||
| + FILE *fp; | ||
| + Id p; | ||
| + Solvable *s; | ||
| + unsigned long long filetime = 0, buildtime = 0; | ||
| + int nsolv = 0; | ||
| + | ||
| + (void)argc; | ||
| + (void)argv; | ||
| + | ||
| + pool = pool_create(); | ||
| + repo = repo_create(pool, "test"); | ||
| + | ||
| + fp = solv_fmemopen(primary_xml, sizeof(primary_xml) - 1, "r"); | ||
| + if (!fp) | ||
| + { | ||
| + fprintf(stderr, "FAIL: solv_fmemopen failed\n"); | ||
| + pool_free(pool); | ||
| + return 1; | ||
| + } | ||
| + if (repo_add_rpmmd(repo, fp, 0, 0) != 0) | ||
| + { | ||
| + fprintf(stderr, "FAIL: repo_add_rpmmd: %s\n", pool_errstr(pool)); | ||
| + fclose(fp); | ||
| + pool_free(pool); | ||
| + return 1; | ||
| + } | ||
| + fclose(fp); | ||
| + | ||
| + FOR_REPO_SOLVABLES(repo, p, s) | ||
| + { | ||
| + nsolv++; | ||
| + buildtime = solvable_lookup_num(s, SOLVABLE_BUILDTIME, 0); | ||
| + filetime = solvable_lookup_num(s, SOLVABLE_FILETIME, 0); | ||
| + } | ||
| + | ||
| + if (nsolv != 1) | ||
| + { | ||
| + fprintf(stderr, "FAIL: expected 1 solvable, parsed %d\n", nsolv); | ||
| + pool_free(pool); | ||
| + return 1; | ||
| + } | ||
| + /* Sanity: the pre-existing <time build="..."> handling must still work. */ | ||
| + if (buildtime != 456) | ||
| + { | ||
| + fprintf(stderr, "FAIL: solvable:buildtime = %llu, expected 456\n", buildtime); | ||
| + pool_free(pool); | ||
| + return 1; | ||
| + } | ||
| + /* The behavior under test: <time file="123"> must land in filetime. */ | ||
| + if (filetime != 123) | ||
| + { | ||
| + fprintf(stderr, "FAIL: solvable:filetime = %llu, expected 123 " | ||
| + "(<time file=\"123\"> not retained)\n", filetime); | ||
| + pool_free(pool); | ||
| + return 1; | ||
| + } | ||
| + | ||
| + printf("PASS: <time file=\"123\"> retained as solvable:filetime=%llu\n", filetime); | ||
| + pool_free(pool); | ||
| + return 0; | ||
| +} | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| [components.libsolv] | ||
|
|
||
| [[components.libsolv.overlays]] | ||
| description = "Make file time available for dnf plugins, a prerequisite for virtual snapshots" | ||
| type = "patch-add" | ||
| source = "0002-Make-file-time-available-for-dnf-plugins.patch" | ||
|
|
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,152 @@ | ||
| diff --git a/ext/repo_rpmmd.c b/ext/repo_rpmmd.c | ||
| index 42b7c73..2d3281c 100644 | ||
| --- a/ext/repo_rpmmd.c | ||
| +++ b/ext/repo_rpmmd.c | ||
| @@ -842,6 +842,9 @@ startElement(struct solv_xmlparser *xmlp, int state, const char *name, const cha | ||
| str = solv_xmlparser_find_attr("build", atts); | ||
| if (str && (ti = strtoull(str, 0, 10)) != 0) | ||
| repodata_set_num(pd->data, handle, SOLVABLE_BUILDTIME, ti); | ||
| + str = solv_xmlparser_find_attr("file", atts); | ||
| + if (str && (ti = strtoull(str, 0, 10)) != 0) | ||
| + repodata_set_num(pd->data, handle, SOLVABLE_FILETIME, ti); | ||
| break; | ||
| } | ||
| case STATE_SIZE: | ||
| diff --git a/src/knownid.h b/src/knownid.h | ||
| index 3d558af..abad692 100644 | ||
| --- a/src/knownid.h | ||
| +++ b/src/knownid.h | ||
| @@ -274,6 +274,7 @@ KNOWNID(UPDATE_COLLECTIONLIST, "update:collectionlist"), /* list of UPDATE_COLL | ||
| KNOWNID(SOLVABLE_MULTIARCH, "solvable:multiarch"), /* debian multi-arch field */ | ||
| KNOWNID(SOLVABLE_SIGNATUREDATA, "solvable:signaturedata"), /* conda */ | ||
| KNOWNID(SOLVABLE_ORDERWITHREQUIRES, "solvable:orderwithrequires"), /* rpm */ | ||
| +KNOWNID(SOLVABLE_FILETIME, "solvable:filetime"), /* file publish time from rpm-md <time file="..."> */ | ||
|
|
||
| KNOWNID(ID_NUM_INTERNAL, 0) | ||
|
|
||
| diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt | ||
| index 8a5cd8a..9fda423 100644 | ||
| --- a/test/CMakeLists.txt | ||
| +++ b/test/CMakeLists.txt | ||
| @@ -18,4 +18,12 @@ FOREACH(tcdir testcases libsolv-zypptestcases) | ||
| ENDIF () | ||
| ENDFOREACH () | ||
| ENDIF () | ||
| -ENDFOREACH () | ||
| \ No newline at end of file | ||
| +ENDFOREACH () | ||
| + | ||
| +# Standalone regression test: verify the rpm-md <time file="..."/> attribute | ||
| +# is retained as solvable:filetime. repo_add_rpmmd is only built with RPMMD. | ||
| +IF (ENABLE_RPMMD) | ||
| + ADD_EXECUTABLE (test_rpmmd_filetime test_rpmmd_filetime.c) | ||
| + TARGET_LINK_LIBRARIES (test_rpmmd_filetime libsolvext libsolv ${SYSTEM_LIBRARIES}) | ||
| + ADD_TEST (rpmmd_filetime ${CMAKE_CURRENT_BINARY_DIR}/test_rpmmd_filetime) | ||
| +ENDIF (ENABLE_RPMMD) | ||
| diff --git a/test/test_rpmmd_filetime.c b/test/test_rpmmd_filetime.c | ||
| new file mode 100644 | ||
| index 0000000..5a9df21 | ||
| --- /dev/null | ||
| +++ b/test/test_rpmmd_filetime.c | ||
| @@ -0,0 +1,100 @@ | ||
| +/* | ||
| + * test_rpmmd_filetime.c | ||
| + * | ||
| + * Regression test for the rpm-md primary.xml parser (ext/repo_rpmmd.c): | ||
| + * the package <time file="..."/> attribute must be recorded as | ||
| + * solvable:filetime. This value is a prerequisite for the DNF | ||
| + * virtual-snapshot plugins. | ||
| + * | ||
| + * If the parsing regresses, filetime is no longer stored and this test | ||
| + * fails, even while the rest of the ctest suite stays green. | ||
| + */ | ||
| + | ||
| +#include <stdio.h> | ||
| + | ||
| +#include "pool.h" | ||
| +#include "repo.h" | ||
| +#include "repo_rpmmd.h" | ||
| +#include "solv_xfopen.h" | ||
| +#include "knownid.h" | ||
| + | ||
| +/* Minimal rpm-md primary.xml with a single package that carries both a | ||
| + * build time and, crucially, a file publish time (<time file="123">). */ | ||
| +static const char primary_xml[] = | ||
| +"<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" | ||
| +"<metadata xmlns=\"http://linux.duke.edu/metadata/common\"" | ||
| +" xmlns:rpm=\"http://linux.duke.edu/metadata/rpm\" packages=\"1\">\n" | ||
| +" <package type=\"rpm\">\n" | ||
| +" <name>filetime-test</name>\n" | ||
| +" <arch>x86_64</arch>\n" | ||
| +" <version epoch=\"0\" ver=\"1.0\" rel=\"1\"/>\n" | ||
| +" <time file=\"123\" build=\"456\"/>\n" | ||
| +" </package>\n" | ||
| +"</metadata>\n"; | ||
| + | ||
| +int | ||
| +main(int argc, char **argv) | ||
| +{ | ||
| + Pool *pool; | ||
| + Repo *repo; | ||
| + FILE *fp; | ||
| + Id p; | ||
| + Solvable *s; | ||
| + unsigned long long filetime = 0, buildtime = 0; | ||
| + int nsolv = 0; | ||
| + | ||
| + (void)argc; | ||
| + (void)argv; | ||
| + | ||
| + pool = pool_create(); | ||
| + repo = repo_create(pool, "test"); | ||
| + | ||
| + fp = solv_fmemopen(primary_xml, sizeof(primary_xml) - 1, "r"); | ||
| + if (!fp) | ||
| + { | ||
| + fprintf(stderr, "FAIL: solv_fmemopen failed\n"); | ||
| + pool_free(pool); | ||
| + return 1; | ||
| + } | ||
| + if (repo_add_rpmmd(repo, fp, 0, 0) != 0) | ||
| + { | ||
| + fprintf(stderr, "FAIL: repo_add_rpmmd: %s\n", pool_errstr(pool)); | ||
| + fclose(fp); | ||
| + pool_free(pool); | ||
| + return 1; | ||
| + } | ||
| + fclose(fp); | ||
| + | ||
| + FOR_REPO_SOLVABLES(repo, p, s) | ||
| + { | ||
| + nsolv++; | ||
| + buildtime = solvable_lookup_num(s, SOLVABLE_BUILDTIME, 0); | ||
| + filetime = solvable_lookup_num(s, SOLVABLE_FILETIME, 0); | ||
| + } | ||
| + | ||
| + if (nsolv != 1) | ||
| + { | ||
| + fprintf(stderr, "FAIL: expected 1 solvable, parsed %d\n", nsolv); | ||
| + pool_free(pool); | ||
| + return 1; | ||
| + } | ||
| + /* Sanity: the pre-existing <time build="..."> handling must still work. */ | ||
| + if (buildtime != 456) | ||
| + { | ||
| + fprintf(stderr, "FAIL: solvable:buildtime = %llu, expected 456\n", buildtime); | ||
| + pool_free(pool); | ||
| + return 1; | ||
| + } | ||
| + /* The behavior under test: <time file="123"> must land in filetime. */ | ||
| + if (filetime != 123) | ||
| + { | ||
| + fprintf(stderr, "FAIL: solvable:filetime = %llu, expected 123 " | ||
| + "(<time file=\"123\"> not retained)\n", filetime); | ||
| + pool_free(pool); | ||
| + return 1; | ||
| + } | ||
| + | ||
| + printf("PASS: <time file=\"123\"> retained as solvable:filetime=%llu\n", filetime); | ||
| + pool_free(pool); | ||
| + return 0; | ||
| +} | ||
|
|
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -2,7 +2,7 @@ | |
| ## (rpmautospec version 0.8.3) | ||
| ## RPMAUTOSPEC: autorelease, autochangelog | ||
| %define autorelease(e:s:pb:n) %{?-p:0.}%{lua: | ||
| release_number = 4; | ||
| release_number = 5; | ||
| base_release_number = tonumber(rpm.expand("%{?-b*}%{!?-b:1}")); | ||
| print(release_number + base_release_number - 1); | ||
| }%{?-e:.%{-e*}}%{?-s:.%{-s*}}%{!?-n:%{?dist}} | ||
|
|
@@ -89,6 +89,7 @@ BuildRequires: libzstd-devel | |
| BuildRequires: pkgconfig(zck) | ||
| %endif | ||
|
|
||
| Patch1: 0002-Make-file-time-available-for-dnf-plugins.patch | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. question (non-blocking): @liunan-ms @reubeno @dmcilvaney Is this the correct location in the spec file to expect the new patch file inclusion after running through Non-blocking since I did confirm the patch file is applied during the RPM build process. |
||
| %description | ||
| A free package dependency solver using a satisfiability algorithm. The | ||
| library is based on two major, but independent, blocks: | ||
|
|
@@ -314,6 +315,10 @@ export LD_LIBRARY_PATH=%{buildroot}%{_libdir} | |
|
|
||
| %changelog | ||
| ## START: Generated by rpmautospec | ||
| * Thu Jul 09 2026 Matt Bearup <mbearup@microsoft.com> - 0.7.35-5 | ||
| - feat(libsolv): Enable libsolv to expose file time to dnf plugins; a | ||
| prerequisite for supporting virtual snapshots | ||
|
|
||
| * Thu Apr 30 2026 Daniel McIlvaney <damcilva@microsoft.com> - 0.7.35-4 | ||
| - feat: introduce deterministic commit resolution via Azure Linux lock file | ||
|
|
||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.