X-Git-Url: https://pd.if.org/git/?a=blobdiff_plain;f=zpm-script.c;h=7c03b241792ae1f91ea504215b1400526580c71b;hb=62f6ff407bc4f2cf03d1fa7cf3dc9a3f4026624a;hp=b8c94589f5d623d4463bc0a5a91b941e20eb5527;hpb=0c748140d9390d13f56e3b6716aaaec147788d9f;p=zpackage diff --git a/zpm-script.c b/zpm-script.c index b8c9458..7c03b24 100644 --- a/zpm-script.c +++ b/zpm-script.c @@ -30,11 +30,12 @@ void usage(void) { } int setdir(char *rootdir) { + if (chdir(rootdir ? rootdir : "/") == -1) { + perror("can not chdir to rootdir"); + return 0; + } +#if 0 if (rootdir && strcmp(rootdir, "/")) { - if (chdir(rootdir) == -1) { - perror("can not chdir to rootdir"); - return 0; - } if (geteuid() == 0) { /* chroot is deprecated, and not in posix. need to use * OS/kernel specific code. @@ -43,12 +44,8 @@ int setdir(char *rootdir) { } else { fprintf(stderr, "unable to chroot as non root user\n"); } - } else { - if (chdir("/") == -1) { - perror("can not chdir to /"); - return 0; - } } +#endif return 1; } @@ -319,6 +316,7 @@ int main(int ac, char **av){ if (!zpm_extract(&zpm, hash, script, 0700)) { fprintf(stderr, "unable to extract script"); fail = HARD; + zpm_note_add(&zpm, pkgid, NULL, hash, "unable to extract %s script", phase); goto cleanup; } @@ -326,6 +324,10 @@ int main(int ac, char **av){ if (rv) { fprintf(stderr, "package %s script failed with code %d\n", pkgid, rv); + + zpm_import(&zpm, output, 0, hash); + zpm_note_add(&zpm, pkgid, NULL, hash, "package %s script failed with code %d", phase, rv); + fail = HARD; } @@ -343,5 +345,4 @@ cleanup: zpm_close(&zpm); return (fail == HARD || (required && fail)) ? EXIT_FAILURE : 0; - }