X-Git-Url: https://pd.if.org/git/?a=blobdiff_plain;f=zpm-script.c;h=8018849b36c450b1f00db39657557e658877b8ea;hb=5405c7c75dc410d93818fabdfa290dbaa4505aac;hp=ceca239530873d7036c7549db8afa1cb0d6cd7dc;hpb=30aa9bfe1e9a0e682f7c942b8e68054551f14857;p=zpackage diff --git a/zpm-script.c b/zpm-script.c index ceca239..8018849 100644 --- a/zpm-script.c +++ b/zpm-script.c @@ -26,7 +26,7 @@ */ void usage(void) { - fprintf(stderr, "usage: db hash file\n"); + fprintf(stderr, "usage: zpm script ...\n"); } int setdir(char *rootdir) { @@ -119,6 +119,12 @@ int run(char *program, char **args, char *output, int *status) { #define SOFT 1 #define HARD 2 +static int list_scripts(void *ud, const char *pkg, const char *stage, + const char *hash) { + printf("%s %s %.8s\n", pkg, stage, hash); + return 0; +} + int main(int ac, char **av){ struct zpm zpm; int rv; @@ -133,7 +139,7 @@ int main(int ac, char **av){ char *pkgid; char *rootdir = 0; - char *db = "/var/lib/zpm/zpm.db"; + char *db = "/var/lib/zpm/local.db"; char *script = "/var/tmp/zpm-script"; char *output = "/var/tmp/zpm-script.out"; char *phase = 0; @@ -177,7 +183,7 @@ int main(int ac, char **av){ case 'h': scriptishash = 1; break; case 'o': output = optarg; break; case 'S': script = optarg; break; - case 'q': quiet = 1; + case 'q': quiet = 1; break; default: usage(); @@ -248,10 +254,14 @@ int main(int ac, char **av){ fail = HARD; } } else if (mode == LIST) { - if (!zpm_script_hash(&zpm, pkgid, phase, hash)) { + if (!phase) { + zpm_foreach_script(&zpm, pkgid, phase, 0, list_scripts); + } else if (!zpm_script_hash(&zpm, pkgid, phase, hash)) { fail = SOFT; } else if (scriptishash) { - printf("%s\n", hash); + if (!quiet) { + printf("%s\n", hash); + } } else { if (!output) { output = "-";