1
0
mirror of https://github.com/qTox/qTox.git synced 2024-03-22 14:00:36 +08:00

refactor(Windows): unify whitespaces in NSIS scripts

While two files differ only by 3 lines, there were many unnecessary
whitespace differences between them.
This commit is contained in:
Maxim Biro 2020-10-06 19:20:56 -04:00
parent 827b2c2210
commit 169009f550
No known key found for this signature in database
GPG Key ID: AB3AD9896472BFA4
2 changed files with 143 additions and 145 deletions

View File

@ -36,72 +36,71 @@ VIAddVersionKey "FileVersion" "${VERSION}"
!macro AddItem Path
FileWrite $UninstLog "${Path}$\r$\n"
!macroend
;File macro
!macro File FileName
IfFileExists "$OUTDIR\${FileName}" +2
FileWrite $UninstLog "$OUTDIR\${FileName}$\r$\n"
File "${FileName}"
!macroend
;CreateShortcut macro
!macro CreateShortcut FilePath FilePointer Pamameters Icon IconIndex
FileWrite $UninstLog "${FilePath}$\r$\n"
CreateShortcut "${FilePath}" "${FilePointer}" "${Pamameters}" "${Icon}" "${IconIndex}"
!macroend
;Copy files macro
!macro CopyFiles SourcePath DestPath
IfFileExists "${DestPath}" +2
FileWrite $UninstLog "${DestPath}$\r$\n"
CopyFiles "${SourcePath}" "${DestPath}"
!macroend
;Rename macro
!macro Rename SourcePath DestPath
IfFileExists "${DestPath}" +2
FileWrite $UninstLog "${DestPath}$\r$\n"
Rename "${SourcePath}" "${DestPath}"
!macroend
;CreateDirectory macro
!macro CreateDirectory Path
CreateDirectory "${Path}"
FileWrite $UninstLog "${Path}$\r$\n"
!macroend
;SetOutPath macro
!macro SetOutPath Path
SetOutPath "${Path}"
FileWrite $UninstLog "${Path}$\r$\n"
!macroend
;WriteUninstaller macro
!macro WriteUninstaller Path
WriteUninstaller "${Path}"
FileWrite $UninstLog "${Path}$\r$\n"
!macroend
;WriteIniStr macro
!macro WriteIniStr IniFile SectionName EntryName NewValue
IfFileExists "${IniFile}" +2
FileWrite $UninstLog "${IniFile}$\r$\n"
WriteIniStr "${IniFile}" "${SectionName}" "${EntryName}" "${NewValue}"
!macroend
;WriteRegStr macro
!macro WriteRegStr RegRoot UnInstallPath Key Value
FileWrite $UninstLog "${RegRoot} ${UnInstallPath}$\r$\n"
WriteRegStr "${RegRoot}" "${UnInstallPath}" "${Key}" "${Value}"
!macroend
;WriteRegDWORD macro
!macro WriteRegDWORD RegRoot UnInstallPath Key Value
FileWrite $UninstLog "${RegRoot} ${UnInstallPath}$\r$\n"
WriteRegDWORD "${RegRoot}" "${UnInstallPath}" "${Key}" "${Value}"
!macroend
;BackupFile macro
!macro BackupFile FILE_DIR FILE BACKUP_TO
IfFileExists "${BACKUP_TO}\*.*" +2
@ -109,13 +108,13 @@ VIAddVersionKey "FileVersion" "${VERSION}"
IfFileExists "${FILE_DIR}\${FILE}" 0 +2
Rename "${FILE_DIR}\${FILE}" "${BACKUP_TO}\${FILE}"
!macroend
;RestoreFile macro
!macro RestoreFile BUP_DIR FILE RESTORE_TO
IfFileExists "${BUP_DIR}\${FILE}" 0 +2
Rename "${BUP_DIR}\${FILE}" "${RESTORE_TO}\${FILE}"
!macroend
;BackupFiles macro
!macro BackupFiles FILE_DIR FILE BACKUP_TO
IfFileExists "${BACKUP_TO}\*.*" +2
@ -128,7 +127,7 @@ VIAddVersionKey "FileVersion" "${VERSION}"
SetOutPath "${FILE_DIR}"
File "${FILE}" #After the Original file is backed up write the new file.
!macroend
;RestoreFiles macro
!macro RestoreFiles BUP_FILE RESTORE_FILE
IfFileExists "${BUP_FILE}" 0 +2
@ -141,52 +140,52 @@ VIAddVersionKey "FileVersion" "${VERSION}"
;Set the name of the uninstall log
!define UninstLog "uninstall.log"
Var UninstLog
;Uninstall log file missing.
LangString UninstLogMissing ${LANG_ENGLISH} "${UninstLog} not found!$\r$\nUninstallation cannot proceed!"
;AddItem macro
!define AddItem "!insertmacro AddItem"
;BackupFile macro
!define BackupFile "!insertmacro BackupFile"
!define BackupFile "!insertmacro BackupFile"
;BackupFiles macro
!define BackupFiles "!insertmacro BackupFiles"
!define BackupFiles "!insertmacro BackupFiles"
;Copy files macro
!define CopyFiles "!insertmacro CopyFiles"
;CreateDirectory macro
!define CreateDirectory "!insertmacro CreateDirectory"
;CreateShortcut macro
!define CreateShortcut "!insertmacro CreateShortcut"
;File macro
!define File "!insertmacro File"
;Rename macro
!define Rename "!insertmacro Rename"
;RestoreFile macro
!define RestoreFile "!insertmacro RestoreFile"
!define RestoreFile "!insertmacro RestoreFile"
;RestoreFiles macro
!define RestoreFiles "!insertmacro RestoreFiles"
;SetOutPath macro
!define SetOutPath "!insertmacro SetOutPath"
;WriteRegDWORD macro
!define WriteRegDWORD "!insertmacro WriteRegDWORD"
!define WriteRegDWORD "!insertmacro WriteRegDWORD"
;WriteRegStr macro
!define WriteRegStr "!insertmacro WriteRegStr"
;WriteUninstaller macro
!define WriteUninstaller "!insertmacro WriteUninstaller"
Section -openlogfile
CreateDirectory "$INSTDIR"
IfFileExists "$INSTDIR\${UninstLog}" +3
@ -207,12 +206,12 @@ VIAddVersionKey "FileVersion" "${VERSION}"
!insertmacro MUI_PAGE_WELCOME
!insertmacro MUI_PAGE_DIRECTORY
!ifdef REG_START_MENU
!define MUI_STARTMENUPAGE_NODISABLE
!define MUI_STARTMENUPAGE_DEFAULTFOLDER "qTox"
!define MUI_STARTMENUPAGE_REGISTRY_ROOT "${REG_ROOT}"
!define MUI_STARTMENUPAGE_REGISTRY_KEY "${UNINSTALL_PATH}"
!define MUI_STARTMENUPAGE_REGISTRY_VALUENAME "${REG_START_MENU}"
!insertmacro MUI_PAGE_STARTMENU Application $SM_Folder
!define MUI_STARTMENUPAGE_NODISABLE
!define MUI_STARTMENUPAGE_DEFAULTFOLDER "qTox"
!define MUI_STARTMENUPAGE_REGISTRY_ROOT "${REG_ROOT}"
!define MUI_STARTMENUPAGE_REGISTRY_KEY "${UNINSTALL_PATH}"
!define MUI_STARTMENUPAGE_REGISTRY_VALUENAME "${REG_START_MENU}"
!insertmacro MUI_PAGE_STARTMENU Application $SM_Folder
!endif
!insertmacro MUI_PAGE_INSTFILES
@ -243,60 +242,60 @@ FunctionEnd
!insertmacro MUI_UNPAGE_FINISH
!insertmacro MUI_LANGUAGE "English"
#################
#INSTALL
#################
Section "Install"
SetShellVarContext all
# Install files
${SetOutPath} "$INSTDIR"
${WriteUninstaller} "uninstall.exe"
${CreateDirectory} "$INSTDIR\bin"
${SetOutPath} "$INSTDIR\bin"
${File} "qtox\*.*"
${CreateDirectory} "$INSTDIR\bin\imageformats"
${SetOutPath} "$INSTDIR\bin\imageformats"
File /nonfatal "qtox\imageformats\*.*"
${SetOutPath} "$INSTDIR\bin"
${CreateDirectory} "$INSTDIR\bin\platforms"
${SetOutPath} "$INSTDIR\bin\platforms"
File /nonfatal "qtox\platforms\*.*"
${SetOutPath} "$INSTDIR\bin"
${CreateDirectory} "$INSTDIR\bin\libsnore-qt5"
${SetOutPath} "$INSTDIR\bin\libsnore-qt5"
File /nonfatal "qtox\libsnore-qt5\*.*"
${SetOutPath} "$INSTDIR\bin"
SetShellVarContext all
# Install files
${SetOutPath} "$INSTDIR"
${WriteUninstaller} "uninstall.exe"
# Create shortcuts
${CreateDirectory} "$SMPROGRAMS\qTox"
${CreateShortCut} "$SMPROGRAMS\qTox\qTox.lnk" "$INSTDIR\${MAIN_APP_EXE}" "" "" ""
${CreateShortCut} "$SMPROGRAMS\qTox\Uninstall qTox.lnk" "$INSTDIR\uninstall.exe" "" "" ""
${CreateDirectory} "$INSTDIR\bin"
${SetOutPath} "$INSTDIR\bin"
${File} "qtox\*.*"
# Write setup/app info into the registry
${WriteRegStr} "${REG_ROOT}" "${REG_APP_PATH}" "" "$INSTDIR\${MAIN_APP_EXE}"
${WriteRegStr} "${REG_ROOT}" "${REG_APP_PATH}" "Path" "$INSTDIR\bin\"
${WriteRegStr} ${REG_ROOT} "${UNINSTALL_PATH}" "DisplayName" "qTox"
${WriteRegStr} ${REG_ROOT} "${UNINSTALL_PATH}" "DisplayVersion" "1.17.2"
${WriteRegStr} ${REG_ROOT} "${UNINSTALL_PATH}" "Publisher" "The qTox Project"
${WriteRegStr} ${REG_ROOT} "${UNINSTALL_PATH}" "UninstallString" "$INSTDIR\uninstall.exe"
${WriteRegStr} ${REG_ROOT} "${UNINSTALL_PATH}" "URLInfoAbout" "https://qtox.github.io"
${CreateDirectory} "$INSTDIR\bin\imageformats"
${SetOutPath} "$INSTDIR\bin\imageformats"
File /nonfatal "qtox\imageformats\*.*"
${SetOutPath} "$INSTDIR\bin"
# Register the tox: protocol
${WriteRegStr} HKCR "tox" "" "URL:tox Protocol"
${WriteRegStr} HKCR "tox" "URL Protocol" ""
${WriteRegStr} HKCR "tox\shell\open\command" "" "$INSTDIR\${MAIN_APP_EXE} %1"
${CreateDirectory} "$INSTDIR\bin\platforms"
${SetOutPath} "$INSTDIR\bin\platforms"
File /nonfatal "qtox\platforms\*.*"
${SetOutPath} "$INSTDIR\bin"
# Register the .tox file associations
${WriteRegStr} "HKCR" "Applications\qtox.exe\SupportedTypes" ".tox" ""
${WriteRegStr} HKCR ".tox" "" "toxsave"
${WriteRegStr} HKCR "toxsave" "" "Tox save file"
${WriteRegStr} HKCR "toxsave\DefaultIcon" "" "$INSTDIR\${MAIN_APP_EXE}"
${WriteRegStr} HKCR "toxsave\shell\open\command" "" "$INSTDIR\${MAIN_APP_EXE} %1"
${CreateDirectory} "$INSTDIR\bin\libsnore-qt5"
${SetOutPath} "$INSTDIR\bin\libsnore-qt5"
File /nonfatal "qtox\libsnore-qt5\*.*"
${SetOutPath} "$INSTDIR\bin"
# Create shortcuts
${CreateDirectory} "$SMPROGRAMS\qTox"
${CreateShortCut} "$SMPROGRAMS\qTox\qTox.lnk" "$INSTDIR\${MAIN_APP_EXE}" "" "" ""
${CreateShortCut} "$SMPROGRAMS\qTox\Uninstall qTox.lnk" "$INSTDIR\uninstall.exe" "" "" ""
# Write setup/app info into the registry
${WriteRegStr} "${REG_ROOT}" "${REG_APP_PATH}" "" "$INSTDIR\${MAIN_APP_EXE}"
${WriteRegStr} "${REG_ROOT}" "${REG_APP_PATH}" "Path" "$INSTDIR\bin\"
${WriteRegStr} ${REG_ROOT} "${UNINSTALL_PATH}" "DisplayName" "qTox"
${WriteRegStr} ${REG_ROOT} "${UNINSTALL_PATH}" "DisplayVersion" "1.17.2"
${WriteRegStr} ${REG_ROOT} "${UNINSTALL_PATH}" "Publisher" "The qTox Project"
${WriteRegStr} ${REG_ROOT} "${UNINSTALL_PATH}" "UninstallString" "$INSTDIR\uninstall.exe"
${WriteRegStr} ${REG_ROOT} "${UNINSTALL_PATH}" "URLInfoAbout" "https://qtox.github.io"
# Register the tox: protocol
${WriteRegStr} HKCR "tox" "" "URL:tox Protocol"
${WriteRegStr} HKCR "tox" "URL Protocol" ""
${WriteRegStr} HKCR "tox\shell\open\command" "" "$INSTDIR\${MAIN_APP_EXE} %1"
# Register the .tox file associations
${WriteRegStr} "HKCR" "Applications\qtox.exe\SupportedTypes" ".tox" ""
${WriteRegStr} HKCR ".tox" "" "toxsave"
${WriteRegStr} HKCR "toxsave" "" "Tox save file"
${WriteRegStr} HKCR "toxsave\DefaultIcon" "" "$INSTDIR\${MAIN_APP_EXE}"
${WriteRegStr} HKCR "toxsave\shell\open\command" "" "$INSTDIR\${MAIN_APP_EXE} %1"
SectionEnd
@ -308,28 +307,28 @@ Section Uninstall
;If there's no uninstall log, we'll try anyway to clean what we can
IfFileExists "$INSTDIR\${UninstLog}" +3
Goto noLog
Push $R0
Push $R1
Push $R2
SetFileAttributes "$INSTDIR\${UninstLog}" NORMAL
FileOpen $UninstLog "$INSTDIR\${UninstLog}" r
StrCpy $R1 -1
GetLineCount:
ClearErrors
FileRead $UninstLog $R0
IntOp $R1 $R1 + 1
StrCpy $R0 $R0 -2
Push $R0
Push $R0
IfErrors 0 GetLineCount
Pop $R0
LoopRead:
StrCmp $R1 0 LoopDone
Pop $R0
IfFileExists "$R0\*.*" 0 +3
RMDir $R0 #is dir
Goto +9
@ -341,7 +340,7 @@ Section Uninstall
Goto +3
StrCmp $R0 "${REG_ROOT} ${UNINSTALL_PATH}" 0 +2
DeleteRegKey ${REG_ROOT} "${UNINSTALL_PATH}" #is Reg Element
IntOp $R1 $R1 - 1
Goto LoopRead
LoopDone:
@ -354,10 +353,10 @@ Section Uninstall
Pop $R2
Pop $R1
Pop $R0
;Remove start menu entries
RMDir /r /REBOOTOK "$SMPROGRAMS\qTox"
;Remove registry keys
DeleteRegKey ${REG_ROOT} "${REG_APP_PATH}"
DeleteRegKey ${REG_ROOT} "${UNINSTALL_PATH}"

View File

@ -95,7 +95,6 @@ VIAddVersionKey "FileVersion" "${VERSION}"
WriteRegStr "${RegRoot}" "${UnInstallPath}" "${Key}" "${Value}"
!macroend
;WriteRegDWORD macro
!macro WriteRegDWORD RegRoot UnInstallPath Key Value
FileWrite $UninstLog "${RegRoot} ${UnInstallPath}$\r$\n"
@ -207,12 +206,12 @@ VIAddVersionKey "FileVersion" "${VERSION}"
!insertmacro MUI_PAGE_WELCOME
!insertmacro MUI_PAGE_DIRECTORY
!ifdef REG_START_MENU
!define MUI_STARTMENUPAGE_NODISABLE
!define MUI_STARTMENUPAGE_DEFAULTFOLDER "qTox"
!define MUI_STARTMENUPAGE_REGISTRY_ROOT "${REG_ROOT}"
!define MUI_STARTMENUPAGE_REGISTRY_KEY "${UNINSTALL_PATH}"
!define MUI_STARTMENUPAGE_REGISTRY_VALUENAME "${REG_START_MENU}"
!insertmacro MUI_PAGE_STARTMENU Application $SM_Folder
!define MUI_STARTMENUPAGE_NODISABLE
!define MUI_STARTMENUPAGE_DEFAULTFOLDER "qTox"
!define MUI_STARTMENUPAGE_REGISTRY_ROOT "${REG_ROOT}"
!define MUI_STARTMENUPAGE_REGISTRY_KEY "${UNINSTALL_PATH}"
!define MUI_STARTMENUPAGE_REGISTRY_VALUENAME "${REG_START_MENU}"
!insertmacro MUI_PAGE_STARTMENU Application $SM_Folder
!endif
!insertmacro MUI_PAGE_INSTFILES
@ -248,56 +247,56 @@ FunctionEnd
#INSTALL
#################
Section "Install"
SetShellVarContext all
# Install files
${SetOutPath} "$INSTDIR"
${WriteUninstaller} "uninstall.exe"
SetShellVarContext all
# Install files
${SetOutPath} "$INSTDIR"
${WriteUninstaller} "uninstall.exe"
${CreateDirectory} "$INSTDIR\bin"
${SetOutPath} "$INSTDIR\bin"
${File} "qtox\*.*"
${CreateDirectory} "$INSTDIR\bin"
${SetOutPath} "$INSTDIR\bin"
${File} "qtox\*.*"
${CreateDirectory} "$INSTDIR\bin\imageformats"
${SetOutPath} "$INSTDIR\bin\imageformats"
File /nonfatal "qtox\imageformats\*.*"
${SetOutPath} "$INSTDIR\bin"
${CreateDirectory} "$INSTDIR\bin\imageformats"
${SetOutPath} "$INSTDIR\bin\imageformats"
File /nonfatal "qtox\imageformats\*.*"
${SetOutPath} "$INSTDIR\bin"
${CreateDirectory} "$INSTDIR\bin\platforms"
${SetOutPath} "$INSTDIR\bin\platforms"
File /nonfatal "qtox\platforms\*.*"
${SetOutPath} "$INSTDIR\bin"
${CreateDirectory} "$INSTDIR\bin\platforms"
${SetOutPath} "$INSTDIR\bin\platforms"
File /nonfatal "qtox\platforms\*.*"
${SetOutPath} "$INSTDIR\bin"
${CreateDirectory} "$INSTDIR\bin\libsnore-qt5"
${SetOutPath} "$INSTDIR\bin\libsnore-qt5"
File /nonfatal "qtox\libsnore-qt5\*.*"
${SetOutPath} "$INSTDIR\bin"
${CreateDirectory} "$INSTDIR\bin\libsnore-qt5"
${SetOutPath} "$INSTDIR\bin\libsnore-qt5"
File /nonfatal "qtox\libsnore-qt5\*.*"
${SetOutPath} "$INSTDIR\bin"
# Create shortcuts
${CreateDirectory} "$SMPROGRAMS\qTox"
${CreateShortCut} "$SMPROGRAMS\qTox\qTox.lnk" "$INSTDIR\${MAIN_APP_EXE}" "" "" ""
${CreateShortCut} "$SMPROGRAMS\qTox\Uninstall qTox.lnk" "$INSTDIR\uninstall.exe" "" "" ""
# Create shortcuts
${CreateDirectory} "$SMPROGRAMS\qTox"
${CreateShortCut} "$SMPROGRAMS\qTox\qTox.lnk" "$INSTDIR\${MAIN_APP_EXE}" "" "" ""
${CreateShortCut} "$SMPROGRAMS\qTox\Uninstall qTox.lnk" "$INSTDIR\uninstall.exe" "" "" ""
# Write setup/app info into the registry
SetRegView 64
${WriteRegStr} "${REG_ROOT}" "${REG_APP_PATH}" "" "$INSTDIR\${MAIN_APP_EXE}"
${WriteRegStr} "${REG_ROOT}" "${REG_APP_PATH}" "Path" "$INSTDIR\bin\"
${WriteRegStr} ${REG_ROOT} "${UNINSTALL_PATH}" "DisplayName" "qTox"
${WriteRegStr} ${REG_ROOT} "${UNINSTALL_PATH}" "DisplayVersion" "1.17.2"
${WriteRegStr} ${REG_ROOT} "${UNINSTALL_PATH}" "Publisher" "The qTox Project"
${WriteRegStr} ${REG_ROOT} "${UNINSTALL_PATH}" "UninstallString" "$INSTDIR\uninstall.exe"
${WriteRegStr} ${REG_ROOT} "${UNINSTALL_PATH}" "URLInfoAbout" "https://qtox.github.io"
# Write setup/app info into the registry
SetRegView 64
${WriteRegStr} "${REG_ROOT}" "${REG_APP_PATH}" "" "$INSTDIR\${MAIN_APP_EXE}"
${WriteRegStr} "${REG_ROOT}" "${REG_APP_PATH}" "Path" "$INSTDIR\bin\"
${WriteRegStr} ${REG_ROOT} "${UNINSTALL_PATH}" "DisplayName" "qTox"
${WriteRegStr} ${REG_ROOT} "${UNINSTALL_PATH}" "DisplayVersion" "1.17.2"
${WriteRegStr} ${REG_ROOT} "${UNINSTALL_PATH}" "Publisher" "The qTox Project"
${WriteRegStr} ${REG_ROOT} "${UNINSTALL_PATH}" "UninstallString" "$INSTDIR\uninstall.exe"
${WriteRegStr} ${REG_ROOT} "${UNINSTALL_PATH}" "URLInfoAbout" "https://qtox.github.io"
# Register the tox: protocol
${WriteRegStr} HKCR "tox" "" "URL:tox Protocol"
${WriteRegStr} HKCR "tox" "URL Protocol" ""
${WriteRegStr} HKCR "tox\shell\open\command" "" "$INSTDIR\${MAIN_APP_EXE} %1"
# Register the tox: protocol
${WriteRegStr} HKCR "tox" "" "URL:tox Protocol"
${WriteRegStr} HKCR "tox" "URL Protocol" ""
${WriteRegStr} HKCR "tox\shell\open\command" "" "$INSTDIR\${MAIN_APP_EXE} %1"
# Register the .tox file associations
${WriteRegStr} "HKCR" "Applications\qtox.exe\SupportedTypes" ".tox" ""
${WriteRegStr} HKCR ".tox" "" "toxsave"
${WriteRegStr} HKCR "toxsave" "" "Tox save file"
${WriteRegStr} HKCR "toxsave\DefaultIcon" "" "$INSTDIR\${MAIN_APP_EXE}"
${WriteRegStr} HKCR "toxsave\shell\open\command" "" "$INSTDIR\${MAIN_APP_EXE} %1"
# Register the .tox file associations
${WriteRegStr} "HKCR" "Applications\qtox.exe\SupportedTypes" ".tox" ""
${WriteRegStr} HKCR ".tox" "" "toxsave"
${WriteRegStr} HKCR "toxsave" "" "Tox save file"
${WriteRegStr} HKCR "toxsave\DefaultIcon" "" "$INSTDIR\${MAIN_APP_EXE}"
${WriteRegStr} HKCR "toxsave\shell\open\command" "" "$INSTDIR\${MAIN_APP_EXE} %1"
SectionEnd