From a66e6ed4024db84f9f604d6e19dec873a02008c1 Mon Sep 17 00:00:00 2001 From: Daniel Lenski Date: Thu, 25 Mar 2021 17:20:05 -0700 Subject: [PATCH] create make-windows-installer.sh Signed-off-by: Daniel Lenski --- .gitlab-ci.yml | 36 +++++-------------------- make-windows-installer.sh | 57 +++++++++++++++++++++++++++++++++++++++ 2 files changed, 63 insertions(+), 30 deletions(-) create mode 100755 make-windows-installer.sh diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index ef21576e..aa2892ca 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -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 index 00000000..34136a67 --- /dev/null +++ b/make-windows-installer.sh @@ -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 < 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 -- 2.49.0