1
mirror of https://invent.kde.org/network/falkon.git synced 2024-12-19 18:26:34 +01:00

Windows: Update installer to support install in standard or portable mode

This commit is contained in:
Razi Alavizadeh 2018-03-26 12:05:34 +04:30
parent c704c5351c
commit 9227a25bbd
4 changed files with 117 additions and 20 deletions

View File

@ -32,11 +32,8 @@
!include /NONFATAL WinVer.nsh !include /NONFATAL WinVer.nsh
!include x64.nsh !include x64.nsh
!ifndef PORTABLE Var installAsPortable
RequestExecutionLevel admin RequestExecutionLevel admin
!else
RequestExecutionLevel user
!endif
!addplugindir "wininstall\" !addplugindir "wininstall\"
@ -61,8 +58,15 @@ SetCompressor /SOLID /FINAL lzma
!insertmacro MUI_PAGE_WELCOME !insertmacro MUI_PAGE_WELCOME
!insertmacro MUI_PAGE_LICENSE ${FALKON_BIN_DIR}\COPYRIGHT.txt !insertmacro MUI_PAGE_LICENSE ${FALKON_BIN_DIR}\COPYRIGHT.txt
;;;
Page custom InstallationModePage InstallationModeLeave
;;;
!define MUI_PAGE_CUSTOMFUNCTION_PRE "SkipComponentsIfPortableInstalltion"
!insertmacro MUI_PAGE_COMPONENTS !insertmacro MUI_PAGE_COMPONENTS
!insertmacro MUI_PAGE_DIRECTORY !insertmacro MUI_PAGE_DIRECTORY
;;;
Page custom installationInfoPage installationInfoLeave
;;;
!insertmacro MUI_PAGE_INSTFILES !insertmacro MUI_PAGE_INSTFILES
!define MUI_FINISHPAGE_RUN !define MUI_FINISHPAGE_RUN
@ -198,9 +202,21 @@ notRunning:
; in some packages *.bdic files use dash '-' instead of underline '_' followed by a version number. e.g. en-US-3-0.bdic ; in some packages *.bdic files use dash '-' instead of underline '_' followed by a version number. e.g. en-US-3-0.bdic
File "${QTWEBENGINE_DICTIONARIES_DIR}\en*US*.bdic" File "${QTWEBENGINE_DICTIONARIES_DIR}\en*US*.bdic"
!ifndef PORTABLE call RegisterCapabilities
call RegisterCapabilities
!endif StrCmp $installAsPortable "YES" 0 skipPortableMode
FileOpen $0 $INSTDIR\falkon.conf w
FileWrite $0 "[Config]$\r$\n"
FileWrite $0 "Portable=true$\r$\n"
StrCmp $0 "" 0 closeHandle
MessageBox MB_OK|MB_ICONEXCLAMATION $(MSG_PortableWriteError)
goto skipPortableMode
closeHandle:
FileClose $0
skipPortableMode:
SectionEnd SectionEnd
SectionGroup $(TITLE_SecThemes) SecThemes SectionGroup $(TITLE_SecThemes) SecThemes
@ -247,51 +263,55 @@ SectionEnd
!insertmacro MUI_DESCRIPTION_TEXT ${SecMain} $(DESC_SecMain) !insertmacro MUI_DESCRIPTION_TEXT ${SecMain} $(DESC_SecMain)
!insertmacro MUI_DESCRIPTION_TEXT ${SecTranslations} $(DESC_SecTranslations) !insertmacro MUI_DESCRIPTION_TEXT ${SecTranslations} $(DESC_SecTranslations)
!insertmacro MUI_DESCRIPTION_TEXT ${SecPlugins} $(DESC_SecPlugins) !insertmacro MUI_DESCRIPTION_TEXT ${SecPlugins} $(DESC_SecPlugins)
!ifndef PORTABLE
!insertmacro MUI_DESCRIPTION_TEXT ${SecDesktop} $(DESC_SecDesktop) !insertmacro MUI_DESCRIPTION_TEXT ${SecDesktop} $(DESC_SecDesktop)
!insertmacro MUI_DESCRIPTION_TEXT ${SecExtensions} $(DESC_SecExtensions) !insertmacro MUI_DESCRIPTION_TEXT ${SecExtensions} $(DESC_SecExtensions)
!endif
!insertmacro MUI_DESCRIPTION_TEXT ${SecThemes} $(DESC_SecThemes)
!ifndef PORTABLE !insertmacro MUI_DESCRIPTION_TEXT ${SecThemes} $(DESC_SecThemes)
!insertmacro MUI_DESCRIPTION_TEXT ${SecSetASDefault} $(DESC_SecSetASDefault) !insertmacro MUI_DESCRIPTION_TEXT ${SecSetASDefault} $(DESC_SecSetASDefault)
!insertmacro MUI_DESCRIPTION_TEXT ${SecProtocols} $(DESC_SecProtocols) !insertmacro MUI_DESCRIPTION_TEXT ${SecProtocols} $(DESC_SecProtocols)
!endif
!insertmacro MUI_FUNCTION_DESCRIPTION_END !insertmacro MUI_FUNCTION_DESCRIPTION_END
!ifndef PORTABLE
SectionGroup $(TITLE_SecSetASDefault) SecSetASDefault SectionGroup $(TITLE_SecSetASDefault) SecSetASDefault
Section $(TITLE_SecExtensions) SecExtensions Section $(TITLE_SecExtensions) SecExtensions
StrCmp $installAsPortable "NO" 0 skipSetExtentions
SetOutPath "$INSTDIR" SetOutPath "$INSTDIR"
${RegisterAssociation} ".htm" "$INSTDIR\falkon.exe" "FalkonHTML" "Falkon HTML Document" "$INSTDIR\falkon.exe,1" "file" ${RegisterAssociation} ".htm" "$INSTDIR\falkon.exe" "FalkonHTML" "Falkon HTML Document" "$INSTDIR\falkon.exe,1" "file"
${RegisterAssociation} ".html" "$INSTDIR\falkon.exe" "FalkonHTML" "Falkon HTML Document" "$INSTDIR\falkon.exe,1" "file" ${RegisterAssociation} ".html" "$INSTDIR\falkon.exe" "FalkonHTML" "Falkon HTML Document" "$INSTDIR\falkon.exe,1" "file"
${UpdateSystemIcons} ${UpdateSystemIcons}
skipSetExtentions:
SectionEnd SectionEnd
Section $(TITLE_SecProtocols) SecProtocols Section $(TITLE_SecProtocols) SecProtocols
StrCmp $installAsPortable "NO" 0 skipSecProtocols
${RegisterAssociation} "http" "$INSTDIR\falkon.exe" "FalkonURL" "Falkon URL" "$INSTDIR\falkon.exe,0" "protocol" ${RegisterAssociation} "http" "$INSTDIR\falkon.exe" "FalkonURL" "Falkon URL" "$INSTDIR\falkon.exe,0" "protocol"
${RegisterAssociation} "https" "$INSTDIR\falkon.exe" "FalkonURL" "Falkon URL" "$INSTDIR\falkon.exe,0" "protocol" ${RegisterAssociation} "https" "$INSTDIR\falkon.exe" "FalkonURL" "Falkon URL" "$INSTDIR\falkon.exe,0" "protocol"
${RegisterAssociation} "ftp" "$INSTDIR\falkon.exe" "FalkonURL" "Falkon URL" "$INSTDIR\falkon.exe,0" "protocol" ${RegisterAssociation} "ftp" "$INSTDIR\falkon.exe" "FalkonURL" "Falkon URL" "$INSTDIR\falkon.exe,0" "protocol"
${UpdateSystemIcons} ${UpdateSystemIcons}
skipSecProtocols:
SectionEnd SectionEnd
SectionGroupEnd SectionGroupEnd
Section -StartMenu Section -StartMenu
StrCmp $installAsPortable "NO" 0 skipStartMenu
SetOutPath "$INSTDIR" SetOutPath "$INSTDIR"
SetShellVarContext all SetShellVarContext all
CreateDirectory "$SMPROGRAMS\Falkon" CreateDirectory "$SMPROGRAMS\Falkon"
CreateShortCut "$SMPROGRAMS\Falkon\Uninstall.lnk" "$INSTDIR\Uninstall.exe" CreateShortCut "$SMPROGRAMS\Falkon\Uninstall.lnk" "$INSTDIR\Uninstall.exe"
CreateShortCut "$SMPROGRAMS\Falkon\Falkon.lnk" "$INSTDIR\falkon.exe" CreateShortCut "$SMPROGRAMS\Falkon\Falkon.lnk" "$INSTDIR\falkon.exe"
CreateShortCut "$SMPROGRAMS\Falkon\License.lnk" "$INSTDIR\COPYRIGHT.txt" CreateShortCut "$SMPROGRAMS\Falkon\License.lnk" "$INSTDIR\COPYRIGHT.txt"
skipStartMenu:
SectionEnd SectionEnd
Section $(TITLE_SecDesktop) SecDesktop Section $(TITLE_SecDesktop) SecDesktop
StrCmp $installAsPortable "NO" 0 skipDesktopIcon
SetOutPath "$INSTDIR" SetOutPath "$INSTDIR"
CreateShortCut "$DESKTOP\Falkon.lnk" "$INSTDIR\falkon.exe" "" CreateShortCut "$DESKTOP\Falkon.lnk" "$INSTDIR\falkon.exe" ""
skipDesktopIcon:
SectionEnd SectionEnd
Section -Uninstaller Section -Uninstaller
StrCmp $installAsPortable "NO" 0 skipUninstaller
WriteUninstaller "$INSTDIR\uninstall.exe" WriteUninstaller "$INSTDIR\uninstall.exe"
WriteRegStr HKLM "${PRODUCT_DIR_REGKEY}" "" "$INSTDIR\falkon.exe" WriteRegStr HKLM "${PRODUCT_DIR_REGKEY}" "" "$INSTDIR\falkon.exe"
WriteRegStr ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_UNINST_KEY}" "DisplayName" "$(^Name)" WriteRegStr ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_UNINST_KEY}" "DisplayName" "$(^Name)"
@ -305,6 +325,7 @@ SectionEnd
WriteRegStr ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_UNINST_KEY}" "URLInfoAbout" "https://kde.org" WriteRegStr ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_UNINST_KEY}" "URLInfoAbout" "https://kde.org"
${GetSize} "$INSTDIR" "/S=0K" $0 $1 $2 ${GetSize} "$INSTDIR" "/S=0K" $0 $1 $2
WriteRegDWORD ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_UNINST_KEY}" "EstimatedSize" "$0" WriteRegDWORD ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_UNINST_KEY}" "EstimatedSize" "$0"
skipUninstaller:
SectionEnd SectionEnd
Section Uninstall Section Uninstall
@ -375,7 +396,6 @@ SectionEnd
${UnRegisterAssociation} "ftp" "FalkonURL" "$INSTDIR\falkon.exe" "protocol" ${UnRegisterAssociation} "ftp" "FalkonURL" "$INSTDIR\falkon.exe" "protocol"
${UpdateSystemIcons} ${UpdateSystemIcons}
SectionEnd SectionEnd
!endif
BrandingText "${PRODUCT_NAME} ${PRODUCT_VERSION} Installer" BrandingText "${PRODUCT_NAME} ${PRODUCT_VERSION} Installer"
@ -396,10 +416,6 @@ Function .onInit
${Endif} ${Endif}
${EndIf} ${EndIf}
!ifdef PORTABLE
StrCpy $InstDir "$DESKTOP\${PRODUCT_NAME} Portable\"
!endif
;Prevent Multiple Instances ;Prevent Multiple Instances
System::Call 'kernel32::CreateMutexA(i 0, i 0, t "FalkonInstaller-4ECB4694-2C39-4f93-9122-A986344C4E7B") i .r1 ?e' System::Call 'kernel32::CreateMutexA(i 0, i 0, t "FalkonInstaller-4ECB4694-2C39-4f93-9122-A986344C4E7B") i .r1 ?e'
Pop $R0 Pop $R0
@ -471,9 +487,16 @@ Function .onInit
Pop $LANGUAGE Pop $LANGUAGE
StrCmp $LANGUAGE "cancel" 0 +2 StrCmp $LANGUAGE "cancel" 0 +2
Abort Abort
;Extract InstallOptions files
;$PLUGINSDIR will automatically be removed when the installer closes
InitPluginsDir
File /oname=$PLUGINSDIR\portable-mode.ini "portable-mode.ini"
File /oname=$PLUGINSDIR\portable-info.ini "portable-info.ini"
FunctionEnd FunctionEnd
Function RegisterCapabilities Function RegisterCapabilities
StrCmp $installAsPortable "NO" 0 skipRegisterCapabilities
!ifdef ___WINVER__NSH___ !ifdef ___WINVER__NSH___
${If} ${AtLeastWinVista} ${If} ${AtLeastWinVista}
; even if we don't associate Falkon as default for ".htm" and ".html" ; even if we don't associate Falkon as default for ".htm" and ".html"
@ -495,6 +518,7 @@ Function RegisterCapabilities
WriteRegStr HKLM "SOFTWARE\RegisteredApplications" "${PRODUCT_NAME}" "${PRODUCT_CAPABILITIES_KEY}" WriteRegStr HKLM "SOFTWARE\RegisteredApplications" "${PRODUCT_NAME}" "${PRODUCT_CAPABILITIES_KEY}"
${EndIf} ${EndIf}
!endif !endif
skipRegisterCapabilities:
FunctionEnd FunctionEnd
Function RunFalkonAsUser Function RunFalkonAsUser
@ -511,3 +535,56 @@ Function un.onInit
Abort Abort
found: found:
FunctionEnd FunctionEnd
Function InstallationModePage
!insertmacro MUI_HEADER_TEXT "$(TITLE_InstallationMode)" "$(DESC_InstallationMode)"
WriteINIStr "$PLUGINSDIR\portable-mode.ini" "Field 1" "Text" "$(TITLE_StandardInstallation)"
WriteINIStr "$PLUGINSDIR\portable-mode.ini" "Field 2" "Text" "$(TITLE_PortableInstallation)"
; set layout direction
IntCmp $(^RTL) 1 0 +2
WriteINIStr "$PLUGINSDIR\portable-mode.ini" "Settings" "RTL" 1
InstallOptions::dialog $PLUGINSDIR\portable-mode.ini
FunctionEnd
Function InstallationModeLeave
ReadINIStr $0 "$PLUGINSDIR\portable-mode.ini" "Field 2" "State"
StrCmp $0 1 0 notchecked
StrCpy $installAsPortable "YES"
StrCpy $InstDir "$DESKTOP\${PRODUCT_NAME} Portable\"
goto skip
notchecked:
StrCpy $installAsPortable "NO"
skip:
FunctionEnd
Function installationInfoPage
!insertmacro MUI_HEADER_TEXT "$(TITLE_InstallInfo)" "$(DESC_InstallInfo)"
; set layout direction
IntCmp $(^RTL) 1 0 +2
WriteINIStr "$PLUGINSDIR\portable-info.ini" "Settings" "RTL" 1
StrCmp $installAsPortable "NO" 0 infoPortable
WriteINIStr "$PLUGINSDIR\portable-info.ini" "Field 1" "Text" "$(DESC_StandardInstallation)"
Goto showInfo
infoPortable:
WriteINIStr "$PLUGINSDIR\portable-info.ini" "Field 1" "Text" "$(DESC_PortableInstallation)"
showInfo:
InstallOptions::dialog $PLUGINSDIR\portable-info.ini
FunctionEnd
Function installationInfoLeave
FunctionEnd
Function SkipComponentsIfPortableInstalltion
StrCmp $installAsPortable "YES" 0 +2
Abort
FunctionEnd

View File

@ -21,6 +21,16 @@ LangString DESC_SecExtensions ${LANG_ENGLISH} "Associate Falkon with .htm(l) fil
LangString DESC_SecThemes ${LANG_ENGLISH} "Additional themes for Falkon" LangString DESC_SecThemes ${LANG_ENGLISH} "Additional themes for Falkon"
LangString DESC_SecSetASDefault ${LANG_ENGLISH} "Set Falkon as default internet browser" LangString DESC_SecSetASDefault ${LANG_ENGLISH} "Set Falkon as default internet browser"
LangString DESC_SecProtocols ${LANG_ENGLISH} "Associate Falkon with http(s) and ftp protocols" LangString DESC_SecProtocols ${LANG_ENGLISH} "Associate Falkon with http(s) and ftp protocols"
LangString TITLE_InstallationMode ${LANG_ENGLISH} "Installation Mode"
LangString DESC_InstallationMode ${LANG_ENGLISH} "Select installation mode"
LangString TITLE_StandardInstallation ${LANG_ENGLISH} "Standard installation"
LangString TITLE_PortableInstallation ${LANG_ENGLISH} "Portable installation"
LangString DESC_PortableInstallation ${LANG_ENGLISH} "Falkon will be installed as a 'Portable Application' to the selected location."
LangString DESC_StandardInstallation ${LANG_ENGLISH} "Falkon will be installed on your computer."
LangString MSG_PortableWriteError ${LANG_ENGLISH} "Error occurred when creating 'falkon.conf' in installation folder. Create it manually."
LangString TITLE_InstallInfo ${LANG_ENGLISH} "Ready to install"
LangString DESC_InstallInfo ${LANG_ENGLISH} "To start installation click 'install'."
; ;
LangString MSG_RunningInstance ${LANG_ENGLISH} "Falkon is already running! Do you want the installer try to terminate it?" LangString MSG_RunningInstance ${LANG_ENGLISH} "Falkon is already running! Do you want the installer try to terminate it?"
LangString MSG_InstallationCanceled ${LANG_ENGLISH} "Process cancelled by user." LangString MSG_InstallationCanceled ${LANG_ENGLISH} "Process cancelled by user."
@ -541,6 +551,16 @@ LangString DESC_SecExtensions ${LANG_FARSI} "کوپزیلا را برای باز
LangString DESC_SecThemes ${LANG_FARSI} "فرهشت‌های اضافی برای کوپزیلا" LangString DESC_SecThemes ${LANG_FARSI} "فرهشت‌های اضافی برای کوپزیلا"
LangString DESC_SecSetASDefault ${LANG_FARSI} "تنظیم کوپزیلا به عنوان مرورگر پیش‌فرض" LangString DESC_SecSetASDefault ${LANG_FARSI} "تنظیم کوپزیلا به عنوان مرورگر پیش‌فرض"
LangString DESC_SecProtocols ${LANG_FARSI} "کوپزیلا را به پروتکل‌های http(s) و ftp اختصاص می‌دهد." LangString DESC_SecProtocols ${LANG_FARSI} "کوپزیلا را به پروتکل‌های http(s) و ftp اختصاص می‌دهد."
LangString TITLE_InstallationMode ${LANG_FARSI} "حالت نصب"
LangString DESC_InstallationMode ${LANG_FARSI} "حالت نصب را انتخاب کنید"
LangString TITLE_StandardInstallation ${LANG_FARSI} "نصب استاندارد"
LangString TITLE_PortableInstallation ${LANG_FARSI} "نصب همراه"
LangString DESC_PortableInstallation ${LANG_FARSI} "فالکون به عنوان 'نرم‌افزار همراه' در مکان انتخاب شده نصب خواهد شد."
LangString DESC_StandardInstallation ${LANG_FARSI} "فالکون بر روی رایانه شما نصب خواهد شد."
LangString MSG_PortableWriteError ${LANG_FARSI} "خطایی هنگام ایجاد فایل 'falkon.conf' در محل نصب رخ داد. فایلی خالی با نام 'falkon.conf' در پوشه نصب ایجاد نمایید."
LangString TITLE_InstallInfo ${LANG_FARSI} "آماده برای آغاز نصب"
LangString DESC_InstallInfo ${LANG_FARSI} "برای شروع نصب روی دکمه 'نصب' کلیک کنید."
; ;
LangString MSG_RunningInstance ${LANG_FARSI} "کوپزیلا هم‌اکنون در حال اجراست! آیا می‌خواهید برنامه نصب تلاش کند به اجرای آن خاتمه دهد؟" LangString MSG_RunningInstance ${LANG_FARSI} "کوپزیلا هم‌اکنون در حال اجراست! آیا می‌خواهید برنامه نصب تلاش کند به اجرای آن خاتمه دهد؟"
LangString MSG_InstallationCanceled ${LANG_FARSI} "فرایند توسط کاربر لغو گردید." LangString MSG_InstallationCanceled ${LANG_FARSI} "فرایند توسط کاربر لغو گردید."

BIN
windows/portable-info.ini Normal file

Binary file not shown.

BIN
windows/portable-mode.ini Normal file

Binary file not shown.