diff deploy/sign-plugin @ 31:6ba82eead9bb

Alternative approach to signing
author Chris Cannam
date Fri, 13 Dec 2019 12:51:22 +0000
parents 297711cfb455
children
line wrap: on
line diff
--- a/deploy/sign-plugin	Fri Dec 13 10:46:28 2019 +0000
+++ b/deploy/sign-plugin	Fri Dec 13 12:51:22 2019 +0000
@@ -2,29 +2,51 @@
 
 set -e
 
-if [ -z "$1" ]; then
+usage() {
     echo "Usage: $0 <plugin> [<plugin> ...]" 1>&2
+    echo "       $0 <plugin-dir>" 1>&2
     exit 2
+}    
+
+first_arg="$1"
+
+if [ -z "$first_arg" ]; then
+    usage
+fi
+
+if [ -d "$first_arg" ] && [ -n "$2" ]; then
+    usage
 fi
 
 paths=("$@")
 
 set -u
 
-for path in "${paths[@]}"; do
-    if [ ! -f "$path" ]; then
-        echo "ERROR: Path $path not found" 1>&2
-        exit 1
-    fi
-done
-
-for path in "${paths[@]}"; do
-
+sign() {
+    path="$1"
     if [ -d /Applications ]; then
         codesign -s "Developer ID Application: Chris Cannam" -fv --options runtime "$path"
     fi
+}
 
-done
+if [ -d "$first_arg" ]; then
+    for path in "$first_arg"/*.{dll,so,dylib} ; do
+        if [ -f "$path" ]; then
+            sign "$path"
+        fi
+    done
+    touch "$first_arg/.signed"
+else
+    for path in "${paths[@]}"; do
+        if [ ! -f "$path" ]; then
+            echo "ERROR: Path $path not found" 1>&2
+            exit 1
+        fi
+    done
+    for path in "${paths[@]}"; do
+        sign "$path"
+    done
+fi
 
 exit 0