pm

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

commit 5d666fd2e3404480c49b8830756c1c565d7e7236
parent 73f293913081b16d19635ceb544530a6d7915d48
Author: z3bra <willyatmailoodotorg>
Date:   Tue Jan 12 14:40:37 2016

Add -v flag to activate verbose mode

Diffstat:
 pm.c | 20 ++++++++++++++++++++
 1 file changed, 20 insertions(+), 0 deletions(-)

diff --git a/pm.c b/pm.c @@ -65,6 +65,7 @@ int delete(const char *rootfs, const char *datadir, const char *name); char *argv0; +int verbose = 0; int overwrite = 0; void @@ -387,6 +388,9 @@ install(char *rootfs, char *datadir, struct pack *p) char tmp[PATH_MAX] = ""; struct stat st; + if (verbose == 1) + printf("%s: installing to %s\n", p->name, rootfs); + if (overwrite == 0) { snprintf(tmp, PATH_MAX, "%s/%s", datadir, p->name); if (stat(tmp, &st) == 0 && S_ISDIR(st.st_mode)) { @@ -394,6 +398,8 @@ install(char *rootfs, char *datadir, struct pack *p) return -1; } + if (verbose == 1) + printf("%s: checking collisions\n", p->name); if (inspect_collision(rootfs, p) != 0) return -1; } @@ -407,13 +413,20 @@ install(char *rootfs, char *datadir, struct pack *p) return -1; } + if (verbose == 1) + printf("%s: writing metadata\n", p->name); if (write_metadata(datadir, p) < 0) { perror(datadir); return -1; } + if (verbose == 1) + printf("%s: extracting %s\n", p->name, p->path); r = unpack(datadir, p); + if (verbose == 1) + printf("%s: installation %s\n", p->name, r != 0 ? "failed" : "complete"); + return r; } @@ -491,6 +504,8 @@ delete(const char *rootfs, const char *datadir, const char *packname) return ERR_DELETE; } + if (verbose == 1) + printf("%s: deleting from %s\n", packname, rootfs); if (chdir(rootfs) < 0) { perror(rootfs); return ERR_DELETE; @@ -504,6 +519,8 @@ delete(const char *rootfs, const char *datadir, const char *packname) } fclose(f); + if (verbose == 1) + printf("%s: removing metadata\n", packname); if (unlink(tmp) < 0) { perror(tmp); fprintf(stderr, "%s: cannot remove file list\n", packname); @@ -616,6 +633,9 @@ main (int argc, char **argv) if (argc > 1) n = ARGF(); break; + case 'v': + verbose = 1; + break; default: action = ACTION_INVALID; }ARGEND;