]> pd.if.org Git - zpackage/blobdiff - zpm-script.c
remove unused variable
[zpackage] / zpm-script.c
index 359970abd567d7934d641864c8e4e034e7c8d706..d947f058b68c9a9076ec02ebb7089c5574613452 100644 (file)
@@ -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;
@@ -140,7 +146,6 @@ int main(int ac, char **av){
        int quiet = 0;
        int scriptishash = 0;
        int mode = RUN;
-       int all = 0;
 
        if (getenv("ZPMDB")) {
                db = getenv("ZPMDB");
@@ -172,12 +177,11 @@ int main(int ac, char **av){
                        case 'l': mode = LIST; break;
                        case 'R': rootdir = optarg; break;
                        case 'F': required = 1; break;
-                       case 'a': all = 1; break;
 
                        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 +252,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 = "-";