]> git.ipfire.org Git - pakfire.git/commitdiff
packages: Replace pakfire_package_{g,s}_build_id with string function
authorMichael Tremer <michael.tremer@ipfire.org>
Tue, 25 Oct 2022 16:42:18 +0000 (16:42 +0000)
committerMichael Tremer <michael.tremer@ipfire.org>
Tue, 25 Oct 2022 16:42:18 +0000 (16:42 +0000)
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
src/libpakfire/archive.c
src/libpakfire/include/pakfire/package.h
src/libpakfire/libpakfire.sym
src/libpakfire/package.c

index 9221f450a54b2cd375dc70cc52ec6aef57080844..2ddaa158981ffc41ecc269551dcfbd00badb6832 100644 (file)
@@ -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);
        }
 
index c142a8683e51be52c3a4abec854a6d6ca29086e5..5d3e52653c83ba9ead073c6f6563f31d459ce449 100644 (file)
@@ -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);
index ede1baa8864c8486bf9346424ff45d4aed333dc4..20b2b3def540460de9a746fb30e558a52da011b3 100644 (file)
@@ -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;
index d85770758f31e34f27ef80af2a4ef72d3e5bd163..81cf4e3c7cb10198bdbddb521efe5728d2bba292 100644 (file)
@@ -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)