From 60f585af06287a51da8d876268c929c72c5d7098 Mon Sep 17 00:00:00 2001 From: George Vlahavas Date: Mon, 17 Jan 2022 03:03:46 +0200 Subject: [PATCH] Update package directory structure for slack 15.0 In Slackware 15.0, the package info installation directories have changed. Almost everything moved out of /var/log, so /var/log can be volatile, as it should have always been. List of changes is: * /var/log/packages -> /var/lib/pkgtools/packages * /var/log/scripts -> /var/lib/pkgtools/scripts * /var/log/setup -> /var/lib/pkgtools/setup * /var/log/removed_packages -> /var/log/pkgtools/removed_packages * /var/log/removed_scripts -> /var/log/pkgtools/removed_scripts There's also a new /var/lib/pkgtools/douninst.sh directory, but I haven't accounted for that yet. I don't think any packages in Slackware 15.0 uses it, yet anyway. --- include/pkgdb.h | 2 +- src/pkgdb.c | 17 +++++++++++------ 2 files changed, 12 insertions(+), 7 deletions(-) diff --git a/include/pkgdb.h b/include/pkgdb.h index b649cf0..0320036 100644 --- a/include/pkgdb.h +++ b/include/pkgdb.h @@ -32,7 +32,7 @@ These functions returns list of package names. G_BEGIN_DECLS /** Directory where the package database is stored. */ -#define PKGDB_DIR "var/log" +#define PKGDB_DIR "var" #define DB_NOPEN E(0) /**< Database is not open. */ #define DB_OPEN E(1) /**< Database is already open (when opening). */ diff --git a/src/pkgdb.c b/src/pkgdb.c index a200fa9..51e4ea4 100644 --- a/src/pkgdb.c +++ b/src/pkgdb.c @@ -63,8 +63,13 @@ static struct db_state _db; // yeah, this is really not uninitialized gint db_open(const gchar* root, gboolean readonly, struct error* e) { gchar** d; - gchar* checkdirs[] = { "packages", "scripts", "removed_packages", - "removed_scripts", "setup", NULL }; + gchar* checkdirs[] = { + "lib/pkgtools/packages", + "lib/pkgtools/scripts", + "lib/pkgtools/setup", + "log/pkgtools/removed_packages", + "log/pkgtools/removed_scripts", + NULL }; g_assert(e != NULL); _db.err = e; @@ -85,8 +90,8 @@ gint db_open(const gchar* root, gboolean readonly, struct error* e) _db.topdir = g_strdup_printf("%s/%s%s", cwd, sane_root, PKGDB_DIR); g_free(cwd); } - _db.pkgdir = g_strdup_printf("%s/packages", _db.topdir); - _db.scrdir = g_strdup_printf("%s/scripts", _db.topdir); + _db.pkgdir = g_strdup_printf("%s/lib/pkgtools/packages", _db.topdir); + _db.scrdir = g_strdup_printf("%s/lib/pkgtools/scripts", _db.topdir); g_free(sane_root); /* check db dirs */ @@ -922,8 +927,8 @@ gint db_rem_pkg(gchar* name) gchar* p = g_strdup_printf("%s/%s", _db.pkgdir, name); gchar* s = g_strdup_printf("%s/%s", _db.scrdir, name); - gchar* rp = g_strdup_printf("%s/removed_packages/%s-removed-%s", _db.topdir, name, _get_date()); - gchar* rs = g_strdup_printf("%s/removed_scripts/%s-removed-%s", _db.topdir, name, _get_date()); + gchar* rp = g_strdup_printf("%s/log/pkgtools/removed_packages/%s-removed-%s", _db.topdir, name, _get_date()); + gchar* rs = g_strdup_printf("%s/log/pkgtools/removed_scripts/%s-removed-%s", _db.topdir, name, _get_date()); if (sys_file_type(p, 1) != SYS_REG) {