Skip to content

Commit

Permalink
Add installer for windows version of dmrRadio
Browse files Browse the repository at this point in the history
  • Loading branch information
Dale Farnsworth committed Sep 4, 2018
1 parent b7eb365 commit 2ce64da
Show file tree
Hide file tree
Showing 2 changed files with 123 additions and 6 deletions.
17 changes: 11 additions & 6 deletions editcp/Makefile
@@ -1,6 +1,6 @@
SHELL = /bin/sh

.PHONY: default linux windows clean clobber upload install docker-usb tag dmrRadio
.PHONY: default linux windows clean clobber upload install docker-usb tag

EDITCP_SRC = *.go
RADIO_SRC = ../dmrRadio/*.go
Expand All @@ -15,7 +15,7 @@ VERSION = $(shell sed -n '/version =/{s/^[^"]*"//;s/".*//p;q}' <version.go)

default: linux dmrRadio

linux: deploy/linux/editcp deploy/linux/editcp.sh deploy/linux/install deploy/linux/99-md380.rules
linux: deploy/linux/editcp deploy/linux/editcp.sh deploy/linux/install deploy/linux/99-md380.rules ../dmrRadio/dmrRadio

deploy/linux/editcp: $(SOURCES)
qtdeploy -docker build
Expand All @@ -41,11 +41,14 @@ editcp-$(VERSION).tar.xz: linux
install: linux
cd deploy/linux && ./install .

windows: editcp-$(VERSION)-installer.exe
windows: editcp-$(VERSION)-installer.exe dmrRadio-$(VERSION)-installer.exe

editcp-$(VERSION)-installer.exe: deploy/win32/editcp.exe editcp.nsi dll/*.dll
makensis -DVERSION=$(VERSION) editcp.nsi

dmrRadio-$(VERSION)-installer.exe: ../dmrRadio/dmrRadio.exe editcp.nsi dll/*.dll
makensis -DVERSION=$(VERSION) dmrRadio.nsi

deploy/win32/editcp.exe: $(SOURCES)
qtdeploy -docker build windows_32_static
mkdir -p deploy/win32
Expand All @@ -59,11 +62,12 @@ docker-usb:
cd ../docker/linux-with-usb && \
docker build -t therecipe/qt:linux .

dmrRadio: ../dmrRadio/dmrRadio

../dmrRadio/dmrRadio: $(RADIO_SRCS)
cd ../dmrRadio && go build

../dmrRadio/dmrRadio.exe: $(RADIO_SRCS)
cd ../dmrRadio && GOOS=windows GOARCH=386 go build

dmrRadio: dmrRadio-$(VERSION).tar.xz

dmrRadio-$(VERSION).tar.xz: ../dmrRadio/dmrRadio
Expand All @@ -82,10 +86,11 @@ clobber: clean

# The targets below are probably only useful for me. -Dale Farnsworth

upload: tag editcp-$(VERSION).tar.xz editcp-$(VERSION)-installer.exe dmrRadio-$(VERSION).tar.xz
upload: tag editcp-$(VERSION).tar.xz editcp-$(VERSION)-installer.exe dmrRadio-$(VERSION).tar.xz dmrRadio-$(VERSION)-installer.exe
rsync editcp-$(VERSION).tar.xz farnsworth.org:
rsync editcp-$(VERSION)-installer.exe farnsworth.org:
rsync dmrRadio-$(VERSION).tar.xz farnsworth.org:
rsync dmrRadio-$(VERSION)-installer.exe farnsworth.org:
git push
git push --tags

Expand Down
112 changes: 112 additions & 0 deletions editcp/dmrRadio.nsi
@@ -0,0 +1,112 @@
; dmrRadio.nsi
;
; This script will install dmrRadio-{VERSION}.exe into a directory that
; the user selects; and optionally installs start menu and desktop shortcuts.
;

;--------------------------------

; The name of the installer
Name "dmrRadio"

; The file to write
OutFile "dmrRadio-${VERSION}-installer.exe"

!include "LogicLib.nsh"

Function .onInit
StrCpy $INSTDIR $PROFILE\dmrRadio

ReadRegStr $R0 HKLM \
"Software\Microsoft\Windows\CurrentVersion\Uninstall\dmrRadio" "UninstallString"
StrCmp $R0 "" FinishedUninstallChecks

MessageBox MB_OKCANCEL|MB_ICONEXCLAMATION \
"dmrRadio is already installed. $\n$\nClick `OK` to remove the \
previous version or `Cancel` to cancel this upgrade." \
IDOK uninst
Abort

;Run the uninstaller
uninst:
ClearErrors
ExecWait "$R0 /S"
FinishedUninstallChecks:
FunctionEnd

Section
Setoutpath $INSTDIR
File ..\dmrRadio\dmrRadio.exe
File dll\STDFU.dll
File dll\STTubeDevice30.dll
SectionEnd

; The default installation directory

; Registry key to check for directory (so if you install again, it will
; overwrite the old one automatically)
InstallDirRegKey HKLM "Software\dmrRadio" "Install_Dir"

; Request application privileges for Windows Vista
RequestExecutionLevel admin

;--------------------------------

; Pages

;Page components
Page directory
Page instfiles

UninstPage uninstConfirm
UninstPage instfiles

;--------------------------------

; The stuff to install
Section "dmrRadio (required)"
SectionIn RO

; Set output path to the installation directory.
SetOutPath $INSTDIR

; Write the installation path into the registry
WriteRegStr HKLM SOFTWARE\dmrRadio "Install_Dir" "$INSTDIR"

; Write the uninstall keys for Windows
WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\dmrRadio" "DisplayName" "dmrRadio-${VERSION}"
WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\dmrRadio" "UninstallString" '"$INSTDIR\uninstall.exe"'
WriteRegDWORD HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\dmrRadio" "NoModify" 1
WriteRegDWORD HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\dmrRadio" "NoRepair" 1
WriteUninstaller "uninstall.exe"

; Check if the path entry already exists and write result to $0
nsExec::Exec 'echo %PATH% | find "$PROFILE\dmrRadio"'
Pop $0 ; gets result code

${If} $0 = 0
nsExec::Exec 'setx PATH "%PATH%;$PROFILE\dmrRadio"'
${EndIf}
SectionEnd

;--------------------------------

; Uninstaller
Section "Uninstall"
; Remove registry keys
DeleteRegKey HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\dmrRadio"
DeleteRegKey HKLM SOFTWARE\dmrRadio

; Remove files and uninstaller
Delete "$INSTDIR\dmrRadio.exe"
Delete "$INSTDIR\STDFU.dll"
Delete "$INSTDIR\STTubeDevice30.dll"
Delete "$INSTDIR\uninstall.exe"

; Remove directories used
RMDir "$SMPROGRAMS\dmrRadio"
RMDir "$INSTDIR"

; Remove directory from PATH
nsExec::Exec 'cmd /c "setx PATH %PATH:;$PROFILE\dmrRadio=%"'
SectionEnd

0 comments on commit 2ce64da

Please sign in to comment.