]> pd.if.org Git - zpackage/commitdiff
ignore missing runscript by default
authorNathan Wagner <nw@hydaspes.if.org>
Mon, 17 Sep 2018 12:02:15 +0000 (12:02 +0000)
committerNathan Wagner <nw@hydaspes.if.org>
Mon, 24 Sep 2018 10:40:18 +0000 (10:40 +0000)
Added option -R to require that there be one.

add zpm-runscript to .gitignore

add tests for required runscript phase

add script to test runscript

.gitignore
t/scripts.t [new file with mode: 0755]
zpm-runscript.c

index 94ec0189ca834a3f48caf7abd8ad4f609e385fe5..8c399ace2d6dca15a14cb45e2c58f75d6b7ecaf0 100644 (file)
@@ -12,6 +12,7 @@ zpm-hash
 zpm-stat
 zpm-findpkg
 zpm-shell
 zpm-stat
 zpm-findpkg
 zpm-shell
+zpm-runscript
 *.zpm
 *.db
 soname
 *.zpm
 *.db
 soname
diff --git a/t/scripts.t b/t/scripts.t
new file mode 100755 (executable)
index 0000000..47ac6f3
--- /dev/null
@@ -0,0 +1,27 @@
+#!/bin/sh
+
+# test addfile
+
+. tap.sh
+
+plan 8
+
+PF=test.db
+pkgid=scriptrunner-1.0-1
+
+require zpm init $PF
+require zpm newpackage -f $PF $pkgid
+
+tryrun zpm setscript -f $PF scriptrunner-1.0-1 configure /bin/true
+tryrun zpm runscript -f $PF -p configure scriptrunner-1.0-1
+tryrun zpm setscript -f $PF scriptrunner-1.0-1 configure /bin/false
+zpm runscript -f $PF -p configure scriptrunner-1.0-1 2>/dev/null
+failsok failure script fails
+
+zpm runscript -f $PF -p nosuchphase -R scriptrunner-1.0-1 2>/dev/null
+failsok required non-existing script fails
+tryrun zpm runscript -f $PF -p nosuchphase scriptrunner-1.0-1 2>/dev/null
+
+finish
+
+rm -f $PF
index e6b1af50f51d97c146c361945488fc50cca4a2ed..84764b6acf2b4d7ee46193540c7cd33a583953ee 100644 (file)
@@ -94,6 +94,7 @@ int main(int ac, char **av){
        int failures = 0;
        char *pkgstr;
        int opt;
        int failures = 0;
        char *pkgstr;
        int opt;
+       int required = 0;
 
        char hash[ZPM_HASH_STRLEN+1];
        char *args[3];
 
        char hash[ZPM_HASH_STRLEN+1];
        char *args[3];
@@ -110,16 +111,13 @@ int main(int ac, char **av){
        }
        /* ZPM_PACKAGE_FILE ? */
 
        }
        /* ZPM_PACKAGE_FILE ? */
 
-       while ((opt = getopt(ac, av, "f:p:s:r:")) != -1) {
+       while ((opt = getopt(ac, av, "f:p:s:r:R")) != -1) {
                switch (opt) {
                switch (opt) {
-                       case 'f': db = optarg;
-                                 break;
-                       case 'p': phase = optarg;
-                                 break;
-                       case 's': script = optarg;
-                                 break;
-                       case 'r': chroot = optarg;
-                                 break;
+                       case 'f': db = optarg; break;
+                       case 'p': phase = optarg; break;
+                       case 's': script = optarg; break;
+                       case 'r': chroot = optarg; break;
+                       case 'R': required = 1; break;
                        default:
                                  usage();
                                  exit(EXIT_FAILURE);
                        default:
                                  usage();
                                  exit(EXIT_FAILURE);
@@ -169,8 +167,10 @@ int main(int ac, char **av){
                                failures++;
                        }
                } else {
                                failures++;
                        }
                } else {
-                       fprintf(stderr, "no script for %s %s\n", phase, pkgid);
-                       failures++;
+                       if (required) {
+                               fprintf(stderr, "no script for %s %s\n", phase, pkgid);
+                               failures++;
+                       }
                }
                free(pkgid);
        } else {
                }
                free(pkgid);
        } else {