Skip to contentSkip to conversation

Added ENABLE_PASSWORD_SAVE to config-win32.h

PATCH In review Samuli Seppänen 2 participants 15 messages Feb 11, 2011 – Feb 27, 2011

lore
Share & tools
lore
#0 lore raw

PATCH 1/13 Added ENABLE_PASSWORD_SAVE to config-win32.h

This change adds ENABLE_PASSWORD_SAVE to config-win32.h. This option is also defined in win/settings.in, but it does not have any effect there.

---
 config-win32.h |    3 +++
 1 files changed, 3 insertions(+), 0 deletions(-)
config-win32.h +3 -0
index be0b320..87a0b68 100644
@@ -50,6 +50,9 @@ typedef unsigned long in_addr_t;
 #define TAP_WIN32_DEBUG
 #endif
 
+/* Enable reading credentials from a file */
+#define ENABLE_PASSWORD_SAVE 1
+
 /* Enable client/server capability */
 #define ENABLE_CLIENT_SERVER 1
 
Signature · 1 line
1.6.3.3
#1 lore raw

PATCH 2/13 Added a nmake makefile for openvpnserv.exe building

This change adds a nmake makefile (service-win32/msvc.mak) which allows building openvpnserv.exe using the new Python-based buildsystem.

---
 service-win32/msvc.mak |   30 ++++++++++++++++++++++++++++++
 1 files changed, 30 insertions(+), 0 deletions(-)
 create mode 100644 service-win32/msvc.mak
service-win32/msvc.mak new file +30 -0
new file mode 100644
index 0000000..0da85a5
@@ -0,0 +1,30 @@
+# This makefile builds the OpenVPN service wrapper for Windows in the 
+# Visual Studio 2008 environment.
+
+# Some of these libs may not be needed
+LIBS = ws2_32.lib crypt32.lib iphlpapi.lib winmm.lib user32.lib gdi32.lib advapi32.lib wininet.lib
+EXE = openvpnserv.exe
+
+CPP=cl.exe
+CPP_ARG_COMMON=/nologo /W3 -DWIN32 -DWIN32_LEAN_AND_MEAN -D_CONSOLE -D_MBCS -D_CRT_SECURE_NO_DEPRECATE /FD /c -I".."
+CPP_PROJ=$(CPP_ARG_COMMON) /O2 /MD -DNDEBUG
+
+LINK32=link.exe
+LINK32_FLAGS=/nologo /subsystem:console /incremental:no
+
+OBJS = \
+	openvpnserv.obj \
+	service.obj
+
+openvpnserv : $(OBJS)
+	$(LINK32) @<<
+	$(LINK32_FLAGS) "/out:$(EXE)" $(LIBS) $(OBJS)
+<<
+
+clean :
+	del /Q $(OBJS) $(EXE) *.idb *.pdb
+
+.c.obj::
+   $(CPP) @<<
+   $(CPP_PROJ) $<
+<<
Signature · 1 line
1.6.3.3
#2 lore raw

PATCH 3/13 Moved TAP-driver version info to version.m4. Cleaned up win/settings.in.

In reply to Samuli Seppänen

Previously parts of TAP-driver version information were stored in win/settings.in. This patch moves all of it to version.m4. This patch also cleans up and adds comments to win/settings.in

---
 version.m4      |    5 ++++-
 win/settings.in |   25 +++++++++----------------
 2 files changed, 13 insertions(+), 17 deletions(-)
version.m4 +4 -1
index 794a4a8..475a82f 100644
@@ -1,6 +1,9 @@
 dnl define the OpenVPN version
-define(PRODUCT_VERSION,[2.2-beta5])
+define(PRODUCT_VERSION,[2.2-rc])
 dnl define the TAP version
 define(PRODUCT_TAP_ID,[tap0901])
 define(PRODUCT_TAP_WIN32_MIN_MAJOR,[9])
 define(PRODUCT_TAP_WIN32_MIN_MINOR,[1])
+define(PRODUCT_TAP_RELDATE,[04/19/2010])
+define(PRODUCT_TAP_DEVICE_DESCRIPTION,[TAP-Win32 Adapter V9])
+define(PRODUCT_TAP_PROVIDER,[TAP-Win32 Provider V9])
win/settings.in +9 -16
index f8eeb20..c349752 100644
@@ -1,39 +1,32 @@
 # Version numbers, settings, and dependencies
 # for Windows OpenVPN installer.
+#
+# Note that some variables are parsed by wb.py from version.m4 and are not 
+# stored in this file. This is done to allow using the old and new Windows build 
+# systems side-by-side
 
 # Branding
 !define PRODUCT_NAME      "OpenVPN"
 !define PRODUCT_UNIX_NAME "openvpn"
 !define PRODUCT_FILE_EXT  "ovpn"
 
-# Allow --askpass and --auth-user-pass passwords to be read from a file
-;!define ENABLE_PASSWORD_SAVE
-
-# Include the OpenVPN GUI exe in the installer.
-# May be undefined.
+# Include the OpenVPN GUI exe in the installer. Comment out USE_GUI to disable.
+!define USE_GUI
 !define OPENVPN_GUI_DIR "../openvpn-gui"
 !define OPENVPN_GUI     "openvpn-gui-1.0.3.exe"
 
 # Prebuilt libraries.  DMALLOC is optional.
 !define OPENSSL_DIR	  "../openssl"
 !define LZO_DIR		  "../lzo"
+!define PKCS11_HELPER_DIR "../pkcs11-helper"
 
 # write output files here
 !define DIST   "dist"
 
-# tapinstall.exe source code.
-# Not needed if DRVBINSRC is defined
-# (or if using pre-built mode).
+# tapinstall.exe (a.k.a. devcon.exe) source code. Not needed if DRVBINSRC is 
+# defined (or if using pre-built mode).
 !define TISRC	"../tapinstall"
 
-# TAP Adapter parameters.  Note that PRODUCT_TAP_ID is
-# defined in version.m4.
-!define PRODUCT_TAP_DEVICE_DESCRIPTION  "TAP-Win32 Adapter V9"
-!define PRODUCT_TAP_PROVIDER            "TAP-Win32 Provider V9"
-!define PRODUCT_TAP_MAJOR_VER           9
-!define PRODUCT_TAP_MINOR_VER           7
-!define PRODUCT_TAP_RELDATE             "04/19/2010"
-
 # TAP adapter icon -- visible=0x81 or hidden=0x89
 !define PRODUCT_TAP_CHARACTERISTICS     0x81
 
Signature · 1 line
1.6.3.3
#3 lore raw

PATCH 4/13 Added helper functionality to win/wb.py

In reply to Samuli Seppänen

This change adds several helper functions to win/wb.py:

- config-win32.h parser (to read build configuration options)
- helper function to cd to service-win32 for openvpnserv.exe building
- code to dynamically generate TAP-driver -related variables from version.m4, required by tap-win32/tapdrv.c
- configure.h generator to allow viewing build options using openvpn --version
- creation of temporary version.m4-based file to allow importing it's variables to the NSI installer script (win/openvpn.nsi)
- helper function to rename files (used in win/make_dist.py)

---
 win/wb.py |   99 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 99 insertions(+), 0 deletions(-)
win/wb.py +99 -0
index 8e23684..2d7bd61 100644
@@ -19,6 +19,12 @@ def get_config():
 
     return kv
 
+def get_build_params():
+    kv = {}
+    parse_config_win32_h(kv,home_fn('config-win32.h'))
+
+    return kv
+
 def mod_fn(fn, src=__file__, real=True):
     p = os.path.join(os.path.dirname(src), os.path.normpath(fn))
     if real:
@@ -31,18 +37,35 @@ def home_fn(fn, real=True):
 def cd_home():
     os.chdir(os.path.join(os.path.dirname(__file__), '..'))
 
+def cd_service_win32():
+    os.chdir(os.path.join(os.path.dirname(__file__), '../service-win32'))
+
 def system(cmd):
     print "RUN:", cmd
     os.system(cmd)
 
 def parse_version_m4(kv, version_m4):
+    '''Parse define lines in version.m4'''
     r = re.compile(r'^define\((\w+),\[(.*)\]\)$')
     f = open(version_m4)
     for line in f:
         line = line.rstrip()
         m = re.match(r, line)
+
         if m:
             g = m.groups()
+
+            # If we encounter PRODUCT_TAP_WIN32_MIN_MAJOR or 
+            # PRODUCT_TAP_WIN32_MIN_MAJOR then we need to generate extra 
+            # variables, PRODUCT_TAP_MAJOR_VER and PRODUCT_TAP_MINOR_VER with 
+            # the same contents. This is necessary because tap-win32/tapdrv.c 
+            # build depends on those.
+            if g[0] == 'PRODUCT_TAP_WIN32_MIN_MAJOR':
+                kv['PRODUCT_TAP_MAJOR_VER'] = g[1]
+            elif g[0] == 'PRODUCT_TAP_WIN32_MIN_MINOR':
+                kv['PRODUCT_TAP_MINOR_VER'] = g[1]
+
+            # Add the variable to build configuration
             kv[g[0]] = g[1]
     f.close()
 
@@ -57,6 +80,39 @@ def parse_settings_in(kv, settings_in):
             kv[g[0]] = g[1] or ''
     f.close()
 
+def parse_config_win32_h(kv, config_win32_h):
+    r = re.compile(r'^#define\s+(ENABLE_\w+)\s+(\w+)')
+    s = re.compile(r'^#ifdef|^#ifndef')
+    e = re.compile(r'^#endif')
+
+    # How "deep" in nested conditional statements are we?
+    depth=0
+
+    f = open(config_win32_h)
+
+    for line in f:
+        line = line.rstrip()
+
+        # Check if this is a #define line starting with ENABLE_
+        m = re.match(r, line)
+
+        # Calculate how deep we're in (nested) conditional statements. A simple
+        # #ifdef/#endif state switcher would get confused by an #endif followed
+        # by a #define.
+        if re.match(s, line):
+            depth=depth+1
+        if re.match(e, line):
+            depth=depth-1
+
+        if m:
+            # Only add this #define if it's not inside a conditional statement 
+            # block
+            if depth == 0:
+                g = m.groups()
+                kv[g[0]] = g[1] or ''
+    f.close()
+
+
 def dict_def(dict, newdefs):
     ret = dict.copy()
     ret.update(newdefs)
@@ -70,6 +126,43 @@ def build_autodefs(kv, autodefs_in, autodefs_out):
                quote_end='@',
                head_comment='/* %s */\n\n' % autogen)
 
+def build_configure_h(kv, configure_h_out, head_comment):
+    """Generate a configure.h dynamically"""
+    fout = open(configure_h_out, 'w')
+    configure_defines='#define CONFIGURE_DEFINES \"'
+    configure_call='#define CONFIGURE_CALL \" config_all.py \"'
+
+    fout.write(head_comment)
+
+    dict = get_build_params()
+
+    for key, value in dict.iteritems():
+        configure_defines = configure_defines + " " + key + "=" + value + ","
+
+    configure_defines = configure_defines + "\"" + "\n"
+
+    fout.write(configure_defines)
+    fout.write(configure_call)
+    fout.close()
+
+def build_version_m4_vars(version_m4_vars_out, head_comment):
+    """Generate a temporary file containing variables from version.m4 in 
+win/settings.in format. This done to allow importing them in win/openvpn.nsi"""
+
+    fout = open(version_m4_vars_out, 'w')
+    fout.write(head_comment)
+
+    kv = {}
+    parse_version_m4(kv, home_fn('version.m4'))
+
+    for key, value in kv.iteritems():
+         line = "!define " + key + "\t" + "\"" + value + "\"" + "\n"
+         fout.write(line)
+
+    fout.close()
+
+
+
 def preprocess(kv, in_fn, out_fn, quote_begin=None, quote_end=None, if_prefix=None, head_comment=None):
     def repfn(m):
         var, = m.groups()
@@ -116,6 +209,7 @@ def print_key_values(kv):
         print "%s%s%s" % (k, ' '*(32-len(k)), repr(v))
 
 def get_sources(makefile_am):
+    """Parse ../Makefile.am to obtain a list of .h and .c files"""
     c = set()
     h = set()
     f = open(makefile_am)
@@ -147,6 +241,7 @@ def output_mak_list(title, srclist, ext):
     return ret
 
 def make_headers_objs(makefile_am):
+    """Generate HEADER and OBJS entries dynamically from ../Makefile.am"""
     c, h = get_sources(makefile_am)
     ret = output_mak_list('HEADERS', h, 'h')
     ret += output_mak_list('OBJS', c, 'obj')
@@ -182,6 +277,10 @@ def cp(src, dest, dest_is_dir=True):
     print "COPY %s %s" % (src, dest)
     shutil.copyfile(src, dest)
 
+def rename(src, dest):
+    print "RENAME %s %s" % (src, dest)
+    shutil.move(src, dest)
+
 def rm_rf(path):
     try:
         shutil.rmtree(path, onerror=onerror)
Signature · 1 line
1.6.3.3
#4 lore raw

PATCH 5/13 Added support for viewing config-win32.h paramters to win/show.py

In reply to Samuli Seppänen

The win/show.py tools is used to view build parameters interactively. This changes it so that it displays parameters parsed from config-win32.h in addition to those from win/settings.in.

---
 win/show.py |    6 +++---
 1 files changed, 3 insertions(+), 3 deletions(-)
win/show.py +3 -3
index 9558c87..6b1140a 100644
@@ -1,9 +1,9 @@
-from wb import get_config
+from wb import get_config, get_build_params
 from js import JSON
 
 def main():
-    kv = get_config()
-    print JSON().encode(kv)
+    print JSON().encode(get_config())
+    print JSON().encode(get_build_params())
 
 # if we are run directly, and not loaded as a module
 if __name__ == "__main__":
Signature · 1 line
1.6.3.3
#5 lore raw

PATCH 6/13 Added comments and made small modifications to win/msvc.mak.in

In reply to Samuli Seppänen

The win/msvc.mak.in file is used as basis for msvc.mak file which drives openvpn.exe building. This change separates output file from LINK32_FLAGS and adds helpful comments to the win/msvc.mak.in file.

---
 win/msvc.mak.in |   32 ++++++++++++++++----------------
 1 files changed, 16 insertions(+), 16 deletions(-)
win/msvc.mak.in +16 -16
index 5d94a6e..1ffb5da 100644
@@ -1,12 +1,15 @@
-# This makefile builds the user-mode component
-# of OpenVPN for Windows in the Visual Studio 2008 environment.
-
-# To build:
-#    python win\config.py
-#    nmake /f msvc.mak
-
-# Each of the OPENSSL and LZO dirs should have 'lib' and 'include'
-# directories under them.
+# This makefile builds the user-mode component of OpenVPN for Windows in the 
+# Visual Studio 2008 environment. Note that this file is basis for the real 
+# makefile (..\msvc.mak) but unusable as is. The real makefile is automatically 
+# generated during the build process by the Python build scripts.
+#
+# A few details are in order:
+#
+# - Everything between @<< and << is inserted into a s.c. "in-line file". This 
+#   file drives the linker (link.exe).
+# - HEADERS_OBJS is expanded to all all header and source files listed in 
+#  ..\Makefile.am
+# - OPENSSL_DIR and LZO_DIR are dynamically created from settings.in
 
 OPENSSL = @OPENSSL_DIR@
 OPENSSL_DYNAMIC = libeay32.lib ssleay32.lib
@@ -30,22 +33,19 @@ LINK32=link.exe
 !ifdef PRODUCT_OPENVPN_DEBUG
 # debug:
 CPP_PROJ=$(CPP_ARG_COMMON) /MD /Z7
-LINK32_FLAGS=/nologo /subsystem:console /incremental:no /opt:ref /opt:icf /debug /out:"$(EXE)"
-# old debug:
-#CPP_PROJ=$(CPP_ARG_COMMON) /MDd /Zi /Od -D_DEBUG
-#LINK32_FLAGS=/nologo /subsystem:console /incremental:no /debug /out:"$(EXE)"
+LINK32_FLAGS=/nologo /subsystem:console /incremental:no /opt:ref /opt:icf /debug
 !else
 # release:
 CPP_PROJ=$(CPP_ARG_COMMON) /O2 /MD -DNDEBUG
-LINK32_FLAGS=/nologo /subsystem:console /incremental:no /out:"$(EXE)"
+LINK32_FLAGS=/nologo /subsystem:console /incremental:no
 !endif
 
-# HEADERS and OBJS definitions, automatically generated
+# HEADERS and OBJS definitions, automatically generated from ../Makefile.am
 @HEADERS_OBJS@
 
 openvpn : $(OBJS)
 	$(LINK32) @<<
-	$(LINK32_FLAGS) $(LIB_DIRS) $(LIBS) $(OBJS)
+	$(LINK32_FLAGS) "/out:$(EXE)" $(LIB_DIRS) $(LIBS) $(OBJS)
 <<
 
 clean :
Signature · 1 line
1.6.3.3
#6 lore raw

PATCH 7/13 Added command-line switch to win/build_all.py to skip TAP driver building

In reply to Samuli Seppänen

Modified win/build_all.py so that by giving -n or --notap switch the TAP driver is not built. This is useful if using prebuilt TAP drivers, or when WinDDK is not installed.

---
 win/build_all.py |   23 ++++++++++++++++-------
 1 files changed, 16 insertions(+), 7 deletions(-)
win/build_all.py +16 -7
index dec3a78..2c4d1aa 100644
@@ -11,6 +11,7 @@ def Usage():
     print
     print " -h, --help		Show this help"
     print " -u, --unsigned	Do not sign the TAP drivers"
+    print " -n, --notap		Don't build the TAP driver"
     sys.exit(1)
 
 def main(config):
@@ -18,9 +19,12 @@ def main(config):
     # Do a signed build by default
     signedBuild=True
 
+    # Build the TAP driver by default
+    tap=True
+
     # Parse the command line argument(s)
     try:
-       opts, args = getopt.getopt(sys.argv[1:], "hu", ["help", "unsigned"])
+       opts, args = getopt.getopt(sys.argv[1:], "hun", ["help", "unsigned", "notap"])
     except getopt.GetoptError:
        Usage()
 
@@ -29,7 +33,8 @@ def main(config):
           Usage()
        if o in ("-u", "--unsigned"):
           signedBuild=False
-
+       if o in ("-n", "--notap"):
+          tap=False
 
     # Check if the SignTool module is present. This avoids ImportErrors popping
     # up annoyingly _after_ the build.
@@ -45,8 +50,12 @@ def main(config):
     # Start the build
     config_all(config)
     build_openvpn()
-    build_ddk(config, 'tap', 'all')
-    build_ddk(config, 'tapinstall', 'all')
+
+    if tap:
+       build_ddk(config, 'tap', 'all')
+       build_ddk(config, 'tapinstall', 'all')
+    else:
+       print "Not building the TAP driver"
 
     if signedBuild:
        sign(config, 'all')
@@ -54,6 +63,6 @@ def main(config):
     make_dist(config)
 
 # if we are run directly, and not loaded as a module
-if __name__ == "__main__":
-    from wb import config
-    main(config)
+if __name__ == "__main__":
+    from wb import config
+    main(config)
Signature · 1 line
1.6.3.3
#7 lore raw

PATCH 8/13 Added configure.h and version.m4 variable parsing to win/config.py

In reply to Samuli Seppänen

Python-based buildsystem uses win/config.py to obtain global build parameters from various sources. Added parsing of the (fake) configure.h and version.m4 to it so that other Python build files can use them.

---
 win/config.py |    4 +++-
 1 files changed, 3 insertions(+), 1 deletions(-)
win/config.py +3 -1
index cf38cac..d4dc6f4 100644
@@ -1,6 +1,8 @@
-from wb import preprocess, autogen, mod_fn, home_fn, build_autodefs, make_headers_objs, dict_def
+from wb import preprocess, autogen, mod_fn, home_fn, build_configure_h, build_version_m4_vars, build_autodefs, make_headers_objs, dict_def
 
 def main(config):
+    build_configure_h(config, mod_fn(home_fn('configure.h')), head_comment='/* %s */\n\n' % autogen)
+    build_version_m4_vars(mod_fn(mod_fn('version_m4_vars.tmp')), head_comment='/* %s */\n\n' % autogen)
     build_autodefs(config, mod_fn('autodefs.h.in'), home_fn('autodefs.h'))
     ho = make_headers_objs(home_fn('Makefile.am'))
 
Signature · 1 line
1.6.3.3
#8 lore raw

PATCH 9/13 Added openvpnserv.exe building to win/build.py

In reply to Samuli Seppänen

Made win/build.py call nmake in service-win32 directory to build openvpnserv.exe after main build (openvpn.exe) has finished.

---
 win/build.py |    9 ++++++++-
 1 files changed, 8 insertions(+), 1 deletions(-)
win/build.py +8 -1
index 3a9fbc7..1861377 100644
@@ -1,18 +1,25 @@
 import os, sys
-from wb import system, config, home_fn, cd_home
+from wb import system, config, home_fn, cd_home, cd_service_win32
 
 os.environ['PATH'] += ";%s\\VC" % (os.path.normpath(config['MSVC']),)
 
 def build_vc(cmd):
+    """Make sure environment variables are setup before build"""
     system('cmd /c "vcvarsall.bat x86 && %s"' % (cmd,))
 
 def main():
+    """Build openvpn.exe and openvpnserv.exe"""
     cd_home()
     build_vc("nmake /f %s" % (home_fn('msvc.mak'),))
+    cd_service_win32()
+    build_vc("nmake /f %s" % ('msvc.mak'))
 
 def clean():
+    """Clean up after openvpn.exe and openvpnserv.exe build"""
     cd_home()
     build_vc("nmake /f %s clean" % (home_fn('msvc.mak'),))
+    os.chdir("service-win32")
+    build_vc("nmake /f %s clean" % ('msvc.mak'))
 
 # if we are run directly, and not loaded as a module
 if __name__ == "__main__":
Signature · 1 line
1.6.3.3
#9 lore raw

PATCH 10/13 Added comments to win/build_ddk.py

In reply to Samuli Seppänen
---
 win/build_ddk.py |    1 +
 1 files changed, 1 insertions(+), 0 deletions(-)
win/build_ddk.py +1 -0
index 1a0cf82..65eed25 100644
@@ -8,6 +8,7 @@ def build_ddk(config, dir, x64):
     return build_tap(ddk_path, ddk_major, debug, dir, x64)
 
 def build_tap(ddk_path, ddk_major, debug, dir, x64):
+    """Build drivers using WinDDK tools"""
     setenv_bat = os.path.realpath(os.path.join(ddk_path, 'bin/setenv.bat'))
     target = 'chk' if debug else 'fre'
     if x64:
Signature · 1 line
1.6.3.3
#10 lore raw

PATCH 11/13 Several modifications to win/make_dist.py to allow building the NSI installer

In reply to Samuli Seppänen

Added copying of all remaining openvpn dependencies to dist directory so that the NSI installer script (win/openvpn.nsi) can find and use them more easily. This includes openvpn.exe, openvpnserv.exe, libpkcs11-helper-1.dll, openssl.exe, and example files. The associated, external DDL/manifest files are copied also, so that embedding them with mt.exe is easier. This is a temporary solution until nmake makefiles are modified to automate this process, except for a few of the library dependencies (lzo2.dll and libpkcs11-helper-1.dll).

---
 win/make_dist.py |   28 +++++++++++++++++++++++++---
 1 files changed, 25 insertions(+), 3 deletions(-)
win/make_dist.py +25 -3
index a6a0563..ab54c2a 100644
@@ -1,5 +1,5 @@
 import os
-from wb import home_fn, rm_rf, mkdir, cp_a, cp
+from wb import home_fn, rm_rf, mkdir, cp_a, cp, rename
 
 def main(config, tap=True):
     dist = config['DIST']
@@ -8,6 +8,7 @@ def main(config, tap=True):
     bin = os.path.join(dist, 'bin')
     i386 = os.path.join(dist, 'i386')
     amd64 = os.path.join(dist, 'amd64')
+    samples = os.path.join(dist, 'samples')
 
     # build dist and subdirectories
     rm_rf(dist)
@@ -16,15 +17,34 @@ def main(config, tap=True):
     if tap:
         mkdir(i386)
         mkdir(amd64)
+    mkdir(samples)
 
-    # copy openvpn.exe and manifest
+    # copy openvpn.exe, openvpnserv.exe and their manifests
     cp(home_fn('openvpn.exe'), bin)
     cp(home_fn('openvpn.exe.manifest'), bin)
+    cp(home_fn('service-win32/openvpnserv.exe'), bin)
+    cp(home_fn('service-win32/openvpnserv.exe.manifest'), bin)
+
+    # copy openvpn-gui
+    cp(home_fn(config['OPENVPN_GUI_DIR']+"/"+config['OPENVPN_GUI']), bin)
 
     # copy DLL dependencies
     cp(home_fn(config['LZO_DIR']+'/bin/lzo2.dll'), bin)
+    cp(home_fn(config['LZO_DIR']+'/bin/lzo2.dll.manifest'), bin)
     cp(home_fn(config['OPENSSL_DIR']+'/bin/libeay32.dll'), bin)
     cp(home_fn(config['OPENSSL_DIR']+'/bin/ssleay32.dll'), bin)
+    cp(home_fn(config['PKCS11_HELPER_DIR']+'/lib/libpkcs11-helper-1.dll'), bin)
+    cp(home_fn(config['PKCS11_HELPER_DIR']+'/lib/libpkcs11-helper-1.dll.manifest'), bin)
+
+    # copy OpenSSL utilities (=openvpn.exe)
+    cp(home_fn(config['OPENSSL_DIR']+'/bin/openssl.exe'), bin)
+
+    # copy sample config files; renaming is necessary due to openvpn.nsi script
+    cp(home_fn('install-win32/sample.ovpn'), samples)
+    cp(home_fn('sample-config-files/client.conf'), samples)
+    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'))
 
     # copy MSVC CRT
     cp_a(home_fn(config['MSVC_CRT']), bin)
@@ -40,16 +60,18 @@ def main(config, tap=True):
                         cp(os.path.join(dir, f), dest)
                 break
 
-        # copy tapinstall
+        # Copy tapinstall.exe (usually known as devcon.exe)
         dest = {'amd64' : amd64, 'i386' : i386}
         for dirpath, dirnames, filenames in os.walk(home_fn('tapinstall')):
             for f in filenames:
                 if f == 'tapinstall.exe':
+		    # dir_name is either i386 or amd64
                     dir_name = os.path.basename(dirpath)
                     src = os.path.join(dirpath, f)
                     if dir_name in dest:
                         cp(src, dest[dir_name])
 
+
 # if we are run directly, and not loaded as a module
 if __name__ == "__main__":
     from wb import config
Signature · 1 line
1.6.3.3
#11 lore raw

PATCH 12/13 Copied install-win32/setpath.nsi to win/setpath.nsi

In reply to Samuli Seppänen
---
 win/setpath.nsi |  231 +++++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 231 insertions(+), 0 deletions(-)
 create mode 100755 win/setpath.nsi
win/setpath.nsi new file +231 -0
new file mode 100755
index 0000000..a9626c3
@@ -0,0 +1,231 @@
+; Modify the user's PATH variable.
+;
+; Modified by JY to have both a RemoveFromPath
+; and an un.RemoveFromPath which are basically
+; copies of each other.  Why does NSIS demand
+; this nonsense?
+;
+; Modified Feb 14, 2005 by Mathias Sundman:
+;   Added code to remove the semicolon at the end of the path
+;   when uninstalling.
+;
+;   Added code to make sure we don't insert an extra semicolon
+;   before our path if there already exist one at the end of
+;   the original path.
+;
+;   Removed duplicated "un. and install" functions and made
+;   macros to duplicate the code instead.
+
+; example usage
+;
+;Section "Add to path"
+;  Push $INSTDIR
+;  Call AddToPath
+;SectionEnd
+;
+;# ...
+;
+;Section "uninstall"
+;  # ...
+;  Push $INSTDIR
+;  Call un.RemoveFromPath
+;  # ...
+;SectionEnd
+
+!verbose 3
+!include "WinMessages.NSH"
+!verbose 4
+
+;====================================================
+; AddToPath - Adds the given dir to the search path.
+;        Input - head of the stack
+;        Note - Win9x systems requires reboot
+;====================================================
+Function AddToPath
+  Exch $0
+  Push $1
+  Push $2
+  
+  Call IsNT
+  Pop $1
+  StrCmp $1 1 AddToPath_NT
+    ; Not on NT
+    StrCpy $1 $WINDIR 2
+    FileOpen $1 "$1\autoexec.bat" a
+    FileSeek $1 0 END
+    GetFullPathName /SHORT $0 $0
+    FileWrite $1 "$\r$\nSET PATH=%PATH%;$0$\r$\n"
+    FileClose $1
+    Goto AddToPath_done
+
+  AddToPath_NT:
+    ReadRegStr $1 HKCU "Environment" "PATH"
+    StrCpy $2 $1 1 -1 # copy last char
+    StrCmp $2 ";" 0 +2 # if last char == ;
+      StrCpy $1 $1 -1 # remove last char
+
+    StrCmp $1 "" AddToPath_NTdoIt
+      StrCpy $0 "$1;$0"
+      Goto AddToPath_NTdoIt
+    AddToPath_NTdoIt:
+      WriteRegExpandStr HKCU "Environment" "PATH" $0
+      SendMessage ${HWND_BROADCAST} ${WM_WININICHANGE} 0 "STR:Environment" /TIMEOUT=5000
+  
+  AddToPath_done:
+    Pop $2
+    Pop $1
+    Pop $0
+FunctionEnd
+
+;====================================================
+; RemoveFromPath - Remove a given dir from the path
+;     Input: head of the stack
+;====================================================
+!macro RemoveFromPath un
+Function ${un}RemoveFromPath
+  Exch $0
+  Push $1
+  Push $2
+  Push $3
+  Push $4
+  Push $5
+  
+  Call ${un}IsNT
+  Pop $1
+  StrCmp $1 1 RemoveFromPath_NT
+    ; Not on NT
+    StrCpy $1 $WINDIR 2
+    FileOpen $1 "$1\autoexec.bat" r
+    GetTempFileName $4
+    FileOpen $2 $4 w
+    GetFullPathName /SHORT $0 $0
+    StrCpy $0 "SET PATH=%PATH%;$0"
+    SetRebootFlag true
+    Goto RemoveFromPath_dosLoop
+    
+    RemoveFromPath_dosLoop:
+      FileRead $1 $3
+      StrCmp $3 "$0$\r$\n" RemoveFromPath_dosLoop
+      StrCmp $3 "$0$\n" RemoveFromPath_dosLoop
+      StrCmp $3 "$0" RemoveFromPath_dosLoop
+      StrCmp $3 "" RemoveFromPath_dosLoopEnd
+      FileWrite $2 $3
+      Goto RemoveFromPath_dosLoop
+    
+    RemoveFromPath_dosLoopEnd:
+      FileClose $2
+      FileClose $1
+      StrCpy $1 $WINDIR 2
+      Delete "$1\autoexec.bat"
+      CopyFiles /SILENT $4 "$1\autoexec.bat"
+      Delete $4
+      Goto RemoveFromPath_done
+
+  RemoveFromPath_NT:
+    StrLen $2 $0
+    ReadRegStr $1 HKCU "Environment" "PATH"
+    Push $1
+    Push $0
+    Call ${un}StrStr ; Find $0 in $1
+    Pop $0 ; pos of our dir
+    IntCmp $0 -1 RemoveFromPath_done
+      ; else, it is in path
+      StrCpy $3 $1 $0 ; $3 now has the part of the path before our dir
+      IntOp $2 $2 + $0 ; $2 now contains the pos after our dir in the path (';')
+      IntOp $2 $2 + 1 ; $2 now containts the pos after our dir and the semicolon.
+      StrLen $0 $1
+      StrCpy $1 $1 $0 $2
+      StrCpy $3 "$3$1"
+
+      StrCpy $5 $3 1 -1 # copy last char
+      StrCmp $5 ";" 0 +2 # if last char == ;
+        StrCpy $3 $3 -1 # remove last char
+
+      WriteRegExpandStr HKCU "Environment" "PATH" $3
+      SendMessage ${HWND_BROADCAST} ${WM_WININICHANGE} 0 "STR:Environment" /TIMEOUT=5000
+  
+  RemoveFromPath_done:
+    Pop $5
+    Pop $4
+    Pop $3
+    Pop $2
+    Pop $1
+    Pop $0
+FunctionEnd
+!macroend
+!insertmacro RemoveFromPath ""
+!insertmacro RemoveFromPath "un."
+
+
+;====================================================
+; StrStr - Finds a given string in another given string.
+;               Returns -1 if not found and the pos if found.
+;          Input: head of the stack - string to find
+;                      second in the stack - string to find in
+;          Output: head of the stack
+;====================================================
+!macro StrStr un
+Function ${un}StrStr
+  Push $0
+  Exch
+  Pop $0 ; $0 now have the string to find
+  Push $1
+  Exch 2
+  Pop $1 ; $1 now have the string to find in
+  Exch
+  Push $2
+  Push $3
+  Push $4
+  Push $5
+
+  StrCpy $2 -1
+  StrLen $3 $0
+  StrLen $4 $1
+  IntOp $4 $4 - $3
+
+  StrStr_loop:
+    IntOp $2 $2 + 1
+    IntCmp $2 $4 0 0 StrStrReturn_notFound
+    StrCpy $5 $1 $3 $2
+    StrCmp $5 $0 StrStr_done StrStr_loop
+
+  StrStrReturn_notFound:
+    StrCpy $2 -1
+
+  StrStr_done:
+    Pop $5
+    Pop $4
+    Pop $3
+    Exch $2
+    Exch 2
+    Pop $0
+    Pop $1
+FunctionEnd
+!macroend
+!insertmacro StrStr ""
+!insertmacro StrStr "un."
+
+;====================================================
+; IsNT - Returns 1 if the current system is NT, 0
+;        otherwise.
+;     Output: head of the stack
+;====================================================
+!macro IsNT un
+Function ${un}IsNT
+  Push $0
+  ReadRegStr $0 HKLM "SOFTWARE\Microsoft\Windows NT\CurrentVersion" CurrentVersion
+  StrCmp $0 "" 0 IsNT_yes
+  ; we are not NT.
+  Pop $0
+  Push 0
+  Return
+
+  IsNT_yes:
+    ; NT!!!
+    Pop $0
+    Push 1
+FunctionEnd
+!macroend
+!insertmacro IsNT ""
+!insertmacro IsNT "un."
+
Signature · 1 line
1.6.3.3
#12 lore raw

PATCH 13/13 Added first version of NSI installer script to win/openvpn.nsi

In reply to Samuli Seppänen

This win/openvpn.nsi file is a heavily cleaned-up version of the install-win32/openvpn.nsi file. The key differences:

- paths have been adapted to new buildsystem's requirements
- obsolete XGUI support has been removed
- unused Windows version detection has been removed
- variables specific to new build system (win/settings.in, version.m4) are imported
- a few new installer options have been introduced:
- install lzo2.dll
- install msvcr90.dll (a requirement from VS2008 builds)

---
 win/openvpn.nsi |  802 +++++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 802 insertions(+), 0 deletions(-)
 create mode 100755 win/openvpn.nsi
win/openvpn.nsi new file +802 -0
new file mode 100755
index 0000000..cbae21a
@@ -0,0 +1,802 @@
+; ****************************************************************************
+; * Copyright (C) 2002-2010 OpenVPN Technologies, Inc.                       *
+; *  This program is free software; you can redistribute it and/or modify    *
+; *  it under the terms of the GNU General Public License version 2          *
+; *  as published by the Free Software Foundation.                           *
+; ****************************************************************************
+
+; OpenVPN install script for Windows, using NSIS
+
+SetCompressor lzma
+
+!include "MUI.nsh"
+
+# Include basic build settings
+!include "settings.in"
+
+# Include variables generated dynamically from version.m4 by wb.py
+!include "version_m4_vars.tmp"
+
+;!include "guidefs.nsi"
+!include "setpath.nsi"
+
+!ifdef EXTRACT_FILES
+!include "MultiFileExtract.nsi"
+!endif
+
+!define GEN "..\dist"
+!define BIN "${GEN}\bin"
+!define EASYRSA "..\easy-rsa"
+
+!define PRODUCT_ICON "icon.ico"
+
+!ifdef PRODUCT_TAP_DEBUG
+!define DBG_POSTFIX "-DBG"
+!else
+!define DBG_POSTFIX ""
+!endif
+
+!define VERSION "${PRODUCT_VERSION}${DBG_POSTFIX}"
+
+!define TAP "${PRODUCT_TAP_ID}"
+!define TAPDRV "${TAP}.sys"
+
+; Default service settings
+!define SERV_CONFIG_DIR   "$INSTDIR\config"
+!define SERV_CONFIG_EXT   "${PRODUCT_FILE_EXT}"
+!define SERV_EXE_PATH     "$INSTDIR\bin\${PRODUCT_UNIX_NAME}.exe"
+!define SERV_LOG_DIR      "$INSTDIR\log"
+!define SERV_PRIORITY     "NORMAL_PRIORITY_CLASS"
+!define SERV_LOG_APPEND   "0"
+
+;--------------------------------
+;Configuration
+
+  ;General
+
+  OutFile "${GEN}\${PRODUCT_UNIX_NAME}-${VERSION}${OUTFILE_LABEL}-install.exe"
+
+  ShowInstDetails show
+  ShowUninstDetails show
+
+  ;Folder selection page
+  InstallDir "$PROGRAMFILES\${PRODUCT_NAME}"
+  
+  ;Remember install folder
+  InstallDirRegKey HKCU "Software\${PRODUCT_NAME}" ""
+
+;--------------------------------
+;Modern UI Configuration
+
+  Name "${PRODUCT_NAME} ${VERSION} ${TITLE_LABEL}"
+
+  !define MUI_WELCOMEPAGE_TEXT "This wizard will guide you through the installation of ${PRODUCT_NAME}, an Open Source VPN package by James Yonan.\r\n\r\nNote that the Windows version of ${PRODUCT_NAME} will only run on Win 2000, XP, or higher.\r\n\r\n\r\n"
+
+  !define MUI_COMPONENTSPAGE_TEXT_TOP "Select the components to install/upgrade.  Stop any ${PRODUCT_NAME} processes or the ${PRODUCT_NAME} service if it is running.  All DLLs are installed locally."
+
+  !define MUI_COMPONENTSPAGE_SMALLDESC
+  !define MUI_FINISHPAGE_SHOWREADME "$INSTDIR\INSTALL-win32.txt"
+  !define MUI_FINISHPAGE_NOAUTOCLOSE
+  !define MUI_ABORTWARNING
+  !define MUI_ICON "..\images\${PRODUCT_ICON}"
+  !define MUI_UNICON "..\images\${PRODUCT_ICON}"
+  !define MUI_HEADERIMAGE
+  !define MUI_HEADERIMAGE_BITMAP "..\images\install-whirl.bmp"
+  !define MUI_UNFINISHPAGE_NOAUTOCLOSE
+
+  !insertmacro MUI_PAGE_WELCOME
+  !insertmacro MUI_PAGE_LICENSE "..\COPYRIGHT.GPL"
+  !insertmacro MUI_PAGE_COMPONENTS
+  !insertmacro MUI_PAGE_DIRECTORY
+  !insertmacro MUI_PAGE_INSTFILES
+  !insertmacro MUI_PAGE_FINISH
+  
+  !insertmacro MUI_UNPAGE_CONFIRM
+  !insertmacro MUI_UNPAGE_INSTFILES  
+  !insertmacro MUI_UNPAGE_FINISH
+
+
+;--------------------------------
+;Languages
+ 
+  !insertmacro MUI_LANGUAGE "English"
+  
+;--------------------------------
+;Language Strings
+
+  LangString DESC_SecOpenVPNUserSpace ${LANG_ENGLISH} "Install ${PRODUCT_NAME} user-space components, including ${PRODUCT_UNIX_NAME}.exe."
+
+!ifdef USE_GUI
+  LangString DESC_SecOpenVPNGUI ${LANG_ENGLISH} "Install ${PRODUCT_NAME} GUI by Mathias Sundman"
+!endif
+
+  LangString DESC_SecOpenVPNEasyRSA ${LANG_ENGLISH} "Install ${PRODUCT_NAME} RSA scripts for X509 certificate management."
+
+  LangString DESC_SecOpenSSLDLLs ${LANG_ENGLISH} "Install OpenSSL DLLs locally (may be omitted if DLLs are already installed globally)."
+
+  LangString DESC_SecPKCS11DLLs ${LANG_ENGLISH} "Install PKCS#11 helper DLLs locally (may be omitted if DLLs are already installed globally)."
+
+  LangString DESC_SecLZO2DLLs ${LANG_ENGLISH} "Install LZO2 DLLs locally (may be omitted if DLLs are already installed globally)."
+
+  LangString DESC_SecMSVCR90DLL ${LANG_ENGLISH} "Install Microsoft Visual C 9.0 Runtime (may be omitted if it is already installed globally)."
+
+  LangString DESC_SecTAP ${LANG_ENGLISH} "Install/Upgrade the TAP virtual device driver.  Will not interfere with CIPE."
+
+  LangString DESC_SecService ${LANG_ENGLISH} "Install the ${PRODUCT_NAME} service wrapper (${PRODUCT_UNIX_NAME}serv.exe)"
+
+  LangString DESC_SecOpenSSLUtilities ${LANG_ENGLISH} "Install the OpenSSL Utilities (used for generating public/private key pairs)."
+
+  LangString DESC_SecAddPath ${LANG_ENGLISH} "Add ${PRODUCT_NAME} executable directory to the current user's PATH."
+
+  LangString DESC_SecAddShortcuts ${LANG_ENGLISH} "Add ${PRODUCT_NAME} shortcuts to the current user's Start Menu."
+
+  LangString DESC_SecFileAssociation ${LANG_ENGLISH} "Register ${PRODUCT_NAME} config file association (*.${SERV_CONFIG_EXT})"
+
+;--------------------------------
+;Reserve Files
+  
+  ;Things that need to be extracted on first (keep these lines before any File command!)
+  ;Only useful for BZIP2 compression
+  
+  ReserveFile "..\images\install-whirl.bmp"
+
+;--------------------------------
+;Macros
+
+!macro WriteRegStringIfUndef ROOT SUBKEY KEY VALUE
+Push $R0
+ReadRegStr $R0 "${ROOT}" "${SUBKEY}" "${KEY}"
+StrCmp $R0 "" +1 +2
+WriteRegStr "${ROOT}" "${SUBKEY}" "${KEY}" '${VALUE}'
+Pop $R0
+!macroend
+
+!macro DelRegStringIfUnchanged ROOT SUBKEY KEY VALUE
+Push $R0
+ReadRegStr $R0 "${ROOT}" "${SUBKEY}" "${KEY}"
+StrCmp $R0 '${VALUE}' +1 +2
+DeleteRegValue "${ROOT}" "${SUBKEY}" "${KEY}"
+Pop $R0
+!macroend
+
+!macro DelRegKeyIfUnchanged ROOT SUBKEY VALUE
+Push $R0
+ReadRegStr $R0 "${ROOT}" "${SUBKEY}" ""
+StrCmp $R0 '${VALUE}' +1 +2
+DeleteRegKey "${ROOT}" "${SUBKEY}"
+Pop $R0
+!macroend
+
+!macro DelRegKeyIfEmpty ROOT SUBKEY
+Push $R0
+EnumRegValue $R0 "${ROOT}" "${SUBKEY}" 1
+StrCmp $R0 "" +1 +2
+DeleteRegKey /ifempty "${ROOT}" "${SUBKEY}"
+Pop $R0
+!macroend
+
+;------------------------------------------
+;Set reboot flag based on tapinstall return
+
+Function CheckReboot
+  IntCmp $R0 1 "" noreboot noreboot
+  IntOp $R0 0 & 0
+  SetRebootFlag true
+  DetailPrint "REBOOT flag set"
+ noreboot:
+FunctionEnd
+
+;--------------------------------
+;Installer Sections
+
+Function .onInit
+  ClearErrors
+
+# Verify that user has admin privs
+  UserInfo::GetName
+  IfErrors ok
+  Pop $R0
+  UserInfo::GetAccountType
+  Pop $R1
+  StrCmp $R1 "Admin" ok
+    Messagebox MB_OK "Administrator privileges required to install ${PRODUCT_NAME} [$R0/$R1]"
+    Abort
+  ok:
+
+# Delete previous start menu
+  RMDir /r $SMPROGRAMS\${PRODUCT_NAME}
+
+# FIXME: reimplement Windows version checking code that was located here, but 
+# disabled intentionally to avoid Windows 7 issues. This should do it:
+#
+# http://nsis.sourceforge.net/Get_Windows_version
+#
+# Blacklisting should be safer than whitelisting used originally.
+
+FunctionEnd
+
+!ifndef SF_SELECTED
+!define SF_SELECTED 1
+!endif
+
+;--------------------
+;Pre-install section
+
+Section -pre
+
+  ; Stop OpenVPN if currently running
+  DetailPrint "Previous Service REMOVE (if exists)"
+  nsExec::ExecToLog '"$INSTDIR\bin\${PRODUCT_UNIX_NAME}serv.exe" -remove'
+  Pop $R0 # return value/error/timeout
+
+  Sleep 3000
+
+SectionEnd
+
+Section "${PRODUCT_NAME} User-Space Components" SecOpenVPNUserSpace
+
+  SetOverwrite on
+  SetOutPath "$INSTDIR\bin"
+
+  File "${BIN}\${PRODUCT_UNIX_NAME}.exe"
+
+SectionEnd
+
+!ifdef USE_GUI
+Section "${PRODUCT_NAME} GUI" SecOpenVPNGUI
+
+  SetOverwrite on
+  SetOutPath "$INSTDIR\bin"
+
+  File "${BIN}\${OPENVPN_GUI}"
+
+SectionEnd
+!endif
+
+Section "${PRODUCT_NAME} RSA Certificate Management Scripts" SecOpenVPNEasyRSA
+
+  SetOverwrite on
+  SetOutPath "$INSTDIR\easy-rsa"
+
+  # FIXME: the easy-rsa directory would need cleaning up
+
+  # Original nsi script looked for openssl.cnf.sample
+  File "${EASYRSA}\2.0\openssl.cnf"
+
+  File "${EASYRSA}\Windows\vars.bat.sample"
+
+  File "${EASYRSA}\Windows\init-config.bat"
+
+  File "${EASYRSA}\Windows\README.txt"
+  File "${EASYRSA}\Windows\build-ca.bat"
+  File "${EASYRSA}\Windows\build-dh.bat"
+  File "${EASYRSA}\Windows\build-key-server.bat"
+  File "${EASYRSA}\Windows\build-key.bat"
+  File "${EASYRSA}\Windows\build-key-pkcs12.bat"
+  File "${EASYRSA}\Windows\clean-all.bat"
+  File "${EASYRSA}\Windows\index.txt.start"
+  File "${EASYRSA}\Windows\revoke-full.bat"
+  File "${EASYRSA}\Windows\serial.start"
+
+SectionEnd
+
+Section "${PRODUCT_NAME} Service" SecService
+
+  SetOverwrite on
+
+  SetOutPath "$INSTDIR\bin"
+  File "${BIN}\${PRODUCT_UNIX_NAME}serv.exe"
+
+  SetOutPath "$INSTDIR\config"
+
+  FileOpen $R0 "$INSTDIR\config\README.txt" w
+  FileWrite $R0 "This directory should contain ${PRODUCT_NAME} configuration files$\r$\n"
+  FileWrite $R0 "each having an extension of .${SERV_CONFIG_EXT}$\r$\n"
+  FileWrite $R0 "$\r$\n"
+  FileWrite $R0 "When ${PRODUCT_NAME} is started as a service, a separate ${PRODUCT_NAME}$\r$\n"
+  FileWrite $R0 "process will be instantiated for each configuration file.$\r$\n"
+  FileClose $R0
+
+  SetOutPath "$INSTDIR\sample-config"
+  File "${GEN}\samples\sample.${SERV_CONFIG_EXT}"
+  File "${GEN}\samples\client.${SERV_CONFIG_EXT}"
+  File "${GEN}\samples\server.${SERV_CONFIG_EXT}"
+
+  CreateDirectory "$INSTDIR\log"
+  FileOpen $R0 "$INSTDIR\log\README.txt" w
+  FileWrite $R0 "This directory will contain the log files for ${PRODUCT_NAME}$\r$\n"
+  FileWrite $R0 "sessions which are being run as a service.$\r$\n"
+  FileClose $R0
+
+SectionEnd
+
+Section "${PRODUCT_NAME} File Associations" SecFileAssociation
+SectionEnd
+
+Section "OpenSSL DLLs" SecOpenSSLDLLs
+
+  SetOverwrite on
+  SetOutPath "$INSTDIR\bin"
+  File "${BIN}\libeay32.dll"
+  File "${BIN}\ssleay32.dll"
+
+SectionEnd
+
+Section "OpenSSL Utilities" SecOpenSSLUtilities
+
+  SetOverwrite on
+  SetOutPath "$INSTDIR\bin"
+  File "${BIN}\openssl.exe"
+
+SectionEnd
+
+Section "PKCS#11 DLLs" SecPKCS11DLLs
+
+  SetOverwrite on
+  SetOutPath "$INSTDIR\bin"
+  File "${BIN}\libpkcs11-helper-1.dll"
+
+SectionEnd
+
+Section "LZO2 DLLs" SecLZO2DLLs
+
+  SetOverwrite on
+  SetOutPath "$INSTDIR\bin"
+  File "${BIN}\lzo2.dll"
+
+SectionEnd
+
+Section "Microsoft Visual C 9.0 Runtime DLL" SecMSVCR90DLL
+
+  SetOverwrite on
+  SetOutPath "$INSTDIR\bin"
+  File "${BIN}\Microsoft.VC90.CRT\msvcr90.dll"
+  File "${BIN}\Microsoft.VC90.CRT\Microsoft.VC90.CRT.manifest"
+
+SectionEnd
+
+
+
+
+Section "TAP Virtual Ethernet Adapter" SecTAP
+
+  SetOverwrite on
+
+  # Generate TAP driver install script dynamically
+  FileOpen $R0 "$INSTDIR\bin\addtap.bat" w
+  FileWrite $R0 "rem Add a new TAP virtual ethernet adapter$\r$\n"
+  FileWrite $R0 '"$INSTDIR\bin\tapinstall.exe" install "$INSTDIR\driver\OemWin2k.inf" ${TAP}$\r$\n'
+  FileWrite $R0 "pause$\r$\n"
+  FileClose $R0
+
+  # Generate TAP driver removal script dynamically
+  FileOpen $R0 "$INSTDIR\bin\deltapall.bat" w
+  FileWrite $R0 "echo WARNING: this script will delete ALL TAP virtual adapters (use the device manager to delete adapters one at a time)$\r$\n"
+  FileWrite $R0 "pause$\r$\n"
+  FileWrite $R0 '"$INSTDIR\bin\tapinstall.exe" remove ${TAP}$\r$\n'
+  FileWrite $R0 "pause$\r$\n"
+  FileClose $R0
+
+  ; Check if we are running on a 64 bit system.
+  System::Call "kernel32::GetCurrentProcess() i .s"
+  System::Call "kernel32::IsWow64Process(i s, *i .r0)"
+  IntCmp $0 0 tap-32bit
+
+; tap-64bit:
+
+  DetailPrint "We are running on a 64-bit system."
+
+  SetOutPath "$INSTDIR\bin"
+
+  File "${GEN}\amd64\tapinstall.exe"
+
+  SetOutPath "$INSTDIR\driver"
+
+  File "${GEN}\amd64\OemWin2k.inf"
+  File "${GEN}\amd64\${TAPDRV}"
+  File "${GEN}\amd64\${PRODUCT_TAP_ID}.cat"
+
+goto tapend
+
+tap-32bit:
+
+  DetailPrint "We are running on a 32-bit system."
+
+  SetOutPath "$INSTDIR\bin"
+  File "${GEN}\i386\tapinstall.exe"
+
+  SetOutPath "$INSTDIR\driver"
+  File "${GEN}\i386\OemWin2k.inf"
+  File "${GEN}\i386\${TAPDRV}"
+  File "${GEN}\i386\${PRODUCT_TAP_ID}.cat"
+
+  tapend:
+
+SectionEnd
+
+Section "Add ${PRODUCT_NAME} to PATH" SecAddPath
+
+  ; remove previously set path (if any)
+  Push "$INSTDIR\bin"
+  Call RemoveFromPath
+
+  ; append our bin directory to end of current user path
+  Push "$INSTDIR\bin"
+  Call AddToPath
+
+SectionEnd
+
+Section "Add Shortcuts to Start Menu" SecAddShortcuts
+
+  SetOverwrite on
+  CreateDirectory "$SMPROGRAMS\${PRODUCT_NAME}"
+  CreateDirectory "$SMPROGRAMS\${PRODUCT_NAME}\Documentation"
+  WriteINIStr "$SMPROGRAMS\${PRODUCT_NAME}\Documentation\${PRODUCT_NAME} Windows Notes.url" "InternetShortcut" "URL" "http://openvpn.net/INSTALL-win32.html"
+  WriteINIStr "$SMPROGRAMS\${PRODUCT_NAME}\Documentation\${PRODUCT_NAME} Manual Page.url" "InternetShortcut" "URL" "http://openvpn.net/man.html"
+  WriteINIStr "$SMPROGRAMS\${PRODUCT_NAME}\Documentation\${PRODUCT_NAME} HOWTO.url" "InternetShortcut" "URL" "http://openvpn.net/howto.html"
+  WriteINIStr "$SMPROGRAMS\${PRODUCT_NAME}\Documentation\${PRODUCT_NAME} Web Site.url" "InternetShortcut" "URL" "http://openvpn.net/"
+  CreateShortCut "$SMPROGRAMS\${PRODUCT_NAME}\Uninstall ${PRODUCT_NAME}.lnk" "$INSTDIR\Uninstall.exe"
+
+SectionEnd
+
+;--------------------
+;Post-install section
+
+Section -post
+
+  SetOverwrite on
+
+  ; delete old tapinstall.exe
+  ;Delete "$INSTDIR\bin\tapinstall.exe"
+
+  ; Store README, license, icon
+  SetOverwrite on
+  SetOutPath $INSTDIR
+  File "..\INSTALL-win32.txt"
+  File "..\COPYRIGHT.GPL"
+  File "..\images\${PRODUCT_ICON}"
+
+  ; store sample config files
+  !ifdef SAMPCONF_DIR
+    SetOverwrite on
+    SetOutPath "$INSTDIR\config"
+  !ifdef SAMPCONF_CONF
+    File "${GEN}\conf\${SAMPCONF_CONF}"
+  !endif
+  !ifdef SAMPCONF_CONF2
+    File "${GEN}\conf\${SAMPCONF_CONF2}"
+  !endif
+  !ifdef SAMPCONF_P12
+    File "${GEN}\conf\${SAMPCONF_P12}"
+  !endif
+  !ifdef SAMPCONF_TA
+    File "${GEN}\conf\${SAMPCONF_TA}"
+  !endif
+  !ifdef SAMPCONF_CA
+    File "${GEN}\conf\${SAMPCONF_CA}"
+  !endif
+  !ifdef SAMPCONF_CRT
+    File "${GEN}\conf\${SAMPCONF_CRT}"
+  !endif
+  !ifdef SAMPCONF_KEY
+    File "${GEN}\conf\${SAMPCONF_KEY}"
+  !endif
+  !ifdef SAMPCONF_DH
+    File "${GEN}\conf\${SAMPCONF_DH}"
+  !endif
+  !endif
+
+  ; Try to extract files if present
+  !ifdef EXTRACT_FILES
+    Push "$INSTDIR"
+    Call MultiFileExtract
+    Pop $R0
+    IntCmp $R0 0 +3 +1 +1
+    DetailPrint "MultiFileExtract Failed status=$R0"
+    goto +2
+    DetailPrint "MultiFileExtract Succeeded"
+  !endif
+
+  ;
+  ; install/upgrade TAP driver if selected, using tapinstall.exe
+  ;
+  SectionGetFlags ${SecTAP} $R0
+  IntOp $R0 $R0 & ${SF_SELECTED}
+  IntCmp $R0 ${SF_SELECTED} "" notap notap
+    ; TAP install/update was selected.
+    ; Should we install or update?
+    ; If tapinstall error occurred, $5 will
+    ; be nonzero.
+    IntOp $5 0 & 0
+    nsExec::ExecToStack '"$INSTDIR\bin\tapinstall.exe" hwids ${TAP}'
+    Pop $R0 # return value/error/timeout
+    IntOp $5 $5 | $R0
+    DetailPrint "tapinstall hwids returned: $R0"
+
+    ; If tapinstall output string contains "${TAP}" we assume
+    ; that TAP device has been previously installed,
+    ; therefore we will update, not install.
+    Push "${TAP}"
+    Call StrStr
+    Pop $R0
+
+    IntCmp $5 0 "" tapinstall_check_error tapinstall_check_error
+    IntCmp $R0 -1 tapinstall
+
+ ;tapupdate:
+    DetailPrint "TAP UPDATE"
+    nsExec::ExecToLog '"$INSTDIR\bin\tapinstall.exe" update "$INSTDIR\driver\OemWin2k.inf" ${TAP}'
+    Pop $R0 # return value/error/timeout
+    Call CheckReboot
+    IntOp $5 $5 | $R0
+    DetailPrint "tapinstall update returned: $R0"
+    Goto tapinstall_check_error
+
+ tapinstall:
+    DetailPrint "TAP REMOVE OLD TAP"
+
+    nsExec::ExecToLog '"$INSTDIR\bin\tapinstall.exe" remove TAP0801'
+    Pop $R0 # return value/error/timeout
+    DetailPrint "tapinstall remove TAP0801 returned: $R0"
+
+    DetailPrint "TAP INSTALL (${TAP})"
+    nsExec::ExecToLog '"$INSTDIR\bin\tapinstall.exe" install "$INSTDIR\driver\OemWin2k.inf" ${TAP}'
+    Pop $R0 # return value/error/timeout
+    Call CheckReboot
+    IntOp $5 $5 | $R0
+    DetailPrint "tapinstall install returned: $R0"
+
+ tapinstall_check_error:
+    DetailPrint "tapinstall cumulative status: $5"
+    IntCmp $5 0 notap
+    MessageBox MB_OK "An error occurred installing the TAP device driver."
+
+ notap:
+
+  ; Store install folder in registry
+  WriteRegStr HKLM SOFTWARE\${PRODUCT_NAME} "" $INSTDIR
+
+  ; install as a service if requested
+  SectionGetFlags ${SecService} $R0
+  IntOp $R0 $R0 & ${SF_SELECTED}
+  IntCmp $R0 ${SF_SELECTED} "" noserv noserv
+
+    ; set registry parameters for openvpnserv	
+    !insertmacro WriteRegStringIfUndef HKLM "SOFTWARE\${PRODUCT_NAME}" "config_dir"  "${SERV_CONFIG_DIR}"
+    !insertmacro WriteRegStringIfUndef HKLM "SOFTWARE\${PRODUCT_NAME}" "config_ext"  "${SERV_CONFIG_EXT}"
+    !insertmacro WriteRegStringIfUndef HKLM "SOFTWARE\${PRODUCT_NAME}" "exe_path"    "${SERV_EXE_PATH}"
+    !insertmacro WriteRegStringIfUndef HKLM "SOFTWARE\${PRODUCT_NAME}" "log_dir"     "${SERV_LOG_DIR}"
+    !insertmacro WriteRegStringIfUndef HKLM "SOFTWARE\${PRODUCT_NAME}" "priority"    "${SERV_PRIORITY}"
+    !insertmacro WriteRegStringIfUndef HKLM "SOFTWARE\${PRODUCT_NAME}" "log_append"  "${SERV_LOG_APPEND}"
+
+    ; install openvpnserv as a service (to be started manually from service control manager)
+    DetailPrint "Service INSTALL"
+    nsExec::ExecToLog '"$INSTDIR\bin\${PRODUCT_UNIX_NAME}serv.exe" -install'
+    Pop $R0 # return value/error/timeout
+
+ noserv:
+
+  ; Create file association if requested
+ fileass:
+  SectionGetFlags ${SecFileAssociation} $R0
+  IntOp $R0 $R0 & ${SF_SELECTED}
+  IntCmp $R0 ${SF_SELECTED} "" noass noass
+    WriteRegStr HKCR ".${SERV_CONFIG_EXT}" "" "${PRODUCT_NAME}File"
+    WriteRegStr HKCR "${PRODUCT_NAME}File" "" "${PRODUCT_NAME} Config File"
+    WriteRegStr HKCR "${PRODUCT_NAME}File\shell" "" "open"
+    WriteRegStr HKCR "${PRODUCT_NAME}File\DefaultIcon" "" "$INSTDIR\${PRODUCT_ICON},0"
+    WriteRegStr HKCR "${PRODUCT_NAME}File\shell\open\command" "" 'notepad.exe "%1"'
+    WriteRegStr HKCR "${PRODUCT_NAME}File\shell\run" "" "Start ${PRODUCT_NAME} on this config file"
+    WriteRegStr HKCR "${PRODUCT_NAME}File\shell\run\command" "" '"$INSTDIR\bin\${PRODUCT_UNIX_NAME}.exe" --pause-exit --config "%1"'
+
+ ; Create start menu folders
+ noass:
+  CreateDirectory "$SMPROGRAMS\${PRODUCT_NAME}\Utilities"
+  CreateDirectory "$SMPROGRAMS\${PRODUCT_NAME}\Shortcuts"
+
+  ; Create start menu and desktop shortcuts to OpenVPN GUI
+  !ifdef USE_GUI
+      CreateShortCut "$SMPROGRAMS\${PRODUCT_NAME}\${PRODUCT_NAME} GUI.lnk" "$INSTDIR\bin\${OPENVPN_GUI}" ""
+      CreateShortcut "$DESKTOP\${PRODUCT_NAME} GUI.lnk" "$INSTDIR\bin\${OPENVPN_GUI}"
+  !endif
+
+ ; Create start menu shortcuts to addtap.bat and deltapall.bat
+ tryaddtap:
+    IfFileExists "$INSTDIR\bin\addtap.bat" "" trydeltap
+      CreateShortCut "$SMPROGRAMS\${PRODUCT_NAME}\Utilities\Add a new TAP virtual ethernet adapter.lnk" "$INSTDIR\bin\addtap.bat" ""
+
+ trydeltap:
+    IfFileExists "$INSTDIR\bin\deltapall.bat" "" config_shortcut
+      CreateShortCut "$SMPROGRAMS\${PRODUCT_NAME}\Utilities\Delete ALL TAP virtual ethernet adapters.lnk" "$INSTDIR\bin\deltapall.bat" ""
+
+ ; Create start menu shortcuts for config and log directories
+ config_shortcut:
+    IfFileExists "$INSTDIR\config" "" log_shortcut
+      CreateShortCut "$SMPROGRAMS\${PRODUCT_NAME}\Shortcuts\${PRODUCT_NAME} configuration file directory.lnk" "$INSTDIR\config" ""
+
+ log_shortcut:
+    IfFileExists "$INSTDIR\log" "" samp_shortcut
+      CreateShortCut "$SMPROGRAMS\${PRODUCT_NAME}\Shortcuts\${PRODUCT_NAME} log file directory.lnk" "$INSTDIR\log" ""
+
+ samp_shortcut:
+    IfFileExists "$INSTDIR\sample-config" "" genkey_shortcut
+      CreateShortCut "$SMPROGRAMS\${PRODUCT_NAME}\Shortcuts\${PRODUCT_NAME} Sample Configuration Files.lnk" "$INSTDIR\sample-config" ""
+
+ genkey_shortcut:
+    IfFileExists "$INSTDIR\bin\${PRODUCT_UNIX_NAME}.exe" "" noshortcuts
+      IfFileExists "$INSTDIR\config" "" noshortcuts
+        CreateShortCut "$SMPROGRAMS\${PRODUCT_NAME}\Utilities\Generate a static ${PRODUCT_NAME} key.lnk" "$INSTDIR\bin\${PRODUCT_UNIX_NAME}.exe" '--pause-exit --verb 3 --genkey --secret "$INSTDIR\config\key.txt"' "$INSTDIR\${PRODUCT_ICON}" 0
+
+ noshortcuts:
+  ; Create uninstaller
+  WriteUninstaller "$INSTDIR\Uninstall.exe"
+
+  ; Show up in Add/Remove programs
+  WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${PRODUCT_NAME}" "DisplayName" "${PRODUCT_NAME} ${VERSION}"
+  WriteRegExpandStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${PRODUCT_NAME}" "UninstallString" "$INSTDIR\Uninstall.exe"
+  WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${PRODUCT_NAME}" "DisplayIcon" "$INSTDIR\${PRODUCT_ICON}"
+  WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${PRODUCT_NAME}" "DisplayVersion" "${VERSION}"
+
+  ; Advise a reboot
+  ;Messagebox MB_OK "IMPORTANT: Rebooting the system is advised in order to finalize TAP driver installation/upgrade (this is an informational message only, pressing OK will not reboot)."
+
+SectionEnd
+
+;--------------------------------
+;Descriptions
+
+!insertmacro MUI_FUNCTION_DESCRIPTION_BEGIN
+  !insertmacro MUI_DESCRIPTION_TEXT ${SecOpenVPNUserSpace} $(DESC_SecOpenVPNUserSpace)
+  !ifdef USE_GUI
+    !insertmacro MUI_DESCRIPTION_TEXT ${SecOpenVPNGUI} $(DESC_SecOpenVPNGUI)
+  !endif
+  !insertmacro MUI_DESCRIPTION_TEXT ${SecOpenVPNEasyRSA} $(DESC_SecOpenVPNEasyRSA)
+  !insertmacro MUI_DESCRIPTION_TEXT ${SecTAP} $(DESC_SecTAP)
+  !insertmacro MUI_DESCRIPTION_TEXT ${SecOpenSSLUtilities} $(DESC_SecOpenSSLUtilities)
+  !insertmacro MUI_DESCRIPTION_TEXT ${SecOpenSSLDLLs} $(DESC_SecOpenSSLDLLs)
+  !insertmacro MUI_DESCRIPTION_TEXT ${SecPKCS11DLLs} $(DESC_SecPKCS11DLLs)
+  !insertmacro MUI_DESCRIPTION_TEXT ${SecLZO2DLLs} $(DESC_SecLZO2DLLs)
+  !insertmacro MUI_DESCRIPTION_TEXT ${SecMSVCR90DLL} $(DESC_SecMSVCR90DLL)
+  !insertmacro MUI_DESCRIPTION_TEXT ${SecAddPath} $(DESC_SecAddPath)
+  !insertmacro MUI_DESCRIPTION_TEXT ${SecAddShortcuts} $(DESC_SecAddShortcuts)
+
+  !insertmacro MUI_DESCRIPTION_TEXT ${SecService} $(DESC_SecService)
+  !insertmacro MUI_DESCRIPTION_TEXT ${SecFileAssociation} $(DESC_SecFileAssociation)
+!insertmacro MUI_FUNCTION_DESCRIPTION_END
+
+;--------------------------------
+;Uninstaller Section
+
+Function un.onInit
+  ClearErrors
+  UserInfo::GetName
+  IfErrors ok
+  Pop $R0
+  UserInfo::GetAccountType
+  Pop $R1
+  StrCmp $R1 "Admin" ok
+    Messagebox MB_OK "Administrator privileges required to uninstall ${PRODUCT_NAME} [$R0/$R1]"
+    Abort
+  ok:
+FunctionEnd
+
+Section "Uninstall"
+
+  ; Stop OpenVPN if currently running
+
+  DetailPrint "Service REMOVE"
+  nsExec::ExecToLog '"$INSTDIR\bin\${PRODUCT_UNIX_NAME}serv.exe" -remove'
+  Pop $R0 # return value/error/timeout
+  
+  Sleep 3000
+
+  DetailPrint "TAP REMOVE"
+  nsExec::ExecToLog '"$INSTDIR\bin\tapinstall.exe" remove ${TAP}'
+  Pop $R0 # return value/error/timeout
+  DetailPrint "tapinstall remove returned: $R0"
+
+  Push "$INSTDIR\bin"
+  Call un.RemoveFromPath
+
+  RMDir /r $SMPROGRAMS\${PRODUCT_NAME}
+
+  ; delete sample config files
+  !ifdef SAMPCONF_DIR
+  !ifdef SAMPCONF_CONF
+    Delete "$INSTDIR\config\${SAMPCONF_CONF}"
+  !endif
+  !ifdef SAMPCONF_CONF2
+    Delete "$INSTDIR\config\${SAMPCONF_CONF2}"
+  !endif
+  !ifdef SAMPCONF_P12
+    Delete "$INSTDIR\config\${SAMPCONF_P12}"
+  !endif
+  !ifdef SAMPCONF_TA
+    Delete "$INSTDIR\config\${SAMPCONF_TA}"
+  !endif
+  !ifdef SAMPCONF_CA
+    Delete "$INSTDIR\config\${SAMPCONF_CA}"
+  !endif
+  !ifdef SAMPCONF_CRT
+    Delete "$INSTDIR\config\${SAMPCONF_CRT}"
+  !endif
+  !ifdef SAMPCONF_KEY
+    Delete "$INSTDIR\config\${SAMPCONF_KEY}"
+  !endif
+  !ifdef SAMPCONF_DH
+    Delete "$INSTDIR\config\${SAMPCONF_DH}"
+  !endif
+  !endif
+
+  !ifdef USE_GUI
+    Delete "$INSTDIR\bin\${OPENVPN_GUI}"
+    Delete "$DESKTOP\${PRODUCT_NAME} GUI.lnk"
+  !endif
+
+  # Files installed by openvpn-2.2-beta5 and earlier
+  Delete "$INSTDIR\easy-rsa\openssl.cnf.sample"
+  Delete "$INSTDIR\license"
+  Delete "$INSTDIR\bin\libssl32.dll"
+
+  Delete "$INSTDIR\bin\${PRODUCT_UNIX_NAME}.exe"
+  Delete "$INSTDIR\bin\${PRODUCT_UNIX_NAME}serv.exe"
+  Delete "$INSTDIR\bin\libeay32.dll"
+  Delete "$INSTDIR\bin\ssleay32.dll"
+  Delete "$INSTDIR\bin\libpkcs11-helper-1.dll"
+  Delete "$INSTDIR\bin\lzo2.dll"
+  Delete "$INSTDIR\bin\msvcr90.dll"
+  Delete "$INSTDIR\bin\Microsoft.VC90.CRT.manifest"
+  Delete "$INSTDIR\bin\tapinstall.exe"
+  Delete "$INSTDIR\bin\addtap.bat"
+  Delete "$INSTDIR\bin\deltapall.bat"
+
+  Delete "$INSTDIR\config\README.txt"
+  Delete "$INSTDIR\config\sample.${SERV_CONFIG_EXT}.txt"
+
+  Delete "$INSTDIR\log\README.txt"
+
+  Delete "$INSTDIR\driver\OemWin2k.inf"
+  Delete "$INSTDIR\driver\${PRODUCT_TAP_ID}.cat"
+  Delete "$INSTDIR\driver\${TAPDRV}"
+
+  Delete "$INSTDIR\bin\openssl.exe"
+
+  Delete "$INSTDIR\INSTALL-win32.txt"
+  Delete "$INSTDIR\${PRODUCT_ICON}"
+  Delete "$INSTDIR\COPYRIGHT.GPL"
+  Delete "$INSTDIR\Uninstall.exe"
+
+  Delete "$INSTDIR\easy-rsa\openssl.cnf"
+  Delete "$INSTDIR\easy-rsa\vars.bat.sample"
+  Delete "$INSTDIR\easy-rsa\init-config.bat"
+  Delete "$INSTDIR\easy-rsa\README.txt"
+  Delete "$INSTDIR\easy-rsa\build-ca.bat"
+  Delete "$INSTDIR\easy-rsa\build-dh.bat"
+  Delete "$INSTDIR\easy-rsa\build-key-server.bat"
+  Delete "$INSTDIR\easy-rsa\build-key.bat"
+  Delete "$INSTDIR\easy-rsa\build-key-pkcs12.bat"
+  Delete "$INSTDIR\easy-rsa\clean-all.bat"
+  Delete "$INSTDIR\easy-rsa\index.txt.start"
+  Delete "$INSTDIR\easy-rsa\revoke-key.bat"
+  Delete "$INSTDIR\easy-rsa\revoke-full.bat"
+  Delete "$INSTDIR\easy-rsa\serial.start"
+
+  Delete "$INSTDIR\sample-config\*.${PRODUCT_FILE_EXT}"
+
+  RMDir "$INSTDIR\bin"
+  RMDir "$INSTDIR\config"
+  RMDir "$INSTDIR\driver"
+  RMDir "$INSTDIR\easy-rsa"
+  RMDir "$INSTDIR\sample-config"
+  RMDir /r "$INSTDIR\log"
+  RMDir "$INSTDIR"
+
+  !insertmacro DelRegKeyIfUnchanged HKCR ".${SERV_CONFIG_EXT}" "${PRODUCT_NAME}File"
+  DeleteRegKey HKCR "${PRODUCT_NAME}File"
+  DeleteRegKey HKLM SOFTWARE\${PRODUCT_NAME}
+  DeleteRegKey HKCU "Software\${PRODUCT_NAME}"
+  DeleteRegKey HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${PRODUCT_NAME}"
+
+  ;Messagebox MB_OK "IMPORTANT: If you intend on reinstalling ${PRODUCT_NAME} after this uninstall, and you are running Win2K, you are strongly urged to reboot before reinstalling (this is an informational message only, pressing OK will not reboot)."
+
+SectionEnd
Signature · 1 line
1.6.3.3
#13 lore raw

PATCH 1/1 Changes to buildsystem patchset

In reply to Samuli Seppänen

Implemented changes to the buildsystem patchset suggested by jamesyonan in IRC meeting on 17th Feb 2010:

1) Remove variables added to version.m4 and use win/settings.in instead
2) Add ENABLE_<FEATURE> configuration to win/settings.in instead of parsing config-win32.h for them

This patch applies on top of the previous 13 patches.

---
 version.m4      |    3 ---
 win/settings.in |   15 +++++++++++++++
 win/show.py     |    3 +--
 win/wb.py       |   39 ++++++++++++++++++---------------------
 4 files changed, 34 insertions(+), 26 deletions(-)
version.m4 +0 -3
index 475a82f..d914fc1 100644
@@ -4,6 +4,3 @@ dnl define the TAP version
 define(PRODUCT_TAP_ID,[tap0901])
 define(PRODUCT_TAP_WIN32_MIN_MAJOR,[9])
 define(PRODUCT_TAP_WIN32_MIN_MINOR,[1])
-define(PRODUCT_TAP_RELDATE,[04/19/2010])
-define(PRODUCT_TAP_DEVICE_DESCRIPTION,[TAP-Win32 Adapter V9])
-define(PRODUCT_TAP_PROVIDER,[TAP-Win32 Provider V9])
win/settings.in +15 -0
index c349752..25109e2 100644
@@ -5,6 +5,16 @@
 # stored in this file. This is done to allow using the old and new Windows build 
 # systems side-by-side
 
+# Features to include
+!define ENABLE_PASSWORD_SAVE 1
+!define ENABLE_CLIENT_SERVER 1
+!define ENABLE_CLIENT_ONLY
+!define ENABLE_MANAGEMENT 1
+!define ENABLE_HTTP_PROXY 1
+!define ENABLE_SOCKS 1
+!define ENABLE_FRAGMENT 1
+!define ENABLE_DEBUG 1
+
 # Branding
 !define PRODUCT_NAME      "OpenVPN"
 !define PRODUCT_UNIX_NAME "openvpn"
@@ -30,6 +40,11 @@
 # TAP adapter icon -- visible=0x81 or hidden=0x89
 !define PRODUCT_TAP_CHARACTERISTICS     0x81
 
+# TAP adapter metadata. Version information in ../version.m4.
+!define PRODUCT_TAP_RELDATE    "04/19/2010"
+!define PRODUCT_TAP_DEVICE_DESCRIPTION    "TAP-Win32 Adapter V9"
+!define PRODUCT_TAP_PROVIDER    "TAP-Win32 Provider V9"
+
 # Build debugging version of TAP driver
 ;!define PRODUCT_TAP_DEBUG
 
win/show.py +1 -2
index 6b1140a..6cfebf2 100644
@@ -1,9 +1,8 @@
-from wb import get_config, get_build_params
+from wb import get_config
 from js import JSON
 
 def main():
     print JSON().encode(get_config())
-    print JSON().encode(get_build_params())
 
 # if we are run directly, and not loaded as a module
 if __name__ == "__main__":
win/wb.py +18 -21
index 2d7bd61..d4f8203 100644
@@ -21,7 +21,7 @@ def get_config():
 
 def get_build_params():
     kv = {}
-    parse_config_win32_h(kv,home_fn('config-win32.h'))
+    parse_build_params(kv,mod_fn('settings.in'))
 
     return kv
 
@@ -80,34 +80,18 @@ def parse_settings_in(kv, settings_in):
             kv[g[0]] = g[1] or ''
     f.close()
 
-def parse_config_win32_h(kv, config_win32_h):
-    r = re.compile(r'^#define\s+(ENABLE_\w+)\s+(\w+)')
-    s = re.compile(r'^#ifdef|^#ifndef')
-    e = re.compile(r'^#endif')
+def parse_build_params(kv, settings_in):
+    r = re.compile(r'^!define\s+(ENABLE_\w+)\s+(\w+)')
 
-    # How "deep" in nested conditional statements are we?
-    depth=0
-
-    f = open(config_win32_h)
+    f = open(settings_in)
 
     for line in f:
         line = line.rstrip()
 
-        # Check if this is a #define line starting with ENABLE_
+        # Check if this is a #define line starts with ENABLE_
         m = re.match(r, line)
 
-        # Calculate how deep we're in (nested) conditional statements. A simple
-        # #ifdef/#endif state switcher would get confused by an #endif followed
-        # by a #define.
-        if re.match(s, line):
-            depth=depth+1
-        if re.match(e, line):
-            depth=depth-1
-
         if m:
-            # Only add this #define if it's not inside a conditional statement 
-            # block
-            if depth == 0:
                 g = m.groups()
                 kv[g[0]] = g[1] or ''
     f.close()
@@ -129,20 +113,33 @@ def build_autodefs(kv, autodefs_in, autodefs_out):
 def build_configure_h(kv, configure_h_out, head_comment):
     """Generate a configure.h dynamically"""
     fout = open(configure_h_out, 'w')
+
+    # These two variables are required to view build parameters during runtime 
     configure_defines='#define CONFIGURE_DEFINES \"'
     configure_call='#define CONFIGURE_CALL \" config_all.py \"'
 
+    # Initialize the list of enabled features
+    features = ''
+
+    # Write the header
     fout.write(head_comment)
 
     dict = get_build_params()
 
     for key, value in dict.iteritems():
+        # Add enabled features
+	features = features + "#define " + key + " " + value + "\n"
+
+	# Add each enabled feature to CONFIGURE_DEFINES list
         configure_defines = configure_defines + " " + key + "=" + value + ","
 
     configure_defines = configure_defines + "\"" + "\n"
 
+    fout.write(features)
     fout.write(configure_defines)
     fout.write(configure_call)
+
+
     fout.close()
 
 def build_version_m4_vars(version_m4_vars_out, head_comment):
Signature · 1 line
1.6.3.3
#14 lore raw
In reply to Samuli Seppänen

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On 11/02/11 16:09, Samuli Seppänen wrote:

| This change adds ENABLE_PASSWORD_SAVE to config-win32.h. This option is also
| defined in win/settings.in, but it does not have any effect there.
| ---
|   config-win32.h |    3 +++
|   1 files changed, 3 insertions(+), 0 deletions(-)
|

All patches (01-13 + the extra additional patch) have been applied to the beta2.2 branch and is pushed out to the git tree.

[PATCH 01/13] Added ENABLE_PASSWORD_SAVE to config-win32.h

	commit 980d44047f4ab1541f80df1c9c2cfe6a2c572af8

[PATCH 02/13] Added a nmake makefile for openvpnserv.exe building

	commit da51a175ed364ae8d41950858d8ebb2a25b742ee

[PATCH 03/13] Moved TAP-driver version info to version.m4. Cleaned up
~ win/settings.in.

	commit 9e178ebe41233c228a3f76c1adb623a633057249

[PATCH 04/13] Added helper functionality to win/wb.py

	commit a8220492b30f2780c55c57d110253f310c170b73

[PATCH 05/13] Added support for viewing config-win32.h paramters to
~ win/show.py

	commit 3b44aa49400647b785721e77da9c5e38eeb9fd83

[PATCH 06/13] Added comments and made small modifications to win/msvc.mak.in

	commit 292cf21a64b4afb3b22a6ba19967f965b486600a

[PATCH 07/13] Added command-line switch to win/build_all.py to skip TAP
~ driver building

	commit 8c1c666e65db37fe680f7760c6ef52c2dd031932

[PATCH 08/13] Added configure.h and version.m4 variable parsing to
~ win/config.py

	commit a7f0fc316caf3fbbe7c75866b4d8d21e2e931fc1

[PATCH 09/13] Added openvpnserv.exe building to win/build.py

	commit 5e0b636ba6cb26a69ce5e863526e44d0fbd33ffc

[PATCH 10/13] Added comments to win/build_ddk.py

	commit 26e127cd59e07825a0785db2247fdac76ff01693

[PATCH 11/13] Several modifications to win/make_dist.py to allow building the
~ NSI installer

	commit 4e4aa65e9df1bfe4b9726eacea2c75cad32c0927

[PATCH 12/13] Copied install-win32/setpath.nsi to win/setpath.nsi

	commit 21c60e9f11d8d53c11611ea66698afea9c0350ef

[PATCH 13/13] Added first version of NSI installer script to win/openvpn.nsi

	commit 3b315a57d579d9ba8e259216f722094f1c1dbcde

[PATCH] Changes to buildsystem patchset

	commit c75a8976f070ef86cfced71b3df5cbce0e32e01a

kind regards,

David Sommerseth
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.10 (GNU/Linux)
Comment: Using GnuPG with Fedora - http://enigmail.mozdev.org/

iEYEARECAAYFAk1pl5UACgkQDC186MBRfrp8qACfcyglwAMWVKgeKtWzQyLZbgfI uJYAnRTzTkgzLFbnx9+Vn98MnDCS4Mgk
=iUJx
-----END PGP SIGNATURE-----