From 068b25315c1ef89a95c45f8f5082363440c07d1a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Uwe=20St=C3=B6hr?= Date: Sun, 3 Jun 2012 17:17:01 +0200 Subject: [PATCH] installer: implement new method to select hunspell and thesaurus dictionaries and to download the selected ones (part 1) --- .../packaging/installer/DictionaryMirrors.txt | 5 + .../installer/HunspellDictionaryNames.txt | 114 ++++++++++++++ .../installer/ThesaurusDictionaryNames.txt | 44 ++++++ .../packaging/installer/include/init.nsh | 143 +++++++++++++++++ .../packaging/installer/include/nsis.nsh | 3 + .../packaging/installer/include/thesaurus.nsh | 145 ++++++++++++++++++ .../packaging/installer/include/variables.nsh | 5 + .../packaging/installer/setup/install.nsh | 12 ++ 8 files changed, 471 insertions(+) create mode 100644 development/Win32/packaging/installer/DictionaryMirrors.txt create mode 100644 development/Win32/packaging/installer/HunspellDictionaryNames.txt create mode 100644 development/Win32/packaging/installer/ThesaurusDictionaryNames.txt create mode 100644 development/Win32/packaging/installer/include/thesaurus.nsh diff --git a/development/Win32/packaging/installer/DictionaryMirrors.txt b/development/Win32/packaging/installer/DictionaryMirrors.txt new file mode 100644 index 0000000000..04da26e39c --- /dev/null +++ b/development/Win32/packaging/installer/DictionaryMirrors.txt @@ -0,0 +1,5 @@ +garr +heanet +ignum +netcologne +switch diff --git a/development/Win32/packaging/installer/HunspellDictionaryNames.txt b/development/Win32/packaging/installer/HunspellDictionaryNames.txt new file mode 100644 index 0000000000..80b8ae6fca --- /dev/null +++ b/development/Win32/packaging/installer/HunspellDictionaryNames.txt @@ -0,0 +1,114 @@ +af_ZA.aff?r=&ts= +af_ZA.dic?r=&ts= +ar_DZ.aff?r=&ts= +ar_DZ.dic?r=&ts= +be_BY.aff?r=&ts= +be_BY.dic?r=&ts= +bg_BG.aff?r=&ts= +bg_BG.dic?r=&ts= +br_FR.aff?r=&ts= +br_FR.dic?r=&ts= +ca_ES.aff?r=&ts= +ca_ES.dic?r=&ts= +cs_CZ.aff?r=&ts= +cs_CZ.dic?r=&ts= +cy_GB.aff?r=&ts= +cy_GB.dic?r=&ts= +da_DK.aff?r=&ts= +da_DK.dic?r=&ts= +de_AT.aff?r=&ts= +de_AT.dic?r=&ts= +de_CH.aff?r=&ts= +de_CH.dic?r=&ts= +de_DE.aff?r=&ts= +de_DE.dic?r=&ts= +db_DE.aff?r=&ts= +db_DE.dic?r=&ts= +el_GR.aff?r=&ts= +el_GR.dic?r=&ts= +en_AU.aff?r=&ts= +en_AU.dic?r=&ts= +en_CA.aff?r=&ts= +en_CA.dic?r=&ts= +en_GB.aff?r=&ts= +en_GB.dic?r=&ts= +en_NZ.aff?r=&ts= +en_NZ.dic?r=&ts= +en_US.aff?r=&ts= +en_US.dic?r=&ts= +eo_EO.aff?r=&ts= +eo_EO.dic?r=&ts= +es_ES.aff?r=&ts= +es_ES.dic?r=&ts= +es_MX.aff?r=&ts= +es_MX.dic?r=&ts= +et_EE.aff?r=&ts= +et_EE.dic?r=&ts= +fa_IR.aff?r=&ts= +fa_IR.dic?r=&ts= +fr_FR.aff?r=&ts= +fr_FR.dic?r=&ts= +ga_IE.aff?r=&ts= +ga_IE.dic?r=&ts= +gd_GB.aff?r=&ts= +gd_GB.dic?r=&ts= +gl_ES.aff?r=&ts= +gl_ES.dic?r=&ts= +he_IL.aff?r=&ts= +he_IL.dic?r=&ts= +hr_HR.aff?r=&ts= +hr_HR.dic?r=&ts= +hu_HU.aff?r=&ts= +hu_HU.dic?r=&ts= +hy_AM.aff?r=&ts= +hy_AM.dic?r=&ts= +id_ID.aff?r=&ts= +id_ID.dic?r=&ts= +is_IS.aff?r=&ts= +is_IS.dic?r=&ts= +it_IT.aff?r=&ts= +it_IT.dic?r=&ts= +kk_KZ.aff?r=&ts= +kk_KZ.dic?r=&ts= +ko_KR.aff?r=&ts= +ko_KR.dic?r=&ts= +la_LA.aff?r=&ts= +la_LA.dic?r=&ts= +lt_LT.aff?r=&ts= +lt_LT.dic?r=&ts= +lv_LV.aff?r=&ts= +lv_LV.dic?r=&ts= +ms_MY.aff?r=&ts= +ms_MY.dic?r=&ts= +nb_NO.aff?r=&ts= +nb_NO.dic?r=&ts= +nl_NL.aff?r=&ts= +nl_NL.dic?r=&ts= +nn_NO.aff?r=&ts= +nn_NO.dic?r=&ts= +pl_PL.aff?r=&ts= +pl_PL.dic?r=&ts= +pt_BR.aff?r=&ts= +pt_BR.dic?r=&ts= +pt_PT.aff?r=&ts= +pt_PT.dic?r=&ts= +ro_RO.aff?r=&ts= +ro_RO.dic?r=&ts= +ru_RU.aff?r=&ts= +ru_RU.dic?r=&ts= +sk_SK.aff?r=&ts= +sk_SK.dic?r=&ts= +sl_SI.aff?r=&ts= +sl_SI.dic?r=&ts= +sq_AL.aff?r=&ts= +sq_AL.dic?r=&ts= +sr_RS.aff?r=&ts= +sr_RS.dic?r=&ts= +sv_SE.aff?r=&ts= +sv_SE.dic?r=&ts= +th_TH.aff?r=&ts= +th_TH.dic?r=&ts= +uk_UA.aff?r=&ts= +uk_UA.dic?r=&ts= +vi_VN.aff?r=&ts= +vi_VN.dic?r=&ts= diff --git a/development/Win32/packaging/installer/ThesaurusDictionaryNames.txt b/development/Win32/packaging/installer/ThesaurusDictionaryNames.txt new file mode 100644 index 0000000000..8584ba6e1d --- /dev/null +++ b/development/Win32/packaging/installer/ThesaurusDictionaryNames.txt @@ -0,0 +1,44 @@ +th_bg_BG_v2.dat?r=&ts= +th_bg_BG_v2.idx?r=&ts= +th_ca_ES_v2.dat?r=&ts=1338694206 +th_ca_ES_v2.idx?r=&ts=1338694208 +th_cs_CZ_v2.dat?r=&ts= +th_cs_CZ_v2.idx?r=&ts= +th_da_DK_v2.dat?r=&ts= +th_da_DK_v2.idx?r=&ts= +th_de_CH_v2.dat?r=&ts=1338690386 +th_de_CH_v2.idx?r=&ts=1338690545 +th_de_DE_v2.dat?r=&ts=1338686429 +th_de_DE_v2.idx?r=&ts=1338690578 +th_el_GR_v2.dat?r=&ts= +th_el_GR_v2.idx?r=&ts= +th_en_GB_v2.dat?r=&ts= +th_en_GB_v2.idx?r=&ts= +th_en_US_v2.dat?r=&ts= +th_en_US_v2.idx?r=&ts= +th_es_ES_v2.dat?r=&ts= +th_es_ES_v2.idx?r=&ts= +th_fr_FR_v2.dat?r=&ts= +th_fr_FR_v2.idx?r=&ts= +th_ga_IE_v2.dat?r=&ts= +th_ga_IE_v2.idx?r=&ts= +th_hu_HU_v2.dat?r=&ts=1338694214 +th_hu_HU_v2.idx?r=&ts=1338694321 +th_it_IT_v2.dat?r=&ts= +th_it_IT_v2.idx?r=&ts= +th_nb_NO_v2.dat?r=&ts= +th_nb_NO_v2.idx?r=&ts= +th_pl_PL_v2.dat?r=&ts= +th_pl_PL_v2.idx?r=&ts= +th_pt_PT_v2.dat?r=&ts= +th_pt_PT_v2.idx?r=&ts= +th_ro_RO_v2.dat?r=&ts= +th_ro_RO_v2.idx?r=&ts= +th_ru_RU_v2.dat?r=&ts= +th_ru_RU_v2.idx?r=&ts= +th_sk_SK_v2.dat?r=&ts=1338686412 +th_sk_SK_v2.idx?r=&ts=1338686211 +th_sl_SI_v2.dat?r=&ts=1338686213 +th_sl_SI_v2.idx?r=&ts=1338686215 +th_sv_SE_v2.dat?r=&ts=1338686216 +th_sv_SE_v2.idx?r=&ts=1338686414 diff --git a/development/Win32/packaging/installer/include/init.nsh b/development/Win32/packaging/installer/include/init.nsh index 43f428c083..f430d972aa 100644 --- a/development/Win32/packaging/installer/include/init.nsh +++ b/development/Win32/packaging/installer/include/init.nsh @@ -210,6 +210,149 @@ SectionEnd SectionEnd !endif +SectionGroup "Dictionaries" SecDictionaries + +Section /o "German (A)" SecDGermanAT + StrCpy $DictCodes "de_AT$DictCodes" + AddSize 1000 +SectionEnd + +Section /o "German (CH)" SecDGermanCH + StrCpy $DictCodes "de_CH$DictCodes" + AddSize 1000 +SectionEnd + +Section "German (D)" SecDGermanD + StrCpy $DictCodes "de_DE$DictCodes" + AddSize 2650 +SectionEnd + +Section "Magyar" SecDHungarian + StrCpy $DictCodes "hu_HU$DictCodes" + AddSize 3380 +SectionEnd + +Section "Serbšcina" SecDSorbian + StrCpy $DictCodes "db_DE$DictCodes" + AddSize 904 +SectionEnd + +SectionGroupEnd + +SectionGroup "Thesaurus" SecThesaurus + +Section /o "Bulgarian" SecTBulgarian + StrCpy $ThesCodes "bg_BG$ThesCodes" + AddSize 3020 +SectionEnd + +Section /o "Català" SecTCatalan + StrCpy $ThesCodes "ca_ES$ThesCodes" + AddSize 731 +SectionEnd + +Section /o "Ceština" SecTCzech + StrCpy $ThesCodes "cs_CZ$ThesCodes" + AddSize 635 +SectionEnd + +Section /o "Dansk" SecTDanish + StrCpy $ThesCodes "da_DK$ThesCodes" + AddSize 2360 +SectionEnd + +Section /o "Deutsch (D/A)" SecTGermanDA + StrCpy $ThesCodes "de_DE$ThesCodes" + AddSize 5360 +SectionEnd + +Section /o "Deutsch (CH)" SecTGermanCH + StrCpy $ThesCodes "de_CH$ThesCodes" + AddSize 5360 +SectionEnd + +Section /o "English (GB)" SecTEnglishGB + StrCpy $ThesCodes "en_GB$ThesCodes" + AddSize 20600 +SectionEnd + +Section /o "English (US/AU)" SecTEnglishUSAU + StrCpy $ThesCodes "en_US$ThesCodes" + AddSize 20600 +SectionEnd + +Section /o "Español" SecTSpanish + StrCpy $ThesCodes "es_ES$ThesCodes" + AddSize 2860 +SectionEnd + +Section /o "Français" SecTFrench + StrCpy $ThesCodes "fr_FR$ThesCodes" + AddSize 5060 +SectionEnd + +Section /o "Gaeilge" SecTGaelic + StrCpy $ThesCodes "ga_IR$ThesCodes" + AddSize 30600 +SectionEnd + +Section /o "Greek" SecTGreek + StrCpy $ThesCodes "el_GR$ThesCodes" + AddSize 903 +SectionEnd + +Section /o "Italiano" SecTItalian + StrCpy $ThesCodes "it_IT$ThesCodes" + AddSize 2640 +SectionEnd + +Section /o "Magyar" SecTHungarian + StrCpy $ThesCodes "hu_HU$ThesCodes" + AddSize 632 +SectionEnd + +Section /o "Norsk" SecTNorwegian + StrCpy $ThesCodes "no_NO$ThesCodes" + AddSize 2470 +SectionEnd + +Section /o "Polski" SecTPolish + StrCpy $ThesCodes "pl_PL$ThesCodes" + AddSize 5580 +SectionEnd + +Section /o "Português" SecTPortuguese + StrCpy $ThesCodes "pt_PT$ThesCodes" + AddSize 855 +SectionEnd + +Section /o "Româna" SecTRomanian + StrCpy $ThesCodes "ro_RO$ThesCodes" + AddSize 3640 +SectionEnd + +Section /o "Russian" SecTRussian + StrCpy $ThesCodes "ru_RU$ThesCodes" + AddSize 2080 +SectionEnd + +Section /o "Slovenšcina" SecTSlowenian + StrCpy $ThesCodes "sl_SI$ThesCodes" + AddSize 107 +SectionEnd + +Section /o "Slovenský" SecTSlowakian + StrCpy $ThesCodes "sk_SK$ThesCodes" + AddSize 907 +SectionEnd + +Section /o "Svenska" SecTSwedish + StrCpy $ThesCodes "sv_SE$ThesCodes" + AddSize 720 +SectionEnd + +SectionGroupEnd + # Section descriptions !insertmacro MUI_FUNCTION_DESCRIPTION_BEGIN !insertmacro MUI_DESCRIPTION_TEXT ${SecCore} "$(SecCoreDescription)" diff --git a/development/Win32/packaging/installer/include/nsis.nsh b/development/Win32/packaging/installer/include/nsis.nsh index 1bcc04f187..5634a2d531 100644 --- a/development/Win32/packaging/installer/include/nsis.nsh +++ b/development/Win32/packaging/installer/include/nsis.nsh @@ -47,6 +47,9 @@ Configuration of standard NSIS header files !include gui\LaTeXFolder.nsh !endif # end if != BUNDLE +# Functions download dictionaries +!include include\Thesaurus.nsh + #-------------------------------- # Include standard functions diff --git a/development/Win32/packaging/installer/include/thesaurus.nsh b/development/Win32/packaging/installer/include/thesaurus.nsh new file mode 100644 index 0000000000..43cce3766d --- /dev/null +++ b/development/Win32/packaging/installer/include/thesaurus.nsh @@ -0,0 +1,145 @@ +# download dictionaries + +Function DownloadHunspellDictionary + # Downloads hunspell dictionaries from a location that is given in the file + # $INSTDIR\Resources\HunspellDictionaryNames.txt + + # read out the locations from the file + FileOpen $R5 "$INSTDIR\Resources\HunspellDictionaryNames.txt" r + ${For} $5 1 114 + FileRead $R5 $String # $String is now the dictionary name + StrCpy $R3 $String 5 3 # $R3 is now the dictionary language code + MessageBox MB_OK|MB_ICONEXCLAMATION "$R3" + + ${if} $DictCode == $R3 + StrCpy $String $String -2 # delete the linebreak characters at the end + StrCpy $FileName $String 15 # extract the real file name + # Download hunspell dictionaries, + # if first download repository is not available try the other ones listed in "DictionaryMirrors.txt" + FileOpen $R4 "$INSTDIR\Resources\DictionaryMirrors.txt" r + + ${For} $4 1 5 + FileRead $R4 $Search # $Search is now the mirror + StrCpy $Search $Search -2 # delete the linebreak characters at the end + Push $R0 + MessageBox MB_OK|MB_ICONEXCLAMATION "http://downloads.sourceforge.net/project/lyxwininstaller/thesaurus/$String&use_mirror=$Search" + InetLoad::load /TIMEOUT=5000 "http://downloads.sourceforge.net/project/lyxwininstaller/thesaurus/$String&use_mirror=$Search" "$INSTDIR\Resources\dicts\$FileName" /END + Pop $R0 + ${if} $R0 == "OK" + ${ExitFor} + ${endif} + ${Next} + + FileClose $R4 + # if download failed + ${if} $R0 != "OK" + MessageBox MB_OK|MB_ICONEXCLAMATION "(AspellDownloadFailed) $R0" + Goto abortinstall + ${endif} + ${endif} # end if $DictCode == $R3 + + ${Next} + FileClose $R5 + + abortinstall: + Delete "$INSTDIR\$FileName" + +FunctionEnd + +#-------------------------------- + +Function DownloadThesaurusDictionary + # Downloads thesaurus dictionaries from a location that is given in the file + # $INSTDIR\Resources\ThesaurusDictionaryNames.txt + + # read out the locations from the file + FileOpen $R5 "$INSTDIR\Resources\ThesaurusDictionaryNames.txt" r + ${For} $5 1 44 + FileRead $R5 $String # $String is now the dictionary name + StrCpy $R3 $String 5 3 # $R3 is now the dictionary language code + + ${if} $ThesCode == $R3 + StrCpy $String $String -2 # delete the linebreak characters at the end + StrCpy $FileName $String 15 # extract the real file name + # Download thesaurus dictionaries, + # if first download repository is not available try the other ones listed in "DictionaryMirrors.txt" + FileOpen $R4 "$INSTDIR\Resources\DictionaryMirrors.txt" r + + ${For} $4 1 5 + FileRead $R4 $Search # $Search is now the mirror + StrCpy $Search $Search -2 # delete the linebreak characters at the end + Push $R0 + MessageBox MB_OK|MB_ICONEXCLAMATION "http://downloads.sourceforge.net/project/lyxwininstaller/thesaurus/$String&use_mirror=$Search" + InetLoad::load /TIMEOUT=5000 "http://downloads.sourceforge.net/project/lyxwininstaller/thesaurus/$String&use_mirror=$Search" "$INSTDIR\Resources\thes\$FileName" /END + Pop $R0 + ${if} $R0 == "OK" + ${ExitFor} + ${endif} + ${Next} + + FileClose $R4 + # if download failed + ${if} $R0 != "OK" + MessageBox MB_OK|MB_ICONEXCLAMATION "(AspellDownloadFailed) $R0" + Goto abortinstall + ${endif} + ${endif} # end if $ThesCode == $R3 + + ${Next} + FileClose $R5 + + abortinstall: + Delete "$INSTDIR\$FileName" + +FunctionEnd + +#-------------------------------- + +Function InstallHunspellDictionary + # install hunspell dictionaries + + # install the dictionary corresponding to the system and the chosen menu language + # check if the system language and the chosen menu language are the same, if not install + # both dictionaries + ${Do} + StrCpy $DictCode $DictCodes 5 + StrCpy $DictCodes $DictCodes "" 5 + MessageBox MB_OK|MB_ICONEXCLAMATION "$DictCode" + Call DownloadHunspellDictionary + ${LoopUntil} $DictCodes == "" + +FunctionEnd + +#-------------------------------- + +Function InstallThesaurusDictionary + # install thesaurus dictionaries + + # install the dictionary corresponding to the system and the chosen menu language + # check if the system language and the chosen menu language are the same, if not install + # both dictionaries + ${Do} + StrCpy $ThesCode $ThesCodes 5 + StrCpy $ThesCodes $ThesCodes "" 5 + MessageBox MB_OK|MB_ICONEXCLAMATION "$ThesCode" + Call DownloadThesaurusDictionary + ${LoopUntil} $ThesCodes == "" + + # some dictionaries of language variants are identic + # therefore copy and rename an existing dictionary + CreateDirectory "$INSTDIR\Resources\backup" + ${if} ${FileExists} "$INSTDIR\Resources\thes\th_de_DE_v2.dat" + CopyFiles "$INSTDIR\Resources\thes\th_de_DE_v2.*" "$INSTDIR\Resources\backup" + Rename "$INSTDIR\Resources\backup\th_de_DE_v2.dat" "$INSTDIR\Resources\backup\th_de_AT_v2.dat" + Rename "$INSTDIR\Resources\backup\th_de_DE_v2.idx" "$INSTDIR\Resources\backup\th_de_AT_v2.idx" + CopyFiles "$INSTDIR\Resources\backup\th_de_AT_v2.*" "$INSTDIR\Resources\thes" + ${endif} + ${if} ${FileExists} "$INSTDIR\Resources\thes\th_en_US_v2.dat" + CopyFiles "$INSTDIR\Resources\thes\th_en_US_v2.*" "$INSTDIR\Resources\backup" + Rename "$INSTDIR\Resources\backup\th_en_US_v2.dat" "$INSTDIR\Resources\backup\th_en_AU_v2.dat" + Rename "$INSTDIR\Resources\backup\th_en_US_v2.idx" "$INSTDIR\Resources\backup\th_en_AU_v2.idx" + CopyFiles "$INSTDIR\Resources\backup\th_en_AU_v2.*" "$INSTDIR\Resources\thes" + ${endif} + RMDir "$INSTDIR\Resources\backup" + +FunctionEnd diff --git a/development/Win32/packaging/installer/include/variables.nsh b/development/Win32/packaging/installer/include/variables.nsh index 2c3d797b71..787f5da138 100644 --- a/development/Win32/packaging/installer/include/variables.nsh +++ b/development/Win32/packaging/installer/include/variables.nsh @@ -20,8 +20,11 @@ var AppSubfolder Var AppSuff Var CreateDesktopIcon Var CreateFileAssociations +Var DictCode +Var DictCodes Var DelPythonFiles Var EditorPath +Var FileName Var GhostscriptPath Var GnumericPath Var ImageEditorPath @@ -44,6 +47,8 @@ Var Search Var SVGPath Var StartmenuFolder Var String +Var ThesCode +Var ThesCodes Var UpdateFNDBReturn Var UserList Var WMFPath diff --git a/development/Win32/packaging/installer/setup/install.nsh b/development/Win32/packaging/installer/setup/install.nsh index 05776fdcb1..4c5b920317 100644 --- a/development/Win32/packaging/installer/setup/install.nsh +++ b/development/Win32/packaging/installer/setup/install.nsh @@ -132,6 +132,18 @@ Section -ProgramFiles SecProgramFiles Call ConfigureMiKTeX # Function from LaTeX.nsh ${endif} + # download dictionaries and thesaurus + ${if} $DictCodes != "" + Call InstallHunspellDictionary # Function from Thesaurus.nsh + ${endif} + ${if} $ThesCodes != "" + Call InstallThesaurusDictionary # Function from Thesaurus.nsh + ${endif} + # finally delete the list of dictionaries and mirrors + Delete "$INSTDIR\Resources\DictionaryMirrors.txt" + Delete "$INSTDIR\Resources\ThesaurusDictionaryNames.txt" + Delete "$INSTDIR\Resources\HunspellDictionaryNames.txt" + # Create uninstaller WriteUninstaller "$INSTDIR\${SETUP_UNINSTALLER}"