pm

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

commit 9aee903d9fa062136b5e605cc0b43e7c03252d49
parent 0290de341b07d207b5b06e7f9597d8c6779e9c87
Author: z3bra <willyatmailoodotorg>
Date:   Sun Jun 19 01:17:02 +0200

Cosmetic changes (output message + variable names)

Diffstat:
pm.c | 29+++++++++++++++--------------
1 file changed, 15 insertions(+), 14 deletions(-)
diff --git a/pm.c b/pm.c @@ -70,7 +70,7 @@ int pack_delete(const char *rootfs, const char *datadir, struct pack *p); int inspect_version(const char *datadir, const char *name, char version[]); int inspect_collision(const char *rootfs, struct pack *p); -int inspect_files(int fd, const char *datadir, const char *packname); +int inspect_files(int fd, const char *datadir, const char *name); int inspect_system(int fd, const char *datadir); int write_metadata(const char *datadir, struct pack *pack); @@ -82,7 +82,7 @@ int delete_content(char *map, size_t size); int install(const char *rootfs, const char *datadir, char *path); int update(const char *rootfs, const char *datadir, char *path); int delete(const char *rootfs, const char *datadir, char *name); -int inspect(const char *datadir, const char *packname); +int inspect(const char *datadir, const char *name); int verbose = LOG_NONE; int overwrite = 0; @@ -90,7 +90,7 @@ int overwrite = 0; void usage(char *name) { - fprintf(stderr, "usage: %s [-vvv] -adfiu [pack]\n" , name); + fprintf(stderr, "usage: %s -adfiuv [PACK..]\n" , name); } @@ -217,7 +217,7 @@ pack_load_directory(const char *datadir, char *path) struct pack *pack = NULL; if (!(pack = malloc(sizeof(struct pack)))) { - perror(path); + perror("malloc"); return NULL; } @@ -292,7 +292,7 @@ pack_extract(const char *rootfs, const char *datadir, struct pack *p) snprintf(tmp, PATH_MAX, "%s/%s/files", datadir, p->name); - log(LOG_DEBUG, "openning %s for writing\n", tmp); + log(LOG_DEBUG, "+ %s\n", tmp); if ((fd = open(tmp, O_WRONLY|O_CREAT|O_TRUNC, 0644)) < 0) { perror(tmp); return -1; @@ -314,6 +314,7 @@ pack_extract(const char *rootfs, const char *datadir, struct pack *p) getcwd(cwd, PATH_MAX); chdir(rootfs); + log(LOG_VERBOSE, "extracting pack\n"); while ((r = archive_read_next_header(a, &e)) != ARCHIVE_EOF) { if (r != ARCHIVE_OK) { fprintf(stderr, "%s: %s\n", archive_entry_pathname(e), @@ -327,7 +328,7 @@ pack_extract(const char *rootfs, const char *datadir, struct pack *p) break; } - log(LOG_DEBUG, "+ %s\n", archive_entry_pathname(e)); + log(LOG_DEBUG, "+ %s%s\n", rootfs, archive_entry_pathname(e)); if ((r = write_entry(a, w)) != ARCHIVE_OK) { fprintf(stderr, "%s: %s\n", archive_entry_pathname(e), archive_error_string(w)); @@ -375,7 +376,6 @@ pack_install(const char *rootfs, const char *datadir, struct pack *p) return -1; } - log(LOG_VERBOSE, "extracting pack to %s\n", rootfs); r = pack_extract(rootfs, datadir, p); return r; @@ -427,7 +427,8 @@ pack_delete(const char *rootfs, const char *datadir, struct pack *p) } close(fd); - log(LOG_VERBOSE, "removing %s\n", tmp); + log(LOG_VERBOSE, "cleaning metadata\n"); + log(LOG_DEBUG, "- %s\n", tmp); if (unlink(tmp) < 0) { perror(tmp); return ERR_DELETE; @@ -435,7 +436,7 @@ pack_delete(const char *rootfs, const char *datadir, struct pack *p) snprintf(tmp, PATH_MAX, "%s/%s/version", datadir, p->name); - log(LOG_VERBOSE, "removing %s\n", tmp); + log(LOG_DEBUG, "- %s\n", tmp); if (unlink(tmp) < 0) { perror(tmp); return ERR_DELETE; @@ -443,7 +444,7 @@ pack_delete(const char *rootfs, const char *datadir, struct pack *p) /* remove metadata directory, no matter what */ snprintf(tmp, PATH_MAX, "%s/%s", datadir, p->name); - log(LOG_DEBUG, "removing %s\n", tmp); + log(LOG_DEBUG, "- %s\n", tmp); rmdir(tmp); chdir(cwd); @@ -521,13 +522,13 @@ inspect_collision(const char *rootfs, struct pack *p) * Write files installed by a pack to a file descriptor */ int -inspect_files(int fd, const char *datadir, const char *packname) +inspect_files(int fd, const char *datadir, const char *name) { int meta; char tmp[PATH_MAX] = ""; size_t len; - snprintf(tmp, PATH_MAX, "%s/%s/files", datadir, packname); + snprintf(tmp, PATH_MAX, "%s/%s/files", datadir, name); if ((meta = open(tmp, O_RDONLY)) < 0) { perror(tmp); return -1; @@ -582,14 +583,14 @@ write_metadata(const char *datadir, struct pack *p) snprintf(tmp, PATH_MAX, "%s/%s", datadir, p->name); if (stat(tmp, &st) < 0 && errno == ENOENT) { - log(LOG_DEBUG, "creating metadata directory %s\n", tmp); + log(LOG_DEBUG, "+ %s\n", tmp); if ((r = mkdir_parents(tmp, 0755)) < 0) return r; } snprintf(tmp, PATH_MAX, "%s/%s/version", datadir, p->name); - log(LOG_DEBUG, "openning %s for writing\n", tmp); + log(LOG_DEBUG, "+ %s\n", tmp); if ((fd = open(tmp, O_CREAT|O_WRONLY|O_TRUNC, 0644)) < 0) { perror(tmp); return -1;