}
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);
}
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);
}
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) {
}
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);
}
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) {
// 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");
// 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");
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");
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
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
}
// 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) {
}
// 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) {
}
// 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) {
// 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);
// 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
// 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?
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;
PAKFIRE_PKG_EVR,
PAKFIRE_PKG_ARCH,
PAKFIRE_PKG_NEVRA,
+ PAKFIRE_PKG_DBID,
PAKFIRE_PKG_UUID,
PAKFIRE_PKG_SUMMARY,
PAKFIRE_PKG_DESCRIPTION,
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,
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);
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);
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;
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;
case PAKFIRE_PKG_SOURCE_ARCH:
ret = solvable_lookup_str(s, SOLVABLE_SOURCEARCH);
break;
+
+ default:
+ break;
}
return ret;
case PAKFIRE_PKG_SOURCE_ARCH:
id = SOLVABLE_SOURCEARCH;
break;
+
+ default:
+ break;
}
// Check if we have found a valid ID
}
}
-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) {
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(
// 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);
}
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);
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);
}
// 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)
}
// 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;
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);
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);
// 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 {
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;
}
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