-
Notifications
You must be signed in to change notification settings - Fork 4
/
pdfjumbler.nsi
154 lines (118 loc) · 8.65 KB
/
pdfjumbler.nsi
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; IMPORTANT: ;;
;; Build fat jars of the plugins (or use gradle)! ;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
!include "MUI2.nsh"
Name "PdfJumbler"
OutFile "build\setup-pdfjumbler.exe"
Unicode true
InstallDir "$LOCALAPPDATA\PdfJumbler"
InstallDirRegKey HKCU "Software\PdfJumbler" ""
CRCCheck on
RequestExecutionLevel user
Var StartMenuFolder
!define MUI_CUSTOMFUNCTION_GUIINIT jreGuiInit
!define MUI_ABORTWARNING
!insertmacro MUI_PAGE_LICENSE "LICENSE"
!insertmacro MUI_PAGE_DIRECTORY
!define MUI_STARTMENUPAGE_REGISTRY_ROOT "HKCU"
!define MUI_STARTMENUPAGE_REGISTRY_KEY "Software\PdfJumbler"
!define MUI_STARTMENUPAGE_REGISTRY_VALUENAME "Start Menu Folder"
!insertmacro MUI_PAGE_STARTMENU Application $StartMenuFolder
!insertmacro MUI_PAGE_INSTFILES
!insertmacro MUI_UNPAGE_CONFIRM
!insertmacro MUI_UNPAGE_INSTFILES
!insertmacro MUI_LANGUAGE "English"
!insertmacro MUI_LANGUAGE "German"
!insertmacro MUI_LANGUAGE "Spanish"
LangString INSTALL_JAVA_QUESTION ${LANG_ENGLISH} "No Java Runtime Environment Found. Download?"
LangString INSTALL_JAVA_QUESTION ${LANG_GERMAN} "Kein Java-Runtime-Environment gefunden. Herunterladen?"
LangString INSTALL_JAVA_QUESTION ${LANG_SPANISH} "No se encontró ningún entorno de ejecución Java. ¿Descargar?"
Function .onInit
StrCpy $Language ${LANG_ENGLISH}
!insertmacro MUI_LANGDLL_DISPLAY
FunctionEnd
Function jreGuiInit
Var /GLOBAL JavaExecutable
Push $R0
Call GetJRE
Pop $R0
StrCpy $JavaExecutable $R0
Pop $R0
FunctionEnd
Section "PdfJumbler Main" PdfJumblerMain
SetOutPath "$INSTDIR"
File "build\libs\pdfjumbler.jar"
File "src\main\resources\icons\pdfjumbler.ico"
File /oname=license.txt "LICENSE"
;File "build\libs\pdfjumbler-itext.jar"
;File "build\libs\pdfjumbler-jpedal.jar"
;File "build\libs\pdfjumbler-pdfbox.jar"
;File "build\libs\pdfjumbler-jpod.jar"
File /oname=readme.txt "README.md"
WriteRegStr HKCU "Software\PdfJumbler" "" $INSTDIR
;Create uninstaller
WriteUninstaller "$INSTDIR\Uninstall.exe"
!insertmacro MUI_STARTMENU_WRITE_BEGIN Application
;Create shortcuts
CreateDirectory "$SMPROGRAMS\$StartMenuFolder"
CreateShortCut "$SMPROGRAMS\$StartMenuFolder\PdfJumbler.lnk" "$JavaExecutable" '-jar "$INSTDIR\pdfjumbler.jar"' "$INSTDIR\pdfjumbler.ico"
CreateShortCut "$SMPROGRAMS\$StartMenuFolder\Uninstall PdfJumbler.lnk" "$INSTDIR\Uninstall.exe"
CreateShortCut "$SMPROGRAMS\$StartMenuFolder\readme.txt.lnk" "$INSTDIR\readme.txt"
!insertmacro MUI_STARTMENU_WRITE_END
SectionEnd
Section "Uninstall"
Delete "$INSTDIR\pdfjumbler.jar"
Delete "$INSTDIR\pdfjumbler.ico"
Delete "$INSTDIR\LICENSE.txt"
;Delete "$INSTDIR\pdfjumbler-itext.jar"
;Delete "$INSTDIR\pdfjumbler-jpedal.jar"
;Delete "$INSTDIR\pdfjumbler-pdfbox.jar"
;Delete "$INSTDIR\pdfjumbler-jpod.jar"
Delete "$INSTDIR\readme.txt"
Delete "$INSTDIR\Uninstall.exe"
RMDir "$INSTDIR"
!insertmacro MUI_STARTMENU_GETFOLDER Application $StartMenuFolder
Delete "$SMPROGRAMS\$StartMenuFolder\readme.txt.lnk"
Delete "$SMPROGRAMS\$StartMenuFolder\Uninstall PdfJumbler.lnk"
Delete "$SMPROGRAMS\$StartMenuFolder\PdfJumbler.lnk"
RMDir "$SMPROGRAMS\$StartMenuFolder"
DeleteRegKey /ifempty HKCU "Software\PdfJumbler"
SectionEnd
Function GetJRE
; returns the full path of a valid java.exe
; looks in:
; 1 - .\jre directory (JRE Installed with application)
; 2 - JAVA_HOME environment variable
; 3 - the registry
; 4 - hopes it is in current dir or PATH
Push $R0
Push $R1
!define JAVAEXE "javaw.exe"
ClearErrors
StrCpy $R0 "$EXEDIR\jre\bin\${JAVAEXE}"
IfFileExists $R0 JreFound ;; 1) found it locally
StrCpy $R0 ""
ClearErrors
ReadEnvStr $R0 "JAVA_HOME"
StrCpy $R0 "$R0\bin\${JAVAEXE}"
IfErrors 0 JreFound ;; 2) found it in JAVA_HOME
ClearErrors
ReadRegStr $R1 HKLM "SOFTWARE\JavaSoft\Java Runtime Environment" "CurrentVersion"
ReadRegStr $R0 HKLM "SOFTWARE\JavaSoft\Java Runtime Environment\$R1" "JavaHome"
StrCpy $R0 "$R0\bin\${JAVAEXE}"
IfErrors 0 JreFound ;; 3) found it in the registry
MessageBox MB_YESNOCANCEL $(INSTALL_JAVA_QUESTION) IDYES Download IDCANCEL GiveUp
StrCpy $R0 "${JAVAEXE}" ;; 4) wishing you good luck
goto JreFound
Download:
ExecShell "open" "https://adoptopenjdk.net"
GiveUp:
Abort
JreFound:
Pop $R1
Exch $R0
FunctionEnd
Function un.onInit
!insertmacro MUI_UNGETLANGUAGE
FunctionEnd