]> git.ipfire.org Git - people/stevee/pakfire.git/commitdiff
packages: Create a unified numbers function
authorMichael Tremer <michael.tremer@ipfire.org>
Tue, 25 Oct 2022 17:57:32 +0000 (17:57 +0000)
committerMichael Tremer <michael.tremer@ipfire.org>
Tue, 25 Oct 2022 17:57:32 +0000 (17:57 +0000)
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
src/_pakfire/package.c
src/libpakfire/archive.c
src/libpakfire/db.c
src/libpakfire/include/pakfire/package.h
src/libpakfire/libpakfire.sym
src/libpakfire/package.c
src/libpakfire/packager.c
src/libpakfire/parser.c
src/libpakfire/transaction.c
tests/libpakfire/makefile.c

index 760170179bcb84c9d39c3771665bc8c41dd14d15..69496ccc6b3b922542d1105b30396c0f7f085b5d 100644 (file)
@@ -323,7 +323,7 @@ static void Package_set_filename(PackageObject* self, PyObject* value) {
 }
 
 static PyObject* Package_get_downloadsize(PackageObject* self) {
-       size_t size = pakfire_package_get_downloadsize(self->package);
+       size_t size = pakfire_package_get_num(self->package, PAKFIRE_PKG_DOWNLOADSIZE, 0);
 
        return PyLong_FromUnsignedLongLong(size);
 }
@@ -331,11 +331,11 @@ static PyObject* Package_get_downloadsize(PackageObject* self) {
 static void Package_set_downloadsize(PackageObject* self, PyObject* value) {
        unsigned long downloadsize = PyLong_AsUnsignedLong(value);
 
-       pakfire_package_set_downloadsize(self->package, downloadsize);
+       pakfire_package_set_num(self->package, PAKFIRE_PKG_DOWNLOADSIZE, downloadsize);
 }
 
 static PyObject* Package_get_installsize(PackageObject* self) {
-       size_t size = pakfire_package_get_installsize(self->package);
+       size_t size = pakfire_package_get_num(self->package, PAKFIRE_PKG_INSTALLSIZE, 0);
 
        return PyLong_FromUnsignedLongLong(size);
 }
@@ -343,7 +343,7 @@ static PyObject* Package_get_installsize(PackageObject* self) {
 static void Package_set_installsize(PackageObject* self, PyObject* value) {
        unsigned long installsize = PyLong_AsUnsignedLong(value);
 
-       pakfire_package_set_installsize(self->package, installsize);
+       pakfire_package_set_num(self->package, PAKFIRE_PKG_INSTALLSIZE, installsize);
 }
 
 static PyObject* Package_get_size(PackageObject* self) {
@@ -367,7 +367,7 @@ static void Package_set_buildhost(PackageObject* self, PyObject* value) {
 }
 
 static PyObject* Package_get_buildtime(PackageObject* self) {
-       time_t build_time = pakfire_package_get_build_time(self->package);
+       time_t build_time = pakfire_package_get_num(self->package, PAKFIRE_PKG_BUILD_TIME, 0);
 
        return PyLong_FromUnsignedLongLong(build_time);
 }
@@ -375,7 +375,7 @@ static PyObject* Package_get_buildtime(PackageObject* self) {
 static void Package_set_buildtime(PackageObject* self, PyObject* value) {
        time_t build_time = PyLong_AsUnsignedLongLong(value);
 
-       pakfire_package_set_build_time(self->package, build_time);
+       pakfire_package_set_num(self->package, PAKFIRE_PKG_BUILD_TIME, build_time);
 }
 
 static PyObject* Package_get_repo(PackageObject* self) {
index a37cf54e4dbc7355bf4431ff30041d8036215b93..cbcabb0ba6a944ec05f101c01e9632c7e52b7c47 100644 (file)
@@ -1166,8 +1166,11 @@ static int pakfire_archive_make_package_from_json(struct pakfire_archive* archiv
 
        // Installed package size
        size_t installsize = pakfire_archive_metadata_get_int64(archive, "size", NULL);
-       if (installsize)
-               pakfire_package_set_installsize(pkg, installsize);
+       if (installsize) {
+               r = pakfire_package_set_num(pkg, PAKFIRE_PKG_INSTALLSIZE, installsize);
+               if (r)
+                       goto ERROR;
+       }
 
        // Build Host
        const char* build_host = pakfire_archive_metadata_get(archive, "build", "host");
@@ -1187,8 +1190,11 @@ static int pakfire_archive_make_package_from_json(struct pakfire_archive* archiv
 
        // Build Time
        time_t build_time = pakfire_archive_metadata_get_int64(archive, "build", "time");
-       if (build_time)
-               pakfire_package_set_build_time(pkg, build_time);
+       if (build_time) {
+               r = pakfire_package_set_num(pkg, PAKFIRE_PKG_BUILD_TIME, build_time);
+               if (r)
+                       goto ERROR;
+       }
 
        // Source package
        const char* source_name = pakfire_archive_metadata_get(archive, "build", "source-name");
@@ -1414,7 +1420,8 @@ static int pakfire_archive_make_legacy_package(struct pakfire_archive* archive,
                goto ERROR;
 
        // Get package size
-       pakfire_package_set_downloadsize(pkg, pakfire_archive_get_size(archive));
+       pakfire_package_set_num(pkg, PAKFIRE_PKG_DOWNLOADSIZE,
+               pakfire_archive_get_size(archive));
 
        // Get install size
        char* size = pakfire_archive_get(archive, "package", "size");
@@ -1422,7 +1429,7 @@ static int pakfire_archive_make_legacy_package(struct pakfire_archive* archive,
                size_t s = strtoul(size, NULL, 10);
                free(size);
 
-               pakfire_package_set_installsize(pkg, s);
+               pakfire_package_set_num(pkg, PAKFIRE_PKG_INSTALLSIZE, s);
        }
 
        // Set vendor
@@ -1451,7 +1458,7 @@ static int pakfire_archive_make_legacy_package(struct pakfire_archive* archive,
                time_t t = strtoull(build_time, NULL, 10);
                free(build_time);
 
-               pakfire_package_set_build_time(pkg, t);
+               pakfire_package_set_num(pkg, PAKFIRE_PKG_BUILD_TIME, t);
        }
 
        // Relations
index defcc5417f4f5fd4e5d34036b3b6634fa199668d..2b7fa90860d2ab6bad1367ea3779f343786f4060 100644 (file)
@@ -1374,7 +1374,7 @@ int pakfire_db_add_package(struct pakfire_db* db,
        }
 
        // Bind size
-       unsigned long long size = pakfire_package_get_downloadsize(pkg);
+       unsigned long long size = pakfire_package_get_num(pkg, PAKFIRE_PKG_DOWNLOADSIZE, 0);
 
        r = sqlite3_bind_int64(stmt, 6, size);
        if (r) {
@@ -1383,7 +1383,7 @@ int pakfire_db_add_package(struct pakfire_db* db,
        }
 
        // Bind installed size
-       unsigned long long inst_size = pakfire_package_get_installsize(pkg);
+       unsigned long long inst_size = pakfire_package_get_num(pkg, PAKFIRE_PKG_INSTALLSIZE, 0);
 
        r = sqlite3_bind_int64(stmt, 7, inst_size);
        if (r) {
@@ -1472,7 +1472,7 @@ int pakfire_db_add_package(struct pakfire_db* db,
        }
 
        // Bind build_time
-       time_t build_time = pakfire_package_get_build_time(pkg);
+       time_t build_time = pakfire_package_get_num(pkg, PAKFIRE_PKG_BUILD_TIME, 0);
 
        r = sqlite3_bind_int64(stmt, 16, build_time);
        if (r) {
@@ -1751,8 +1751,11 @@ static int pakfire_db_load_package(struct pakfire_db* db, struct pakfire_repo* r
 
        // ID
        uint64_t id = sqlite3_column_int64(stmt, 3);
-       if (id)
-               pakfire_package_set_dbid(pkg, id);
+       if (id) {
+               r = pakfire_package_set_num(pkg, PAKFIRE_PKG_DBID, id);
+               if (r)
+                       goto ERROR;
+       }
 
        // Groups
        const char* groups = (const char*)sqlite3_column_text(stmt, 4);
@@ -1773,13 +1776,17 @@ static int pakfire_db_load_package(struct pakfire_db* db, struct pakfire_repo* r
        // Size
        size_t size = sqlite3_column_int64(stmt, 6);
        if (size) {
-               pakfire_package_set_downloadsize(pkg, size);
+               r = pakfire_package_set_num(pkg, PAKFIRE_PKG_DOWNLOADSIZE, size);
+               if (r)
+                       goto ERROR;
        }
 
        // Installed size
        size = sqlite3_column_int64(stmt, 7);
        if (size) {
-               pakfire_package_set_installsize(pkg, size);
+               r = pakfire_package_set_num(pkg, PAKFIRE_PKG_INSTALLSIZE, size);
+               if (r)
+                       goto ERROR;
        }
 
        // Digest type
@@ -1845,13 +1852,17 @@ static int pakfire_db_load_package(struct pakfire_db* db, struct pakfire_repo* r
        // Build Time
        time_t build_time = sqlite3_column_int64(stmt, 16);
        if (build_time) {
-               pakfire_package_set_build_time(pkg, build_time);
+               r = pakfire_package_set_num(pkg, PAKFIRE_PKG_BUILD_TIME, build_time);
+               if (r)
+                       goto ERROR;
        }
 
        // Install Time
        time_t install_time = sqlite3_column_int64(stmt, 17);
        if (install_time) {
-               pakfire_package_set_install_time(pkg, install_time);
+               r = pakfire_package_set_num(pkg, PAKFIRE_PKG_INSTALLTIME, install_time);
+               if (r)
+                       goto ERROR;
        }
 
        // installed by user?
@@ -2301,7 +2312,7 @@ int pakfire_db_package_filelist(struct pakfire_db* db, struct pakfire_filelist**
        int r = 1;
 
        // Fetch the package ID
-       uint64_t id = pakfire_package_get_dbid(pkg);
+       uint64_t id = pakfire_package_get_num(pkg, PAKFIRE_PKG_DBID, 0);
        if (!id) {
                ERROR(db->pakfire, "Package did not have an ID\n");
                return 1;
index 6a3a3dc3875faf1ad0c7e1b0f20cf940ab3d306e..bf633d0faa4e6dbb0f3dfb577cbd59445e9ffde1 100644 (file)
@@ -38,6 +38,7 @@ enum pakfire_package_key {
        PAKFIRE_PKG_EVR,
        PAKFIRE_PKG_ARCH,
        PAKFIRE_PKG_NEVRA,
+       PAKFIRE_PKG_DBID,
        PAKFIRE_PKG_UUID,
        PAKFIRE_PKG_SUMMARY,
        PAKFIRE_PKG_DESCRIPTION,
@@ -48,8 +49,12 @@ enum pakfire_package_key {
        PAKFIRE_PKG_DISTRO,
        PAKFIRE_PKG_MAINTAINER,
        PAKFIRE_PKG_FILENAME,
+       PAKFIRE_PKG_DOWNLOADSIZE,
+       PAKFIRE_PKG_INSTALLSIZE,
+       PAKFIRE_PKG_INSTALLTIME,
        PAKFIRE_PKG_BUILD_HOST,
        PAKFIRE_PKG_BUILD_ID,
+       PAKFIRE_PKG_BUILD_TIME,
        PAKFIRE_PKG_SOURCE_PKG,
        PAKFIRE_PKG_SOURCE_NAME,
        PAKFIRE_PKG_SOURCE_EVR,
@@ -79,21 +84,19 @@ int pakfire_package_get_uuid(struct pakfire_package* pkg,
 int pakfire_package_set_uuid(struct pakfire_package* pkg,
        const enum pakfire_package_key key, const uuid_t uuid);
 
+// Numeric
+unsigned long long pakfire_package_get_num(struct pakfire_package* pkg,
+       const enum pakfire_package_key key, unsigned long long notfound);
+int pakfire_package_set_num(struct pakfire_package* pkg,
+       const enum pakfire_package_key key, unsigned long long num);
+
 const unsigned char* pakfire_package_get_digest(struct pakfire_package* pkg,
        enum pakfire_digest_types* type, size_t* length);
 int pakfire_package_set_digest(struct pakfire_package* pkg,
        enum pakfire_digest_types type, const unsigned char* digest, const size_t length);
 const char* pakfire_package_get_path(struct pakfire_package* pkg);
 void pakfire_package_set_path(struct pakfire_package* pkg, const char* path);
-size_t pakfire_package_get_downloadsize(struct pakfire_package* pkg);
-void pakfire_package_set_downloadsize(struct pakfire_package* pkg, size_t downloadsize);
-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);
-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);
-void pakfire_package_set_install_time(struct pakfire_package* pkg, time_t install_time);
 
 char** pakfire_package_get_provides(struct pakfire_package* pkg);
 char** pakfire_package_get_prerequires(struct pakfire_package* pkg);
@@ -134,9 +137,6 @@ enum pakfire_package_dump_flags {
 int pakfire_package_create_from_solvable(struct pakfire_package** package,
        struct pakfire* pakfire, Id id);
 
-uint64_t pakfire_package_get_dbid(struct pakfire_package* pkg);
-void pakfire_package_set_dbid(struct pakfire_package* pkg, uint64_t id);
-
 Id pakfire_package_id(struct pakfire_package* pkg);
 int pakfire_package_is_source(struct pakfire_package* pkg);
 
index 8154a84f367c0835678e7da54dee6c19ef894001..00ff171d122566a10dfb565f30a0e3cf947e791f 100644 (file)
@@ -167,16 +167,13 @@ global:
        pakfire_package_create;
        pakfire_package_dump;
        pakfire_package_eq;
-       pakfire_package_get_build_time;
        pakfire_package_get_cache_path;
        pakfire_package_get_conflicts;
        pakfire_package_get_digest;
-       pakfire_package_get_downloadsize;
        pakfire_package_get_enhances;
        pakfire_package_get_filelist;
        pakfire_package_get_location;
-       pakfire_package_get_installsize;
-       pakfire_package_get_install_time;
+       pakfire_package_get_num;
        pakfire_package_get_obsoletes;
        pakfire_package_get_pakfire;
        pakfire_package_get_path;
@@ -192,12 +189,9 @@ global:
        pakfire_package_get_supplements;
        pakfire_package_get_uuid;
        pakfire_package_ref;
-       pakfire_package_set_build_time;
        pakfire_package_set_checksum;
-       pakfire_package_set_downloadsize;
        pakfire_package_set_filelist;
-       pakfire_package_set_installsize;
-       pakfire_package_set_install_time;
+       pakfire_package_set_num;
        pakfire_package_set_path;
        pakfire_package_set_string;
        pakfire_package_set_uuid;
index b52b74a11d39acf004db05abc0e0485c2f913b1f..812a43e231d11bb1d09df3ae2f87ac8d66cf1326 100644 (file)
@@ -433,6 +433,9 @@ PAKFIRE_EXPORT const char* pakfire_package_get_string(
                case PAKFIRE_PKG_SOURCE_ARCH:
                        ret = solvable_lookup_str(s, SOLVABLE_SOURCEARCH);
                        break;
+
+               default:
+                       break;
        }
 
        return ret;
@@ -543,6 +546,9 @@ PAKFIRE_EXPORT int pakfire_package_set_string(
                case PAKFIRE_PKG_SOURCE_ARCH:
                        id = SOLVABLE_SOURCEARCH;
                        break;
+
+               default:
+                       break;
        }
 
        // Check if we have found a valid ID
@@ -612,25 +618,70 @@ PAKFIRE_EXPORT int pakfire_package_set_uuid(struct pakfire_package* pkg,
        }
 }
 
-static unsigned long long pakfire_package_get_num(struct pakfire_package* pkg, Id type) {
-       pakfire_package_internalize_repo(pkg);
+PAKFIRE_EXPORT unsigned long long pakfire_package_get_num(struct pakfire_package* pkg,
+               const enum pakfire_package_key key, unsigned long long notfound) {
+       Id id = ID_NULL;
 
-       Solvable* s = get_solvable(pkg);
-       return solvable_lookup_num(s, type, 0);
-}
+       switch (key) {
+               case PAKFIRE_PKG_DOWNLOADSIZE:
+                       id = SOLVABLE_DOWNLOADSIZE;
+                       break;
+
+               case PAKFIRE_PKG_INSTALLSIZE:
+                       id = SOLVABLE_INSTALLSIZE;
+                       break;
+
+               case PAKFIRE_PKG_BUILD_TIME:
+                       id = SOLVABLE_BUILDTIME;
+                       break;
+
+               case PAKFIRE_PKG_INSTALLTIME:
+                       id = SOLVABLE_INSTALLTIME;
+                       break;
+
+               // Return zero for all unhandled keys
+               default:
+                       errno = EINVAL;
+                       return 1;
+       }
 
-static void pakfire_package_set_num(struct pakfire_package* pkg, Id type, unsigned long long value) {
        Solvable* s = get_solvable(pkg);
 
-       solvable_set_num(s, type, value);
+       return solvable_lookup_num(s, id, notfound);
 }
 
-uint64_t pakfire_package_get_dbid(struct pakfire_package* pkg) {
-       return pakfire_package_get_num(pkg, RPM_RPMDBID);
-}
+PAKFIRE_EXPORT int pakfire_package_set_num(struct pakfire_package* pkg,
+               const enum pakfire_package_key key, unsigned long long num) {
+       Id id = ID_NULL;
+
+       switch (key) {
+               case PAKFIRE_PKG_DOWNLOADSIZE:
+                       id = SOLVABLE_DOWNLOADSIZE;
+                       break;
 
-void pakfire_package_set_dbid(struct pakfire_package* pkg, uint64_t id) {
-       pakfire_package_set_num(pkg, RPM_RPMDBID, id);
+               case PAKFIRE_PKG_INSTALLSIZE:
+                       id = SOLVABLE_INSTALLSIZE;
+                       break;
+
+               case PAKFIRE_PKG_BUILD_TIME:
+                       id = SOLVABLE_BUILDTIME;
+                       break;
+
+               case PAKFIRE_PKG_INSTALLTIME:
+                       id = SOLVABLE_INSTALLTIME;
+                       break;
+
+               // Return zero for all unhandled keys
+               default:
+                       errno = EINVAL;
+                       return 1;
+       }
+
+       Solvable* s = get_solvable(pkg);
+
+       solvable_set_num(s, id, num);
+
+       return 0;
 }
 
 static enum pakfire_digest_types pakfire_package_id2digest(Id id) {
@@ -768,43 +819,11 @@ int pakfire_package_is_installed(struct pakfire_package* pkg) {
        return pool->installed == s->repo;
 }
 
-PAKFIRE_EXPORT size_t pakfire_package_get_downloadsize(struct pakfire_package* pkg) {
-       return pakfire_package_get_num(pkg, SOLVABLE_DOWNLOADSIZE);
-}
-
-PAKFIRE_EXPORT void pakfire_package_set_downloadsize(struct pakfire_package* pkg, size_t downloadsize) {
-       pakfire_package_set_num(pkg, SOLVABLE_DOWNLOADSIZE, downloadsize);
-}
-
-PAKFIRE_EXPORT size_t pakfire_package_get_installsize(struct pakfire_package* pkg) {
-       return pakfire_package_get_num(pkg, SOLVABLE_INSTALLSIZE);
-}
-
-PAKFIRE_EXPORT void pakfire_package_set_installsize(struct pakfire_package* pkg, size_t installsize) {
-       pakfire_package_set_num(pkg, SOLVABLE_INSTALLSIZE, installsize);
-}
-
 PAKFIRE_EXPORT size_t pakfire_package_get_size(struct pakfire_package* pkg) {
        if (pakfire_package_is_installed(pkg))
-               return pakfire_package_get_installsize(pkg);
-
-       return pakfire_package_get_downloadsize(pkg);
-}
+               return pakfire_package_get_num(pkg, PAKFIRE_PKG_INSTALLSIZE, 0);
 
-PAKFIRE_EXPORT time_t pakfire_package_get_build_time(struct pakfire_package* pkg) {
-       return pakfire_package_get_num(pkg, SOLVABLE_BUILDTIME);
-}
-
-PAKFIRE_EXPORT void pakfire_package_set_build_time(struct pakfire_package* pkg, time_t build_time) {
-       pakfire_package_set_num(pkg, SOLVABLE_BUILDTIME, build_time);
-}
-
-PAKFIRE_EXPORT time_t pakfire_package_get_install_time(struct pakfire_package* pkg) {
-       return pakfire_package_get_num(pkg, SOLVABLE_INSTALLTIME);
-}
-
-PAKFIRE_EXPORT void pakfire_package_set_install_time(struct pakfire_package* pkg, time_t install_time) {
-       pakfire_package_set_num(pkg, SOLVABLE_INSTALLTIME, install_time);
+       return pakfire_package_get_num(pkg, PAKFIRE_PKG_DOWNLOADSIZE, 0);
 }
 
 static char** pakfire_package_get_relationlist(
@@ -1095,13 +1114,13 @@ PAKFIRE_EXPORT char* pakfire_package_dump(struct pakfire_package* pkg, int flags
 
        // Installed Size
        if (pakfire_package_is_installed(pkg)) {
-               size_t installsize = pakfire_package_get_installsize(pkg);
+               size_t installsize = pakfire_package_get_num(pkg, PAKFIRE_PKG_INSTALLSIZE, 0);
                if (installsize)
                        pakfire_package_dump_add_line_size(&string, _("Installed Size"), installsize);
 
        // Download Size
        } else {
-               size_t downloadsize = pakfire_package_get_downloadsize(pkg);
+               size_t downloadsize = pakfire_package_get_num(pkg, PAKFIRE_PKG_DOWNLOADSIZE, 0);
                if (downloadsize)
                        pakfire_package_dump_add_line_size(&string, _("Download Size"), downloadsize);
        }
@@ -1144,10 +1163,9 @@ PAKFIRE_EXPORT char* pakfire_package_dump(struct pakfire_package* pkg, int flags
 
        if (flags & PAKFIRE_PKG_DUMP_LONG) {
                // Install Time
-               time_t install_time = pakfire_package_get_install_time(pkg);
-               if (install_time) {
+               time_t install_time = pakfire_package_get_num(pkg, PAKFIRE_PKG_INSTALLTIME, 0);
+               if (install_time)
                        pakfire_package_dump_add_line_date(&string, _("Install Time"), install_time);
-               }
 
                // Distribution
                const char* distro = pakfire_package_get_string(pkg, PAKFIRE_PKG_DISTRO);
@@ -1207,8 +1225,9 @@ PAKFIRE_EXPORT char* pakfire_package_dump(struct pakfire_package* pkg, int flags
                        pakfire_package_dump_add_line(&string, _("Source Package"), source_package);
 
                // Build time
-               time_t build_time = pakfire_package_get_build_time(pkg);
-               pakfire_package_dump_add_line_date(&string, _("Build Time"), build_time);
+               time_t build_time = pakfire_package_get_num(pkg, PAKFIRE_PKG_BUILD_TIME, 0);
+               if (build_time)
+                       pakfire_package_dump_add_line_date(&string, _("Build Time"), build_time);
 
                // Build host
                const char* build_host = pakfire_package_get_string(pkg, PAKFIRE_PKG_BUILD_HOST);
@@ -1625,7 +1644,7 @@ static int pakfire_package_add_build_metadata(struct pakfire_package* pkg,
        }
 
        // Write build host
-       time_t build_time = pakfire_package_get_build_time(pkg);
+       time_t build_time = pakfire_package_get_num(pkg, PAKFIRE_PKG_BUILD_TIME, 0);
        if (build_time) {
                r = pakfire_json_add_integer(pkg->pakfire, object, "time", build_time);
                if (r)
@@ -1769,7 +1788,8 @@ struct json_object* pakfire_package_to_json(struct pakfire_package* pkg) {
        }
 
        // Installed package size
-       size_t installsize = pakfire_package_get_installsize(pkg);
+       size_t installsize = pakfire_package_get_num(pkg, PAKFIRE_PKG_INSTALLSIZE, 0);
+
        r = pakfire_json_add_integer(pkg->pakfire, md, "size", installsize);
        if (r)
                goto ERROR;
index eb6427f041276796f46d0659ecb985d7a639b24d..71f10b40dcd0994c521959ad9dd6837ef503e317 100644 (file)
@@ -119,7 +119,7 @@ int pakfire_packager_create(struct pakfire_packager** packager,
        pakfire_package_set_string(pkg, PAKFIRE_PKG_BUILD_HOST, pakfire_hostname());
 
        // Set build time
-       pakfire_package_set_build_time(pkg, p->time_created);
+       pakfire_package_set_num(pkg, PAKFIRE_PKG_BUILD_TIME, p->time_created);
 
        // Create reader
        p->reader = pakfire_make_archive_disk_reader(p->pakfire, 1);
@@ -371,7 +371,9 @@ int pakfire_packager_finish(struct pakfire_packager* packager, FILE* f) {
        const size_t installsize = pakfire_filelist_total_size(packager->filelist);
 
        // Store total install size
-       pakfire_package_set_installsize(packager->pkg, installsize);
+       r = pakfire_package_set_num(packager->pkg, PAKFIRE_PKG_INSTALLSIZE, installsize);
+       if (r)
+               goto ERROR;
 
        // Dump package metadata
        char* dump = pakfire_package_dump(packager->pkg, PAKFIRE_PKG_DUMP_LONG);
index 9b3c3b11ac18e4a3ca5c8d264a40c3f9756335c6..e861c08ecd6f3d363a9019643beb1639c2087e28 100644 (file)
@@ -934,7 +934,7 @@ int pakfire_parser_create_package(struct pakfire_parser* parser,
        // Set build time
        time_t now = time(NULL);
 
-       pakfire_package_set_build_time(*pkg, now);
+       pakfire_package_set_num(*pkg, PAKFIRE_PKG_BUILD_TIME, now);
 
        // Assign more attributes
        const struct attribute {
index d14d33260c600a6e1a3b4e13c361476c4545946c..33aebd36a44f7f34af6f164d6c77e5e76e9a0a5d 100644 (file)
@@ -329,7 +329,8 @@ static ssize_t pakfire_transaction_downloadsize(struct pakfire_transaction* tran
        ssize_t size = 0;
 
        for (unsigned int i = 0; i < transaction->num; i++)
-               size += pakfire_package_get_downloadsize(transaction->packages[i]);
+               size += pakfire_package_get_num(
+                       transaction->packages[i], PAKFIRE_PKG_DOWNLOADSIZE, 0);
 
        return size;
 }
index ea12c3c82c8518cd4159e48a80c3f9afaea3c3ee..a2b9d276529546fa88a3fa8b81a9340f2fab9859 100644 (file)
@@ -241,7 +241,7 @@ static int test_dist_dummy(const struct test* t) {
        ASSERT(description);
 
        // Check size
-       size_t installed_size = pakfire_package_get_installsize(package);
+       size_t installed_size = pakfire_package_get_num(package, PAKFIRE_PKG_INSTALLSIZE, 0);
        ASSERT(installed_size == 0);
 
        // Fetch the filelist