From: Michael Tremer Date: Tue, 25 Oct 2022 16:42:18 +0000 (+0000) Subject: packages: Replace pakfire_package_{g,s}_build_id with string function X-Git-Tag: 0.9.28~214 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=70f6900d12f885730f90429ac0ea1a85e3f15810;p=pakfire.git packages: Replace pakfire_package_{g,s}_build_id with string function Signed-off-by: Michael Tremer --- diff --git a/src/libpakfire/archive.c b/src/libpakfire/archive.c index 9221f450a..2ddaa1589 100644 --- a/src/libpakfire/archive.c +++ b/src/libpakfire/archive.c @@ -1179,8 +1179,11 @@ static int pakfire_archive_make_package_from_json(struct pakfire_archive* archiv // Build ID const char* build_id = pakfire_archive_metadata_get(archive, "build", "id"); - if (build_id) - pakfire_package_set_build_id(pkg, build_id); + if (build_id) { + r = pakfire_package_set_string(pkg, PAKFIRE_PKG_BUILD_ID, build_id); + if (r) + goto ERROR; + } // Build Time time_t build_time = pakfire_archive_metadata_get_int64(archive, "build", "time"); @@ -1429,7 +1432,7 @@ static int pakfire_archive_make_legacy_package(struct pakfire_archive* archive, // Set build ID char* build_id = pakfire_archive_get(archive, "build", "id"); if (build_id) { - pakfire_package_set_build_id(pkg, build_id); + pakfire_package_set_string(pkg, PAKFIRE_PKG_BUILD_ID, build_id); free(build_id); } diff --git a/src/libpakfire/include/pakfire/package.h b/src/libpakfire/include/pakfire/package.h index c142a8683..5d3e52653 100644 --- a/src/libpakfire/include/pakfire/package.h +++ b/src/libpakfire/include/pakfire/package.h @@ -47,6 +47,7 @@ enum pakfire_package_key { PAKFIRE_PKG_MAINTAINER, PAKFIRE_PKG_FILENAME, PAKFIRE_PKG_BUILD_HOST, + PAKFIRE_PKG_BUILD_ID, }; int pakfire_package_create(struct pakfire_package** package, struct pakfire* pakfire, @@ -76,8 +77,6 @@ void pakfire_package_set_downloadsize(struct pakfire_package* pkg, size_t downlo size_t pakfire_package_get_installsize(struct pakfire_package* pkg); void pakfire_package_set_installsize(struct pakfire_package* pkg, size_t installsize); size_t pakfire_package_get_size(struct pakfire_package* pkg); -const char* pakfire_package_get_build_id(struct pakfire_package* pkg); -void pakfire_package_set_build_id(struct pakfire_package* pkg, const char* build_id); time_t pakfire_package_get_build_time(struct pakfire_package* pkg); void pakfire_package_set_build_time(struct pakfire_package* pkg, time_t build_time); time_t pakfire_package_get_install_time(struct pakfire_package* pkg); diff --git a/src/libpakfire/libpakfire.sym b/src/libpakfire/libpakfire.sym index ede1baa88..20b2b3def 100644 --- a/src/libpakfire/libpakfire.sym +++ b/src/libpakfire/libpakfire.sym @@ -167,7 +167,6 @@ global: pakfire_package_create; pakfire_package_dump; pakfire_package_eq; - pakfire_package_get_build_id; pakfire_package_get_build_time; pakfire_package_get_cache_path; pakfire_package_get_conflicts; @@ -196,7 +195,6 @@ global: pakfire_package_get_suggests; pakfire_package_get_supplements; pakfire_package_ref; - pakfire_package_set_build_id; pakfire_package_set_build_time; pakfire_package_set_checksum; pakfire_package_set_downloadsize; diff --git a/src/libpakfire/package.c b/src/libpakfire/package.c index d85770758..81cf4e3c7 100644 --- a/src/libpakfire/package.c +++ b/src/libpakfire/package.c @@ -399,6 +399,10 @@ PAKFIRE_EXPORT const char* pakfire_package_get_string( case PAKFIRE_PKG_BUILD_HOST: ret = solvable_lookup_str(s, SOLVABLE_BUILDHOST); break; + + case PAKFIRE_PKG_BUILD_ID: + ret = solvable_lookup_str(s, SOLVABLE_BUILDVERSION); + break; } return ret; @@ -485,6 +489,10 @@ PAKFIRE_EXPORT int pakfire_package_set_string( case PAKFIRE_PKG_BUILD_HOST: id = SOLVABLE_BUILDHOST; break; + + case PAKFIRE_PKG_BUILD_ID: + id = SOLVABLE_BUILDVERSION; + break; } // Check if we have found a valid ID @@ -685,21 +693,13 @@ PAKFIRE_EXPORT size_t pakfire_package_get_size(struct pakfire_package* pkg) { return pakfire_package_get_downloadsize(pkg); } -PAKFIRE_EXPORT const char* pakfire_package_get_build_id(struct pakfire_package* pkg) { - return pakfire_package_get_string(pkg, SOLVABLE_BUILDVERSION); -} - -PAKFIRE_EXPORT void pakfire_package_set_build_id(struct pakfire_package* pkg, const char* build_id) { - pakfire_package_set_string(pkg, SOLVABLE_BUILDVERSION, build_id); -} - void pakfire_package_set_build_id_from_uuid(struct pakfire_package* pkg, uuid_t* build_id) { char buffer[UUID_STR_LEN]; // Convert the UUID to string uuid_unparse_lower(*build_id, buffer); - pakfire_package_set_build_id(pkg, buffer); + pakfire_package_set_string(pkg, PAKFIRE_PKG_BUILD_ID, buffer); } PAKFIRE_EXPORT time_t pakfire_package_get_build_time(struct pakfire_package* pkg) { @@ -1126,7 +1126,7 @@ PAKFIRE_EXPORT char* pakfire_package_dump(struct pakfire_package* pkg, int flags pakfire_package_dump_add_line(&string, _("UUID"), uuid); // Build ID - const char* build_id = pakfire_package_get_build_id(pkg); + const char* build_id = pakfire_package_get_string(pkg, PAKFIRE_PKG_BUILD_ID); if (build_id) pakfire_package_dump_add_line(&string, _("Build ID"), build_id); @@ -1573,7 +1573,7 @@ static int pakfire_package_add_build_metadata(struct pakfire_package* pkg, } // Write build id - const char* build_id = pakfire_package_get_build_id(pkg); + const char* build_id = pakfire_package_get_string(pkg, PAKFIRE_PKG_BUILD_ID); if (build_id) { r = pakfire_json_add_string(pkg->pakfire, object, "id", build_id); if (r)