pm

barely a pack manager
git clone git://z3bra.org/pm
Log | Files | Refs | README | LICENSE

commit 1faefbbfe0b101f39b95ce9140ced9b692889273
parent 6b12ca0f78ebb93d54b883bc2a49876af4d6ba0a
Author: z3bra <willyatmailoodotorg>
Date:   Sat Jan 23 11:46:55 +0100

Have datadir relative to $ROOT

datadir is now relative to $ROOT and hardcoded to $ROOT/var/pm.
Current debate is now to figure wether it should be in the
environment or not (I don't think so).

$ROOT now defaults to /.

Diffstat:
pm.c | 20+++++++++++++-------
1 file changed, 13 insertions(+), 7 deletions(-)
diff --git a/pm.c b/pm.c @@ -13,8 +13,7 @@ #include "arg.h" -#define PACK_ROOT (getenv("ROOT")?getenv("ROOT"):"/ns/pm/rootfs") -#define PACK_DATA (getenv("META")?getenv("META"):"/ns/pm/rootfs/metadata") +#define PACK_DATA "var/pm" #define PACK_BUFF_SIZE 8192 #define PACK_SEPARATOR '#' #define PACK_EXTENSION ".tar.bz2" @@ -617,6 +616,13 @@ main (int argc, char **argv) char *n = NULL; struct pack *p = NULL; uint8_t action = ACTION_DEFAULT; + char rootfs[PATH_MAX] = ""; + char datadir[PATH_MAX] = ""; + + strncpy(rootfs, getenv("ROOT"), PATH_MAX); + strncat(rootfs, "/", PATH_MAX); + strncpy(datadir, rootfs, PATH_MAX); + strncat(datadir, PACK_DATA, PATH_MAX); ARGBEGIN{ case 'a': @@ -647,7 +653,7 @@ main (int argc, char **argv) case ACTION_INSTALL: while (*argv) { if ((p = pack_load(*(argv++)))) { - r += install(PACK_ROOT, PACK_DATA, p); + r += install(rootfs, datadir, p); pack_free(p); } } @@ -656,8 +662,8 @@ main (int argc, char **argv) case ACTION_UPDATE: while (*argv) { if ((p = pack_load(*(argv++)))) { - if (delete(PACK_ROOT, PACK_DATA, p->name) == 0) - r += install(PACK_ROOT, PACK_DATA, p); + if (delete(rootfs, datadir, p->name) == 0) + r += install(rootfs, datadir, p); pack_free(p); } } @@ -665,11 +671,11 @@ main (int argc, char **argv) case ACTION_DELETE: while (*argv) - r += delete(PACK_ROOT, PACK_DATA, *argv++); + r += delete(rootfs, datadir, *argv++); break; case ACTION_INSPECT: - if (inspect(PACK_DATA, n) != 0) + if (inspect(datadir, n) != 0) return ERR_INSPECT; break;