pm

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

commit 8ac938b57e4fe44d05aa7662a32e21939291f555
parent e75a29dc260ce4d1a54c83eb9ec5de73c958875d
Author: z3bra <willyatmailoodotorg>
Date:   Sat Jun 18 01:29:57 +0200

Change back to working dir after pack_delete()

Diffstat:
pm.c | 14++++++++++----
1 file changed, 10 insertions(+), 4 deletions(-)
diff --git a/pm.c b/pm.c @@ -448,7 +448,7 @@ pack_install(const char *rootfs, const char *datadir, struct pack *p) return -1; } - log(LOG_VERBOSE, "writing metadata to %s\n", datadir); + log(LOG_VERBOSE, "writing metadata\n"); if (write_metadata(datadir, p) < 0) { perror(datadir); return -1; @@ -553,7 +553,7 @@ pack_delete(const char *rootfs, const char *datadir, struct pack *p) { int fd; char *addr = NULL; - char tmp[PATH_MAX]; + char tmp[PATH_MAX], cwd[PATH_MAX]; struct stat st; snprintf(tmp, PATH_MAX, "%s/%s/files", datadir, p->name); @@ -572,6 +572,7 @@ pack_delete(const char *rootfs, const char *datadir, struct pack *p) close(fd); } + getcwd(cwd, PATH_MAX); if (chdir(rootfs) < 0) { perror(rootfs); close(fd); @@ -602,8 +603,13 @@ pack_delete(const char *rootfs, const char *datadir, struct pack *p) } /* remove metadata directory, no matter what */ - log(LOG_DEBUG, "removing %s\n", p->path); - return rmdir(p->path); + snprintf(tmp, PATH_MAX, "%s/%s", datadir, p->name); + log(LOG_DEBUG, "removing %s\n", tmp); + rmdir(tmp); + + chdir(cwd); + + return 0; }