]> git.ipfire.org Git - thirdparty/openvpn.git/commitdiff
Added support for prebuilt TAP-drivers. Automated embedding manifests.
authorSamuli Seppänen <samuli@openvpn.net>
Tue, 8 Mar 2011 14:07:49 +0000 (16:07 +0200)
committerDavid Sommerseth <davids@redhat.com>
Mon, 21 Mar 2011 14:15:12 +0000 (15:15 +0100)
Removed win/make_dist.py's dependency on TAP-driver and tapinstall.exe building.
Also added manifest embedding commands to win/make_dist.py. To avoid duplicate
code moved the "build_vc" method from win/build.py to win/wb.py and renamed it
"run_in_vs_shell".

Signed-off-by: Samuli Seppänen <samuli@openvpn.net>
Acked-by: James Yonan <james@openvpn.net>
Signed-off-by: David Sommerseth <davids@redhat.com>
win/build.py
win/build_all.py
win/make_dist.py
win/settings.in
win/tap_span.py
win/wb.py

index fdec7cf3f8e9166a7dde89fc644e80ec78a6f614..25f70c489595babe3da0588218c5a99a33044137 100644 (file)
@@ -1,28 +1,22 @@
-import os, sys\r
-from wb import system, config, home_fn, cd_home, cd_service_win32
-\r
-os.environ['PATH'] += ";%s\\VC" % (os.path.normpath(config['MSVC']),)\r
-\r
-def build_vc(cmd):\r
-    """Make sure environment variables are setup before build"""
-    system('cmd /c "vcvarsall.bat x86 && %s"' % (cmd,))\r
-\r
-def main():\r
+import os, sys
+from wb import system, config, home_fn, cd_home, cd_service_win32, run_in_vs_shell
+
+def main():
     """Build openvpn.exe and openvpnserv.exe"""
-    cd_home()\r
-    build_vc("nmake /f %s" % (home_fn('msvc.mak'),))\r
+    cd_home()
+    run_in_vs_shell("nmake /f %s" % (home_fn('msvc.mak'),))
     cd_service_win32()
-    build_vc("nmake /f %s" % ('msvc.mak'))
-\r
-def clean():\r
+    run_in_vs_shell("nmake /f %s" % ('msvc.mak'))
+
+def clean():
     """Clean up after openvpn.exe and openvpnserv.exe build"""
-    cd_home()\r
-    build_vc("nmake /f %s clean" % (home_fn('msvc.mak'),))\r
+    cd_home()
+    run_in_vs_shell("nmake /f %s clean" % (home_fn('msvc.mak'),))
     os.chdir("service-win32")
-    build_vc("nmake /f %s clean" % ('msvc.mak'))
-\r
-# if we are run directly, and not loaded as a module\r
-if __name__ == "__main__":\r
+    run_in_vs_shell("nmake /f %s clean" % ('msvc.mak'))
+
+# if we are run directly, and not loaded as a module
+if __name__ == "__main__":
     if len(sys.argv) == 2 and sys.argv[1] == 'clean':\r
         clean()\r
     else:\r
index 2c4d1aaed8f0918e32c438460e57775740c5fdbd..47716a15895c16e1f258322713d0c95da250bc62 100644 (file)
@@ -54,13 +54,14 @@ def main(config):
     if tap:
        build_ddk(config, 'tap', 'all')
        build_ddk(config, 'tapinstall', 'all')
-    else:
-       print "Not building the TAP driver"
-
-    if signedBuild:
-       sign(config, 'all')
+       if signedBuild:
+          sign(config, 'all')
+       make_dist(config,tap=True)
 
-    make_dist(config)
+    else:
+       if 'TAP_PREBUILT' in config:
+          print "Using prebuilt TAP driver"
+          make_dist(config,tap=False)
 
 # if we are run directly, and not loaded as a module
 if __name__ == "__main__":
index 70aaa60d6f17c994b3b8d010826c0a7542662d3c..730ccb70fd9288b59cd3dd3a0905678ead9d30af 100644 (file)
@@ -1,8 +1,8 @@
-import os\r
-from wb import home_fn, rm_rf, mkdir, cp_a, cp, rename
-\r
-def main(config, tap=True):\r
-    dist = config['DIST']\r
+import os
+from wb import home_fn, rm_rf, mkdir, cp_a, cp, rename, run_in_vs_shell
+
+def main(config, tap=True):
+    dist = config['DIST']
     assert dist\r
     dist = home_fn(dist)\r
     bin = os.path.join(dist, 'bin')\r
@@ -11,14 +11,13 @@ def main(config, tap=True):
     samples = os.path.join(dist, 'samples')
 \r
     # build dist and subdirectories\r
-    rm_rf(dist)\r
-    mkdir(dist)\r
-    mkdir(bin)\r
-    if tap:\r
-        mkdir(i386)\r
-        mkdir(amd64)\r
+    rm_rf(dist)
+    mkdir(dist)
+    mkdir(bin)
+    mkdir(i386)
+    mkdir(amd64)
     mkdir(samples)
-\r
+
     # copy openvpn.exe, openvpnserv.exe and their manifests
     cp(home_fn('openvpn.exe'), bin)\r
     cp(home_fn('openvpn.exe.manifest'), bin)\r
@@ -45,34 +44,64 @@ def main(config, tap=True):
     cp(home_fn('sample-config-files/server.conf'), samples)
     rename(os.path.join(samples,'client.conf'), os.path.join(samples, 'client.ovpn'))
     rename(os.path.join(samples,'server.conf'), os.path.join(samples, 'server.ovpn'))
-\r
-    # copy MSVC CRT\r
-    cp_a(home_fn(config['MSVC_CRT']), bin)\r
-\r
-    if tap:\r
-        # copy TAP drivers\r
-        for dir_name, dest in (('amd64', amd64), ('i386', i386)):\r
-            dir = home_fn(os.path.join('tap-win32', dir_name))\r
-            for dirpath, dirnames, filenames in os.walk(dir):\r
-                for f in filenames:\r
-                    root, ext = os.path.splitext(f)\r
-                    if ext in ('.inf', '.cat', '.sys'):\r
-                        cp(os.path.join(dir, f), dest)\r
-                break\r
-\r
-        # Copy tapinstall.exe (usually known as devcon.exe)
-        dest = {'amd64' : amd64, 'i386' : i386}\r
-        for dirpath, dirnames, filenames in os.walk(home_fn('tapinstall')):\r
-            for f in filenames:\r
-                if f == 'tapinstall.exe':\r
-                   # dir_name is either i386 or amd64
-                    dir_name = os.path.basename(dirpath)\r
-                    src = os.path.join(dirpath, f)\r
-                    if dir_name in dest:\r
-                        cp(src, dest[dir_name])\r
-\r
 
-# if we are run directly, and not loaded as a module\r
-if __name__ == "__main__":\r
+    # embed manifests to executables and DLLs
+    for f in [ "openvpn.exe", "openvpnserv.exe", "lzo2.dll", "libpkcs11-helper-1.dll" ]:
+
+        outputresource = os.path.join(bin,f)
+        manifest = outputresource+".manifest"
+
+        # EXEs and DLLs require slightly different treatment
+        if f.endswith(".exe"):
+            type = "1"
+        elif f.endswith(".dll"):
+            type = "2"
+        else:
+            print "ERROR: Could not embed manifest to "+outputresouce+", bailing out."
+            sys.exit(1)
+
+        # Embed the manifest
+        run_in_vs_shell('mt.exe -manifest %s -outputresource:%s;%s' % (manifest, outputresource, type))
+
+    # copy MSVC CRT
+    cp_a(home_fn(config['MSVC_CRT']), bin)
+
+    # TAP-driver and tapinstall.exe were built, so copy those over
+    if tap:
+        drv_dir = 'tap-win32'
+        ti_dir = 'tapinstall'
+
+    # we're using prebuilt TAP-driver and tapinstall.exe
+    elif 'TAP_PREBUILT' in config:
+        drv_dir = config['TAP_PREBUILT']
+        ti_dir = config['TAP_PREBUILT']
+
+    else:
+        print "ERROR: Could not find prebuilt TAP-drivers or tapinstall.exe. Please check win/settings.in"
+        sys.exit(1)
+
+    # copy TAP drivers
+    for dir_name, dest in (('amd64', amd64), ('i386', i386)):
+        dir = home_fn(os.path.join(drv_dir, dir_name))
+        for dirpath, dirnames, filenames in os.walk(dir):
+            for f in filenames:
+                root, ext = os.path.splitext(f)
+                if ext in ('.inf', '.cat', '.sys'):
+                    cp(os.path.join(dir, f), dest)
+            break
+
+    # Copy tapinstall.exe (usually known as devcon.exe)
+    dest = {'amd64' : amd64, 'i386' : i386}
+    for dirpath, dirnames, filenames in os.walk(home_fn(ti_dir)):
+        for f in filenames:
+            if f == 'devcon.exe':
+                dir_name = os.path.basename(dirpath)
+                src = os.path.join(dirpath, f)
+                dst = os.path.join(dest[dir_name],'tapinstall.exe')
+                if dir_name in dest:
+                    cp(src, dst, dest_is_dir=False)
+
+# if we are run directly, and not loaded as a module
+if __name__ == "__main__":
     from wb import config\r
     main(config)\r
index 25109e2721ea31bf60ca0d15df6cf77309cdc26e..6dded7931cb8f329470d673200a088577206c644 100644 (file)
@@ -69,6 +69,9 @@
 !define SIGNTOOL        "../signtool"
 !define PRODUCT_SIGN_CN "openvpn"
 
+# Directory with prebuilt TAP drivers and tapinstall.exes
+!define TAP_PREBUILT "../tap-prebuilt"
+
 ; DEBUGGING -- set to something like "-DBG2"
 !define OUTFILE_LABEL ""
 
index 9cd127baa8c442459c6ca70ef007058948f748a4..82c60d32145208aa67369ad5ca5723717db0c340 100644 (file)
@@ -23,13 +23,13 @@ def copy_tap(src, dest, x64):
 \r
 def copy_tapinstall(src, dest, x64):\r
     base = { False : 'i386', True: 'amd64' }[x64]\r
-    mkdir_silent(dest)\r
-    for dirpath, dirnames, filenames in os.walk(home_fn(src)):\r
-        for f in filenames:\r
-            if f == 'tapinstall.exe':\r
-                dir_name = os.path.basename(dirpath)\r
-                s = os.path.join(dirpath, f)\r
-                if dir_name == base:\r
+    mkdir_silent(dest)
+    for dirpath, dirnames, filenames in os.walk(home_fn(src)):
+        for f in filenames:
+            if f == 'devcon.exe':
+                dir_name = os.path.basename(dirpath)
+                s = os.path.join(dirpath, f)
+                if dir_name == base:
                     cp(s, dest)\r
 \r
 def main():\r
index d1b0b3e6a85dc00489df9f976ecfbf20412dd1f7..33eefbd7745a0a2821e1acc1c095c9b89b498574 100644 (file)
--- a/win/wb.py
+++ b/win/wb.py
@@ -41,12 +41,17 @@ def cd_service_win32():
     os.chdir(os.path.join(os.path.dirname(__file__), '../service-win32'))
 
 def system(cmd):\r
-    print "RUN:", cmd\r
-    os.system(cmd)\r
-\r
-def parse_version_m4(kv, version_m4):\r
+    print "RUN:", cmd
+    os.system(cmd)
+
+def run_in_vs_shell(cmd):
+    """Make sure environment variables are setup before running command"""
+    os.environ['PATH'] += ";%s\\VC" % (os.path.normpath(config['MSVC']),)
+    system('cmd /c "vcvarsall.bat x86 && %s"' % (cmd,))
+
+def parse_version_m4(kv, version_m4):
     '''Parse define lines in version.m4'''
-    r = re.compile(r'^define\((\w+),\[(.*)\]\)$')\r
+    r = re.compile(r'^define\((\w+),\[(.*)\]\)$')
     f = open(version_m4)\r
     for line in f:\r
         line = line.rstrip()\r