From c159d1ae6fd34dff9dfa905b98478d1a9e846231 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Enrico=20Tr=C3=B6ger?= Date: Mon, 10 Jun 2019 14:39:50 +0200 Subject: [PATCH 1/2] Windows installer: Migrate to NSIS 3.x Closes #1302. --- geany.nsi.in | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/geany.nsi.in b/geany.nsi.in index 06e340b536..ac2959463d 100644 --- a/geany.nsi.in +++ b/geany.nsi.in @@ -26,6 +26,8 @@ ; Do a Cyclic Redundancy Check to make sure the installer was not corrupted by the download CRCCheck force RequestExecutionLevel highest ; set execution level for Windows Vista +; NSIS 3 Unicode support +Unicode true ;;;;;;;;;;;;;;;;;;; ; helper defines ; @@ -53,13 +55,14 @@ VIAddVersionKey "ProductVersion" "${PRODUCT_VERSION}" VIAddVersionKey "LegalCopyright" "Copyright 2005 The Geany contributors" VIAddVersionKey "FileDescription" "${PRODUCT_NAME} Installer" -BrandingText "$(^NAME) installer (NSIS 2.51)" +BrandingText "$(^NAME) installer (NSIS 3.04)" InstallDir "$PROGRAMFILES\Geany" Name "${PRODUCT_NAME} ${PRODUCT_VERSION}" SetCompressor /SOLID lzma ShowInstDetails hide ShowUnInstDetails hide XPStyle on +ManifestSupportedOS all !ifdef INCLUDE_GTK OutFile "geany-${PRODUCT_VERSION}_setup.exe" !else @@ -77,10 +80,10 @@ Var UNINSTDIR !include "MUI2.nsh" ;Reserve files used in .onInit, for faster start-up -ReserveFile "${NSISDIR}\Plugins\System.dll" -ReserveFile "${NSISDIR}\Plugins\UserInfo.dll" -ReserveFile "${NSISDIR}\Plugins\InstallOptions.dll" -ReserveFile "${NSISDIR}\Plugins\LangDLL.dll" +ReserveFile "${NSISDIR}\Plugins\x86-unicode\System.dll" +ReserveFile "${NSISDIR}\Plugins\x86-unicode\UserInfo.dll" +ReserveFile "${NSISDIR}\Plugins\x86-unicode\InstallOptions.dll" +ReserveFile "${NSISDIR}\Plugins\x86-unicode\LangDLL.dll" !define MUI_ABORTWARNING !define MUI_ICON "icons\geany.ico" From 3820a4fb6e57865d4acb4988a6e6a9647cce9173 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Enrico=20Tr=C3=B6ger?= Date: Mon, 10 Jun 2019 14:45:24 +0200 Subject: [PATCH 2/2] Update functions and variables for the NSIS filetype And add a script to make this task easier in the future. --- data/filedefs/filetypes.nsis | 4 +-- scripts/update-nsis-functions.sh | 51 ++++++++++++++++++++++++++++++++ 2 files changed, 53 insertions(+), 2 deletions(-) create mode 100644 scripts/update-nsis-functions.sh diff --git a/data/filedefs/filetypes.nsis b/data/filedefs/filetypes.nsis index e9b8429cdb..092cd2e90a 100644 --- a/data/filedefs/filetypes.nsis +++ b/data/filedefs/filetypes.nsis @@ -23,8 +23,8 @@ commentbox=comment [keywords] # all items must be in one line and in lowercase -functions=abort addbrandingimage !addincludedir !addincludedirdir !addplugindir addsize addsizesize_to_add_to_section_in_kb allowrootdirinstall allowskipfiles !appendfile autoclosewindow bgfont bggradient brandingtext bringtofront call callinstdll caption captioninstaller_caption !cd changeui checkbitmap clearerrors completedtext componenttext contributors: copyfiles crccheck createdirectory createdirectorydirectory_name createfont createshortcut !define delete deleteinisec deleteinistr deleteregkey deleteregvalue !delfilefile detailprint detailprintmessage detailsbuttontext dirshow dirtext dirvar dirverify dirverifyauto !echo !echomessage !else enablewindow !endif enumregkey enumregvalue !error exch exec execshell !execute execwait expandenvstrings file filebufsize fileclose fileerrortext fileopen fileread filereadbyte fileseek filewrite filewritebyte findclose findfirst findnext findwindow flushini function functionend function_name getcurinsttype getcurrentaddress getcurrentaddressoutput getdlgitem getdllversion getdllversionlocal geterrorlevel getfiletime getfiletimelocal getfullpathname getfunctionaddress getinstdirerror getlabeladdress gettempfilename goto gotolabel hidewindow icon !if ifabort !ifdef iferrors iffileexists !ifmacrodef !ifmacrondef !ifndef ifrebootflag ifsilent !include initpluginsdir !insertmacro installbuttontext installcolors installdir installdirregkey instprogressflags insttype insttypegettext insttypesettext intcmp intcmpu intfmt intop iswindow langstring langstringup licensebkcolor licensedata licenseforceselection licenselangstring licensetext loadlanguagefile lockwindow logset logtext !macro !macroend makensis messagebox miscbuttontext name none nop outfile !packhdr page pagecallbacks pageex pageexend pop portions push pushstring quit readenvstr readinistr readregdword readregstr reboot regdll rename requestexecutionlevel reservefile return rmdir !searchparse searchpath !searchreplace section sectionend sectiongetflags sectiongetinsttypes sectiongetsize sectiongettext sectiongroup sectiongroupend sectionin sectionsetflags sectionsetinsttypes sectionsetsize sectionsettext sendmessage setautoclose setbrandingimage setcompress setcompressionlevel setcompressor setcompressordictsize setctlcolors setcurinsttype setdatablockoptimize setdatesave setdetailsprint setdetailsview seterrorlevel seterrors setfileattributes setfont setoutpath setoverwrite setpluginunload setrebootflag setregview setshellvarcontext setsilent showinstdetails showuninstdetails showwindow silentinstall silentuninstall sleep spacetexts strcmp strcmps strcpy strlen subcaption subsection subsectionend !system !tempfilesymbol !undef uninstallbuttontext uninstallcaption uninstallexename uninstallicon uninstallsubcaption uninstalltext uninstpage unregdll var !verbose viaddversionkey viproductversion !warning windowicon writeinistr writeregbin writeregdword writeregexpandstr writeregstr writeuninstaller xpstyle -variables=$$ $` $' $" $0 $0, $1 $2 $3 $4 $5 $6 $7 $8 $9 $admintools $appdata $cdburn_area $cmdline $commonfiles $cookies $desktop $documents $exedir $favorites $fonts $history $hwndparent $instdir $internet_cache $language $music $nethood ${nsisdir} $outdir $pictures $pluginsdir $printhood $profile $programfiles $quicklaunch $\r $r0 $r1 $r2 $r3 $r4 $r5 $r6 $r7 $r8 $r9 $recent $resources $resources_localized $sendto $smprograms $smstartup $startmenu $sysdir $temp $templates $varname $videos $windir +functions=!addincludedir !addplugindir !appendfile !cd !define !delfile !echo !else !endif !error !execute !finalize !getdllversion !gettlbversion !if !ifdef !ifmacrodef !ifmacrondef !ifndef !include !insertmacro !macro !macroend !macroundef !makensis !packhdr !pragma !searchparse !searchreplace !system !tempfile !undef !verbose !warning abort addbrandingimage addsize allowrootdirinstall allowskipfiles autoclosewindow bgfont bggradient brandingtext bringtofront cpu crccheck call callinstdll caption changeui checkbitmap clearerrors completedtext componenttext copyfiles createdirectory createfont createshortcut delete deleteinisec deleteinistr deleteregkey deleteregvalue detailprint detailsbuttontext dirshow dirtext dirvar dirverify enablewindow enumregkey enumregvalue exch exec execshell execshellwait execwait expandenvstrings file filebufsize fileclose fileerrortext fileopen fileread filereadbyte filereadutf16le filereadword fileseek filewrite filewritebyte filewriteutf16le filewriteword findclose findfirst findnext findwindow flushini function functionend getcurinsttype getcurrentaddress getdllversion getdllversionlocal getdlgitem geterrorlevel getfiletime getfiletimelocal getfullpathname getfunctionaddress getinstdirerror getlabeladdress gettempfilename goto hidewindow icon ifabort iferrors iffileexists ifrebootflag ifsilent initpluginsdir instprogressflags insttype insttypegettext insttypesettext installbuttontext installcolors installdir installdirregkey int64cmp int64cmpu int64fmt intcmp intcmpu intfmt intop intptrcmp intptrcmpu intptrop iswindow langstring langstringup licensebkcolor licensedata licenseforceselection licenselangstring licensetext loadandsetimage loadlanguagefile lockwindow logset logtext manifestdpiaware manifestdpiawareness manifestdisablewindowfiltering manifestgdiscaling manifestmaxversiontested manifestsupportedos messagebox miscbuttontext name nop outfile peaddresource pedllcharacteristics peremoveresource pesubsysver page page pagecallbacks pageex pageexend pop push quit rmdir readenvstr readinistr readregdword readregstr reboot regdll rename requestexecutionlevel reservefile return searchpath section sectionend sectiongetflags sectiongetinsttypes sectiongetsize sectiongettext sectiongroup sectiongroupend sectionin sectionsetflags sectionsetinsttypes sectionsetsize sectionsettext sendmessage setautoclose setbrandingimage setcompress setcompressionlevel setcompressor setcompressordictsize setctlcolors setcurinsttype setdatablockoptimize setdatesave setdetailsprint setdetailsview seterrorlevel seterrors setfileattributes setfont setoutpath setoverwrite setpluginunload setrebootflag setregview setshellvarcontext setsilent showinstdetails showuninstdetails showwindow silentinstall silentuninstall sleep spacetexts strcmp strcmps strcpy strlen subcaption subsection subsectionend target unregdll unicode uninstpage uninstpage uninstallbuttontext uninstallcaption uninstallexename uninstallicon uninstallsubcaption uninstalltext unsafestrcpy viaddversionkey vifileversion viproductversion var windowicon writeinistr writeregbin writeregdword writeregexpandstr writeregmultistr writeregnone writeregstr writeuninstaller xpstyle +variables=${nsisdir} $0 $1 $2 $3 $4 $5 $6 $7 $8 $9 $r0 $r1 $r2 $r3 $r4 $r5 $r6 $r7 $r8 $r9 $\n $\r $\t $$ $admintools $appdata $cdburn_area $cmdline $commonfiles $commonfiles32 $commonfiles64 $cookies $desktop $documents $exedir $exefile $exepath $favorites $fonts $history $hwndparent $instdir $internet_cache $language $localappdata $music $nethood $outdir $pictures $pluginsdir $printhood $profile $programfiles $programfiles32 $programfiles64 $quicklaunch $recent $resources $resources_localized $sendto $smprograms $smstartup $startmenu $sysdir $temp $templates $videos $windir $_click $_outdir lables=all alt alwaysoff archive auto both bottom bzip2 center colored components control current custom directory dlg_id ext false file_attribute_archive file_attribute_hidden file_attribute_normal file_attribute_offline file_attribute_readonly file_attribute_system file_attribute_temporary filesonly force hidden hide hkcc hkcr hkcu hkdd hkey_classes_root hkey_current_config hkey_current_user hkey_dyn_data hkey_local_machine hkey_performance_data hkey_users hklm hkpd hku idabort idcancel idignore idno idok idretry idyes ifdiff ifnewer instfiles italic lastused leave left license listonly lzma manual mb_abortretryignore mb_defbutton1 mb_defbutton2 mb_defbutton3 mb_defbutton4 mb_iconexclamation mb_iconinformation mb_iconquestion mb_iconstop mb_ok mb_okcancel mb_retrycancel mb_right mb_setforeground mb_topmost mb_yesno mb_yesnocancel nevershow none nonfatal normal of off offline on open print readonly rebootok right shctx shift show silent silentlog smooth strike sw_hide sw_showmaximized sw_showmaximized sw_showminimized sw_showminimized sw_showminnoactive sw_showna sw_shownoactivate sw_shownormal sw_shownormal system temporary textonly top trim true try underline uninstconfirm zlib userdefined= diff --git a/scripts/update-nsis-functions.sh b/scripts/update-nsis-functions.sh new file mode 100644 index 0000000000..20705e9c3f --- /dev/null +++ b/scripts/update-nsis-functions.sh @@ -0,0 +1,51 @@ +#!/bin/bash +# +# Author: Enrico Tröger +# License: GPL v2 or later +# +# Updates the `functions` and `variables` entries in data/filetypes.nsis. + +set -e + +TOKENS_CPP_FILE="/tmp/nsis_tokens.cpp" +TOKENS_CPP_URL="https://raw.githubusercontent.com/kichik/nsis/master/Source/tokens.cpp" +BUILD_CPP_FILE="/tmp/nsis_build.cpp" +BUILD_CPP_URL="https://raw.githubusercontent.com/kichik/nsis/master/Source/build.cpp" +DATA_FILE=data/filedefs/filetypes.nsis + +[ -f "${DATA_FILE}" ] + +# download tokens.cpp and build.cpp from NSIS +wget --quiet --output-document="${TOKENS_CPP_FILE}" "${TOKENS_CPP_URL}" +wget --quiet --output-document="${BUILD_CPP_FILE}" "${BUILD_CPP_URL}" + +normalize() { + # sort, remove line breaks, convert to lower case and remove leading and trailing whitespace + sort | tr '[:upper:][:space:]' '[:lower:] ' | sed 's/^[[:blank:]]*//;s/[[:blank:]]*$//' +} + +# extract function names (then sort the result, conver to lowercase and replace new lines by spaces) +functions=$( + sed --silent --regexp-extended 's/^\{TOK_.*,_T\("(.*)"\),[0-9]+,.*$/\1/p' "${TOKENS_CPP_FILE}" | \ + normalize +) + +# extract variable names (then sort the result, conver to lowercase and replace new lines by spaces) +variables=$( + sed --silent --regexp-extended \ + --expression 's/^[ ]*m_ShellConstants.add\(_T\("(.*)"\),.*,.*\);.*$/\1/p' \ + --expression 's/^[ ]*m_UserVarNames.add\(_T\("(.*)"\),.*\);.*$/\1/p' "${BUILD_CPP_FILE}" | \ + normalize +) + +# hardcode a few more, as found in the documentation ("4.2.2 Other Writable Variables") +variables_extra='{nsisdir} 0 1 2 3 4 5 6 7 8 9 r0 r1 r2 r3 r4 r5 r6 r7 r8 r9 \\n \\r \\t $' +variables="${variables_extra} ${variables}" +# prefix each element with a dollar sign +variables="$(echo "$variables" | sed 's/[^ ]*/$&/g')" + +rm "${TOKENS_CPP_FILE}" "${BUILD_CPP_FILE}" + +sed --expression "s/^functions=.*$/functions=$functions/" \ + --expression "s/^variables=.*$/variables=$variables/" \ + --in-place "${DATA_FILE}"