diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 2929027..867ff74 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -48,8 +48,70 @@ npm_test: # - echo "Do another parallel test here" # - echo "For example run a lint test" - # package binaries and create build artifacts that may be used in later stages +win-packaging: + stage: package + rules: + # only do this with a manual tag starting with v or test_ + - if: '$CI_COMMIT_TAG =~ /^(v|test_).*/' + artifacts: + paths: + - artifacts/ + name: '$CI_COMMIT_REF_SLUG' + cache: + paths: + - .cache/ + - node_modules/ + key: + files: + - package.json + - package.nw/package.json + script: + - | + mkdir -p $APT_CACHE_DIR $NPM_CONFIG_CACHE + mkdir -p artifacts + dpkg --add-architecture i386 + - | + echo -e "\e[0Ksection_start:`date +%s`:apt_get[collapsed=true]\r\e[0KGetting Build Dependencies" + apt-get -qq update + apt-get -qq -o dir::cache::archives="$APT_CACHE_DIR" install -y npm wine wine32 + apt-get -qq -o dir::cache::archives="$APT_CACHE_DIR" install -y build-essential devscripts + apt-get -qq -o dir::cache::archives="$APT_CACHE_DIR" install -y zip nsis nsis nsis-pluginapi wget + wget https://nsis.sourceforge.io/mediawiki/images/4/47/Registry.zip + unzip Registry.zip + mv Desktop/Plugin/registry.dll /usr/share/nsis/Plugins/x86-unicode/ + mv Desktop/Include/Registry.nsh /usr/share/nsis/Include/ + rm -Rf Desktop PocketPC Source + echo -e "\e[0Ksection_end:`date +%s`:apt_get\r\e[0K" + - test `node version.js` = `dpkg-parsechangelog -S version` || (echo "package.nw/package.json and debian/changelog version mismatch"; exit 1) + # Making our Windows, MacOS and distro agnostic Linux packages + - | + echo -e "\e[0Ksection_start:`date +%s`:native_build\r\e[0KBuilding native packages" + npm install --prefer-offline + npm run dist-win + for dir in dist/*-win-* ; do + if [ -d $dir ] ; then + mkdir $dir/package.nw + for file in package.nw/* ; do + mv $dir/`basename $file` $dir/package.nw + done + elif [ -f $dir ] && [[ "$dir" == *"win-x86-Setup.exe"* ]] ; then + echo "would delete broken installer $dir" + # rm $dir + fi + done + # TODO infer new version from version.js and inject into nsis installer + ls dist/GridTracker-1.21.0307-win-x86/ -la + sed "s#GridTracker-1.21.0307-win-x86/#`pwd`/dist/GridTracker-1.21.0307-win-x86/#g" windows/setup.nsi.tmpl > windows/setup.nsi.tmp + sed "s#GridTracker-Installer.#`pwd`/dist/GridTracker-Installer.#g" windows/setup.nsi.tmp > windows/setup.nsi + makensis windows/setup.nsi + # clean up generated files + rm windows/setup.nsi + rm windows/setup.nsi.tmp + (cd dist ; mv *.exe ../artifacts) + echo -e "\e[0Ksection_end:`date +%s`:native_build\e[0K" + + intel-packaging: stage: package rules: @@ -85,7 +147,7 @@ intel-packaging: - | echo -e "\e[0Ksection_start:`date +%s`:native_build\r\e[0KBuilding native packages" npm install --prefer-offline - npm run dist + npm run dist-nix chmod 755 dist/*-linux-*/GridTracker dist/*-linux-*/lib dist/*-linux-*/locales dist/*-linux-*/swiftshader/ for dir in dist/*-linux-* ; do if [ -d $dir ] ; then @@ -93,7 +155,7 @@ intel-packaging: tar -C dist -czf ${dir}.tar.gz `basename $dir` fi done - (cd dist ; mv *.exe *-mac-x64.zip *.tar.gz ../artifacts) + (cd dist ; mv *-mac-x64.zip *.tar.gz ../artifacts) echo -e "\e[0Ksection_end:`date +%s`:native_build\e[0K" # This section handles making RPMs for Fedora/CentOS/RHEL - | diff --git a/docker/Dockerfile b/docker/Dockerfile index 297f698..00df711 100644 --- a/docker/Dockerfile +++ b/docker/Dockerfile @@ -8,7 +8,11 @@ RUN dpkg --add-architecture i386 && \ apt-get install -y npm wine wine32 && \ apt-get install -y build-essential devscripts lintian diffutils patch \ patchutils quilt git && \ - apt-get install -y rpm zip + apt-get install -y rpm zip nsis nsis nsis-pluginapi wget +RUN wget https://nsis.sourceforge.io/mediawiki/images/4/47/Registry.zip && \ + unzip Registry.zip && \ + mv Desktop/Plugin/registry.dll /usr/share/nsis/Plugins/x86-unicode/ && \ + mv Desktop/Include/Registry.nsh /usr/share/nsis/Include/ VOLUME /build/gridtracker VOLUME /build/dist diff --git a/docker/build-all.sh b/docker/build-all.sh index c7ed4d0..699405d 100755 --- a/docker/build-all.sh +++ b/docker/build-all.sh @@ -6,26 +6,33 @@ test -d ../dist/rpm || mkdir -p ../dist/rpm mv ../*.{deb,dsc,buildinfo,changes,tar.xz} ../dist/debian debian/rules clean npm install -npm run dist +npm run dist-win +npm run dist-nix chmod 755 dist/*-linux-*/GridTracker dist/*-linux-*/lib dist/*-linux-*/locales dist/*-linux-*/swiftshader/ for dir in dist/*-linux-* ; do if [ -d $dir ] ; then -# mkdir $dir/package.nw -# for file in package.nw/* ; do -# if [ `basename $file` = "lib" ] ; then -# continue # skip lib dir -# fi -# mv $dir/`basename $file` $dir/package.nw -# done -# pushd . -# cd $dir/package.nw -# zip ../package.nw.zip -r * -# popd -# rm -Rf $dir/package.nw -# mv $dir/package.nw.zip $dir/package.nw tar -C dist -czf ${dir}.tar.gz `basename $dir` fi done +for dir in dist/*-win-* ; do + if [ -d $dir ] ; then + mkdir $dir/package.nw + for file in package.nw/* ; do + mv $dir/`basename $file` $dir/package.nw + done + elif [ -f $dir ] && [[ "$dir" == *"win-x86-Setup.exe"* ]] ; then + echo "would delete broken installer $dir" + # rm $dir + fi +done +pwd +sed "s#GridTracker-1.21.0307-win-x86/#`pwd`/dist/GridTracker-1.21.0307-win-x86/#g" windows/setup.nsi.tmpl > windows/setup.nsi.tmp +sed "s#GridTracker-Installer.#`pwd`/dist/GridTracker-Installer.#g" windows/setup.nsi.tmp > windows/setup.nsi +makensis windows/setup.nsi +# clean up generated files +rm windows/setup.nsi +rm windows/setup.nsi.tmp + mv dist/*{.exe,mac-x64.zip,.tar.gz} ../dist rpmbuild -D "version `node ./version.js`" --build-in-place -bb gridtracker.i386.spec rpmbuild -D "version `node ./version.js`" --build-in-place -bb gridtracker.x86_64.spec diff --git a/package.json b/package.json index 6dc661e..e979dbc 100644 --- a/package.json +++ b/package.json @@ -13,7 +13,8 @@ "test": "eslint package.nw", "lint-check": "eslint package.nw", "lint-fix": "eslint --fix package.nw", - "dist": "build --concurrent --tasks win-x86,linux-x86,linux-x64,mac-x64 package.nw", + "dist-nix": "build --concurrent --tasks linux-x86,linux-x64,mac-x64 package.nw", + "dist-win": "build --concurrent --tasks win-x86,win-x64 package.nw", "distsome": "build --debug --tasks linux-x64,mac-x64 package.nw", "start": "run package.nw" } diff --git a/package.nw/package.json b/package.nw/package.json index 79b8fb1..35438cb 100644 --- a/package.nw/package.json +++ b/package.nw/package.json @@ -43,7 +43,9 @@ }, "nsis": { "installDirectory": "$PROGRAMFILES\\${_APPNAME}", - "diffUpdaters": false + "RequestExecutionLevel": "admin", + "diffUpdaters": false, + "MUI_FINISHPAGE_RUN": "" } } } diff --git a/windows/setup.nsi.tmpl b/windows/setup.nsi.tmpl new file mode 100644 index 0000000..5622d4d --- /dev/null +++ b/windows/setup.nsi.tmpl @@ -0,0 +1,175 @@ +RequestExecutionLevel highest +SetCompressor /SOLID LZMA +!include Sections.nsh +!include MUI2.nsh +!include Registry.nsh +Name "GridTracker" + +BrandingText " Gridtracker.org : GridTracker Installer " +# General Symbol Definitions +!define REGKEY "SOFTWARE\$(^Name)" +!define VERSION 1.21.0307 +!define COMPANY "Gridtracker.org" +!define URL http://gridtracker.org +#d + +# MUI Symbol Definitions + + +# Included files + + +# Reserved Files + +ReserveFile "${NSISDIR}/Plugins/x86-unicode/registry.dll" + +# Variables +Var StartMenuGroup +Var response +Var keysearch +Var uninstallstring +Var realkey + + + +# Installer pages +#!define MUI_ICON "GridTracker-1.21.0307-win-x86/package.nw/gridview.ico" +!define MUI_ICON "GridTracker-1.21.0307-win-x86/package.nw/gridview.ico" +!define MUI_FINISHPAGE_NOAUTOCLOSE +!define MUI_UNICON "${NSISDIR}/Contrib/Graphics/Icons/modern-uninstall-colorful.ico" +!define MUI_UNFINISHPAGE_NOAUTOCLOSE + +!insertmacro MUI_PAGE_WELCOME +!insertmacro MUI_PAGE_DIRECTORY +!insertmacro MUI_PAGE_INSTFILES + + +!insertmacro MUI_UNPAGE_CONFIRM +!insertmacro MUI_UNPAGE_INSTFILES + + +!insertmacro MUI_PAGE_FINISH + +# Installer languages +!insertmacro MUI_LANGUAGE English + +# Installer attributes +OutFile "GridTracker-Installer.${VERSION}.exe" +InstallDir "$PROGRAMFILES\GridTracker" +CRCCheck on +XPStyle on +ShowInstDetails show +VIProductVersion ${VERSION}.0 +VIAddVersionKey ProductName "GridTracker" +VIAddVersionKey ProductVersion "${VERSION}" +VIAddVersionKey CompanyName "${COMPANY}" +VIAddVersionKey CompanyWebsite "${URL}" +VIAddVersionKey FileVersion "${VERSION}" +VIAddVersionKey FileDescription "An Amateur Radio Community" +VIAddVersionKey LegalCopyright "2021 Gridtracker.org" +InstallDirRegKey HKLM "${REGKEY}" Path +ShowUninstDetails nevershow + +# Installer sections +Section -Main SEC0000 + SetOverwrite on + +SetDetailsPrint none + RMDir /r "$INSTDIR" +SetDetailsPrint both + SetOutPath $INSTDIR + File /x debug.log /x package.nw.zip /x package.zip /x nw.exe "GridTracker-1.21.0307-win-x86/*" + SetOutPath $INSTDIR\locales +SetDetailsPrint none + SetOverwrite on + File /r "GridTracker-1.21.0307-win-x86/locales/*" + + SetOutPath $INSTDIR\package.nw + SetOverwrite on + File /r "GridTracker-1.21.0307-win-x86/package.nw/*" + SetOverwrite on + + SetOutPath $INSTDIR\swiftshader + File /r "GridTracker-1.21.0307-win-x86/swiftshader/*" + + + + +SetDetailsPrint both + SetOutPath $INSTDIR + CreateDirectory "$SMPROGRAMS\GridTracker" + SetOutPath $INSTDIR + CreateShortCut "$SMPROGRAMS\GridTracker\GridTracker.lnk" $INSTDIR\GridTracker.exe + Delete /REBOOTOK "$SMPROGRAMS\GridTracker\Quickstart Guide.lnk" + CreateShortCut "$DESKTOP\GridTracker.lnk" "$INSTDIR\GridTracker.exe" + + +WriteRegStr HKLM "${REGKEY}\Components" Main 1 + +SectionEnd + +Section -post SEC0001 + WriteRegStr HKLM "${REGKEY}" Path $INSTDIR + SetOutPath $INSTDIR + WriteUninstaller $INSTDIR\uninstall.exe + SetOutPath $SMPROGRAMS\GridTracker + CreateShortcut "$SMPROGRAMS\GridTracker\Uninstall $(^Name).lnk" $INSTDIR\uninstall.exe + WriteRegStr HKLM "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\$(^Name)" DisplayName "$(^Name)" + WriteRegStr HKLM "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\$(^Name)" DisplayVersion "${VERSION}" + WriteRegStr HKLM "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\$(^Name)" Publisher "${COMPANY}" + WriteRegStr HKLM "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\$(^Name)" URLInfoAbout "${URL}" + WriteRegStr HKLM "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\$(^Name)" DisplayIcon $INSTDIR\uninstall.exe + WriteRegStr HKLM "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\$(^Name)" UninstallString $INSTDIR\uninstall.exe + WriteRegDWORD HKLM "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\$(^Name)" NoModify 1 + WriteRegDWORD HKLM "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\$(^Name)" NoRepair 1 +SectionEnd + +# Macro for selecting uninstaller sections +!macro SELECT_UNSECTION SECTION_NAME UNSECTION_ID + Push $R0 + ReadRegStr $R0 HKLM "${REGKEY}\Components" "${SECTION_NAME}" + StrCmp $R0 1 0 next${UNSECTION_ID} + !insertmacro SelectSection "${UNSECTION_ID}" + GoTo done${UNSECTION_ID} +next${UNSECTION_ID}: + !insertmacro UnselectSection "${UNSECTION_ID}" +done${UNSECTION_ID}: + Pop $R0 +!macroend + +# Uninstaller sections +Section /o -un.Main UNSEC0000 +SetDetailsPrint none + RmDir /r /REBOOTOK $INSTDIR + DeleteRegValue HKLM "${REGKEY}\Components" Main +SectionEnd + +Section -un.post UNSEC0001 + DeleteRegKey HKLM "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\$(^Name)" + Delete /REBOOTOK "$SMPROGRAMS\GridTracker\GridTracker.lnk" + Delete /REBOOTOK "$SMPROGRAMS\GridTracker\Quickstart Guide.lnk" + Delete /REBOOTOK "$DESKTOP\GridTracker.lnk" + Delete /REBOOTOK "$SMPROGRAMS\GridTracker\Uninstall $(^Name).lnk" + Delete /REBOOTOK $INSTDIR\uninstall.exe + DeleteRegValue HKLM "${REGKEY}" Path + DeleteRegKey /IfEmpty HKLM "${REGKEY}\Components" + DeleteRegKey /IfEmpty HKLM "${REGKEY}" +SetDetailsPrint none + RmDir /REBOOTOK $SMPROGRAMS\GridTracker + RmDir /r $LOCALAPPDATA\GridTracker + RmDir /REBOOTOK $INSTDIR +SetDetailsPrint both +SectionEnd + +# Installer functions + + +# Uninstaller functions +Function un.onInit + ReadRegStr $INSTDIR HKLM "${REGKEY}" Path + StrCpy $StartMenuGroup "GridTracker" + !insertmacro SELECT_UNSECTION Main ${UNSEC0000} +FunctionEnd + + +