# # $Id$ # Copyright © 2007 lolo_32 # Copyright © 2007-2020 gingko - https://www.pouchintv.fr/ # # This file is part of Pouchin TV Mod, a free DVB-T viewer. # See https://www.pouchintv.fr/ for updates. # # Pouchin TV Mod is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. # # Pouchin TV Mod is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA # # # Most files of this project have been changed from the Pouchin TV # project (Copyright © 2006 Pouchin ), # to use with a modified version of this software. # See http://pouchinteve.free.fr/ for the original project. # ; Script d'installation pour Pouchin TV Mod en 32 bits ;-------------------------------- ;Style moderne !include "MUI.nsh" ;Conditions pour le x64 !include "x64.nsh" ;Pour la gestion des sections !include "Sections.nsh" ;Récupération du numéro de version (généré automatiquement au préalable) !include "..\version.nsh" ;-------------------------------- ;Quelques constantes ;Construction du nom de l'application et du chemin d'accès, selon la configuration ;Nom de la configuration à définir par /DEXE_SRC_DIR=xxxx en ligne de commande !ifndef EXE_SRC_DIR ; Valeur par défaut !define EXE_SRC_DIR "..\Builds\" !endif ;$DEBUG_SFX est un suffixe ajouté au nom de l'application et de l'installeur pour ;différencier les versions Debug ;Cette variable est à définir est à définir par /DDEBUG_SFX=xxxx en ligne de commande ;Normalement vide (par défaut) ou bien "_debug" ou "_diag" !ifndef DEBUG_SFX !define DEBUG_SFX "" !endif ;$DSPDBG_SFX est un suffixe ajouté au nom des répertoires et des raccourcis du menu démarrer ;pour différencier les versions Debug ;Cette variable est à définir est à définir par /DDSPDBG_SFX=xxxx en ligne de commande ;Normalement vide (par défaut) ou bien " (debug)" ou " (diag)" !ifndef DSPDBG_SFX !define DSPDBG_SFX "" !endif ;$SBCS_SUFFIX est un suffixe ajouté au nom de l'installeur pour différencier les versions SBCS ;Cette variable est à définir par /DSBCS_SFX=xxxx en ligne de commande ;Normalement vide (par défaut) ou bien "_sbcs" !ifndef SBCS_SFX !define SBCS_SFX "" !endif ;$APP_BASENAME est le nom de base de l'application ;Cette variable *peut* se redéfinir par /DAPP_BASENAME=xxxx en ligne de commande !ifndef APP_BASENAME !define APP_BASENAME PouchinTVMod !endif !define PRODUCT_BASE_NAME "Pouchin TV Mod" !define PRODUCT_NAME "${PRODUCT_BASE_NAME}${DSPDBG_SFX}" !define PRODUCT_COMMENT "https://www.pouchintv.fr/, http://www.etud.insa-toulouse.fr/~mvelten/pouchintvmod/, http://pouchinteve.free.fr/" !define PRODUCT_INSTALL_DESCRIPTION "Installeur pour ${PRODUCT_NAME}" !define PRODUCT_WEB_SITE "https://www.pouchintv.fr/" !define PRODUCT_UNINST_KEY "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\${PRODUCT_NAME}" !define PRODUCT_UNINST_ROOT_KEY HKLM !define EXE_SRC_DIR_X86 "${EXE_SRC_DIR}" !define EXE_SRC_DIR_X64 "${EXE_SRC_DIR}x64\" !define EXE_BASENAME_X86 "${APP_BASENAME}${DEBUG_SFX}" !define EXE_BASENAME_X64 "${EXE_BASENAME_X86}_x64" !define INSTALL_FILENAME "${EXE_BASENAME_X86}${SBCS_SFX}_setup.${PRODUCT_VERSION}.exe" ;-------------------------------- ;Général ;Nom et fichier Name "${PRODUCT_NAME}" OutFile "${EXE_SRC_DIR}${INSTALL_FILENAME}" ;Répertoire par défaut vide InstallDir "" ;Récupère le dossier d'installation d'une précédente installation InstallDirRegKey ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_UNINST_KEY}" "InstallLocation" ;Compresse en utilisant LZMA SetCompressor /SOLID lzma ;Sauvegarde le CRC du fichier (pour download non corrompu) CRCCheck on ;Demande les droits admin pour Vista RequestExecutionLevel admin ;Active les boutons avec le style Windows XP XPStyle on ;Récupère le chemin vers la page pour le menu démarrer !define MUI_STARTMENUPAGE_REGISTRY_ROOT "${PRODUCT_UNINST_ROOT_KEY}" !define MUI_STARTMENUPAGE_REGISTRY_KEY "${PRODUCT_UNINST_KEY}" !define MUI_STARTMENUPAGE_REGISTRY_VALUENAME "Menu Démarrer" ;-------------------------------- ;Variables Var STARTMENU_FOLDER Var INSTALL_X64 ;-------------------------------- ;Interface !define MUI_ICON "install.ico" !define MUI_UNICON "uninstall.ico" !define MUI_WELCOMEFINISHPAGE_BITMAP "welcome-install.bmp" !define MUI_UNWELCOMEFINISHPAGE_BITMAP "welcome-uninstall.bmp" !define MUI_COMPONENTSPAGE_CHECKBITMAP "checks.bmp" !define MUI_COMPONENTSPAGE_NODESC !define MUI_FINISHPAGE_NOAUTOCLOSE !define MUI_HEADERIMAGE !define MUI_HEADERIMAGE_BITMAP "header-install.bmp" !define MUI_HEADERIMAGE_UNBITMAP "header-uninstall.bmp" !define MUI_ABORTWARNING ;-------------------------------- ;Pages !insertmacro MUI_PAGE_WELCOME !insertmacro MUI_PAGE_LICENSE "gpl.txt" LicenseForceSelection checkbox ;Necessité de cocher la case Accepter la license !insertmacro MUI_PAGE_COMPONENTS !define MUI_PAGE_CUSTOMFUNCTION_PRE ChangeRep !insertmacro MUI_PAGE_DIRECTORY !insertmacro MUI_PAGE_STARTMENU Application $STARTMENU_FOLDER !insertmacro MUI_PAGE_INSTFILES !insertmacro MUI_PAGE_FINISH !insertmacro MUI_UNPAGE_WELCOME !insertmacro MUI_UNPAGE_CONFIRM !insertmacro MUI_UNPAGE_INSTFILES !insertmacro MUI_UNPAGE_FINISH ;-------------------------------- ;Langues !insertmacro MUI_LANGUAGE "French" ;-------------------------------- ;Informations de versions sur l'installeur VIAddVersionKey /LANG=${LANG_FRENCH} "Comments" "${PRODUCT_COMMENT}" VIAddVersionKey /LANG=${LANG_FRENCH} "FileDescription" "${PRODUCT_INSTALL_DESCRIPTION} 32 et 64 bits" VIAddVersionKey /LANG=${LANG_FRENCH} "FileVersion" "${PRODUCT_VERSION}" VIAddVersionKey /LANG=${LANG_FRENCH} "InternalName" "${PRODUCT_INSTALL_DESCRIPTION}" VIAddVersionKey /LANG=${LANG_FRENCH} "LegalCopyright" "Copyright (C) 2006-2011" VIAddVersionKey /LANG=${LANG_FRENCH} "OriginalFilename" "${INSTALL_FILENAME}" VIAddVersionKey /LANG=${LANG_FRENCH} "ProductName" "${PRODUCT_NAME}" VIProductVersion "${PRODUCT_VERSION}" ;-------------------------------- ;Sections d'installation Section "" ;Vide car commun à toutes les installations SetOutPath "$INSTDIR" ;Crée le programme de suppression WriteUninstaller "$INSTDIR\Désinstaller.exe" ;Ajout de la désinstallation WriteRegStr ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_UNINST_KEY}" "DisplayName" "${PRODUCT_NAME}" WriteRegStr ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_UNINST_KEY}" "UninstallString" "$\"$INSTDIR\Désinstaller.exe$\"" WriteRegStr ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_UNINST_KEY}" "InstallLocation" "$INSTDIR" WriteRegStr ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_UNINST_KEY}" "URLInfoAbout" "${PRODUCT_WEB_SITE}" WriteRegStr ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_UNINST_KEY}" "URLUpdateInfo" "${PRODUCT_WEB_SITE}" WriteRegDWORD ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_UNINST_KEY}" "NoModify" 0x1 WriteRegDWORD ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_UNINST_KEY}" "NoRepair" 0x1 ;Fichiers communs File "..\AUTHORS" File "gpl.txt" File "..\canaux.ini" File "REFERENCES" File "..\changelog.html" File "..\style.css" File "..\Help\PouchinTvMod.chm" ;Crée les raccourcis internet WriteINIStr "$INSTDIR\${PRODUCT_BASE_NAME}.url" "InternetShortcut" "URL" "${PRODUCT_WEB_SITE}" SectionEnd Section /o "!${PRODUCT_NAME} pour Windows 64 bits" PouchinTVMod64 ${If} ${RunningX64} ;On a installé une version 64 bits de Windows StrCpy $INSTALL_X64 "1" SetOutPath "$INSTDIR" ;Les répertoires sont "All Users" SetShellVarContext all File "${EXE_SRC_DIR_X64}${EXE_BASENAME_X64}.exe" !insertmacro MUI_STARTMENU_WRITE_BEGIN Application ;Nettoyage préalable (raccourcis obsolètes, réinstallations avec moins d'options) : Delete "$SMPROGRAMS\$STARTMENU_FOLDER\Site internet de *.lnk" Delete "$SMPROGRAMS\$STARTMENU_FOLDER\${PRODUCT_NAME}*.lnk" ;Crée les raccourcis vers Pouchin CreateDirectory "$SMPROGRAMS\$STARTMENU_FOLDER" CreateShortCut "$SMPROGRAMS\$STARTMENU_FOLDER\${PRODUCT_NAME}.lnk" "$INSTDIR\${EXE_BASENAME_X64}.exe" CreateShortCut "$SMPROGRAMS\$STARTMENU_FOLDER\Historique des versions.lnk" "$INSTDIR\changelog.html" ;Raccourci internet WriteINIStr "$SMPROGRAMS\$STARTMENU_FOLDER\Site internet de ${PRODUCT_BASE_NAME}.url" "InternetShortcut" "URL" "${PRODUCT_WEB_SITE}" !insertmacro MUI_STARTMENU_WRITE_END ${EndIf} SectionEnd Section /o "${PRODUCT_NAME} pour Windows 32 bits" PouchinTVMod32 SetOutPath "$INSTDIR" SetShellVarContext all File "${EXE_SRC_DIR_X86}${EXE_BASENAME_X86}.exe" ;Crée les raccourcis internet WriteINIStr "$INSTDIR\${PRODUCT_BASE_NAME}.url" "InternetShortcut" "URL" "${PRODUCT_WEB_SITE}" !insertmacro MUI_STARTMENU_WRITE_BEGIN Application ;Nettoyage préalable (raccourcis obsolètes, réinstallations avec moins d'options) : Delete "$SMPROGRAMS\$STARTMENU_FOLDER\Site internet de *.lnk" Delete "$SMPROGRAMS\$STARTMENU_FOLDER\${PRODUCT_NAME}*.lnk" ;Crée les raccourcis vers Pouchin CreateDirectory "$SMPROGRAMS\$STARTMENU_FOLDER" CreateShortCut "$SMPROGRAMS\$STARTMENU_FOLDER\${PRODUCT_NAME}.lnk" "$INSTDIR\${EXE_BASENAME_X86}.exe" CreateShortCut "$SMPROGRAMS\$STARTMENU_FOLDER\Historique des versions.lnk" "$INSTDIR\changelog.html" ;Raccourcis internet WriteINIStr "$SMPROGRAMS\$STARTMENU_FOLDER\Site internet de ${PRODUCT_BASE_NAME}.url" "InternetShortcut" "URL" "${PRODUCT_WEB_SITE}" !insertmacro MUI_STARTMENU_WRITE_END SectionEnd Section "" ; Définit l'icône et sauve le type de la précédente installation (x32 / x64) ; Utile simplement pour Windows x64, ignoré sinon ${If} $INSTALL_X64 == "0" WriteRegStr ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_UNINST_KEY}" "DisplayIcon" "$INSTDIR\${EXE_BASENAME_X86}.exe,0" WriteRegStr ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_UNINST_KEY}" "Systeme" "x32" ${Else} WriteRegStr ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_UNINST_KEY}" "DisplayIcon" "$INSTDIR\${EXE_BASENAME_X64}.exe,0" WriteRegStr ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_UNINST_KEY}" "Systeme" "x64" ${EndIf} SectionEnd SectionGroup /e "Icônes des chaines" Icones Section "Françaises nationales" IconesFR SetOutPath "$INSTDIR\Icones" ;Ajout des icones File "..\Icones\*.bmp" SectionEnd Section "Françaises locales" IconesFRLocales SetOutPath "$INSTDIR\Icones\Locales" ;Ajout des icones des chaines locales File "..\Icones\Locales\*.bmp" SectionEnd Section /o "Allemandes" IconesAllemandes SetOutPath "$INSTDIR\Icones\Allemandes" ;Ajout des icones des chaines allemandes File "..\Icones\Allemandes\*.bmp" SectionEnd Section /o "Belges" IconesBelges SetOutPath "$INSTDIR\Icones\Belges" ;Ajout des icones des chaines belges File "..\Icones\Belges\*.bmp" SectionEnd Section /o "Suisses" IconesSuisses SetOutPath "$INSTDIR\Icones\Suisses" ;Ajout des icones des chaines suisses File "..\Icones\Suisses\*.bmp" SectionEnd Section /o "DOM-TOM" IconesDomTom SetOutPath "$INSTDIR\Icones\DOM-TOM" ;Ajout des icones des chaines des Dom-Tom français File "..\Icones\Suisses\*.bmp" SectionEnd SectionGroupEnd Section "Raccourci sur le bureau" IconeBureau ${If} $INSTALL_X64 == "0" CreateShortCut "$DESKTOP\${PRODUCT_NAME}.lnk" "$INSTDIR\${EXE_BASENAME_X86}.exe" ${Else} CreateShortCut "$DESKTOP\${PRODUCT_NAME}.lnk" "$INSTDIR\${EXE_BASENAME_X64}.exe" ${EndIf} SectionEnd Section /o "Raccourcis pour tuners supplémentaires" MultiTuners !insertmacro MUI_STARTMENU_WRITE_BEGIN Application ${If} $INSTALL_X64 == "0" CreateShortCut "$SMPROGRAMS\$STARTMENU_FOLDER\${PRODUCT_NAME} Tuner 2.lnk" "$INSTDIR\${EXE_BASENAME_X86}.exe" "--prefix t2_" CreateShortCut "$SMPROGRAMS\$STARTMENU_FOLDER\${PRODUCT_NAME} Tuner 3.lnk" "$INSTDIR\${EXE_BASENAME_X86}.exe" "--prefix t3_" ${Else} CreateShortCut "$SMPROGRAMS\$STARTMENU_FOLDER\${PRODUCT_NAME} Tuner 2.lnk" "$INSTDIR\${EXE_BASENAME_X64}.exe" "--prefix t2_" CreateShortCut "$SMPROGRAMS\$STARTMENU_FOLDER\${PRODUCT_NAME} Tuner 3.lnk" "$INSTDIR\${EXE_BASENAME_X64}.exe" "--prefix t3_" ${EndIf} !insertmacro MUI_STARTMENU_WRITE_END SectionEnd Section /o "Réinitialiser la configuration" EffaceConfig ;On supprime la configuration dans "Application Data", et aussi dans "Program Files", car ;certaines anciennes versions plaçaient leurs fichiers là. SetShellVarContext current Delete "$INSTDIR\config.ini" Delete "$INSTDIR\chaines.xml" Delete "$APPDATA\${PRODUCT_BASE_NAME}\*config.ini" Delete "$APPDATA\${PRODUCT_BASE_NAME}\*chaines.xml" SectionEnd Function .onInit ;Recherche si Pouchin TV Mod est lancé FindWindow $0 "${PRODUCT_BASE_NAME}" ${If} $0 != "0" MessageBox MB_YESNO "$\"${PRODUCT_NAME}$\" est en cours de fonctionnement. Vous ne pouvez pas installer une nouvelle version sans le quitter avant.$\n$\rDois-je le fermer pour vous ?" /SD IDYES IDNO quitte ;Envoie le message d'arrêt SendMessage $0 ${WM_CLOSE} 0 0 $0 /TIMEOUT=10000 ;Recherche une seconde fois, pour voir si il est quitté FindWindow $0 "${PRODUCT_BASE_NAME}" StrCmp $0 "0" suite quitte: MessageBox MB_ICONSTOP "Je ne peux continuer l’installation tant que $\"${PRODUCT_NAME}$\" ne sera pas arrêté." Abort suite: ${EndIf} ;Initialise StrCpy $INSTALL_X64 "0" ${If} ${RunningX64} ;On demande un accès en 64 bits à la base de registres SetRegView 64 ;Récupère la dernière version installée (x32 / x64) ReadRegStr $0 ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_UNINST_KEY}" "Systeme" IntOp $0 ${SF_SELECTED} | ${SF_BOLD} IntOp $0 $0 | ${SF_RO} ${If} $0 == "x32" ;Dernière installation en 32 bits SectionSetFlags ${PouchinTVMod32} $0 StrCpy $1 ${PouchinTVMod32} ${Else} ${If} $0 == "x64" ;Dernière installation en 64 bits SectionSetFlags ${PouchinTVMod64} $0 StrCpy $1 ${PouchinTVMod64} ${Else} ;Pas d'autres installations: sélection du 64 bits SectionSetFlags ${PouchinTVMod64} ${SF_SELECTED} StrCpy $1 ${PouchinTVMod64} ${EndIf} ${EndIf} ${Else} ;Supprime la section 64 bits pour les systèmes 32 bits SectionSetText ${PouchinTVMod64} "" SectionSetSize ${PouchinTVMod64} 0 ;Met en gras, et en lecture seule la section 32 bits IntOp $0 ${SF_SELECTED} | ${SF_BOLD} IntOp $0 $0 | ${SF_RO} SectionSetFlags ${PouchinTVMod32} $0 ;Rajoute "requis" à la fin SectionGetText ${PouchinTVMod32} $0 StrCpy $0 "$0 (requis)" SectionSetText ${PouchinTVMod32} $0 ;Sélectionne par défaut l'installation 64 bits StrCpy $1 ${PouchinTVMod32} ${EndIf} FunctionEnd Function .onSelChange !insertmacro StartRadioButtons $1 !insertmacro RadioButton ${PouchinTVMod64} !insertmacro RadioButton ${PouchinTVMod32} !insertmacro EndRadioButtons FunctionEnd Function ChangeRep ;Utilisation du répertoire de la précédente install StrCmp $INSTDIR "" 0 suite ${If} ${RunningX64} ;On est en 64bits. On vérifie si l'install en 64 bits est sélectionnée StrCmp $1 ${PouchinTVMod64} x64 ${EndIf} ;Système 32bits, ou install en 32 bits sélectionnée StrCpy $INSTDIR "$PROGRAMFILES\${PRODUCT_NAME}\" goto suite x64: StrCpy $INSTDIR "$PROGRAMFILES64\${PRODUCT_NAME}\" suite: FunctionEnd ;-------------------------------- ; Section Suppression ; TODO : Faire en sorte que ne soient retirés que les fichiers qui ont effectivement été installés. ; Voir exemple de comment faire ici : ; http://nsis.sourceforge.net/Uninstall_only_installed_files ; ; Lire aussi le "warning" dans la documentation "RMDir" de NSIS, expliquant pourquoi il est ; peu souhaitable d'exécuter une commande "RMDir /r" sur le répertoire d'installation de l'application. Section "uninstall" SetShellVarContext all ; Recherche si Pouchin TV Mod est lancé FindWindow $0 "Pouchin TV Mod" ${If} $0 != "0" ; Envoie le message d'arrêt SendMessage $0 ${WM_CLOSE} 0 0 $0 /TIMEOUT=10000 ; Recherche pour voir si il est quitté FindWindow $0 "Pouchin TV Mod" StrCmp $0 "0" suite MessageBox MB_ICONSTOP "Je ne peux continuer la désinstallation tant que $\"${PRODUCT_NAME}$\" ne sera pas arrêté." Abort ${EndIf} suite: ; Menu Démarrer !insertmacro MUI_STARTMENU_GETFOLDER Application $STARTMENU_FOLDER ; TODO : Problème à corriger : ça supprime les raccourcis ajoutés ou renommés RMDir /r "$SMPROGRAMS\$STARTMENU_FOLDER" ; Pour une raison inconnue, ceci ne marche pas sous Windows (XP ou Vista) 64 bits : DeleteRegKey ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_UNINST_KEY}" RMDir /r "$INSTDIR" ; Raccourci sur le bureau Delete "$DESKTOP\${PRODUCT_NAME}" MessageBox MB_YESNO|MB_DEFBUTTON2 "Dois-je supprimer aussi les paramètres de ${PRODUCT_BASE_NAME} ?$\n$\rVous pourriez en avoir besoin si vous le réinstallez ultérieurement." /SD IDNO IDNO quitte ; "Application Data" de l'utilisateur courant SetShellVarContext current RMDir /r "$APPDATA\${PRODUCT_BASE_NAME}" quitte: SectionEnd