|
# The MIT License (MIT) |
|
|
|
# Copyright (c) 2021 Tom J. Sun |
|
|
|
# Permission is hereby granted, free of charge, to any person obtaining a copy |
|
# of this software and associated documentation files (the "Software"), to deal |
|
# in the Software without restriction, including without limitation the rights |
|
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell |
|
# copies of the Software, and to permit persons to whom the Software is |
|
# furnished to do so, subject to the following conditions: |
|
|
|
# The above copyright notice and this permission notice shall be included in |
|
# all copies or substantial portions of the Software. |
|
|
|
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
|
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
|
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE |
|
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
|
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
|
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN |
|
# THE SOFTWARE. |
|
|
|
#Basic definitions |
|
!define APPNAME "Krux" |
|
!define COMPANYNAME "Selfcustody" |
|
!define DESCRIPTION "Krux is an open-source DIY hardware signer for Bitcoin that can sign for multisignature and single-key wallets" |
|
!define APPSHORTNAME "krux" |
|
!define VERSIONMAJOR %VERSIONMAJOR |
|
!define VERSIONMINOR %VERSIONMINOR |
|
!define VERSIONBUILD %VERSIONBUILD |
|
!define HELPURL "https://selfcustody.github.io/krux/" |
|
!define UPDATEURL "https://github.com/selfcustody/krux/releases" |
|
!define ABOUTURL "https://github.com/selfcustody/krux/blob/main/README.md" |
|
|
|
# This is the size (in kB) of all the files copied into "Program Files" |
|
# to calculate, use `du -cb <files> | awk 'END{ print $1}` |
|
!define INSTALLSIZE 15327 |
|
|
|
# Ask for administrative rights |
|
# Other options include: |
|
# none |
|
# user |
|
# highest |
|
RequestExecutionLevel admin |
|
|
|
# Default installation location |
|
# let's clutter up our root directory! |
|
InstallDir "C:\${APPSHORTNAME}" |
|
|
|
# Text (or RTF) file with license information. |
|
# The text file must be in DOS end line format (\r\n) |
|
LicenseData "LICENSE.md" |
|
|
|
#'Name' goes in the installer's title bar |
|
Name "${COMPANYNAME}-${APPSHORTNAME}" |
|
|
|
# Icon for the installer - this is the default icon |
|
# The following lines replace the default icons |
|
!include "MUI2.nsh" |
|
|
|
#The name of the installer executable |
|
outFile "${APPSHORTNAME}-inst.exe" |
|
|
|
#...Not certain about this one |
|
!include LogicLib.nsh |
|
|
|
# Defines installation pages |
|
# these are known to NSIS |
|
# Shows the license |
|
Page license |
|
|
|
#Allows user to pick install path |
|
Page directory |
|
|
|
#Installs the files |
|
Page instfiles |
|
|
|
#A macro to verify that administrator rights have been acquired |
|
!macro VerifyUserIsAdmin |
|
UserInfo::GetAccountType |
|
pop $0 |
|
${If} $0 != "admin" ;Require admin rights on NT4+ |
|
messageBox mb_iconstop "Administrator rights required!" |
|
setErrorLevel 740 ;ERROR_ELEVATION_REQUIRED |
|
quit |
|
${EndIf} |
|
!macroend |
|
|
|
#This ensures the administrator check is performed at startup? |
|
function .onInit |
|
setShellVarContext all |
|
!insertmacro VerifyUserIsAdmin |
|
functionEnd |
|
|
|
# Files for the install directory |
|
# to build the installer, |
|
# these should be in the same directory as the install script (this file) |
|
section "install" |
|
setOutPath $INSTDIR |
|
CreateDirectory $INSTDIR\"maixpy_m5stickv" |
|
|
|
# Files added here should be removed by the uninstaller (see section "uninstall") |
|
file "README.md" |
|
file "LICENSE.md" |
|
file "favicon.png" |
|
file "ktool-win.exe" |
|
file "maixpy_m5stickv/firmware.bin" |
|
file "maixpy_m5stickv/kboot.kfpkg" |
|
|
|
# Files added here |
|
# should be removed |
|
# by the uninstaller |
|
# (see section "uninstall") |
|
# file /r ..\dist\*.* |
|
|
|
# Uninstaller - See function un.onInit and section "uninstall" for configuration |
|
WriteUninstaller "$INSTDIR\uninstall.exe" |
|
|
|
#Add a directory for logfiles |
|
#CreateDirectory $INSTDIR\logs |
|
|
|
# Start Menu |
|
CreateDirectory "$SMPROGRAMS\${COMPANYNAME}" |
|
#CreateShortcut "$SMPROGRAMS\${COMPANYNAME}\${APPSHORTNAME}.lnk" "$INSTDIR\${APPSHORTNAME}.exe" "" "$INSTDIR\favicon.png" |
|
|
|
# Registry information for add/remove programs |
|
WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${COMPANYNAME} ${APPNAME}" "DisplayName" "${COMPANYNAME} - ${APPNAME} - ${DESCRIPTION}" |
|
WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${COMPANYNAME} ${APPNAME}" "UninstallString" "$\"$INSTDIR\uninstall.exe$\"" |
|
WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${COMPANYNAME} ${APPNAME}" "QuietUninstallString" "$\"$INSTDIR\uninstall.exe$\" /S" |
|
WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${COMPANYNAME} ${APPNAME}" "InstallLocation" "$\"$INSTDIR$\"" |
|
WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${COMPANYNAME} ${APPNAME}" "DisplayIcon" "$\"$INSTDIR\favicon.png$\"" |
|
WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${COMPANYNAME} ${APPNAME}" "Publisher" "$\"${COMPANYNAME}$\"" |
|
WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${COMPANYNAME} ${APPNAME}" "HelpLink" "$\"${HELPURL}$\"" |
|
WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${COMPANYNAME} ${APPNAME}" "URLUpdateInfo" "$\"${UPDATEURL}$\"" |
|
WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${COMPANYNAME} ${APPNAME}" "URLInfoAbout" "$\"${ABOUTURL}$\"" |
|
WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${COMPANYNAME} ${APPNAME}" "DisplayVersion" "$\"${VERSIONMAJOR}.${VERSIONMINOR}.${VERSIONBUILD}$\"" |
|
WriteRegDWORD HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${COMPANYNAME} ${APPNAME}" "VersionMajor" ${VERSIONMAJOR} |
|
WriteRegDWORD HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${COMPANYNAME} ${APPNAME}" "VersionMinor" ${VERSIONMINOR} |
|
|
|
# There is no option for modifying or repairing the install |
|
WriteRegDWORD HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${COMPANYNAME} ${APPNAME}" "NoModify" 1 |
|
WriteRegDWORD HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${COMPANYNAME} ${APPNAME}" "NoRepair" 1 |
|
|
|
# Set the INSTALLSIZE constant (!defined at the top of this script) so Add/Remove Programs can accurately report the size |
|
WriteRegDWORD HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${COMPANYNAME} ${APPNAME}" "EstimatedSize" ${INSTALLSIZE} |
|
sectionEnd |
|
|
|
# Uninstaller |
|
function un.onInit |
|
SetShellVarContext all |
|
|
|
#Verify the uninstaller - last chance to back out |
|
MessageBox MB_OKCANCEL "Permanantly remove ${APPNAME}?" IDOK next |
|
Abort |
|
next: |
|
!insertmacro VerifyUserIsAdmin |
|
functionEnd |
|
|
|
section "uninstall" |
|
# Remove Start Menu launcher |
|
# delete "$SMPROGRAMS\${COMPANYNAME}\${APPSHORTNAME}.lnk" |
|
|
|
# Try to remove the Start Menu folder - this will only happen if it is empty |
|
rmDir "$SMPROGRAMS\${COMPANYNAME}" |
|
|
|
# Remove files |
|
delete $INSTDIR\README.md |
|
delete $INSTDIR\LICENSE.md |
|
delete $INSTDIR\favicon.png |
|
delete "ktool-win.exe" |
|
delete "maixpy_m5stickv/firmware.bin" |
|
delete "maixpy_m5stickv/kboot.kfpkg" |
|
|
|
# Always delete uninstaller as the last action |
|
delete $INSTDIR\uninstall.exe |
|
|
|
# Try to remove the install directory - this will only happen if it is empty |
|
rmDir $INSTDIR |
|
|
|
# Remove uninstaller information from the registry |
|
DeleteRegKey HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${COMPANYNAME} ${APPNAME}" |
|
sectionEnd |
|
|
|
|