From f810c6bd724e61977b4e94ca2d8abfa5bd766379 Mon Sep 17 00:00:00 2001 From: Abs62 Date: Tue, 10 May 2022 18:34:42 +0300 Subject: [PATCH 1/3] Zips: Expand headwords while indexing --- zipsounds.cc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/zipsounds.cc b/zipsounds.cc index ada28807..f4b27351 100644 --- a/zipsounds.cc +++ b/zipsounds.cc @@ -44,7 +44,7 @@ DEF_EX( exInvalidData, "Invalid data encountered", Dictionary::Ex ) enum { Signature = 0x5350495a, // ZIPS on little-endian, SPIZ on big-endian - CurrentFormatVersion = 5 + BtreeIndexing::FormatVersion + CurrentFormatVersion = 6 + BtreeIndexing::FormatVersion }; struct IdxHeader @@ -471,7 +471,7 @@ vector< sptr< Dictionary::Class > > makeDictionaries( wstring word = stripExtension( links[ x ].word ); if( !word.empty() ) - names.addSingleWord( word, offset ); + names.addWord( word, offset ); } } From f4bcfdc3d593be7f0fabc31cbb26609b56a6c930 Mon Sep 17 00:00:00 2001 From: Xiao YiFang Date: Wed, 11 May 2022 20:34:27 +0800 Subject: [PATCH 2/3] github: escape single quote --- .github/workflows/macos-6.2.yml | 1 + .github/workflows/macos.yml | 1 + .github/workflows/ubuntu-6.2.yml | 1 + .github/workflows/ubuntu.yml | 1 + .github/workflows/windows-6.2.yml | 1 + .github/workflows/windows.yml | 1 + 6 files changed, 6 insertions(+) diff --git a/.github/workflows/macos-6.2.yml b/.github/workflows/macos-6.2.yml index 469b9083..6d334deb 100644 --- a/.github/workflows/macos-6.2.yml +++ b/.github/workflows/macos-6.2.yml @@ -88,6 +88,7 @@ jobs: CHANGELOG="${CHANGELOG//$'\n'/'%0A'}" CHANGELOG="${CHANGELOG//$'\r'/'%0D'}" CHANGELOG="${CHANGELOG//'\"'/'%22'}" + CHANGELOG="${CHANGELOG//"'"/'%20'}" echo "::set-output name=COMMIT_SUMMARY::$(echo "$CHANGELOG")" # tag 上传Release - name: uploadRelease diff --git a/.github/workflows/macos.yml b/.github/workflows/macos.yml index 5dcdf307..5029b8e8 100644 --- a/.github/workflows/macos.yml +++ b/.github/workflows/macos.yml @@ -91,6 +91,7 @@ jobs: CHANGELOG="${CHANGELOG//$'\n'/'%0A'}" CHANGELOG="${CHANGELOG//$'\r'/'%0D'}" CHANGELOG="${CHANGELOG//'\"'/'%22'}" + CHANGELOG="${CHANGELOG//"'"/'%20'}" echo "::set-output name=COMMIT_SUMMARY::$(echo "$CHANGELOG")" # tag 上传Release - name: uploadRelease diff --git a/.github/workflows/ubuntu-6.2.yml b/.github/workflows/ubuntu-6.2.yml index 8c3e8117..a0e42420 100644 --- a/.github/workflows/ubuntu-6.2.yml +++ b/.github/workflows/ubuntu-6.2.yml @@ -95,6 +95,7 @@ jobs: CHANGELOG="${CHANGELOG//$'\n'/'%0A'}" CHANGELOG="${CHANGELOG//$'\r'/'%0D'}" CHANGELOG="${CHANGELOG//'\"'/'%22'}" + CHANGELOG="${CHANGELOG//"'"/'%20'}" echo "::set-output name=COMMIT_SUMMARY::$(echo "$CHANGELOG")" - name: uploadRelease # if: startsWith(github.event.ref, 'refs/tags/') diff --git a/.github/workflows/ubuntu.yml b/.github/workflows/ubuntu.yml index 09c032a9..5f35e623 100644 --- a/.github/workflows/ubuntu.yml +++ b/.github/workflows/ubuntu.yml @@ -92,6 +92,7 @@ jobs: CHANGELOG="${CHANGELOG//$'\n'/'%0A'}" CHANGELOG="${CHANGELOG//$'\r'/'%0D'}" CHANGELOG="${CHANGELOG//'\"'/'%22'}" + CHANGELOG="${CHANGELOG//"'"/'%20'}" echo "::set-output name=COMMIT_SUMMARY::$(echo "$CHANGELOG")" - name: uploadRelease # if: startsWith(github.event.ref, 'refs/tags/') diff --git a/.github/workflows/windows-6.2.yml b/.github/workflows/windows-6.2.yml index 8d766e8a..a7f07eb2 100644 --- a/.github/workflows/windows-6.2.yml +++ b/.github/workflows/windows-6.2.yml @@ -67,6 +67,7 @@ jobs: CHANGELOG="${CHANGELOG//$'\n'/'%0A'}" CHANGELOG="${CHANGELOG//$'\r'/'%0D'}" CHANGELOG="${CHANGELOG//'\"'/'%22'}" + CHANGELOG="${CHANGELOG//"'"/'%20'}" echo "::set-output name=COMMIT_SUMMARY::$(echo "$CHANGELOG")" # # msvc编译 diff --git a/.github/workflows/windows.yml b/.github/workflows/windows.yml index e2c05a34..5c139867 100644 --- a/.github/workflows/windows.yml +++ b/.github/workflows/windows.yml @@ -69,6 +69,7 @@ jobs: CHANGELOG="${CHANGELOG//$'\n'/'%0A'}" CHANGELOG="${CHANGELOG//$'\r'/'%0D'}" CHANGELOG="${CHANGELOG//'\"'/'%22'}" + CHANGELOG="${CHANGELOG//"'"/'%20'}" echo "::set-output name=COMMIT_SUMMARY::$(echo "$CHANGELOG")" - uses: ilammy/msvc-dev-cmd@v1 # msvc编译 From 5acb76704fda9452d8a40ec99aeedfabb12556de Mon Sep 17 00:00:00 2001 From: Xiao YiFang Date: Thu, 12 May 2022 22:01:56 +0800 Subject: [PATCH 3/3] tools: nsis script update --- .github/workflows/windows-6.2.yml | 37 +- .github/workflows/windows.yml | 49 +- tools/nsis/GoldenDict-EnRuEn.nsi | 420 ------------------ tools/nsis/GoldenDict.nsi | 344 ++------------ tools/nsis/gen_uninstall/gen_uninstall.cc | 78 ---- .../gen_uninstall/gen_uninstall.exe.manifest | 9 - tools/nsis/gen_uninstall/gen_uninstall.pro | 15 - tools/nsis/gen_uninstall/gen_uninstall.rc | 3 - tools/nsis/makensis.sh | 14 - 9 files changed, 87 insertions(+), 882 deletions(-) delete mode 100644 tools/nsis/GoldenDict-EnRuEn.nsi delete mode 100644 tools/nsis/gen_uninstall/gen_uninstall.cc delete mode 100644 tools/nsis/gen_uninstall/gen_uninstall.exe.manifest delete mode 100644 tools/nsis/gen_uninstall/gen_uninstall.pro delete mode 100644 tools/nsis/gen_uninstall/gen_uninstall.rc delete mode 100755 tools/nsis/makensis.sh diff --git a/.github/workflows/windows-6.2.yml b/.github/workflows/windows-6.2.yml index a7f07eb2..a8ef4e5b 100644 --- a/.github/workflows/windows-6.2.yml +++ b/.github/workflows/windows-6.2.yml @@ -135,15 +135,28 @@ jobs: overwrite: true release_name: GoldenDict-v${{env.version}}.${{ steps.vars.outputs.release_hm }}.${{ steps.vars.outputs.sha_short }} prerelease: true - body: | - release on date: ${{steps.vars.outputs.release_date}} time: ${{steps.vars.outputs.release_time_clock}} - branch: ${{ github.ref_name }} - commit: ${{ steps.vars.outputs.sha_short }} - Qt version: Qt5.15.2,Qt6.X ${{ matrix.qt_arch }} - Windows built with: msvc64 Visual studio 2019 - goldendict.exe was provided alone ,if you have a previous version. replace this maybe ok. if not ,download the whole bundle. - AppImage built with: Ubuntu-20.04 ,latest gcc - macos built with: macos-10.15,macos-11.0,clang_64 x86_64 - qt6.X(Universal Build) - qt5.15.2(Intel Kind) - auto built by github action. use on your on risk:-) + + - name: copy nsis + shell: bash + run: | + cp tools/nsis/GoldenDict.nsi ${{ steps.package.outputs.packageName }}/ + - name: Create installer + uses: joncloud/makensis-action@v3.6 + with: + arguments: "/V3" + script-file: ${{ steps.package.outputs.packageName }}/GoldenDict.nsi + - name: make installer + run: | + cd ${{ steps.package.outputs.packageName }} + ls *.exe + - name: upload goldendict installer + # if: startsWith(github.event.ref, 'refs/tags/') + uses: svenstaro/upload-release-action@v2 + with: + repo_token: ${{ secrets.GITHUB_TOKEN }} + file: ${{ steps.package.outputs.packageName }}/GoldenDict-v22-Install.exe + asset_name: ${{ matrix.qt_ver }}-GoldenDict-v22-Install.exe + tag: v${{env.version}}.${{ steps.vars.outputs.release_hm }}.${{ steps.vars.outputs.sha_short }} + overwrite: true + release_name: GoldenDict-v${{env.version}}.${{ steps.vars.outputs.release_hm }}.${{ steps.vars.outputs.sha_short }} + prerelease: true \ No newline at end of file diff --git a/.github/workflows/windows.yml b/.github/workflows/windows.yml index 5c139867..6b362d95 100644 --- a/.github/workflows/windows.yml +++ b/.github/workflows/windows.yml @@ -98,13 +98,7 @@ jobs: & .github\scripts\windows-publish.ps1 ${env:archiveName} ${env:targetName} $name = ${env:archiveName} echo "::set-output name=packageName::$name" - # tag 查询github-Release - # 上传artifacts -# - uses: actions/upload-artifact@v2 -# with: -# name: ${{ steps.package.outputs.packageName }} -# path: ${{ steps.package.outputs.packageName }}.zip - # tag 上传Release + - name: uploadRelease # if: startsWith(github.event.ref, 'refs/tags/') uses: svenstaro/upload-release-action@v2 @@ -141,17 +135,32 @@ jobs: overwrite: true release_name: GoldenDict-v${{env.version}}.${{ steps.vars.outputs.release_hm }}.${{ steps.vars.outputs.sha_short }} prerelease: true - body: | - release on date: ${{steps.vars.outputs.release_date}} time: ${{steps.vars.outputs.release_time_clock}} - branch: ${{ github.ref_name }} - commit: ${{ steps.vars.outputs.sha_short }} - Qt version: Qt5.15.2,Qt6.X ${{ matrix.qt_arch }} - Windows built with: msvc64 Visual studio 2019 - ## goldendict.exe can not be used alone - if you have a previous version. replace this maybe ok. if not ,download the whole bundle. - AppImage built with: Ubuntu-20.04 ,latest gcc - macos built with: macos-10.15,macos-11.0,clang_64 x86_64 - qt6.X(Universal Build) - qt5.15.2(Intel Kind) - auto built by github action. use on your on risk:-) + + - name: copy nsis + shell: bash + run: | + ls -al + cp tools/nsis/GoldenDict.nsi ${{ steps.package.outputs.packageName }}/ + - name: Create installer + uses: joncloud/makensis-action@v3.6 + with: + arguments: "/V3" + script-file: ${{ steps.package.outputs.packageName }}/GoldenDict.nsi + - name: make installer + run: | + ls *.exe + cd ${{ steps.package.outputs.packageName }} + ls *.exe + - name: upload goldendict installer + # if: startsWith(github.event.ref, 'refs/tags/') + uses: svenstaro/upload-release-action@v2 + with: + repo_token: ${{ secrets.GITHUB_TOKEN }} + file: ${{ steps.package.outputs.packageName }}/GoldenDict-v22-Install.exe + asset_name: ${{ matrix.qt_ver }}-GoldenDict-v22-Install.exe + tag: v${{env.version}}.${{ steps.vars.outputs.release_hm }}.${{ steps.vars.outputs.sha_short }} + overwrite: true + release_name: GoldenDict-v${{env.version}}.${{ steps.vars.outputs.release_hm }}.${{ steps.vars.outputs.sha_short }} + prerelease: true + \ No newline at end of file diff --git a/tools/nsis/GoldenDict-EnRuEn.nsi b/tools/nsis/GoldenDict-EnRuEn.nsi deleted file mode 100644 index 194a84fc..00000000 --- a/tools/nsis/GoldenDict-EnRuEn.nsi +++ /dev/null @@ -1,420 +0,0 @@ -!include "MUI2.nsh" - - Name "GoldenDict" - OutFile "GoldenDict-1.0.1-1-EnRuEn-Install.exe" - - InstallDir "$PROGRAMFILES\GoldenDict" - - RequestExecutionLevel admin - - SetCompressor /final lzma - -Var StartMenuFolder - -;-------------------------------- -;Interface Settings - - !define MUI_ABORTWARNING - -;-------------------------------- -;Pages - - !insertmacro MUI_PAGE_WELCOME - !insertmacro MUI_PAGE_LICENSE "LICENSE.txt" - !insertmacro MUI_PAGE_DIRECTORY - - !insertmacro MUI_PAGE_STARTMENU GDApplication $StartMenuFolder - - !insertmacro MUI_PAGE_INSTFILES - !insertmacro MUI_PAGE_FINISH - - !insertmacro MUI_UNPAGE_WELCOME - !insertmacro MUI_UNPAGE_CONFIRM - !insertmacro MUI_UNPAGE_INSTFILES - !insertmacro MUI_UNPAGE_FINISH - -;-------------------------------- -;Languages - - !insertmacro MUI_LANGUAGE "Russian" - !insertmacro MUI_LANGUAGE "English" ;first language is the default language - !insertmacro MUI_LANGUAGE "French" - !insertmacro MUI_LANGUAGE "German" - !insertmacro MUI_LANGUAGE "Spanish" - !insertmacro MUI_LANGUAGE "SpanishInternational" - !insertmacro MUI_LANGUAGE "SimpChinese" - !insertmacro MUI_LANGUAGE "TradChinese" - !insertmacro MUI_LANGUAGE "Japanese" - !insertmacro MUI_LANGUAGE "Korean" - !insertmacro MUI_LANGUAGE "Italian" - !insertmacro MUI_LANGUAGE "Dutch" - !insertmacro MUI_LANGUAGE "Danish" - !insertmacro MUI_LANGUAGE "Swedish" - !insertmacro MUI_LANGUAGE "Norwegian" - !insertmacro MUI_LANGUAGE "NorwegianNynorsk" - !insertmacro MUI_LANGUAGE "Finnish" - !insertmacro MUI_LANGUAGE "Greek" - !insertmacro MUI_LANGUAGE "Portuguese" - !insertmacro MUI_LANGUAGE "PortugueseBR" - !insertmacro MUI_LANGUAGE "Polish" - !insertmacro MUI_LANGUAGE "Ukrainian" - !insertmacro MUI_LANGUAGE "Czech" - !insertmacro MUI_LANGUAGE "Slovak" - !insertmacro MUI_LANGUAGE "Croatian" - !insertmacro MUI_LANGUAGE "Bulgarian" - !insertmacro MUI_LANGUAGE "Hungarian" - !insertmacro MUI_LANGUAGE "Thai" - !insertmacro MUI_LANGUAGE "Romanian" - !insertmacro MUI_LANGUAGE "Latvian" - !insertmacro MUI_LANGUAGE "Macedonian" - !insertmacro MUI_LANGUAGE "Estonian" - !insertmacro MUI_LANGUAGE "Turkish" - !insertmacro MUI_LANGUAGE "Lithuanian" - !insertmacro MUI_LANGUAGE "Slovenian" - !insertmacro MUI_LANGUAGE "Serbian" - !insertmacro MUI_LANGUAGE "SerbianLatin" - !insertmacro MUI_LANGUAGE "Arabic" - !insertmacro MUI_LANGUAGE "Farsi" - !insertmacro MUI_LANGUAGE "Hebrew" - !insertmacro MUI_LANGUAGE "Indonesian" - !insertmacro MUI_LANGUAGE "Mongolian" - !insertmacro MUI_LANGUAGE "Luxembourgish" - !insertmacro MUI_LANGUAGE "Albanian" - !insertmacro MUI_LANGUAGE "Breton" - !insertmacro MUI_LANGUAGE "Belarusian" - !insertmacro MUI_LANGUAGE "Icelandic" - !insertmacro MUI_LANGUAGE "Malay" - !insertmacro MUI_LANGUAGE "Bosnian" - !insertmacro MUI_LANGUAGE "Kurdish" - !insertmacro MUI_LANGUAGE "Irish" - !insertmacro MUI_LANGUAGE "Uzbek" - !insertmacro MUI_LANGUAGE "Galician" - !insertmacro MUI_LANGUAGE "Afrikaans" - !insertmacro MUI_LANGUAGE "Catalan" - !insertmacro MUI_LANGUAGE "Esperanto" - -;-------------------------------- -;Installer Sections - -Section - - SetOutPath "$INSTDIR" - - CreateDirectory $INSTDIR\imageformats - SetOutPath $INSTDIR\imageformats - File ..\release\imageformats\* - - CreateDirectory $INSTDIR\phonon_backend - SetOutPath $INSTDIR\phonon_backend - File ..\release\phonon_backend\* - - CreateDirectory $INSTDIR\locale - SetOutPath $INSTDIR\locale - File ..\release\locale\* - - CreateDirectory $INSTDIR\content - SetOutPath $INSTDIR\content - File ..\release\content\* - CreateDirectory $INSTDIR\content\morphology - SetOutPath $INSTDIR\content\morphology - File ..\release\content\morphology\* - - SetOutPath $INSTDIR - File ..\release\*.dll - File LICENSE.txt - File /oname=$INSTDIR\GoldenDict.exe ..\release\goldendict.exe - - WriteUninstaller "$INSTDIR\Uninstall.exe" - - !insertmacro MUI_STARTMENU_WRITE_BEGIN GDApplication - - CreateDirectory "$SMPROGRAMS\$StartMenuFolder" - CreateShortCut "$SMPROGRAMS\$StartMenuFolder\GoldenDict.lnk" "$INSTDIR\GoldenDict.exe" - CreateShortCut "$SMPROGRAMS\$StartMenuFolder\Uninstall.lnk" "$INSTDIR\Uninstall.exe" - !insertmacro MUI_STARTMENU_WRITE_END - - - WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\GoldenDict" \ - "DisplayName" "GoldenDict" - WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\GoldenDict" \ - "UninstallString" "$INSTDIR\Uninstall.exe" - -SectionEnd - -!define PROGRAM_NAME "GoldenDict" - -Function .onInit - - !insertmacro MUI_LANGDLL_DISPLAY - - ReadRegStr $R0 HKLM \ - "Software\Microsoft\Windows\CurrentVersion\Uninstall\${PROGRAM_NAME}" \ - "UninstallString" - StrCmp $R0 "" done - - MessageBox MB_OKCANCEL|MB_ICONEXCLAMATION \ - "${PROGRAM_NAME} is already installed. $\n$\nClick `OK` to remove the \ - previous version or `Cancel` to cancel this upgrade." \ - IDOK uninst - Abort - -;Run the uninstaller -uninst: - ClearErrors - ExecWait '$R0 /NODELCFG=1 _?=$INSTDIR' ;Do not copy the uninstaller to a temp file - - IfErrors no_remove_uninstaller done - ;You can either use Delete /REBOOTOK in the uninstaller or add some code - ;here to remove the uninstaller. Use a registry key to check - ;whether the user has chosen to uninstall. If you are using an uninstaller - ;components page, make sure all sections are uninstalled. - no_remove_uninstaller: - -done: - -FunctionEnd - -;-------------------------------- -;Uninstaller Section - -!define WND_CLASS "QWidget" -!define WND_TITLE "GoldenDict" -!define TO_MS 2000 -!define SYNC_TERM 0x00100001 - -!include WinMessages.nsh - -LangString termMsg ${LANG_ENGLISH} "Installer cannot stop running ${WND_TITLE}.$\nDo you want to terminate process?" -LangString stopMsg ${LANG_ENGLISH} "Stopping ${WND_TITLE}" - -!macro TerminateApp - - Push $0 ; window handle - Push $1 - Push $2 ; process handle - DetailPrint "$(stopMsg)" - FindWindow $0 '${WND_CLASS}' '' - IntCmp $0 0 done - System::Call 'user32.dll::GetWindowThreadProcessId(i r0, *i .r1) i .r2' - System::Call 'kernel32.dll::OpenProcess(i ${SYNC_TERM}, i 0, i r1) i .r2' - SendMessage $0 ${WM_CLOSE} 0 0 /TIMEOUT=${TO_MS} - System::Call 'kernel32.dll::WaitForSingleObject(i r2, i ${TO_MS}) i .r1' - terminate: - System::Call 'kernel32.dll::TerminateProcess(i r2, i 0) i .r1' - close: - System::Call 'kernel32.dll::CloseHandle(i r2) i .r1' - ; Make sure all process files are released - Sleep 2000 - done: - Pop $2 - Pop $1 - Pop $0 - -!macroend - -Function un.StrStr -/*After this point: - ------------------------------------------ - $R0 = SubString (input) - $R1 = String (input) - $R2 = SubStringLen (temp) - $R3 = StrLen (temp) - $R4 = StartCharPos (temp) - $R5 = TempStr (temp)*/ - - ;Get input from user - Exch $R0 - Exch - Exch $R1 - Push $R2 - Push $R3 - Push $R4 - Push $R5 - - ;Get "String" and "SubString" length - StrLen $R2 $R0 - StrLen $R3 $R1 - ;Start "StartCharPos" counter - StrCpy $R4 0 - - ;Loop until "SubString" is found or "String" reaches its end - loop: - ;Remove everything before and after the searched part ("TempStr") - StrCpy $R5 $R1 $R2 $R4 - - ;Compare "TempStr" with "SubString" - StrCmp $R5 $R0 done - ;If not "SubString", this could be "String"'s end - IntCmp $R4 $R3 done 0 done - ;If not, continue the loop - IntOp $R4 $R4 + 1 - Goto loop - done: - -/*After this point: - ------------------------------------------ - $R0 = ResultVar (output)*/ - - ;Remove part before "SubString" on "String" (if there has one) - StrCpy $R0 $R1 `` $R4 - - ;Return output to user - Pop $R5 - Pop $R4 - Pop $R3 - Pop $R2 - Pop $R1 - Exch $R0 -FunctionEnd - - ; GetParameters - ; input, none - ; output, top of stack (replaces, with e.g. whatever) - ; modifies no other variables. - -Function un.GetParameters - - Push $R0 - Push $R1 - Push $R2 - Push $R3 - - StrCpy $R2 1 - StrLen $R3 $CMDLINE - - ;Check for quote or space - StrCpy $R0 $CMDLINE $R2 - StrCmp $R0 '"' 0 +3 - StrCpy $R1 '"' - Goto loop - StrCpy $R1 " " - - loop: - IntOp $R2 $R2 + 1 - StrCpy $R0 $CMDLINE 1 $R2 - StrCmp $R0 $R1 get - StrCmp $R2 $R3 get - Goto loop - - get: - IntOp $R2 $R2 + 1 - StrCpy $R0 $CMDLINE 1 $R2 - StrCmp $R0 " " get - StrCpy $R0 $CMDLINE "" $R2 - - Pop $R3 - Pop $R2 - Pop $R1 - Exch $R0 - -FunctionEnd - -Function un.GetParameterValue - Exch $R0 ; get the top of the stack(default parameter) into R0 - Exch ; exchange the top of the stack(default) with - ; the second in the stack(parameter to search for) - Exch $R1 ; get the top of the stack(search parameter) into $R1 - - ;Preserve on the stack the registers used in this function - Push $R2 - Push $R3 - Push $R4 - Push $R5 - - Strlen $R2 $R1+2 ; store the length of the search string into R2 - - Call un.GetParameters ; get the command line parameters - Pop $R3 ; store the command line string in R3 - - # search for quoted search string - StrCpy $R5 '"' ; later on we want to search for a open quote - Push $R3 ; push the 'search in' string onto the stack - Push '"/$R1=' ; push the 'search for' - Call un.StrStr ; search for the quoted parameter value - Pop $R4 - StrCpy $R4 $R4 "" 1 ; skip over open quote character, "" means no maxlen - StrCmp $R4 "" "" next ; if we didn't find an empty string go to next - - # search for non-quoted search string - StrCpy $R5 ' ' ; later on we want to search for a space since we - ; didn't start with an open quote '"' we shouldn't - ; look for a close quote '"' - Push $R3 ; push the command line back on the stack for searching - Push '/$R1=' ; search for the non-quoted search string - Call un.StrStr - Pop $R4 - - ; $R4 now contains the parameter string starting at the search string, - ; if it was found -next: - StrCmp $R4 "" check_for_switch ; if we didn't find anything then look for - ; usage as a command line switch - # copy the value after /$R1= by using StrCpy with an offset of $R2, - # the length of '/OUTPUT=' - StrCpy $R0 $R4 "" $R2 ; copy commandline text beyond parameter into $R0 - # search for the next parameter so we can trim this extra text off - Push $R0 - Push $R5 ; search for either the first space ' ', or the first - ; quote '"' - ; if we found '"/output' then we want to find the - ; ending ", as in '"/output=somevalue"' - ; if we found '/output' then we want to find the first - ; space after '/output=somevalue' - Call un.StrStr ; search for the next parameter - Pop $R4 - StrCmp $R4 "" done ; if 'somevalue' is missing, we are done - StrLen $R4 $R4 ; get the length of 'somevalue' so we can copy this - ; text into our output buffer - StrCpy $R0 $R0 -$R4 ; using the length of the string beyond the value, - ; copy only the value into $R0 - goto done ; if we are in the parameter retrieval path skip over - ; the check for a command line switch - -; See if the parameter was specified as a command line switch, like '/output' -check_for_switch: - Push $R3 ; push the command line back on the stack for searching - Push '/$R1' ; search for the non-quoted search string - Call un.StrStr - Pop $R4 - StrCmp $R4 "" done ; if we didn't find anything then use the default - StrCpy $R0 "" ; otherwise copy in an empty string since we found the - ; parameter, just didn't find a value - -done: - Pop $R5 - Pop $R4 - Pop $R3 - Pop $R2 - Pop $R1 - Exch $R0 ; put the value in $R0 at the top of the stack -FunctionEnd - -Section "Uninstall" - - !insertmacro TerminateApp - - Push "NODELCFG" ; push the search string onto the stack - Push "0" ; push a default value onto the stack - Call un.GetParameterValue - Pop $2 - - StrCmp $2 "1" skip_cfg - - MessageBox MB_YESNO "Delete all configuration data and index? This will save a lot of space, but at the expense of reconfiguring and reindexing everything if GoldenDict is ever installed again." IDNO skip_cfg - - RMDir /r $APPDATA\GoldenDict - - skip_cfg: - - !insertmacro MUI_STARTMENU_GETFOLDER GDApplication $StartMenuFolder - -; This file is auto-generated - !include "uninst.nsh" - - Delete "$INSTDIR\Uninstall.exe" - - RMDir "$INSTDIR" - - DeleteRegKey HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\GoldenDict" - -SectionEnd diff --git a/tools/nsis/GoldenDict.nsi b/tools/nsis/GoldenDict.nsi index e19f211d..0f0df492 100644 --- a/tools/nsis/GoldenDict.nsi +++ b/tools/nsis/GoldenDict.nsi @@ -1,7 +1,7 @@ !include "MUI2.nsh" Name "GoldenDict" - OutFile "GoldenDict-1.5.0-Install.exe" + OutFile "GoldenDict-v22-Install.exe" InstallDir "$PROGRAMFILES\GoldenDict" @@ -20,7 +20,7 @@ Var StartMenuFolder ;Pages !insertmacro MUI_PAGE_WELCOME - !insertmacro MUI_PAGE_LICENSE "../LICENSE.txt" + !insertmacro MUI_PAGE_LICENSE "LICENSE.txt" !insertmacro MUI_PAGE_DIRECTORY !insertmacro MUI_PAGE_STARTMENU GDApplication $StartMenuFolder @@ -100,325 +100,47 @@ Section SetOutPath "$INSTDIR" - CreateDirectory $INSTDIR\imageformats - SetOutPath $INSTDIR\imageformats - File ..\imageformats\* + File /r *.* - CreateDirectory $INSTDIR\codecs - SetOutPath $INSTDIR\codecs - File ..\codecs\* - - CreateDirectory $INSTDIR\x64 - SetOutPath $INSTDIR\x64 - File ..\x64\* - - CreateDirectory $INSTDIR\locale - SetOutPath $INSTDIR\locale - File ..\locale\* - - CreateDirectory $INSTDIR\content - CreateDirectory $INSTDIR\content\morphology - SetOutPath $INSTDIR\content\morphology - File ..\content\morphology\* - - SetOutPath $INSTDIR - File ..\*.dll - File ..\LICENSE.txt - File /oname=$INSTDIR\GoldenDict.exe ..\goldendict.exe + ; Write the installation path into the registry + WriteRegStr HKLM SOFTWARE\GoldenDict "Install_Dir" "$INSTDIR" - WriteUninstaller "$INSTDIR\Uninstall.exe" + ; Write the uninstall keys for Windows + WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\GoldenDict" "DisplayName" "GoldenDict" + WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\GoldenDict" "UninstallString" '"$INSTDIR\uninstall.exe"' + WriteRegDWORD HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\GoldenDict" "NoModify" 1 + WriteRegDWORD HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\GoldenDict" "NoRepair" 1 + WriteUninstaller "$INSTDIR\uninstall.exe" - !insertmacro MUI_STARTMENU_WRITE_BEGIN GDApplication - - SetShellVarContext all - CreateDirectory "$SMPROGRAMS\$StartMenuFolder" - CreateShortCut "$SMPROGRAMS\$StartMenuFolder\GoldenDict.lnk" "$INSTDIR\GoldenDict.exe" - CreateShortCut "$SMPROGRAMS\$StartMenuFolder\Uninstall.lnk" "$INSTDIR\Uninstall.exe" - !insertmacro MUI_STARTMENU_WRITE_END - - - WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\GoldenDict" \ - "DisplayName" "GoldenDict" - WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\GoldenDict" \ - "UninstallString" "$INSTDIR\Uninstall.exe" + CreateDirectory "$SMPROGRAMS\GoldenDict" + CreateShortcut "$SMPROGRAMS\GoldenDict\Uninstall.lnk" "$INSTDIR\uninstall.exe" + CreateShortcut "$SMPROGRAMS\GoldenDict\GoldenDict.lnk" "$INSTDIR\GoldenDict.exe" SectionEnd !define PROGRAM_NAME "GoldenDict" -Function .onInit - - !insertmacro MUI_LANGDLL_DISPLAY - - ReadRegStr $R0 HKLM \ - "Software\Microsoft\Windows\CurrentVersion\Uninstall\${PROGRAM_NAME}" \ - "UninstallString" - StrCmp $R0 "" done - - MessageBox MB_OKCANCEL|MB_ICONEXCLAMATION \ - "${PROGRAM_NAME} is already installed. $\n$\nClick `OK` to remove the \ - previous version or `Cancel` to cancel this upgrade." \ - IDOK uninst - Abort - -;Run the uninstaller -uninst: - ClearErrors - ExecWait '$R0 /NODELCFG=1 _?=$INSTDIR' ;Do not copy the uninstaller to a temp file - - IfErrors no_remove_uninstaller done - ;You can either use Delete /REBOOTOK in the uninstaller or add some code - ;here to remove the uninstaller. Use a registry key to check - ;whether the user has chosen to uninstall. If you are using an uninstaller - ;components page, make sure all sections are uninstalled. - no_remove_uninstaller: - -done: - -FunctionEnd - -;-------------------------------- -;Uninstaller Section - -!define WND_CLASS "QWidget" -!define WND_TITLE "GoldenDict" -!define TO_MS 2000 -!define SYNC_TERM 0x00100001 - -!include WinMessages.nsh - -LangString termMsg ${LANG_ENGLISH} "Installer cannot stop running ${WND_TITLE}.$\nDo you want to terminate process?" -LangString stopMsg ${LANG_ENGLISH} "Stopping ${WND_TITLE}" - -!macro TerminateApp - - Push $0 ; window handle - Push $1 - Push $2 ; process handle - DetailPrint "$(stopMsg)" - FindWindow $0 '${WND_CLASS}' '' - IntCmp $0 0 done - System::Call 'user32.dll::GetWindowThreadProcessId(i r0, *i .r1) i .r2' - System::Call 'kernel32.dll::OpenProcess(i ${SYNC_TERM}, i 0, i r1) i .r2' - SendMessage $0 ${WM_CLOSE} 0 0 /TIMEOUT=${TO_MS} - System::Call 'kernel32.dll::WaitForSingleObject(i r2, i ${TO_MS}) i .r1' - terminate: - System::Call 'kernel32.dll::TerminateProcess(i r2, i 0) i .r1' - close: - System::Call 'kernel32.dll::CloseHandle(i r2) i .r1' - ; Make sure all process files are released - Sleep 2000 - done: - Pop $2 - Pop $1 - Pop $0 - -!macroend - -Function un.StrStr -/*After this point: - ------------------------------------------ - $R0 = SubString (input) - $R1 = String (input) - $R2 = SubStringLen (temp) - $R3 = StrLen (temp) - $R4 = StartCharPos (temp) - $R5 = TempStr (temp)*/ - - ;Get input from user - Exch $R0 - Exch - Exch $R1 - Push $R2 - Push $R3 - Push $R4 - Push $R5 - - ;Get "String" and "SubString" length - StrLen $R2 $R0 - StrLen $R3 $R1 - ;Start "StartCharPos" counter - StrCpy $R4 0 - - ;Loop until "SubString" is found or "String" reaches its end - loop: - ;Remove everything before and after the searched part ("TempStr") - StrCpy $R5 $R1 $R2 $R4 - - ;Compare "TempStr" with "SubString" - StrCmp $R5 $R0 done - ;If not "SubString", this could be "String"'s end - IntCmp $R4 $R3 done 0 done - ;If not, continue the loop - IntOp $R4 $R4 + 1 - Goto loop - done: - -/*After this point: - ------------------------------------------ - $R0 = ResultVar (output)*/ - - ;Remove part before "SubString" on "String" (if there has one) - StrCpy $R0 $R1 `` $R4 - - ;Return output to user - Pop $R5 - Pop $R4 - Pop $R3 - Pop $R2 - Pop $R1 - Exch $R0 -FunctionEnd - - ; GetParameters - ; input, none - ; output, top of stack (replaces, with e.g. whatever) - ; modifies no other variables. - -Function un.GetParameters - - Push $R0 - Push $R1 - Push $R2 - Push $R3 - - StrCpy $R2 1 - StrLen $R3 $CMDLINE - - ;Check for quote or space - StrCpy $R0 $CMDLINE $R2 - StrCmp $R0 '"' 0 +3 - StrCpy $R1 '"' - Goto loop - StrCpy $R1 " " - - loop: - IntOp $R2 $R2 + 1 - StrCpy $R0 $CMDLINE 1 $R2 - StrCmp $R0 $R1 get - StrCmp $R2 $R3 get - Goto loop - - get: - IntOp $R2 $R2 + 1 - StrCpy $R0 $CMDLINE 1 $R2 - StrCmp $R0 " " get - StrCpy $R0 $CMDLINE "" $R2 - - Pop $R3 - Pop $R2 - Pop $R1 - Exch $R0 - -FunctionEnd - -Function un.GetParameterValue - Exch $R0 ; get the top of the stack(default parameter) into R0 - Exch ; exchange the top of the stack(default) with - ; the second in the stack(parameter to search for) - Exch $R1 ; get the top of the stack(search parameter) into $R1 - - ;Preserve on the stack the registers used in this function - Push $R2 - Push $R3 - Push $R4 - Push $R5 - - Strlen $R2 $R1+2 ; store the length of the search string into R2 - - Call un.GetParameters ; get the command line parameters - Pop $R3 ; store the command line string in R3 - - # search for quoted search string - StrCpy $R5 '"' ; later on we want to search for a open quote - Push $R3 ; push the 'search in' string onto the stack - Push '"/$R1=' ; push the 'search for' - Call un.StrStr ; search for the quoted parameter value - Pop $R4 - StrCpy $R4 $R4 "" 1 ; skip over open quote character, "" means no maxlen - StrCmp $R4 "" "" next ; if we didn't find an empty string go to next - - # search for non-quoted search string - StrCpy $R5 ' ' ; later on we want to search for a space since we - ; didn't start with an open quote '"' we shouldn't - ; look for a close quote '"' - Push $R3 ; push the command line back on the stack for searching - Push '/$R1=' ; search for the non-quoted search string - Call un.StrStr - Pop $R4 - - ; $R4 now contains the parameter string starting at the search string, - ; if it was found -next: - StrCmp $R4 "" check_for_switch ; if we didn't find anything then look for - ; usage as a command line switch - # copy the value after /$R1= by using StrCpy with an offset of $R2, - # the length of '/OUTPUT=' - StrCpy $R0 $R4 "" $R2 ; copy commandline text beyond parameter into $R0 - # search for the next parameter so we can trim this extra text off - Push $R0 - Push $R5 ; search for either the first space ' ', or the first - ; quote '"' - ; if we found '"/output' then we want to find the - ; ending ", as in '"/output=somevalue"' - ; if we found '/output' then we want to find the first - ; space after '/output=somevalue' - Call un.StrStr ; search for the next parameter - Pop $R4 - StrCmp $R4 "" done ; if 'somevalue' is missing, we are done - StrLen $R4 $R4 ; get the length of 'somevalue' so we can copy this - ; text into our output buffer - StrCpy $R0 $R0 -$R4 ; using the length of the string beyond the value, - ; copy only the value into $R0 - goto done ; if we are in the parameter retrieval path skip over - ; the check for a command line switch - -; See if the parameter was specified as a command line switch, like '/output' -check_for_switch: - Push $R3 ; push the command line back on the stack for searching - Push '/$R1' ; search for the non-quoted search string - Call un.StrStr - Pop $R4 - StrCmp $R4 "" done ; if we didn't find anything then use the default - StrCpy $R0 "" ; otherwise copy in an empty string since we found the - ; parameter, just didn't find a value - -done: - Pop $R5 - Pop $R4 - Pop $R3 - Pop $R2 - Pop $R1 - Exch $R0 ; put the value in $R0 at the top of the stack -FunctionEnd +; Uninstaller Section "Uninstall" - - !insertmacro TerminateApp - - Push "NODELCFG" ; push the search string onto the stack - Push "0" ; push a default value onto the stack - Call un.GetParameterValue - Pop $2 - - StrCmp $2 "1" skip_cfg - - MessageBox MB_YESNO "Delete all configuration data and index? This will save a lot of space, but at the expense of reconfiguring and reindexing everything if GoldenDict is ever installed again." IDNO skip_cfg - - RMDir /r $APPDATA\GoldenDict - - skip_cfg: - - SetShellVarContext all - !insertmacro MUI_STARTMENU_GETFOLDER GDApplication $StartMenuFolder - -; This file is auto-generated - !include "uninst.nsh" - - Delete "$INSTDIR\Uninstall.exe" - - RMDir "$INSTDIR" + ; Remove registry keys DeleteRegKey HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\GoldenDict" -SectionEnd + ; Remove registry keys + DeleteRegKey HKLM SOFTWARE\GoldenDict + + ; Remove files and uninstaller + Delete $INSTDIR\GoldenDict.nsi + Delete $INSTDIR\GoldenDict.exe + Delete $INSTDIR\uninstall.exe + Delete $INSTDIR\*.* + + ; Remove shortcuts, if any + Delete "$SMPROGRAMS\GoldenDict\*.lnk" + + ; Remove directories + RMDir "$SMPROGRAMS\GoldenDict" + RMDir "$INSTDIR" + +SectionEnd \ No newline at end of file diff --git a/tools/nsis/gen_uninstall/gen_uninstall.cc b/tools/nsis/gen_uninstall/gen_uninstall.cc deleted file mode 100644 index 52272529..00000000 --- a/tools/nsis/gen_uninstall/gen_uninstall.cc +++ /dev/null @@ -1,78 +0,0 @@ -// This program generates uninstallation script automatically, using the -// output of the makensis command. -// Why is this not part of NSIS? Ask NSIS developers. - -#include -#include - -int main( int argc, char *argv[] ) -{ - QCoreApplication app( argc, argv ); - - QTextStream stream( stdin ); - - QRegExp setOutPath( "^SetOutPath: \"(.*)\"$" ); - QRegExp createDirectory( "^CreateDirectory: \"(.*)\"$" ); - QRegExp file( "^File: \"([^\"]*)\"(->\"([^\"]*)\")?.*$" ); - QRegExp createShortCut( "^CreateShortCut: \"([^\"]*)\"(->\"([^\"]*)\")?.*$" ); - - QStringList log; - - QString currentOutPath; - - for( QString line; !( line = stream.readLine() ).isNull(); ) - { - if ( setOutPath.exactMatch( line ) ) - { - qDebug( "Setting out path to %s", qPrintable( setOutPath.cap( 1 ) ) ); - - currentOutPath = setOutPath.cap( 1 ); - } - else - if ( createDirectory.exactMatch( line ) ) - { - qDebug( "Creating directory %s", qPrintable( createDirectory.cap( 1 ) ) ); - - log.append( "RMDir \"" + createDirectory.cap( 1 ) + "\"" ); - } - else - if ( file.exactMatch( line ) ) - { - QString command( "Delete \"" ); - - if ( file.cap( 3 ).isEmpty() ) - { - // Using the current out path - command += currentOutPath + "\\" + file.cap( 1 ); - } - else - { - // Use the complete path available - command += file.cap( 3 ); - } - - command += "\""; - - log.append( command ); - - qDebug( "Writing file %s (%s)", qPrintable( file.cap( 1 ) ), - qPrintable( file.cap( 3 ) ) ); - } - else - if ( createShortCut.exactMatch( line ) ) - { - qDebug( "Creating shortcut %s", qPrintable( createShortCut.cap( 1 ) ) ); - - log.append( "Delete \"" + createShortCut.cap( 1 ) + "\"" ); - } - } - - // Ok, replay the log back - - for( int x = log.size(); x--; ) - { - printf( "%s\n", qPrintable( log[ x ] ) ); - } - - return 0; -} diff --git a/tools/nsis/gen_uninstall/gen_uninstall.exe.manifest b/tools/nsis/gen_uninstall/gen_uninstall.exe.manifest deleted file mode 100644 index c1cb4831..00000000 --- a/tools/nsis/gen_uninstall/gen_uninstall.exe.manifest +++ /dev/null @@ -1,9 +0,0 @@ - - - - - - - - - \ No newline at end of file diff --git a/tools/nsis/gen_uninstall/gen_uninstall.pro b/tools/nsis/gen_uninstall/gen_uninstall.pro deleted file mode 100644 index fc58d946..00000000 --- a/tools/nsis/gen_uninstall/gen_uninstall.pro +++ /dev/null @@ -1,15 +0,0 @@ -###################################################################### -# Automatically generated by qmake (2.01a) ?? ???. 4 17:15:56 2010 -###################################################################### - -TEMPLATE = app -TARGET = gen_uninstall -DEPENDPATH += . -INCLUDEPATH += . - -QT += core5compat core -CONFIG+=utf8_source -# Input -SOURCES += gen_uninstall.cc - -#RC_FILE = gen_uninstall.rc diff --git a/tools/nsis/gen_uninstall/gen_uninstall.rc b/tools/nsis/gen_uninstall/gen_uninstall.rc deleted file mode 100644 index 85f8f6b1..00000000 --- a/tools/nsis/gen_uninstall/gen_uninstall.rc +++ /dev/null @@ -1,3 +0,0 @@ -#include - -1 RT_MANIFEST gen_uninstall.exe.manifest diff --git a/tools/nsis/makensis.sh b/tools/nsis/makensis.sh deleted file mode 100755 index 6bc2e6a2..00000000 --- a/tools/nsis/makensis.sh +++ /dev/null @@ -1,14 +0,0 @@ -#!/bin/bash - -if [ $# != 1 ]; then - echo Usage: $0 infile.nsi - exit 1 -fi - -echo > uninst.nsh || exit 1 - -( makensis "-XSetCompress off" "$1" | tee log; exit ${PIPESTATUS[0]} ) || exit 1 - -./gen_uninstall/gen_uninstall < log > uninst.nsh || exit 1 - -exec makensis "$1"