]> pd.if.org Git - zpackage/blobdiff - zpm-script.c
add foreach_script function
[zpackage] / zpm-script.c
index 359970abd567d7934d641864c8e4e034e7c8d706..a91f2ac3195974c030a0fc5b28c9645e319feaf6 100644 (file)
@@ -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;
@@ -248,7 +254,9 @@ 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);