X-Git-Url: https://pd.if.org/git/?a=blobdiff_plain;f=lib%2Fzpm.c;h=d9041ff33c6daf3b4510022fd6e7b2387ae983d9;hb=3fbafae81dbc483ba0e37bd66e269702cd666af2;hp=99984fbef7d645864fa235fdfdd072dd1a9a0682;hpb=6274fb230a7d4ee8ccd893b306541c2b13658bcc;p=zpackage diff --git a/lib/zpm.c b/lib/zpm.c index 99984fb..d9041ff 100644 --- a/lib/zpm.c +++ b/lib/zpm.c @@ -372,7 +372,7 @@ int zpm_readopts(struct zpm *pkg, int ac, char **av) { /* now, parse the options, return optind so the caller can adjust if needed */ - return 1; + return av ? ac : 1; } int zpm_extract(struct zpm *pkg, char *hash, char *path, int mode) { @@ -450,6 +450,7 @@ int zpm_extract(struct zpm *pkg, char *hash, char *path, int mode) { //fprintf(stderr, "uncompressing %d bytes at %p, expect %lld\n", blobsize, xzdata, (long long int)size); uncompresslzma(xzdata, blobsize, out); fclose(out); + chmod(path, mode); sqlite3_finalize(ifile); @@ -498,7 +499,7 @@ int zpm_hash(char *path, char *hash, uint32_t flags) { } hash[64] = 0; munmap(content, sbuf.st_size); - return 1; + return flags ? fd : 1; } static sqlite3_stmt *run_for_hash(sqlite3 *db, char *sql, char *hash) { @@ -712,6 +713,7 @@ int zpm_import(struct zpm *pkg, char *path, uint32_t flags, char *hash) { hash = hashbuf; } + flags = 0; /* suppress warning, probably use to follow symlinks */ /* mmap the file */ fd = open(path, O_RDONLY); if (fd == -1) {