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
zpm-stat
zpm-findpkg
zpm-shell
zpm-stat
zpm-findpkg
zpm-shell
--- /dev/null
+#!/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
int failures = 0;
char *pkgstr;
int opt;
int failures = 0;
char *pkgstr;
int opt;
char hash[ZPM_HASH_STRLEN+1];
char *args[3];
char hash[ZPM_HASH_STRLEN+1];
char *args[3];
}
/* 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) {
- 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);
- fprintf(stderr, "no script for %s %s\n", phase, pkgid);
- failures++;
+ if (required) {
+ fprintf(stderr, "no script for %s %s\n", phase, pkgid);
+ failures++;
+ }