Fix patch for gen_key to test gpg version.
[monkeysphere.git] / src / share / m / gen_subkey
index 9cc6028325a3621ec019b3d242bd53269e6b0573..cf1ed0cc08dd4d0bb9c19672318fa28d8f3d66f1 100644 (file)
@@ -44,12 +44,25 @@ Type '$PGRM help' for usage."
     # check that an authentication subkey does not already exist
     check_gpg_authentication_subkey "$keyID"
 
+    # determine which keyType to use from gpg version
+    keyType=7
+    case $(gpg --version | head -1 | awk '{ print $3 }' | cut -d. -f1) in
+       1)
+           if is_gpg_version_greater_equal 1.4.10 ; then
+               keyType=8
+           fi
+           ;;
+       2)
+           if is_gpg_version_greater_equal 2.0.13 ; then
+               keyType=8
+           fi
+           ;;
+       *)
+           keyType=8
+           ;;
+    esac
+
     # generate the list of commands that will be passed to edit-key
-    # 7 for < 1.4.10
-    # 8 for >= 1.4.10
-    # 7 for < 2.0.13
-    # 8 for >= 2.0.13
-    keyType=8
     editCommands="addkey
 $keyType
 S