From: Michael Tremer Date: Thu, 11 Feb 2021 16:35:26 +0000 (+0000) Subject: db: Read install time back from database X-Git-Tag: 0.9.28~1285^2~756 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=af647c5564273e70fe9aeee5568159b6e0513f8e;p=pakfire.git db: Read install time back from database Signed-off-by: Michael Tremer --- diff --git a/src/libpakfire/db.c b/src/libpakfire/db.c index d130a6166..82e1af166 100644 --- a/src/libpakfire/db.c +++ b/src/libpakfire/db.c @@ -1479,8 +1479,14 @@ static int pakfire_db_load_package(struct pakfire_db* db, PakfireRepo repo, sqli pakfire_package_set_build_time(pkg, build_time); } + // Install Time + time_t install_time = sqlite3_column_int64(stmt, 17); + if (install_time) { + pakfire_package_set_install_time(pkg, install_time); + } + // Files - const char* files = (const char*)sqlite3_column_text(stmt, 17); + const char* files = (const char*)sqlite3_column_text(stmt, 18); if (files) { r = pakfire_package_set_filelist_from_string(pkg, files); if (r) @@ -1493,15 +1499,15 @@ static int pakfire_db_load_package(struct pakfire_db* db, PakfireRepo repo, sqli unsigned int field; void (*func)(PakfirePackage pkg, PakfireRelationList list); } dependencies[] = { - { 18, pakfire_package_set_provides }, - { 19, pakfire_package_set_prerequires }, - { 20, pakfire_package_set_requires }, - { 21, pakfire_package_set_conflicts }, - { 22, pakfire_package_set_obsoletes }, - { 23, pakfire_package_set_recommends }, - { 24, pakfire_package_set_suggests }, - { 25, pakfire_package_set_supplements }, - { 26, pakfire_package_set_enhances }, + { 19, pakfire_package_set_provides }, + { 20, pakfire_package_set_prerequires }, + { 21, pakfire_package_set_requires }, + { 22, pakfire_package_set_conflicts }, + { 23, pakfire_package_set_obsoletes }, + { 24, pakfire_package_set_recommends }, + { 25, pakfire_package_set_suggests }, + { 26, pakfire_package_set_supplements }, + { 27, pakfire_package_set_enhances }, { 0, NULL }, }; @@ -1546,6 +1552,7 @@ int pakfire_db_load(struct pakfire_db* db, PakfireRepo repo) { "SELECT " "name, epoch, version, release, arch, groups, filename, size, inst_size, " "hash1, license, summary, description, uuid, vendor, build_host, build_time, " + "strftime('%s', installed) AS installed, " "(" "SELECT group_concat(name, '\n') FROM files WHERE files.pkg = packages.id" ") AS files, " diff --git a/src/libpakfire/include/pakfire/package.h b/src/libpakfire/include/pakfire/package.h index 26cde93a1..86a82ce5e 100644 --- a/src/libpakfire/include/pakfire/package.h +++ b/src/libpakfire/include/pakfire/package.h @@ -85,7 +85,8 @@ const char* pakfire_package_get_build_host(PakfirePackage pkg); void pakfire_package_set_build_host(PakfirePackage pkg, const char* build_host); time_t pakfire_package_get_build_time(PakfirePackage pkg); void pakfire_package_set_build_time(PakfirePackage pkg, time_t build_time); -time_t pakfire_package_get_installtime(PakfirePackage pkg); +time_t pakfire_package_get_install_time(PakfirePackage pkg); +void pakfire_package_set_install_time(PakfirePackage pkg, time_t install_time); PakfireRelationList pakfire_package_get_provides(PakfirePackage pkg); void pakfire_package_set_provides(PakfirePackage pkg, PakfireRelationList relationlist); diff --git a/src/libpakfire/libpakfire.sym b/src/libpakfire/libpakfire.sym index 221a1b52a..9450119ed 100644 --- a/src/libpakfire/libpakfire.sym +++ b/src/libpakfire/libpakfire.sym @@ -177,7 +177,7 @@ global: pakfire_package_get_license; pakfire_package_get_location; pakfire_package_get_installsize; - pakfire_package_get_installtime; + pakfire_package_get_install_time; pakfire_package_get_maintainer; pakfire_package_get_name; pakfire_package_get_nevra; @@ -214,6 +214,7 @@ global: pakfire_package_set_filename; pakfire_package_set_groups; pakfire_package_set_installsize; + pakfire_package_set_install_time; pakfire_package_set_license; pakfire_package_set_maintainer; pakfire_package_set_name; diff --git a/src/libpakfire/package.c b/src/libpakfire/package.c index 5ffd6c288..efd3ba7e1 100644 --- a/src/libpakfire/package.c +++ b/src/libpakfire/package.c @@ -524,10 +524,14 @@ PAKFIRE_EXPORT void pakfire_package_set_build_time(PakfirePackage pkg, time_t bu pakfire_package_set_num(pkg, SOLVABLE_BUILDTIME, build_time); } -PAKFIRE_EXPORT time_t pakfire_package_get_installtime(PakfirePackage pkg) { +PAKFIRE_EXPORT time_t pakfire_package_get_install_time(PakfirePackage pkg) { return pakfire_package_get_num(pkg, SOLVABLE_INSTALLTIME); } +PAKFIRE_EXPORT void pakfire_package_set_install_time(PakfirePackage pkg, time_t install_time) { + pakfire_package_set_num(pkg, SOLVABLE_INSTALLTIME, install_time); +} + static PakfireRelationList pakfire_package_get_relationlist( PakfirePackage pkg, Id type, Id marker) { Queue q; @@ -823,6 +827,12 @@ PAKFIRE_EXPORT char* pakfire_package_dump(PakfirePackage pkg, int flags) { pakfire_package_dump_add_line(&string, _("License"), license); if (flags & PAKFIRE_PKG_DUMP_LONG) { + // Install Time + time_t install_time = pakfire_package_get_install_time(pkg); + if (install_time) { + pakfire_package_dump_add_line_date(&string, _("Install Time"), install_time); + } + // Maintainer const char* maintainer = pakfire_package_get_maintainer(pkg); pakfire_package_dump_add_line(&string, _("Maintainer"), maintainer);