return PyUnicode_FromString(package_dump);
}
+static PyObject* Package_get_source_package(PackageObject* self) {
+ const char* source_package = pakfire_package_get_source_package(self->package);
+
+ return PyUnicode_FromString(source_package);
+}
+
+static PyObject* Package_get_source_name(PackageObject* self) {
+ const char* source_name = pakfire_package_get_source_name(self->package);
+
+ return PyUnicode_FromString(source_name);
+}
+
+static PyObject* Package_set_source_name(PackageObject* self, PyObject* value) {
+ const char* source_name = PyUnicode_AsUTF8(value);
+
+ pakfire_package_set_source_name(self->package, source_name);
+
+ Py_RETURN_NONE;
+}
+
+static PyObject* Package_get_source_evr(PackageObject* self) {
+ const char* source_evr = pakfire_package_get_source_evr(self->package);
+
+ return PyUnicode_FromString(source_evr);
+}
+
+static PyObject* Package_set_source_evr(PackageObject* self, PyObject* value) {
+ const char* source_evr = PyUnicode_AsUTF8(value);
+
+ pakfire_package_set_source_evr(self->package, source_evr);
+
+ Py_RETURN_NONE;
+}
+
+static PyObject* Package_get_source_arch(PackageObject* self) {
+ const char* source_arch = pakfire_package_get_source_arch(self->package);
+
+ return PyUnicode_FromString(source_arch);
+}
+
+static PyObject* Package_set_source_arch(PackageObject* self, PyObject* value) {
+ const char* source_arch = PyUnicode_AsUTF8(value);
+
+ pakfire_package_set_source_arch(self->package, source_arch);
+
+ Py_RETURN_NONE;
+}
+
static struct PyMethodDef Package_methods[] = {
{
"dump",
NULL,
NULL
},
+ {
+ "source_package",
+ (getter)Package_get_source_package,
+ NULL,
+ NULL,
+ NULL
+ },
+ {
+ "source_name",
+ (getter)Package_get_source_name,
+ (setter)Package_set_source_name,
+ NULL,
+ NULL
+ },
+ {
+ "source_evr",
+ (getter)Package_get_source_evr,
+ (setter)Package_set_source_evr,
+ NULL,
+ NULL
+ },
+ {
+ "source_arch",
+ (getter)Package_get_source_arch,
+ (setter)Package_set_source_arch,
+ NULL,
+ NULL
+ },
// Dependencies
{
if (build_time)
pakfire_package_set_build_time(pkg, build_time);
+ // Source package
+ const char* source_name = pakfire_archive_metadata_get(archive, "build", "source-name");
+ if (source_name)
+ pakfire_package_set_source_name(pkg, source_name);
+
+ // Source EVR
+ const char* source_evr = pakfire_archive_metadata_get(archive, "build", "source-evr");
+ if (source_evr)
+ pakfire_package_set_source_evr(pkg, source_evr);
+
+ // Source arch
+ const char* source_arch = pakfire_archive_metadata_get(archive, "build", "source-arch");
+ if (source_arch)
+ pakfire_package_set_source_arch(pkg, source_arch);
+
// Dependencies
const struct dependencies {
const char* type;
// Set build ID
pakfire_package_set_build_id_from_uuid(pkg, build_id);
+ // Set source package
+ const char* source_name = pakfire_parser_get(makefile, NULL, "name");
+ if (source_name)
+ pakfire_package_set_source_name(pkg, source_name);
+
+ // Set source EVR
+ const char* source_evr = pakfire_parser_get(makefile, NULL, "evr");
+ if (source_evr)
+ pakfire_package_set_source_evr(pkg, source_evr);
+
+ // Set source arch
+ pakfire_package_set_source_arch(pkg, "src");
+
// Create a packager
r = pakfire_packager_create(&packager, pakfire, pkg);
if (r)
"build_time INTEGER, "
"installed INTEGER, "
"userinstalled INTEGER, "
- "repository TEXT"
+ "repository TEXT, "
+ "source_name TEXT, "
+ "source_evr TEXT, "
+ "source_arch TEXT"
")");
if (r)
return 1;
if (r)
goto ERROR;
- const char* sql = "INSERT INTO packages(name, evr, arch, groups, filename, size, "
- "inst_size, digest, license, summary, description, uuid, "
- "vendor, build_host, build_time, installed, repository, userinstalled) "
- "VALUES(?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, CURRENT_TIMESTAMP, ?, ?)";
+ const char* sql = "INSERT INTO "
+ "packages("
+ "name, "
+ "evr, "
+ "arch, "
+ "groups, "
+ "filename, "
+ "size, "
+ "inst_size, "
+ "digest, "
+ "license, "
+ "summary, "
+ "description, "
+ "uuid, "
+ "vendor, "
+ "build_host, "
+ "build_time, "
+ "installed, "
+ "repository, "
+ "userinstalled, "
+ "source_name, "
+ "source_evr, "
+ "source_arch"
+ ") VALUES("
+ "?, "
+ "?, "
+ "?, "
+ "?, "
+ "?, "
+ "?, "
+ "?, "
+ "?, "
+ "?, "
+ "?, "
+ "?, "
+ "?, "
+ "?, "
+ "?, "
+ "?, "
+ "CURRENT_TIMESTAMP, "
+ "?, "
+ "?, "
+ "?, "
+ "?, "
+ "?"
+ ")";
// Prepare the statement
r = sqlite3_prepare_v2(db->handle, sql, strlen(sql), &stmt, NULL);
goto ERROR;
}
+ // Source package name
+ const char* source_name = pakfire_package_get_source_name(pkg);
+ if (source_name) {
+ r = sqlite3_bind_text(stmt, 18, source_name, -1, NULL);
+ if (r)
+ goto ERROR;
+ } else {
+ r = sqlite3_bind_null(stmt, 18);
+ if (r)
+ goto ERROR;
+ }
+
+ // Source EVR
+ const char* source_evr = pakfire_package_get_source_evr(pkg);
+ if (source_evr) {
+ r = sqlite3_bind_text(stmt, 19, source_evr, -1, NULL);
+ if (r)
+ goto ERROR;
+ } else {
+ r = sqlite3_bind_null(stmt, 19);
+ if (r)
+ goto ERROR;
+ }
+
+ // Source arch
+ const char* source_arch = pakfire_package_get_source_arch(pkg);
+ if (source_arch) {
+ r = sqlite3_bind_text(stmt, 20, source_arch, -1, NULL);
+ if (r)
+ goto ERROR;
+ } else {
+ r = sqlite3_bind_null(stmt, 20);
+ if (r)
+ goto ERROR;
+ }
+
// Run query
do {
r = sqlite3_step(stmt);
}
}
+ // Source package
+ const char* source_name = (const char*)sqlite3_column_text(stmt, 28);
+ if (source_name)
+ pakfire_package_set_source_name(pkg, source_name);
+
+ // Source EVR
+ const char* source_evr = (const char*)sqlite3_column_text(stmt, 29);
+ if (source_evr)
+ pakfire_package_set_source_evr(pkg, source_evr);
+
+ // Source arch
+ const char* source_arch = (const char*)sqlite3_column_text(stmt, 30);
+ if (source_arch)
+ pakfire_package_set_source_arch(pkg, source_arch);
+
// Success
r = 0;
const char* sql =
"SELECT "
- "name, evr, arch, id, groups, filename, size, inst_size, "
- "digest, license, summary, description, uuid, vendor, "
- "build_host, build_time, strftime('%s', installed) AS installed, userinstalled, "
+ "name, "
+ "evr, "
+ "arch, "
+ "id, "
+ "groups, "
+ "filename, "
+ "size, "
+ "inst_size, "
+ "digest, "
+ "license, "
+ "summary, "
+ "description, "
+ "uuid, "
+ "vendor, "
+ "build_host, "
+ "build_time, "
+ "strftime('%s', installed) AS installed, "
+ "userinstalled, "
"("
"SELECT group_concat(path, '\n') FROM files WHERE files.pkg = packages.id"
") AS files, "
"("
"SELECT group_concat(dependency, '\n') FROM dependencies d "
"WHERE d.pkg = packages.id AND d.type = 'enhances'"
- ") AS enhances "
+ ") AS enhances, "
+ "source_name, "
+ "source_evr, "
+ "source_arch "
"FROM "
"packages"
";";
// Set epoch
pakfire_parser_set(parser, NULL, "epoch", "0", 0);
+ // Set EVR
+ pakfire_parser_set(parser, NULL, "evr", "%{epoch}:%{version}-%{_release}", 0);
+
// Set vendor
pakfire_parser_set(parser, NULL, "vendor", "%{DISTRO_VENDOR}", 0);
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);
+const char* pakfire_package_get_source_package(struct pakfire_package* pkg);
+const char* pakfire_package_get_source_name(struct pakfire_package* pkg);
+void pakfire_package_set_source_name(struct pakfire_package* pkg, const char* name);
+const char* pakfire_package_get_source_evr(struct pakfire_package* pkg);
+void pakfire_package_set_source_evr(struct pakfire_package* pkg, const char* evr);
+const char* pakfire_package_get_source_arch(struct pakfire_package* pkg);
+void pakfire_package_set_source_arch(struct pakfire_package* pkg, const char* arch);
char** pakfire_package_get_provides(struct pakfire_package* pkg);
char** pakfire_package_get_prerequires(struct pakfire_package* pkg);
pakfire_package_get_requires;
pakfire_package_get_reverse_requires;
pakfire_package_get_size;
+ pakfire_package_get_source_arch;
+ pakfire_package_get_source_evr;
+ pakfire_package_get_source_name;
+ pakfire_package_get_source_package;
pakfire_package_get_suggests;
pakfire_package_get_summary;
pakfire_package_get_supplements;
pakfire_package_set_maintainer;
pakfire_package_set_name;
pakfire_package_set_path;
+ pakfire_package_set_source_arch;
+ pakfire_package_set_source_evr;
+ pakfire_package_set_source_name;
pakfire_package_set_summary;
pakfire_package_set_url;
pakfire_package_set_uuid;
struct pakfire_repo* repo;
char nevra[NAME_MAX];
+ char source_nevra[NAME_MAX];
char filename[NAME_MAX];
char path[PATH_MAX];
pakfire_package_set_num(pkg, SOLVABLE_INSTALLTIME, install_time);
}
+PAKFIRE_EXPORT const char* pakfire_package_get_source_package(struct pakfire_package* pkg) {
+ if (!*pkg->source_nevra) {
+ const char* name = pakfire_package_get_source_name(pkg);
+ const char* evr = pakfire_package_get_source_evr(pkg);
+ const char* arch = pakfire_package_get_source_arch(pkg);
+
+ // Return nothing if we don't have all information
+ if (!name || !evr || !arch)
+ return NULL;
+
+ // Format package name
+ pakfire_string_format(pkg->source_nevra, "%s-%s.%s", name, evr, arch);
+ }
+
+ return pkg->source_nevra;
+}
+
+PAKFIRE_EXPORT const char* pakfire_package_get_source_name(struct pakfire_package* pkg) {
+ return pakfire_package_get_string(pkg, SOLVABLE_SOURCENAME);
+}
+
+PAKFIRE_EXPORT void pakfire_package_set_source_name(struct pakfire_package* pkg, const char* name) {
+ pakfire_package_set_string(pkg, SOLVABLE_SOURCENAME, name);
+}
+
+PAKFIRE_EXPORT const char* pakfire_package_get_source_evr(struct pakfire_package* pkg) {
+ return pakfire_package_get_string(pkg, SOLVABLE_SOURCEEVR);
+}
+
+PAKFIRE_EXPORT void pakfire_package_set_source_evr(struct pakfire_package* pkg, const char* evr) {
+ // Skip empty epoch
+ if (pakfire_string_startswith(evr, "0:"))
+ evr += 2;
+
+ pakfire_package_set_string(pkg, SOLVABLE_SOURCEEVR, evr);
+}
+
+PAKFIRE_EXPORT const char* pakfire_package_get_source_arch(struct pakfire_package* pkg) {
+ return pakfire_package_get_string(pkg, SOLVABLE_SOURCEARCH);
+}
+
+PAKFIRE_EXPORT void pakfire_package_set_source_arch(struct pakfire_package* pkg, const char* arch) {
+ pakfire_package_set_string(pkg, SOLVABLE_SOURCEARCH, arch);
+}
+
static char** pakfire_package_get_relationlist(
struct pakfire_package* pkg, Id type, Id marker) {
char** array = NULL;
break;
}
+ // Source package
+ const char* source_package = pakfire_package_get_source_package(pkg);
+ if (source_package)
+ 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);
goto ERROR;
}
+ // Source package name
+ const char* name = pakfire_package_get_source_name(pkg);
+ if (name) {
+ r = pakfire_json_add_string(pkg->pakfire, object, "source-name", name);
+ if (r)
+ goto ERROR;
+ }
+
+ // Source package EVR
+ const char* evr = pakfire_package_get_source_evr(pkg);
+ if (evr) {
+ r = pakfire_json_add_string(pkg->pakfire, object, "source-evr", evr);
+ if (r)
+ goto ERROR;
+ }
+
+ // Source package arch
+ const char* arch = pakfire_package_get_source_arch(pkg);
+ if (arch) {
+ r = pakfire_json_add_string(pkg->pakfire, object, "source-arch", arch);
+ if (r)
+ goto ERROR;
+ }
+
// Add object
r = json_object_object_add(md, "build", object);
if (r)