]> git.ipfire.org Git - thirdparty/openvpn.git/commitdiff
Added command-line option parser and an unsigned build option to build_all.py
authorSamuli Seppänen <samuli@openvpn.net>
Thu, 18 Nov 2010 16:00:54 +0000 (18:00 +0200)
committerDavid Sommerseth <dazo@users.sourceforge.net>
Thu, 18 Nov 2010 18:02:02 +0000 (19:02 +0100)
Modified win/build_all.py so that it parses command-line options using getopt.
Added option "-u / --unsigned" which allows forcing unsigned builds and a "-h /
--help" option. By default a signed build is generated, provided that the Python
SignTool module is installed. If not, the build is interrupted.

Signed-off-by: Samuli Seppänen <samuli@openvpn.net>
Acked-by: Peter Stuge <peter@stuge.se>
Signed-off-by: David Sommerseth <dazo@users.sourceforge.net>
win/build_all.py

index 92d2bf42c57683fc9cc3c9aa2a93483abd47f8ae..dec3a78d585af28acf9c9ca5d0d6b641b22e2580 100644 (file)
@@ -1,18 +1,59 @@
-from config_all import main as config_all\r
-from build import main as build_openvpn\r
-from build_ddk import main as build_ddk\r
-from sign import main as sign\r
-from make_dist import main as make_dist\r
-\r
-def main(config):\r
-    config_all(config)\r
-    build_openvpn()\r
-    build_ddk(config, 'tap', 'all')\r
-    build_ddk(config, 'tapinstall', 'all')\r
-    sign(config, 'all')\r
-    make_dist(config)\r
-\r
-# if we are run directly, and not loaded as a module\r
+import getopt, sys
+from config_all import main as config_all
+from build import main as build_openvpn
+from build_ddk import main as build_ddk
+from make_dist import main as make_dist
+
+def Usage():
+    '''Show usage information'''
+    print "Usage: build_all.py [OPTIONS]..."
+    print "Build OpenVPN using Visual Studio tools"
+    print
+    print " -h, --help         Show this help"
+    print " -u, --unsigned     Do not sign the TAP drivers"
+    sys.exit(1)
+
+def main(config):
+
+    # Do a signed build by default
+    signedBuild=True
+
+    # Parse the command line argument(s)
+    try:
+       opts, args = getopt.getopt(sys.argv[1:], "hu", ["help", "unsigned"])
+    except getopt.GetoptError:
+       Usage()
+
+    for o, a in opts:
+       if o in ("-h","--help"):
+          Usage()
+       if o in ("-u", "--unsigned"):
+          signedBuild=False
+
+
+    # Check if the SignTool module is present. This avoids ImportErrors popping
+    # up annoyingly _after_ the build.
+    if signedBuild:
+       try:
+          from signtool import SignTool
+       except (ImportError):
+          print "ERROR: SignTool python module not found! Can't do a signed build."
+          sys.exit(1)
+    else:
+       print "Doing an unsigned build as requested"
+
+    # Start the build
+    config_all(config)
+    build_openvpn()
+    build_ddk(config, 'tap', 'all')
+    build_ddk(config, 'tapinstall', 'all')
+
+    if signedBuild:
+       sign(config, 'all')
+
+    make_dist(config)
+
+# if we are run directly, and not loaded as a module
 if __name__ == "__main__":\r
     from wb import config\r
     main(config)\r