Permalink
Browse files

basic installer

  • Loading branch information...
abma committed Oct 11, 2015
1 parent d630e1a commit 41ec7597116abb6ca39e9a0768f1bba5bdbb523c
View
@@ -39,3 +39,7 @@ Makefile
# codeblocks
/springlobby.cbp
/springlobby.layout
# installer stuff
/installer/*.zip
/installer/uninstall.nsh
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -0,0 +1,169 @@
!define registry::Open `!insertmacro registry::Open`
!macro registry::Open _PATH _OPTIONS _HANDLE
registry::_Open /NOUNLOAD `${_PATH}` `${_OPTIONS}`
Pop ${_HANDLE}
!macroend
!define registry::Find `!insertmacro registry::Find`
!macro registry::Find _HANDLE _PATH _VALUEORKEY _STRING _TYPE
registry::_Find /NOUNLOAD `${_HANDLE}`
Pop ${_PATH}
Pop ${_VALUEORKEY}
Pop ${_STRING}
Pop ${_TYPE}
!macroend
!define registry::Close `!insertmacro registry::Close`
!macro registry::Close _HANDLE
registry::_Close /NOUNLOAD `${_HANDLE}`
!macroend
!define registry::KeyExists `!insertmacro registry::KeyExists`
!macro registry::KeyExists _PATH _ERR
registry::_KeyExists /NOUNLOAD `${_PATH}`
Pop ${_ERR}
!macroend
!define registry::Read `!insertmacro registry::Read`
!macro registry::Read _PATH _VALUE _STRING _TYPE
registry::_Read /NOUNLOAD `${_PATH}` `${_VALUE}`
Pop ${_STRING}
Pop ${_TYPE}
!macroend
!define registry::Write `!insertmacro registry::Write`
!macro registry::Write _PATH _VALUE _STRING _TYPE _ERR
registry::_Write /NOUNLOAD `${_PATH}` `${_VALUE}` `${_STRING}` `${_TYPE}`
Pop ${_ERR}
!macroend
!define registry::ReadExtra `!insertmacro registry::ReadExtra`
!macro registry::ReadExtra _PATH _VALUE _NUMBER _STRING _TYPE
registry::_ReadExtra /NOUNLOAD `${_PATH}` `${_VALUE}` `${_NUMBER}`
Pop ${_STRING}
Pop ${_TYPE}
!macroend
!define registry::WriteExtra `!insertmacro registry::WriteExtra`
!macro registry::WriteExtra _PATH _VALUE _STRING _ERR
registry::_WriteExtra /NOUNLOAD `${_PATH}` `${_VALUE}` `${_STRING}`
Pop ${_ERR}
!macroend
!define registry::CreateKey `!insertmacro registry::CreateKey`
!macro registry::CreateKey _PATH _ERR
registry::_CreateKey /NOUNLOAD `${_PATH}`
Pop ${_ERR}
!macroend
!define registry::DeleteValue `!insertmacro registry::DeleteValue`
!macro registry::DeleteValue _PATH _VALUE _ERR
registry::_DeleteValue /NOUNLOAD `${_PATH}` `${_VALUE}`
Pop ${_ERR}
!macroend
!define registry::DeleteKey `!insertmacro registry::DeleteKey`
!macro registry::DeleteKey _PATH _ERR
registry::_DeleteKey /NOUNLOAD `${_PATH}`
Pop ${_ERR}
!macroend
!define registry::DeleteKeyEmpty `!insertmacro registry::DeleteKeyEmpty`
!macro registry::DeleteKeyEmpty _PATH _ERR
registry::_DeleteKeyEmpty /NOUNLOAD `${_PATH}`
Pop ${_ERR}
!macroend
!define registry::CopyValue `!insertmacro registry::CopyValue`
!macro registry::CopyValue _PATH_SOURCE _VALUE_SOURCE _PATH_TARGET _VALUE_TARGET _ERR
registry::_CopyValue /NOUNLOAD `${_PATH_SOURCE}` `${_VALUE_SOURCE}` `${_PATH_TARGET}` `${_VALUE_TARGET}`
Pop ${_ERR}
!macroend
!define registry::MoveValue `!insertmacro registry::MoveValue`
!macro registry::MoveValue _PATH_SOURCE _VALUE_SOURCE _PATH_TARGET _VALUE_TARGET _ERR
registry::_MoveValue /NOUNLOAD `${_PATH_SOURCE}` `${_VALUE_SOURCE}` `${_PATH_TARGET}` `${_VALUE_TARGET}`
Pop ${_ERR}
!macroend
!define registry::CopyKey `!insertmacro registry::CopyKey`
!macro registry::CopyKey _PATH_SOURCE _PATH_TARGET _ERR
registry::_CopyKey /NOUNLOAD `${_PATH_SOURCE}` `${_PATH_TARGET}`
Pop ${_ERR}
!macroend
!define registry::MoveKey `!insertmacro registry::MoveKey`
!macro registry::MoveKey _PATH_SOURCE _PATH_TARGET _ERR
registry::_MoveKey /NOUNLOAD `${_PATH_SOURCE}` `${_PATH_TARGET}`
Pop ${_ERR}
!macroend
!define registry::SaveKey `!insertmacro registry::SaveKey`
!macro registry::SaveKey _PATH _FILE _OPTIONS _ERR
registry::_SaveKey /NOUNLOAD `${_PATH}` `${_FILE}` `${_OPTIONS}`
Pop ${_ERR}
!macroend
!define registry::RestoreKey `!insertmacro registry::RestoreKey`
!macro registry::RestoreKey _FILE _ERR
registry::_RestoreKey /NOUNLOAD `${_FILE}`
Pop ${_ERR}
!macroend
!define registry::StrToHex `!insertmacro registry::StrToHex`
!macro registry::StrToHex _STRING _HEX_STRING
registry::_StrToHex /NOUNLOAD `${_STRING}`
Pop ${_HEX_STRING}
!macroend
!define registry::HexToStr `!insertmacro registry::HexToStr`
!macro registry::HexToStr _HEX_STRING _STRING
registry::_HexToStr /NOUNLOAD `${_HEX_STRING}`
Pop ${_STRING}
!macroend
!define registry::Unload `!insertmacro registry::Unload`
!macro registry::Unload
registry::_Unload
!macroend
@@ -0,0 +1,30 @@
Function CheckExecutableRunningFunc
Pop $R1 ; executable
Pop $R2 ; human-name
begin:
FindProcDLL::FindProc "$R1"
; $R0 == 1: process found
; 0: process not found
; >1: some error, assume everything's ok
IntCmp $R0 1 do_abort proceed proceed
do_abort:
MessageBox MB_RETRYCANCEL|MB_ICONEXCLAMATION "Please close application '$R2' ('$R1') before installing." IDRETRY begin
Abort
proceed:
Return
FunctionEnd
!macro Call_CheckExecutableRunningFunc _EXECUTABLE _HUMAN_NAME
Push "${_HUMAN_NAME}"
Push "${_EXECUTABLE}"
Call CheckExecutableRunningFunc
!macroend
!define CheckExecutableRunning "!insertmacro Call_CheckExecutableRunningFunc"
; Usage:
;${CheckExecutableRunning} "springsettings.exe" "Spring Settings"
View
@@ -0,0 +1,18 @@
; A cross-platform compile-time echo command.
; This should do what `!echo` is meant to do, but this works under linux.
!macro !compile_time_echo _MSG
!ifdef NSIS_WIN32_MAKENSIS
; Windows - cmd.exe
!system 'echo ${_MSG}'
!else
; Posix - sh
!system 'echo "${_MSG}"'
!endif
!macroend
!define !echonow "!insertmacro !compile_time_echo"
; Usage:
;${!echonow} "Packaging the installer now ..."
@@ -0,0 +1,14 @@
; install .7z instdir + extract + delete .7z
!macro extractFile filename tempfile path
File /oname=${tempfile} "${filename}"
${If} "${path}" != ""
SetOutPath "$INSTDIR\${path}"
${EndIf}
Nsis7z::Extract "$INSTDIR\${tempfile}"
${If} "${path}" != ""
SetOutPath "$INSTDIR"
${EndIf}
Delete "$INSTDIR\${tempfile}"
!macroend
@@ -0,0 +1,46 @@
; See http://nsis.sourceforge.net/Check_if_a_file_exists_at_compile_time for documentation
!macro !defineiffileexists _VAR_NAME _FILE_NAME
!tempfile _TEMPFILE
!ifdef NSIS_WIN32_MAKENSIS
; Windows - cmd.exe
!system 'if exist "${_FILE_NAME}" echo !define ${_VAR_NAME} > "${_TEMPFILE}"'
!else
; Posix - sh
!system 'if [ -e "$(echo "${_FILE_NAME}" | sed -e "s_\\_\/_g")" ]; then echo "!define ${_VAR_NAME}" > "${_TEMPFILE}"; fi'
!endif
!include '${_TEMPFILE}'
!delfile '${_TEMPFILE}'
!undef _TEMPFILE
!macroend
!define !defineiffileexists "!insertmacro !defineiffileexists"
!macro !defineifdirexists _VAR_NAME _FILE_NAME
!tempfile _TEMPFILE
!ifdef NSIS_WIN32_MAKENSIS
; Windows - cmd.exe
!system 'if exist "${_FILE_NAME}\*.*" echo !define ${_VAR_NAME} > "${_TEMPFILE}"'
!else
; Posix - sh
!system 'if [ -d "$(echo "${_FILE_NAME}" | sed -e "s_\\_\/_g")" ]; then echo "!define ${_VAR_NAME}" > "${_TEMPFILE}"; fi'
!endif
!include '${_TEMPFILE}'
!delfile '${_TEMPFILE}'
!undef _TEMPFILE
!macroend
!define !defineifdirexists "!insertmacro !defineifdirexists"
; Usage:
;${!defineiffileexists} FILE_EXISTS ".\to\check\file.txt"
;!ifdef FILE_EXISTS
; !system 'echo "The file exists!"'
; !undef FILE_EXISTS
;!endif
;
;${!defineifdirexists} DIR_EXISTS ".\to\check\dir"
;!ifdef DIR_EXISTS
; !system 'echo "The dir exists!"'
; !undef DIR_EXISTS
;!endif
@@ -0,0 +1,11 @@
!macro createemptyfile _FILE_NAME
ClearErrors
FileOpen $0 ${_FILE_NAME} w
IfErrors +3
FileWrite $0 ""
FileClose $0
!macroend
; Usage:
;!insertmacro createemptyfile "$INSTDIR\template.txt"
Oops, something went wrong.

0 comments on commit 41ec759

Please sign in to comment.