~ubuntu-branches/ubuntu/oneiric/openvpn/oneiric

« back to all changes in this revision

Viewing changes to win/make_dist.py

  • Committer: Bazaar Package Importer
  • Author(s): Chuck Short
  • Date: 2011-06-16 18:33:37 UTC
  • mfrom: (1.3.6 upstream)
  • mto: This revision was merged to the branch mainline in revision 46.
  • Revision ID: james.westby@ubuntu.com-20110616183337-etb3qgbwjkn8zniq
Tags: upstream-2.2.0
ImportĀ upstreamĀ versionĀ 2.2.0

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
import os
2
 
from wb import home_fn, rm_rf, mkdir, cp_a, cp
3
 
 
4
 
def main(config, tap=True):
5
 
    dist = config['DIST']
6
 
    assert dist
7
 
    dist = home_fn(dist)
8
 
    bin = os.path.join(dist, 'bin')
9
 
    i386 = os.path.join(dist, 'i386')
10
 
    amd64 = os.path.join(dist, 'amd64')
11
 
 
12
 
    # build dist and subdirectories
13
 
    rm_rf(dist)
14
 
    mkdir(dist)
15
 
    mkdir(bin)
16
 
    if tap:
17
 
        mkdir(i386)
18
 
        mkdir(amd64)
19
 
 
20
 
    # copy openvpn.exe and manifest
21
 
    cp(home_fn('openvpn.exe'), bin)
22
 
    cp(home_fn('openvpn.exe.manifest'), bin)
23
 
 
24
 
    # copy DLL dependencies
25
 
    cp(home_fn(config['LZO_DIR']+'/bin/lzo2.dll'), bin)
26
 
    cp(home_fn(config['OPENSSL_DIR']+'/bin/libeay32.dll'), bin)
27
 
    cp(home_fn(config['OPENSSL_DIR']+'/bin/ssleay32.dll'), bin)
28
 
 
29
 
    # copy MSVC CRT
30
 
    cp_a(home_fn(config['MSVC_CRT']), bin)
31
 
 
32
 
    if tap:
33
 
        # copy TAP drivers
34
 
        for dir_name, dest in (('amd64', amd64), ('i386', i386)):
35
 
            dir = home_fn(os.path.join('tap-win32', dir_name))
36
 
            for dirpath, dirnames, filenames in os.walk(dir):
37
 
                for f in filenames:
38
 
                    root, ext = os.path.splitext(f)
39
 
                    if ext in ('.inf', '.cat', '.sys'):
40
 
                        cp(os.path.join(dir, f), dest)
41
 
                break
42
 
 
43
 
        # copy tapinstall
44
 
        dest = {'amd64' : amd64, 'i386' : i386}
45
 
        for dirpath, dirnames, filenames in os.walk(home_fn('tapinstall')):
46
 
            for f in filenames:
47
 
                if f == 'tapinstall.exe':
48
 
                    dir_name = os.path.basename(dirpath)
49
 
                    src = os.path.join(dirpath, f)
50
 
                    if dir_name in dest:
51
 
                        cp(src, dest[dir_name])
52
 
 
53
 
# if we are run directly, and not loaded as a module
54
 
if __name__ == "__main__":
55
 
    from wb import config
56
 
    main(config)
 
1
import os
 
2
from wb import home_fn, rm_rf, mkdir, cp_a, cp, rename, run_in_vs_shell
 
3
 
 
4
def main(config, tap=True):
 
5
    dist = config['DIST']
 
6
    assert dist
 
7
    dist = home_fn(dist)
 
8
    bin = os.path.join(dist, 'bin')
 
9
    i386 = os.path.join(dist, 'i386')
 
10
    amd64 = os.path.join(dist, 'amd64')
 
11
    samples = os.path.join(dist, 'samples')
 
12
 
 
13
    # build dist and subdirectories
 
14
    rm_rf(dist)
 
15
    mkdir(dist)
 
16
    mkdir(bin)
 
17
    mkdir(i386)
 
18
    mkdir(amd64)
 
19
    mkdir(samples)
 
20
 
 
21
    # copy openvpn.exe, openvpnserv.exe and their manifests
 
22
    cp(home_fn('openvpn.exe'), bin)
 
23
    cp(home_fn('openvpn.exe.manifest'), bin)
 
24
    cp(home_fn('service-win32/openvpnserv.exe'), bin)
 
25
    cp(home_fn('service-win32/openvpnserv.exe.manifest'), bin)
 
26
 
 
27
    # copy openvpn-gui
 
28
    cp(home_fn(config['OPENVPN_GUI_DIR']+"/"+config['OPENVPN_GUI']), bin)
 
29
 
 
30
    # copy DLL dependencies
 
31
    cp(home_fn(config['LZO_DIR']+'/bin/lzo2.dll'), bin)
 
32
    cp(home_fn(config['LZO_DIR']+'/bin/lzo2.dll.manifest'), bin)
 
33
    cp(home_fn(config['OPENSSL_DIR']+'/bin/libeay32.dll'), bin)
 
34
    cp(home_fn(config['OPENSSL_DIR']+'/bin/ssleay32.dll'), bin)
 
35
    cp(home_fn(config['PKCS11_HELPER_DIR']+'/lib/libpkcs11-helper-1.dll'), bin)
 
36
    cp(home_fn(config['PKCS11_HELPER_DIR']+'/lib/libpkcs11-helper-1.dll.manifest'), bin)
 
37
 
 
38
    # copy OpenSSL utilities (=openvpn.exe)
 
39
    cp(home_fn(config['OPENSSL_DIR']+'/bin/openssl.exe'), bin)
 
40
 
 
41
    # copy sample config files; renaming is necessary due to openvpn.nsi script
 
42
    cp(home_fn('install-win32/sample.ovpn'), samples)
 
43
    cp(home_fn('sample-config-files/client.conf'), samples)
 
44
    cp(home_fn('sample-config-files/server.conf'), samples)
 
45
    rename(os.path.join(samples,'client.conf'), os.path.join(samples, 'client.ovpn'))
 
46
    rename(os.path.join(samples,'server.conf'), os.path.join(samples, 'server.ovpn'))
 
47
 
 
48
    # embed manifests to executables and DLLs
 
49
    for f in [ "openvpn.exe", "openvpnserv.exe", "lzo2.dll", "libpkcs11-helper-1.dll" ]:
 
50
 
 
51
        outputresource = os.path.join(bin,f)
 
52
        manifest = outputresource+".manifest"
 
53
 
 
54
        # EXEs and DLLs require slightly different treatment
 
55
        if f.endswith(".exe"):
 
56
            type = "1"
 
57
        elif f.endswith(".dll"):
 
58
            type = "2"
 
59
        else:
 
60
            print "ERROR: Could not embed manifest to "+outputresouce+", bailing out."
 
61
            sys.exit(1)
 
62
 
 
63
        # Embed the manifest
 
64
        run_in_vs_shell('mt.exe -manifest %s -outputresource:%s;%s' % (manifest, outputresource, type))
 
65
 
 
66
    # copy MSVC CRT
 
67
    cp_a(home_fn(config['MSVC_CRT']), bin)
 
68
 
 
69
    # TAP-driver and tapinstall.exe were built, so copy those over
 
70
    if tap:
 
71
        drv_dir = 'tap-win32'
 
72
        ti_dir = 'tapinstall'
 
73
 
 
74
    # we're using prebuilt TAP-driver and tapinstall.exe
 
75
    elif 'TAP_PREBUILT' in config:
 
76
        drv_dir = config['TAP_PREBUILT']
 
77
        ti_dir = config['TAP_PREBUILT']
 
78
 
 
79
    else:
 
80
        print "ERROR: Could not find prebuilt TAP-drivers or tapinstall.exe. Please check win/settings.in"
 
81
        sys.exit(1)
 
82
 
 
83
    # copy TAP drivers
 
84
    for dir_name, dest in (('amd64', amd64), ('i386', i386)):
 
85
        dir = home_fn(os.path.join(drv_dir, dir_name))
 
86
        for dirpath, dirnames, filenames in os.walk(dir):
 
87
            for f in filenames:
 
88
                root, ext = os.path.splitext(f)
 
89
                if ext in ('.inf', '.cat', '.sys'):
 
90
                    cp(os.path.join(dir, f), dest)
 
91
            break
 
92
 
 
93
    # Copy tapinstall.exe (usually known as devcon.exe)
 
94
    dest = {'amd64' : amd64, 'i386' : i386}
 
95
    for dirpath, dirnames, filenames in os.walk(home_fn(ti_dir)):
 
96
        for f in filenames:
 
97
            if f in ( 'devcon.exe', 'tapinstall.exe' ):
 
98
                dir_name = os.path.basename(dirpath)
 
99
                src = os.path.join(dirpath, f)
 
100
                dst = os.path.join(dest[dir_name],'tapinstall.exe')
 
101
                if dir_name in dest:
 
102
                    cp(src, dst, dest_is_dir=False)
 
103
 
 
104
# if we are run directly, and not loaded as a module
 
105
if __name__ == "__main__":
 
106
    from wb import config
 
107
    main(config)