]> www.infradead.org Git - users/dwmw2/openconnect.git/commitdiff
create make-windows-installer.sh
authorDaniel Lenski <dlenski@gmail.com>
Fri, 26 Mar 2021 00:20:05 +0000 (17:20 -0700)
committerDaniel Lenski <dlenski@gmail.com>
Fri, 26 Mar 2021 00:34:28 +0000 (17:34 -0700)
Signed-off-by: Daniel Lenski <dlenski@gmail.com>
.gitlab-ci.yml
make-windows-installer.sh [new file with mode: 0755]

index ef21576e9ff52863f417d1d885dc15958ef552ed..aa2892ca62e85602edb117be158da3ac88754e78 100644 (file)
@@ -367,19 +367,7 @@ MinGW32/GnuTLS:
 # These tests seem to fail due to wine failing to start; setting as XFAIL
 # since these never run before this patch set.
   - make VERBOSE=1 -j4 check XFAIL_TESTS="sigterm dtls-psk"
-# Build NSIS installer
-  - SYSROOT=/usr/i686-w64-mingw32/sys-root
-  - VERSION=$(cut -f2 -d\" version.c)
-  - PROD_VERSION=$(echo "$VERSION" | perl -ne 'm|v(\d+)\.(\d+)(?:\-(\d+)-g.+)|; print "$1.$2." . ($3 or "0") . ".0"') # only X.Y.Z.W is allowed
-  - make -C www update && mv public docs
-  - curl "https://gitlab.com/openconnect/vpnc-scripts/raw/master/vpnc-script-win.js" > vpnc-script-win.js
-  - ln -bs .libs/openconnect.exe .libs/libopenconnect-5.dll $SYSROOT/mingw/{bin,lib}/*.dll .
-  - PATH="$PATH:$PWD" nsiswrapper --name OpenConnect --outfile openconnect-installer.exe $PWD/openconnect.exe $PWD/docs $PWD/vpnc-script-win.js > openconnect.nsi
-  - >
-    makensis -X"SetCompressor /FINAL lzma" -X'VIAddVersionKey ProductName "OpenConnect"'
-    -X"VIProductVersion \"$PROD_VERSION\"" -X"VIAddVersionKey ProductVersion \"$VERSION\""
-    -X'VIAddVersionKey Comments "OpenConnect multi-protocol VPN client for Windows (command-line version) built with GnuTLS. For more information, visit https://openconnect.gitlab.io/openconnect"'
-    openconnect.nsi
+  - ./make-windows-installer.sh
   tags:
   - shared
   except:
@@ -390,8 +378,8 @@ MinGW32/GnuTLS:
     when: always
     paths:
       - tests/*.log
-      - openconnect.nsi
-      - openconnect-installer.exe
+      - nsis/openconnect.nsi
+      - nsis/openconnect-installer.exe
 
 MinGW32/OpenSSL:
   script:
@@ -403,19 +391,7 @@ MinGW32/OpenSSL:
 # These tests seem to fail due to wine failing to start; setting as XFAIL
 # since these never run before this patch set.
   - make VERBOSE=1 -j4 check XFAIL_TESTS="sigterm dtls-psk"
-# Build NSIS installer
-  - SYSROOT=/usr/i686-w64-mingw32/sys-root
-  - VERSION=$(cut -f2 -d\" version.c)
-  - PROD_VERSION=$(echo "$VERSION" | perl -ne 'm|v(\d+)\.(\d+)(?:\-(\d+)-g.+)|; print "$1.$2." . ($3 or "0") . ".0"') # only X.Y.Z.W is allowed
-  - make -C www update && mv public docs
-  - curl "https://gitlab.com/openconnect/vpnc-scripts/raw/master/vpnc-script-win.js" > vpnc-script-win.js
-  - ln -bs .libs/openconnect.exe .libs/libopenconnect-5.dll $SYSROOT/mingw/{bin,lib}/*.dll .
-  - PATH="$PATH:$PWD" nsiswrapper --name OpenConnect --outfile openconnect-installer.exe $PWD/openconnect.exe $PWD/docs $PWD/vpnc-script-win.js > openconnect.nsi
-  - >
-    makensis -X"SetCompressor /FINAL lzma" -X'VIAddVersionKey ProductName "OpenConnect"'
-    -X"VIProductVersion \"$PROD_VERSION\"" -X"VIAddVersionKey ProductVersion \"$VERSION\""
-    -X'VIAddVersionKey Comments "OpenConnect multi-protocol VPN client for Windows (command-line version) built with OpenSSL. For more information, visit https://openconnect.gitlab.io/openconnect"'
-    openconnect.nsi
+  - ./make-windows-installer.sh
   tags:
   - shared
   except:
@@ -426,8 +402,8 @@ MinGW32/OpenSSL:
     when: always
     paths:
       - tests/*.log
-      - openconnect.nsi
-      - openconnect-installer.exe
+      - nsis/openconnect.nsi
+      - nsis/openconnect-installer.exe
 
 MinGW64/GnuTLS:
   script:
diff --git a/make-windows-installer.sh b/make-windows-installer.sh
new file mode 100755 (executable)
index 0000000..34136a6
--- /dev/null
@@ -0,0 +1,57 @@
+#!/bin/bash
+#
+# Copyright (C) 2021 Daniel Lenski
+#
+# This builds a Windows installer for OpenConnect using the Fedora nsiswrapper
+# program from https://fedoraproject.org/wiki/MinGW, which in turn depends on
+# NSIS (https://nsis.sourceforge.io).
+#
+# This script should be run *after* successfully cross-building openconnect.exe
+# and libopenconnect-5.dll.
+
+set -e
+
+SYSROOT=/usr/i686-w64-mingw32/sys-root
+
+# only X.Y.Z.W is allowed for the installer's "product version" property
+VERSION=$(cut -f2 -d\" version.c)
+PROD_VERSION=$(echo "$VERSION" | perl -ne 'm|v(\d+)\.(\d+)(?:\-(\d+)-g.+)|; print "$1.$2." . ($3 or "0") . ".0"')
+
+if egrep -q '^#define OPENCONNECT_GNUTLS' config.h; then
+    TLS_LIBRARY=GnuTLS
+elif egrep -q '^#define OPENCONNECT_OPENSSL' config.h; then
+    TLS_LIBRARY=OpenSSL
+else
+    TLS_LIBRARY="Unknown TLS library"
+fi
+
+mkdir nsis
+cd nsis
+
+# build HTML documentation
+make -C ../www update
+ln -s ../public docs
+
+# download latest vpnc-script-win.js
+curl "https://gitlab.com/openconnect/vpnc-scripts/raw/master/vpnc-script-win.js" > vpnc-script-win.js
+
+# add symlinks to OpenConnect .exe/.dll, and all DLLs installed by package manager
+# (so that nsiswrapper can find them)
+ln -s ../.libs/openconnect.exe ../.libs/libopenconnect-5.dll $SYSROOT/mingw/{bin,lib}/*.dll .
+
+# build openconnect.nsi (input to makensis)
+PATH="$PATH:." nsiswrapper --name OpenConnect --outfile openconnect-installer.exe \
+    openconnect.exe docs vpnc-script-win.js > openconnect.nsi.in
+
+# add version information
+cat <<EOF > openconnect.nsi
+SetCompressor /FINAL lzma
+VIAddVersionKey ProductName "OpenConnect"
+VIProductVersion "$PROD_VERSION"
+VIAddVersionKey ProductVersion "$VERSION"
+VIAddVersionKey Comments "OpenConnect multi-protocol VPN client for Windows (command-line version, built with $TLS_LIBRARY). For more information, visit https://openconnect.gitlab.io/openconnect"
+EOF
+
+# build installer
+cat openconnect.nsi.in >> openconnect.nsi
+makensis openconnect.nsi