]> git.ipfire.org Git - thirdparty/openvpn.git/commitdiff
Added ExtractAuxFile capability to Windows Installer.
authorjames <james@e7ae566f-a301-0410-adde-c780ea21d3b5>
Sun, 30 Nov 2008 09:51:58 +0000 (09:51 +0000)
committerjames <james@e7ae566f-a301-0410-adde-c780ea21d3b5>
Sun, 30 Nov 2008 09:51:58 +0000 (09:51 +0000)
Changed Windows installer to use LZMA instead of BZIP2 compression.

git-svn-id: http://svn.openvpn.net/projects/openvpn/branches/BETA21/openvpn@3616 e7ae566f-a301-0410-adde-c780ea21d3b5

install-win32/ExtractAuxFile.nsi [new file with mode: 0644]
install-win32/maketext
install-win32/openvpn.nsi
install-win32/settings.in

diff --git a/install-win32/ExtractAuxFile.nsi b/install-win32/ExtractAuxFile.nsi
new file mode 100644 (file)
index 0000000..ffb7b34
--- /dev/null
@@ -0,0 +1,117 @@
+; ExtractAuxFile
+;   Copies a text file appended to the end of the installer EXE
+;   to a caller-specified output file.
+; Inputs:
+;   output_filename (string) -- the output filename
+; Outputs:
+;   status (int) -- 0 on success, > 0 on failure
+
+Function ExtractAuxFile
+  Exch $R1            ; output filename argument
+  ; locals
+  Push $R0
+  Push $1
+  Push $2
+  Push $3
+  Push $4
+  Push $5
+  ClearErrors
+
+  ; $R0 = installer filename
+  System::Call 'kernel32::GetModuleFileNameA(i 0, t .R0, i 1024) i r1'
+
+  ; $1 = open (installer_exe) for read
+  FileOpen $1 $R0 r
+  IfErrors openin_err
+
+  ; seek to EOF - 8 (start of 8-byte trailer)
+  ; $3 = seekpos
+  IntOp $2 0 - 8
+  FileSeek $1 $2 END $3
+
+  ; $4 = -(content_length(auxfile) + 8)
+  ; seek position from end of file to beginning of content
+  FileReadByte $1 $4
+  FileReadByte $1 $5
+  IfErrors readlen_err
+  IntOp $5 $5 << 8
+  IntOp $4 $4 + $5
+  IntOp $4 $4 + 8
+  IntOp $4 0 - $4
+
+  ; verify magic sequence 0xae, 0xb7, 0x03, 0x69, 0x42, 0x11
+  FileReadByte $1 $5
+  IntCmp $5 0xae 0 magic_err magic_err
+  FileReadByte $1 $5
+  IntCmp $5 0xb7 0 magic_err magic_err
+  FileReadByte $1 $5
+  IntCmp $5 0x03 0 magic_err magic_err
+  FileReadByte $1 $5
+  IntCmp $5 0x69 0 magic_err magic_err
+  FileReadByte $1 $5
+  IntCmp $5 0x42 0 magic_err magic_err
+  FileReadByte $1 $5
+  IntCmp $5 0x11 0 magic_err magic_err
+  IfErrors magic_err
+
+  ; seek to start of auxfile data
+  FileSeek $1 $4 END
+
+  ; $2 = open (output_filename) for write
+  FileOpen $2 $R1 w
+  IfErrors openout_err
+
+loop:
+  ; check if we are finished
+  FileSeek $1 0 CUR $5
+  IntCmp $5 $3 success 0 overshot_err
+
+  ; copy next line from .exe to output file
+  FileRead $1 $5
+  IfErrors read_err
+  FileWrite $2 $5
+  IfErrors write_err
+  goto loop
+
+success:
+  IntOp $R1 0 + 0
+  goto fin
+
+openin_err:
+  IntOp $R1 1 + 0
+  goto fin
+
+openout_err:
+  IntOp $R1 2 + 0
+  goto fin
+
+readlen_err:
+  IntOp $R1 3 + 0
+  goto fin
+
+overshot_err:
+  IntOp $R1 4 + 0
+  goto fin
+
+read_err:
+  IntOp $R1 5 + 0
+  goto fin
+
+write_err:
+  IntOp $R1 6 + 0
+  goto fin
+
+magic_err:
+  IntOp $R1 7 + 0
+  goto fin
+
+fin:
+  Pop $5
+  Pop $4
+  Pop $3
+  Pop $2
+  Pop $1
+  Pop $R0
+  Exch $R1
+FunctionEnd
index 5aed4eabd6dae1337ffeb319163c5d74ec7f3d8a..f8354dbdfc041dfb429d358f4c9ad47e51d97eb3 100644 (file)
@@ -39,6 +39,7 @@ cp autodefs/xguidefs.nsi $n
 cp install-win32/openvpn.nsi $n
 cp install-win32/setpath.nsi $n
 cp install-win32/GetWindowsVersion.nsi $n
+cp install-win32/ExtractAuxFile.nsi $n
 
 # get OpenVPN client config files
 if [ -n "$SAMPCONF_DIR" ]; then
index c33439e3d30ae27481804d14be8ef1a0583ca0a9..ae86475f9f36596bd4018388d23256e0dcb2eda3 100755 (executable)
@@ -7,6 +7,8 @@
 
 ; OpenVPN install script for Windows, using NSIS
 
+SetCompressor lzma
+
 !include "MUI.nsh"
 
 !include "defs.nsi"
@@ -14,6 +16,7 @@
 !include "xguidefs.nsi"
 !include "setpath.nsi"
 !include "GetWindowsVersion.nsi"
+!include "ExtractAuxFile.nsi"
 
 !define GEN ".."
 !define BIN "${GEN}\bin"
@@ -73,8 +76,6 @@
 
   OutFile "${GEN}\${PRODUCT_UNIX_NAME}-${VERSION}${OUTFILE_LABEL}-install.exe"
 
-  SetCompressor bzip2
-
   ShowInstDetails show
   ShowUninstDetails show
 
@@ -528,6 +529,17 @@ Section -post
   !endif
   !endif
 
+  ; Try to extract AUX_FILE, if present
+  !ifdef AUX_FILE
+    Push "$INSTDIR\config\${AUX_FILE}"
+    Call ExtractAuxFile
+    Pop $R0
+    IntCmp $R0 0 +3 +1 +1
+    DetailPrint "ExtractAuxFile Failed status=$R0"
+    goto +2
+    DetailPrint "ExtractAuxFile Succeeded"
+  !endif
+
   ;
   ; install/upgrade TAP driver if selected, using tapinstall.exe
   ;
index 0be1c2d2859faf3bb92c52f0369b586d3368e90d..af801cbc6e3cfefb4f77c882e29765b7c96f9c3d 100644 (file)
@@ -89,3 +89,7 @@
 ;!define SAMPCONF_CA    "ca.crt"
 ;!define SAMPCONF_CRT   "test.crt"
 ;!define SAMPCONF_KEY   "test.key"
+
+# Include a sample configuration file via ExtractAuxFile
+# functionality.
+!define AUX_FILE        "client.ovpn"