mirror of https://github.com/keeweb/keeweb
nsis
parent
0ec98dde6c
commit
b3e737e7f4
|
@ -1,21 +1,26 @@
|
|||
'use strict';
|
||||
|
||||
module.exports = function (grunt) {
|
||||
grunt.registerMultiTask('nsis', 'Launches NSIS installer', function (done) {
|
||||
grunt.registerMultiTask('nsis', 'Launches NSIS installer', function () {
|
||||
let done = this.async();
|
||||
let opt = this.options();
|
||||
let args = [];
|
||||
let win = process.platform === 'win32';
|
||||
let prefix = win ? '/' : '-';
|
||||
Object.keys(opt.vars).forEach(key => {
|
||||
let value = opt.vars[key];
|
||||
if (typeof value === 'function') {
|
||||
value = value();
|
||||
}
|
||||
args.push(`-D${key}=${value}`);
|
||||
args.push(`${prefix}D${key}=${value}`);
|
||||
});
|
||||
args.push('-Darch=' + opt.arch);
|
||||
args.push('-NOCD');
|
||||
args.push(`${prefix}Darch=${opt.arch}`);
|
||||
args.push(`${prefix}NOCD`);
|
||||
args.push(opt.installScript);
|
||||
let executable = win ? 'C:\\Program Files (x86)\\NSIS\\makensis.exe' : 'makensis';
|
||||
grunt.log.writeln('Running NSIS:', args.join(' '));
|
||||
grunt.util.spawn({
|
||||
cmd: 'makensis',
|
||||
cmd: executable,
|
||||
args: args,
|
||||
opts: {stdio: 'inherit'}
|
||||
}, function (error, result, code) {
|
||||
|
|
|
@ -19,7 +19,6 @@
|
|||
"exports-loader": "0.6.3",
|
||||
"get-folder-size": "1.0.0",
|
||||
"grunt": "1.0.1",
|
||||
"grunt-appdmg": "^0.4.0",
|
||||
"grunt-bower-install-simple": "1.2.3",
|
||||
"grunt-concurrent": "2.3.0",
|
||||
"grunt-contrib-clean": "1.0.0",
|
||||
|
@ -49,6 +48,9 @@
|
|||
"webpack": "1.13.1",
|
||||
"webpack-dev-server": "1.14.1"
|
||||
},
|
||||
"optionalDependencies": {
|
||||
"grunt-appdmg": "0.4.0",
|
||||
},
|
||||
"scripts": {
|
||||
"start": "grunt",
|
||||
"test": "grunt test",
|
||||
|
|
|
@ -0,0 +1,5 @@
|
|||
Name "${PRODUCT_NAME}"
|
||||
OutFile dist/desktop/KeeWeb.win32.${arch}.exe
|
||||
InstallDir "$PROGRAMFILES\KeeWeb"
|
||||
ShowInstDetails show
|
||||
ShowUnInstDetails show
|
|
@ -0,0 +1,17 @@
|
|||
!define PRODUCT_NAME "KeeWeb"
|
||||
!define PRODUCT_VERSION "${version}"
|
||||
!define PRODUCT_PUBLISHER "KeeWeb"
|
||||
!define PRODUCT_WEB_SITE "${homepage}"
|
||||
!define PRODUCT_UNINST_KEY "Software\Microsoft\Windows\CurrentVersion\Uninstall\${PRODUCT_NAME}"
|
||||
!define PRODUCT_UNINST_ROOT_KEY "HKLM"
|
||||
|
||||
!define MUI_ABORTWARNING
|
||||
!define MUI_ICON "graphics\icon.ico"
|
||||
!define MUI_UNICON "graphics\icon.ico"
|
||||
!define MUI_FINISHPAGE_RUN "$INSTDIR\KeeWeb.exe"
|
||||
|
||||
!define MULTIUSER_EXECUTIONLEVEL Highest
|
||||
!define MULTIUSER_MUI
|
||||
!define MULTIUSER_INSTALLMODE_COMMANDLINE
|
||||
|
||||
SetCompressor lzma
|
|
@ -0,0 +1,8 @@
|
|||
!include MultiUser.nsh
|
||||
!include MUI2.nsh
|
||||
!include x64.nsh
|
||||
!include nsDialogs.nsh
|
||||
!include LogicLib.nsh
|
||||
!include WinVer.nsh
|
||||
|
||||
!include package\nsis\lib\FileAssoc.nsh
|
|
@ -0,0 +1,52 @@
|
|||
Function .onInit
|
||||
${If} ${RunningX64}
|
||||
${If} ${arch} == "x64"
|
||||
SetRegView 64
|
||||
StrCpy $InstDir "$PROGRAMFILES64\KeeWeb"
|
||||
${Else}
|
||||
MessageBox MB_ICONSTOP|MB_OK "Please use 64-bit installer on 64-bit system"
|
||||
Quit
|
||||
${EndIf}
|
||||
${Else}
|
||||
${If} ${arch} == "x64"
|
||||
MessageBox MB_ICONSTOP|MB_OK "Please use 32-bit installer on 32-bit system"
|
||||
Quit
|
||||
${EndIf}
|
||||
${EndIf}
|
||||
|
||||
${IfNot} ${AtLeastWin7}
|
||||
MessageBox MB_OK "Windows 7 and above required"
|
||||
Quit
|
||||
${EndIf}
|
||||
|
||||
!insertmacro MULTIUSER_INIT
|
||||
FunctionEnd
|
||||
|
||||
Section "MainSection" SEC01
|
||||
ReadRegStr $R0 ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_UNINST_KEY}" "UninstallString"
|
||||
${If} $R0 != ""
|
||||
ClearErrors
|
||||
ExecWait '"$R0" /S _?=$INSTDIR'
|
||||
${EndIf}
|
||||
|
||||
SetOutPath "$INSTDIR"
|
||||
SetOverwrite ifnewer
|
||||
File /r "tmp\desktop\KeeWeb-win32-${arch}\*"
|
||||
CreateDirectory "$SMPROGRAMS\KeeWeb"
|
||||
CreateShortCut "$SMPROGRAMS\KeeWeb\KeeWeb.lnk" "$INSTDIR\KeeWeb.exe"
|
||||
CreateShortCut "$DESKTOP\KeeWeb.lnk" "$INSTDIR\KeeWeb.exe"
|
||||
|
||||
!insertmacro APP_ASSOCIATE "kdbx" "kdbxfile" "KeePass Password Database" \
|
||||
"$INSTDIR\KeeWeb.exe,0" "Open with KeeWeb" "$INSTDIR\KeeWeb.exe $\"%1$\""
|
||||
!insertmacro UPDATEFILEASSOC
|
||||
SectionEnd
|
||||
|
||||
Section -Post
|
||||
WriteUninstaller "$INSTDIR\uninst.exe"
|
||||
WriteRegStr ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_UNINST_KEY}" "DisplayName" "$(^Name)"
|
||||
WriteRegStr ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_UNINST_KEY}" "UninstallString" "$INSTDIR\uninst.exe"
|
||||
WriteRegStr ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_UNINST_KEY}" "DisplayIcon" "$INSTDIR\KeeWeb.exe"
|
||||
WriteRegStr ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_UNINST_KEY}" "DisplayVersion" "${PRODUCT_VERSION}"
|
||||
WriteRegStr ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_UNINST_KEY}" "URLInfoAbout" "${PRODUCT_WEB_SITE}"
|
||||
WriteRegStr ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_UNINST_KEY}" "Publisher" "${PRODUCT_PUBLISHER}"
|
||||
SectionEnd
|
|
@ -0,0 +1,121 @@
|
|||
# http://nsis.sourceforge.net/FileAssoc
|
||||
|
||||
; fileassoc.nsh
|
||||
; File association helper macros
|
||||
; Written by Saivert
|
||||
;
|
||||
; Features automatic backup system and UPDATEFILEASSOC macro for
|
||||
; shell change notification.
|
||||
;
|
||||
; |> How to use <|
|
||||
; To associate a file with an application so you can double-click it in explorer, use
|
||||
; the APP_ASSOCIATE macro like this:
|
||||
;
|
||||
; Example:
|
||||
; !insertmacro APP_ASSOCIATE "txt" "myapp.textfile" "Description of txt files" \
|
||||
; "$INSTDIR\myapp.exe,0" "Open with myapp" "$INSTDIR\myapp.exe $\"%1$\""
|
||||
;
|
||||
; Never insert the APP_ASSOCIATE macro multiple times, it is only ment
|
||||
; to associate an application with a single file and using the
|
||||
; the "open" verb as default. To add more verbs (actions) to a file
|
||||
; use the APP_ASSOCIATE_ADDVERB macro.
|
||||
;
|
||||
; Example:
|
||||
; !insertmacro APP_ASSOCIATE_ADDVERB "myapp.textfile" "edit" "Edit with myapp" \
|
||||
; "$INSTDIR\myapp.exe /edit $\"%1$\""
|
||||
;
|
||||
; To have access to more options when registering the file association use the
|
||||
; APP_ASSOCIATE_EX macro. Here you can specify the verb and what verb is to be the
|
||||
; standard action (default verb).
|
||||
;
|
||||
; And finally: To remove the association from the registry use the APP_UNASSOCIATE
|
||||
; macro. Here is another example just to wrap it up:
|
||||
; !insertmacro APP_UNASSOCIATE "txt" "myapp.textfile"
|
||||
;
|
||||
; |> Note <|
|
||||
; When defining your file class string always use the short form of your application title
|
||||
; then a period (dot) and the type of file. This keeps the file class sort of unique.
|
||||
; Examples:
|
||||
; Winamp.Playlist
|
||||
; NSIS.Script
|
||||
; Photoshop.JPEGFile
|
||||
;
|
||||
; |> Tech info <|
|
||||
; The registry key layout for a file association is:
|
||||
; HKEY_CLASSES_ROOT
|
||||
; <applicationID> = <"description">
|
||||
; shell
|
||||
; <verb> = <"menu-item text">
|
||||
; command = <"command string">
|
||||
;
|
||||
|
||||
!macro APP_ASSOCIATE EXT FILECLASS DESCRIPTION ICON COMMANDTEXT COMMAND
|
||||
; Backup the previously associated file class
|
||||
ReadRegStr $R0 HKCR ".${EXT}" ""
|
||||
WriteRegStr HKCR ".${EXT}" "${FILECLASS}_backup" "$R0"
|
||||
|
||||
WriteRegStr HKCR ".${EXT}" "" "${FILECLASS}"
|
||||
|
||||
WriteRegStr HKCR "${FILECLASS}" "" `${DESCRIPTION}`
|
||||
WriteRegStr HKCR "${FILECLASS}\DefaultIcon" "" `${ICON}`
|
||||
WriteRegStr HKCR "${FILECLASS}\shell" "" "open"
|
||||
WriteRegStr HKCR "${FILECLASS}\shell\open" "" `${COMMANDTEXT}`
|
||||
WriteRegStr HKCR "${FILECLASS}\shell\open\command" "" `${COMMAND}`
|
||||
!macroend
|
||||
|
||||
!macro APP_ASSOCIATE_EX EXT FILECLASS DESCRIPTION ICON VERB DEFAULTVERB SHELLNEW COMMANDTEXT COMMAND
|
||||
; Backup the previously associated file class
|
||||
ReadRegStr $R0 HKCR ".${EXT}" ""
|
||||
WriteRegStr HKCR ".${EXT}" "${FILECLASS}_backup" "$R0"
|
||||
|
||||
WriteRegStr HKCR ".${EXT}" "" "${FILECLASS}"
|
||||
StrCmp "${SHELLNEW}" "0" +2
|
||||
WriteRegStr HKCR ".${EXT}\ShellNew" "NullFile" ""
|
||||
|
||||
WriteRegStr HKCR "${FILECLASS}" "" `${DESCRIPTION}`
|
||||
WriteRegStr HKCR "${FILECLASS}\DefaultIcon" "" `${ICON}`
|
||||
WriteRegStr HKCR "${FILECLASS}\shell" "" `${DEFAULTVERB}`
|
||||
WriteRegStr HKCR "${FILECLASS}\shell\${VERB}" "" `${COMMANDTEXT}`
|
||||
WriteRegStr HKCR "${FILECLASS}\shell\${VERB}\command" "" `${COMMAND}`
|
||||
!macroend
|
||||
|
||||
!macro APP_ASSOCIATE_ADDVERB FILECLASS VERB COMMANDTEXT COMMAND
|
||||
WriteRegStr HKCR "${FILECLASS}\shell\${VERB}" "" `${COMMANDTEXT}`
|
||||
WriteRegStr HKCR "${FILECLASS}\shell\${VERB}\command" "" `${COMMAND}`
|
||||
!macroend
|
||||
|
||||
!macro APP_ASSOCIATE_REMOVEVERB FILECLASS VERB
|
||||
DeleteRegKey HKCR `${FILECLASS}\shell\${VERB}`
|
||||
!macroend
|
||||
|
||||
|
||||
!macro APP_UNASSOCIATE EXT FILECLASS
|
||||
; Backup the previously associated file class
|
||||
ReadRegStr $R0 HKCR ".${EXT}" `${FILECLASS}_backup`
|
||||
WriteRegStr HKCR ".${EXT}" "" "$R0"
|
||||
|
||||
DeleteRegKey HKCR `${FILECLASS}`
|
||||
!macroend
|
||||
|
||||
!macro APP_ASSOCIATE_GETFILECLASS OUTPUT EXT
|
||||
ReadRegStr ${OUTPUT} HKCR ".${EXT}" ""
|
||||
!macroend
|
||||
|
||||
|
||||
; !defines for use with SHChangeNotify
|
||||
!ifdef SHCNE_ASSOCCHANGED
|
||||
!undef SHCNE_ASSOCCHANGED
|
||||
!endif
|
||||
!define SHCNE_ASSOCCHANGED 0x08000000
|
||||
!ifdef SHCNF_FLUSH
|
||||
!undef SHCNF_FLUSH
|
||||
!endif
|
||||
!define SHCNF_FLUSH 0x1000
|
||||
|
||||
!macro UPDATEFILEASSOC
|
||||
; Using the system.dll plugin to call the SHChangeNotify Win32 API function so we
|
||||
; can update the shell.
|
||||
System::Call "shell32::SHChangeNotify(i,i,i,i) (${SHCNE_ASSOCCHANGED}, ${SHCNF_FLUSH}, 0, 0)"
|
||||
!macroend
|
||||
|
||||
;EOF
|
|
@ -0,0 +1,190 @@
|
|||
/*
|
||||
_____________________________________________________________________________
|
||||
|
||||
File Association
|
||||
_____________________________________________________________________________
|
||||
|
||||
Based on code taken from http://nsis.sourceforge.net/File_Association
|
||||
|
||||
Usage in script:
|
||||
1. !include "FileAssociation.nsh"
|
||||
2. [Section|Function]
|
||||
${FileAssociationFunction} "Param1" "Param2" "..." $var
|
||||
[SectionEnd|FunctionEnd]
|
||||
|
||||
FileAssociationFunction=[RegisterExtension|UnRegisterExtension]
|
||||
|
||||
_____________________________________________________________________________
|
||||
|
||||
${RegisterExtension} "[executable]" "[extension]" "[description]"
|
||||
|
||||
"[executable]" ; executable which opens the file format
|
||||
;
|
||||
"[extension]" ; extension, which represents the file format to open
|
||||
;
|
||||
"[description]" ; description for the extension. This will be display in Windows Explorer.
|
||||
;
|
||||
|
||||
|
||||
${UnRegisterExtension} "[extension]" "[description]"
|
||||
|
||||
"[extension]" ; extension, which represents the file format to open
|
||||
;
|
||||
"[description]" ; description for the extension. This will be display in Windows Explorer.
|
||||
;
|
||||
|
||||
_____________________________________________________________________________
|
||||
|
||||
Macros
|
||||
_____________________________________________________________________________
|
||||
|
||||
Change log window verbosity (default: 3=no script)
|
||||
|
||||
Example:
|
||||
!include "FileAssociation.nsh"
|
||||
!insertmacro RegisterExtension
|
||||
${FileAssociation_VERBOSE} 4 # all verbosity
|
||||
!insertmacro UnRegisterExtension
|
||||
${FileAssociation_VERBOSE} 3 # no script
|
||||
*/
|
||||
|
||||
|
||||
!ifndef FileAssociation_INCLUDED
|
||||
!define FileAssociation_INCLUDED
|
||||
|
||||
!include Util.nsh
|
||||
|
||||
!verbose push
|
||||
!verbose 3
|
||||
!ifndef _FileAssociation_VERBOSE
|
||||
!define _FileAssociation_VERBOSE 3
|
||||
!endif
|
||||
!verbose ${_FileAssociation_VERBOSE}
|
||||
!define FileAssociation_VERBOSE `!insertmacro FileAssociation_VERBOSE`
|
||||
!verbose pop
|
||||
|
||||
!macro FileAssociation_VERBOSE _VERBOSE
|
||||
!verbose push
|
||||
!verbose 3
|
||||
!undef _FileAssociation_VERBOSE
|
||||
!define _FileAssociation_VERBOSE ${_VERBOSE}
|
||||
!verbose pop
|
||||
!macroend
|
||||
|
||||
|
||||
|
||||
!macro RegisterExtensionCall _EXECUTABLE _EXTENSION _DESCRIPTION
|
||||
!verbose push
|
||||
!verbose ${_FileAssociation_VERBOSE}
|
||||
Push `${_DESCRIPTION}`
|
||||
Push `${_EXTENSION}`
|
||||
Push `${_EXECUTABLE}`
|
||||
${CallArtificialFunction} RegisterExtension_
|
||||
!verbose pop
|
||||
!macroend
|
||||
|
||||
!macro UnRegisterExtensionCall _EXTENSION _DESCRIPTION
|
||||
!verbose push
|
||||
!verbose ${_FileAssociation_VERBOSE}
|
||||
Push `${_EXTENSION}`
|
||||
Push `${_DESCRIPTION}`
|
||||
${CallArtificialFunction} UnRegisterExtension_
|
||||
!verbose pop
|
||||
!macroend
|
||||
|
||||
|
||||
|
||||
!define RegisterExtension `!insertmacro RegisterExtensionCall`
|
||||
!define un.RegisterExtension `!insertmacro RegisterExtensionCall`
|
||||
|
||||
!macro RegisterExtension
|
||||
!macroend
|
||||
|
||||
!macro un.RegisterExtension
|
||||
!macroend
|
||||
|
||||
!macro RegisterExtension_
|
||||
!verbose push
|
||||
!verbose ${_FileAssociation_VERBOSE}
|
||||
|
||||
Exch $R2 ;exe
|
||||
Exch
|
||||
Exch $R1 ;ext
|
||||
Exch
|
||||
Exch 2
|
||||
Exch $R0 ;desc
|
||||
Exch 2
|
||||
Push $0
|
||||
Push $1
|
||||
|
||||
ReadRegStr $1 HKCR $R1 "" ; read current file association
|
||||
StrCmp "$1" "" NoBackup ; is it empty
|
||||
StrCmp "$1" "$R0" NoBackup ; is it our own
|
||||
WriteRegStr HKCR $R1 "backup_val" "$1" ; backup current value
|
||||
NoBackup:
|
||||
WriteRegStr HKCR $R1 "" "$R0" ; set our file association
|
||||
|
||||
ReadRegStr $0 HKCR $R0 ""
|
||||
StrCmp $0 "" 0 Skip
|
||||
WriteRegStr HKCR "$R0" "" "$R0"
|
||||
WriteRegStr HKCR "$R0\shell" "" "open"
|
||||
WriteRegStr HKCR "$R0\DefaultIcon" "" "$R2,0"
|
||||
Skip:
|
||||
WriteRegStr HKCR "$R0\shell\open\command" "" '"$R2" "%1"'
|
||||
WriteRegStr HKCR "$R0\shell\edit" "" "Edit $R0"
|
||||
WriteRegStr HKCR "$R0\shell\edit\command" "" '"$R2" "%1"'
|
||||
|
||||
Pop $1
|
||||
Pop $0
|
||||
Pop $R2
|
||||
Pop $R1
|
||||
Pop $R0
|
||||
|
||||
!verbose pop
|
||||
!macroend
|
||||
|
||||
|
||||
|
||||
!define UnRegisterExtension `!insertmacro UnRegisterExtensionCall`
|
||||
!define un.UnRegisterExtension `!insertmacro UnRegisterExtensionCall`
|
||||
|
||||
!macro UnRegisterExtension
|
||||
!macroend
|
||||
|
||||
!macro un.UnRegisterExtension
|
||||
!macroend
|
||||
|
||||
!macro UnRegisterExtension_
|
||||
!verbose push
|
||||
!verbose ${_FileAssociation_VERBOSE}
|
||||
|
||||
Exch $R1 ;desc
|
||||
Exch
|
||||
Exch $R0 ;ext
|
||||
Exch
|
||||
Push $0
|
||||
Push $1
|
||||
|
||||
ReadRegStr $1 HKCR $R0 ""
|
||||
StrCmp $1 $R1 0 NoOwn ; only do this if we own it
|
||||
ReadRegStr $1 HKCR $R0 "backup_val"
|
||||
StrCmp $1 "" 0 Restore ; if backup="" then delete the whole key
|
||||
DeleteRegKey HKCR $R0
|
||||
Goto NoOwn
|
||||
|
||||
Restore:
|
||||
WriteRegStr HKCR $R0 "" $1
|
||||
DeleteRegValue HKCR $R0 "backup_val"
|
||||
DeleteRegKey HKCR $R1 ;Delete key with association name settings
|
||||
|
||||
NoOwn:
|
||||
|
||||
Pop $1
|
||||
Pop $0
|
||||
Pop $R1
|
||||
Pop $R0
|
||||
|
||||
!verbose pop
|
||||
!macroend
|
||||
|
||||
!endif # !FileAssociation_INCLUDED
|
|
@ -1,7 +1,6 @@
|
|||
OutFile dist/desktop/KeeWeb.win32.${arch}.exe
|
||||
|
||||
Section
|
||||
|
||||
# TODO
|
||||
|
||||
SectionEnd
|
||||
!include package\nsis\defines.nsh
|
||||
!include package\nsis\includes.nsh
|
||||
!include package\nsis\mui.nsh
|
||||
!include package\nsis\config.nsh
|
||||
!include package\nsis\install.nsh
|
||||
!include package\nsis\uninstall.nsh
|
||||
|
|
|
@ -0,0 +1,9 @@
|
|||
!insertmacro MUI_PAGE_WELCOME
|
||||
#!insertmacro MULTIUSER_PAGE_INSTALLMODE
|
||||
!insertmacro MUI_PAGE_DIRECTORY
|
||||
!insertmacro MUI_PAGE_INSTFILES
|
||||
!insertmacro MUI_PAGE_FINISH
|
||||
|
||||
!insertmacro MUI_UNPAGE_INSTFILES
|
||||
|
||||
!insertmacro MUI_LANGUAGE "English"
|
|
@ -0,0 +1,29 @@
|
|||
Function un.onInit
|
||||
MessageBox MB_ICONQUESTION|MB_YESNO|MB_DEFBUTTON2 "Remove $(^Name) from your computer?" /SD IDYES IDYES yes
|
||||
Abort
|
||||
yes:
|
||||
${If} ${RunningX64}
|
||||
SetRegView 64
|
||||
${EndIf}
|
||||
!insertmacro MULTIUSER_UNINIT
|
||||
FunctionEnd
|
||||
|
||||
Function un.onUninstSuccess
|
||||
HideWindow
|
||||
MessageBox MB_ICONINFORMATION|MB_OK "$(^Name) was successfully removed from your computer." /SD IDOK
|
||||
FunctionEnd
|
||||
|
||||
Section Uninstall
|
||||
Delete "$DESKTOP\KeeWeb.lnk"
|
||||
Delete "$SMPROGRAMS\KeeWeb\KeeWeb.lnk"
|
||||
|
||||
RMDir "$SMPROGRAMS\KeeWeb"
|
||||
RMDir /r "$INSTDIR"
|
||||
|
||||
DeleteRegKey ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_UNINST_KEY}"
|
||||
|
||||
!insertmacro APP_UNASSOCIATE "kdbx" "kdbxfile"
|
||||
!insertmacro UPDATEFILEASSOC
|
||||
|
||||
SetAutoClose true
|
||||
SectionEnd
|
Loading…
Reference in New Issue