}
// Set build ID
- pakfire_package_set_build_id_from_uuid(pkg, &build->id);
+ pakfire_package_set_uuid(pkg, PAKFIRE_PKG_BUILD_ID, build->id);
// Set source package
const char* source_name = pakfire_parser_get(makefile, NULL, "name");
#include <time.h>
+#include <uuid/uuid.h>
+
struct pakfire_package;
#include <pakfire/digest.h>
int pakfire_package_cmp(struct pakfire_package* pkg1, struct pakfire_package* pkg2);
int pakfire_package_evr_cmp(struct pakfire_package* pkg1, struct pakfire_package* pkg2);
+// String
const char* pakfire_package_get_string(struct pakfire_package* pkg,
const enum pakfire_package_key key);
int pakfire_package_set_string(struct pakfire_package* pkg,
const enum pakfire_package_key key, const char* value);
+// UUID
+int pakfire_package_get_uuid(struct pakfire_package* pkg,
+ const enum pakfire_package_key key, uuid_t uuid);
+int pakfire_package_set_uuid(struct pakfire_package* pkg,
+ const enum pakfire_package_key key, const uuid_t uuid);
+
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,
#include <json.h>
#include <solv/pooltypes.h>
-#include <uuid/uuid.h>
int pakfire_package_create_from_solvable(struct pakfire_package** package,
struct pakfire* pakfire, Id id);
-void pakfire_package_set_build_id_from_uuid(struct pakfire_package* pkg, uuid_t* build_id);
uint64_t pakfire_package_get_dbid(struct pakfire_package* pkg);
void pakfire_package_set_dbid(struct pakfire_package* pkg, uint64_t id);
pakfire_package_get_string;
pakfire_package_get_suggests;
pakfire_package_get_supplements;
+ pakfire_package_get_uuid;
pakfire_package_ref;
pakfire_package_set_build_time;
pakfire_package_set_checksum;
pakfire_package_set_source_evr;
pakfire_package_set_source_name;
pakfire_package_set_string;
+ pakfire_package_set_uuid;
pakfire_package_unref;
# packagelist
return 0;
}
+PAKFIRE_EXPORT int pakfire_package_get_uuid(struct pakfire_package* pkg,
+ const enum pakfire_package_key key, uuid_t uuid) {
+ const char* buffer = NULL;
+ int r;
+
+ switch (key) {
+ case PAKFIRE_PKG_UUID:
+ case PAKFIRE_PKG_BUILD_ID:
+ // Clear the UUID
+ uuid_clear(uuid);
+
+ // Fetch the value
+ buffer = pakfire_package_get_string(pkg, key);
+ if (!buffer)
+ return 1;
+
+ // Read buffer into the output
+ r = uuid_parse(buffer, uuid);
+ if (r)
+ return r;
+
+ return 0;
+
+ default:
+ errno = EINVAL;
+ return 1;
+ }
+}
+
+PAKFIRE_EXPORT int pakfire_package_set_uuid(struct pakfire_package* pkg,
+ const enum pakfire_package_key key, const uuid_t uuid) {
+ char buffer[UUID_STR_LEN];
+
+ switch (key) {
+ case PAKFIRE_PKG_UUID:
+ case PAKFIRE_PKG_BUILD_ID:
+ // Convert the UUID to string
+ uuid_unparse_lower(uuid, buffer);
+
+ // Store the UUID as string
+ return pakfire_package_set_string(pkg, key, buffer);
+
+ default:
+ errno = EINVAL;
+ return 1;
+ }
+}
+
static unsigned long long pakfire_package_get_num(struct pakfire_package* pkg, Id type) {
pakfire_package_internalize_repo(pkg);
return pakfire_package_get_downloadsize(pkg);
}
-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_string(pkg, PAKFIRE_PKG_BUILD_ID, buffer);
-}
-
PAKFIRE_EXPORT time_t pakfire_package_get_build_time(struct pakfire_package* pkg) {
return pakfire_package_get_num(pkg, SOLVABLE_BUILDTIME);
}