1;NSIS Modern User Interface
2;Basic Example Script
3
4;--------------------------------
5;Include custom settings if exists
6  !include /NONFATAL "custom.nsh"
7
8;--------------------------------
9;Include version information
10  !include /NONFATAL "generated_scmrev.nsh"
11!ifndef SCMREVISION
12    !define SCMREVISION "2.0.x"
13!endif
14
15;--------------------------------
16;Include Modern UI
17
18  !include "MUI2.nsh"
19  !include "WinVer.nsh"
20
21  !define APPNAME "LibreCAD"
22  !define MUI_ICON "..\..\librecad\res\main\librecad.ico"
23  !define MUI_UNICON "..\..\librecad\res\main\uninstall.ico"
24
25  !define UNINSTKEY "Software\Microsoft\Windows\CurrentVersion\Uninstall\${APPNAME}"
26
27  ; GPL is not an EULA, no need to agree to it.
28  !define MUI_LICENSEPAGE_BUTTON $(^NextBtn)
29  !define MUI_LICENSEPAGE_TEXT_BOTTOM "You are now aware of your rights. Click Next to continue."
30
31;--------------------------------
32;General
33
34  ;Name and file
35  Name "${APPNAME}"
36  OutFile "../../generated/LibreCAD-Installer.exe"
37
38  ;Default installation folder
39  InstallDir "$PROGRAMFILES\LibreCAD"
40
41  ;Get installation folder from registry if available
42  InstallDirRegKey HKCU "Software\LibreCAD" ""
43
44  ;Request application privileges for Windows Vista
45  RequestExecutionLevel admin
46  ;TargetMinimalOS 5.1
47
48;--------------------------------
49;Interface Settings
50
51  !define MUI_ABORTWARNING
52
53;--------------------------------
54;Pages
55
56  !insertmacro MUI_PAGE_LICENSE "../../licenses/gpl-2.0.txt"
57  !insertmacro MUI_PAGE_DIRECTORY
58  !insertmacro MUI_PAGE_INSTFILES
59
60  !insertmacro MUI_UNPAGE_CONFIRM
61  !insertmacro MUI_UNPAGE_INSTFILES
62
63;--------------------------------
64;Languages
65
66  !insertmacro MUI_LANGUAGE "English"
67
68
69
70Function .onInit
71
72  Push $R0
73  Push $R1
74  Push $R2
75
76; get account info into $R2
77  userInfo::getAccountType
78  pop $0
79  StrCpy $R2 $0 5
80
81${If} ${IsWin2000}
82    strCmp $R2 "Admin" lbl_checkok
83    messageBox MB_OK "I am sorry, this installer needs Admin privileges, Please login as an administrator and install the software."
84    Quit
85${EndIf}
86
87${If} ${IsWinXP}
88    strCmp $R2 "Admin" lbl_checkok
89    messageBox MB_OK "I am sorry, this installer needs Admin privileges, Please login as an administrator and install the software."
90    Quit
91${EndIf}
92
93  lbl_checkok:
94  Pop $R2
95  Pop $R1
96  Pop $R0
97
98FunctionEnd
99
100;--- define Qt folders if not already defined in custom-5.3.nsi
101!ifndef Qt_Dir
102    !define Qt_Dir 	"C:\Qt\Qt5.4.0"
103!endif
104!ifndef Qt_Version
105    !define Qt_Version 	"5.4"
106!endif
107!ifndef Mingw_Ver
108    !define Mingw_Ver 	"mingw491_32"
109!endif
110;--- folder contains mingw32-make.exe
111!define MINGW_DIR 	"${Qt_Dir}\Tools\${Mingw_Ver}\bin"
112!define QTCREATOR_DIR 	"${Qt_Dir}\Tools\QtCreator\bin"
113!define QTMINGW_DIR 	"${Qt_Dir}\${Qt_Version}\${Mingw_Ver}"
114;--- folder contains qmake.exe
115!define QMAKE_DIR 	"${QTMINGW_DIR}\bin"
116!define PLUGINS_DIR 	"${QTMINGW_DIR}\plugins"
117!define TRANSLATIONS_DIR	"${QTMINGW_DIR}\translations"
118
119;--------------------------------
120;Installer Sections
121
122Section "Install Section" SecInstall
123  SetOutPath "$INSTDIR"
124  File /r "..\..\windows\*.*"
125  SetOutPath "$INSTDIR\resources\qm"
126  File /NONFATAL "${TRANSLATIONS_DIR}\qt*.qm"
127  SetOutPath "$INSTDIR"
128
129  ;Store installation folder
130  WriteRegStr HKCU "Software\LibreCAD" "" $INSTDIR
131
132  ;Create uninstaller
133  WriteUninstaller "$INSTDIR\Uninstall.exe"
134
135  ; create shortcuts
136  createShortCut "$DESKTOP\LibreCAD.lnk" "$INSTDIR\LibreCAD.exe"
137
138  ; Startmenu shortcuts
139  createDirectory "$SMPROGRAMS\LibreCAD\"
140  createShortCut "$SMPROGRAMS\LibreCAD\LibreCAD.lnk" "$INSTDIR\LibreCAD.exe"
141  createShortCut "$SMPROGRAMS\LibreCAD\Uninstall.lnk" "$INSTDIR\Uninstall.exe"
142
143  ; create add/remove software entries
144  WriteRegStr HKLM "${UNINSTKEY}" "DisplayName" "${APPNAME}"
145  WriteRegStr HKLM "${UNINSTKEY}" "DisplayIcon" "$INSTDIR\LibreCAD.exe"
146  WriteRegStr HKLM "${UNINSTKEY}" "DisplayVersion" "${SCMREVISION}"
147  WriteRegStr HKLM "${UNINSTKEY}" "Publisher" "LibreCAD Team"
148  WriteRegStr HKLM "${UNINSTKEY}" "Version" "2.0"
149  WriteRegStr HKLM "${UNINSTKEY}" "HelpLink" "https://librecad.org/"
150  WriteRegStr HKLM "${UNINSTKEY}" "InstallLocation" "$INSTDIR"
151  WriteRegStr HKLM "${UNINSTKEY}" "URLInfoAbout" "http://librecad.org/"
152  WriteRegStr HKLM "${UNINSTKEY}" "Comments" "LibreCAD - Open Source 2D-CAD"
153  WriteRegStr HKLM "${UNINSTKEY}" "UninstallString" "$INSTDIR\Uninstall.exe"
154  WriteRegDWORD HKLM "${UNINSTKEY}" "VersionMinor" "0"
155  WriteRegDWORD HKLM "${UNINSTKEY}" "VersionMajor" "2"
156  WriteRegDWORD HKLM "${UNINSTKEY}" "NoModify" "1"
157  WriteRegDWORD HKLM "${UNINSTKEY}" "NoRepair" "1"
158
159  ; Open Donate URL
160  Exec "rundll32 url.dll,FileProtocolHandler http://librecad.org/donate.html"
161
162SectionEnd
163
164;--------------------------------
165;Descriptions
166
167  ;Language strings
168  LangString DESC_SecInstall ${LANG_ENGLISH} "A test section."
169
170;--------------------------------
171;Uninstaller Section
172
173Section "Uninstall"
174
175  ;ADD YOUR OWN FILES HERE...
176
177  Delete "$INSTDIR\Uninstall.exe"
178  Delete "$DESKTOP\LibreCAD.lnk"
179  RMDir /r "$SMPROGRAMS\LibreCAD\"
180  RMDir /r $INSTDIR
181
182  RMDir "$INSTDIR"
183
184  DeleteRegKey /ifempty HKCU "Software\LibreCAD"
185  DeleteRegKey HKLM "${UNINSTKEY}"
186
187SectionEnd
188
189
190