/
FreeCAD_x64_WindowsInstaller.nsi
192 lines (158 loc) · 8.31 KB
/
FreeCAD_x64_WindowsInstaller.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
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
# Copyright (c) 2014 Werner Mayer <wmayer[at]users.sourceforge.net>
#
# This file is part of the FreeCAD CAx development system.
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU Library General Public License (LGPL)
# as published by the Free Software Foundation; either version 2 of
# the License, or (at your option) any later version.
# for detail see the LICENCE text file.
#
# FreeCAD is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Library General Public License for more details.
#
# You should have received a copy of the GNU Library General Public
# License along with FreeCAD; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
# USA
#
# Werner Mayer 2014
#http://www.fredshack.com/docs/nsis.html
# include the Version information
!include Version.nsi
!include "MUI2.nsh"
!include "Sections.nsh"
# All the other settings can be tweaked by editing the !defines at the top of this script
!define APPNAME "FreeCAD"
!define PUPNAME "Juergen Riegel"
!define DESCRIPTION "A free open source CAD system"
# These will be displayed by the "Click here for support information" link in "Add/Remove Programs"
# It is possible to use "mailto:" links in here to open the email client
!define HELPURL "http://freecadweb.org" # "Support Information" link
!define UPDATEURL "http://freecadweb.org" # "Product Updates" link
!define ABOUTURL "http://freecadweb.org" # "Publisher" link
# This is the size (in kB) of all the files copied into "Program Files"
!define INSTALLSIZE 200000
!define FULLNAME "${APPNAME} ${VERSIONMAJOR}.${VERSIONMINOR}"
!define INSTNAME "${APPNAME}-${VERSIONMAJOR}.${VERSIONMINOR}"
RequestExecutionLevel admin ;Require admin rights on NT6+ (When UAC is turned on)
InstallDir "$PROGRAMFILES64\${FULLNAME}"
# This will be in the installer/uninstaller's title bar
Name "${FULLNAME}"
#Icon "logo.ico"
outFile "..\..\${INSTNAME}.${VERSIONBUILD}_x64_unstable_setup.exe"
#Interface Settings
!define MUI_ABORTWARNING
#Pages
# rtf or txt file - remember if it is txt, it must be in the DOS text format (\r\n)
!insertmacro MUI_PAGE_LICENSE "License.rtf"
!insertmacro MUI_PAGE_DIRECTORY
!insertmacro MUI_PAGE_COMPONENTS
!insertmacro MUI_PAGE_INSTFILES
!insertmacro MUI_UNPAGE_CONFIRM
!insertmacro MUI_UNPAGE_INSTFILES
#Languages
!insertmacro MUI_LANGUAGE "English"
!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
function .onInit
setShellVarContext all
!insertmacro VerifyUserIsAdmin
Call unSelectPythonPath
functionEnd
section "FreeCAD (Required)"
SectionIn RO
# Files for the install directory - to build the installer, these should be in the same directory as the install script (this file)
setOutPath $INSTDIR\bin
# Files added here should be removed by the uninstaller (see section "uninstall")
file /r /X *.idb /X *.pyc /X *.pyo "..\..\bin\"
setOutPath $INSTDIR\Mod
file /r /X *.idb "..\..\Mod\"
setOutPath $INSTDIR\doc
file /r "..\..\doc\"
setOutPath $INSTDIR\data
file /r /X CMakeFiles /X *.cmake /X *.dir /X *.vcproj /X CMakeLists.txt /X *.am "..\..\data\"
setOutPath $INSTDIR
file "vcredist_x64.exe"
# Install the Visual Studio redistributable
ExecWait '"$INSTDIR\vcredist_x64.exe" /q:a /c:"VCREDI~1.EXE /q:a /c:""msiexec /i vcredist.msi /qb!"" "'
# Uninstaller - See function un.onInit and section "uninstall" for configuration
WriteUninstaller "$INSTDIR\Uninstall.exe"
# Start Menu
CreateDirectory "$SMPROGRAMS\${FULLNAME}"
CreateShortCut "$SMPROGRAMS\${FULLNAME}\${APPNAME}.lnk" "$INSTDIR\bin\FreeCAD.exe" "" ""
CreateShortCut "$SMPROGRAMS\${FULLNAME}\Uninstall.lnk" "$INSTDIR\Uninstall.exe" "" ""
# Access the right location for 64-bit applications
SetRegView 64
# Registry information for add/remove programs
WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${FULLNAME}" "DisplayName" "${FULLNAME} - ${DESCRIPTION}"
WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${FULLNAME}" "UninstallString" "$\"$INSTDIR\uninstall.exe$\""
WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${FULLNAME}" "QuietUninstallString" "$\"$INSTDIR\uninstall.exe$\" /S"
WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${FULLNAME}" "InstallLocation" "$\"$INSTDIR$\""
WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${FULLNAME}" "DisplayIcon" "$\"$INSTDIR\bin\FreeCAD.exe$\""
WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${FULLNAME}" "Publisher" "${PUPNAME}"
WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${FULLNAME}" "HelpLink" "$\"${HELPURL}$\""
WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${FULLNAME}" "URLUpdateInfo" "$\"${UPDATEURL}$\""
WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${FULLNAME}" "URLInfoAbout" "$\"${ABOUTURL}$\""
WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${FULLNAME}" "DisplayVersion" "${VERSIONMAJOR}.${VERSIONMINOR}.${VERSIONBUILD}"
WriteRegDWORD HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${FULLNAME}" "VersionMajor" ${VERSIONMAJOR}
WriteRegDWORD HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${FULLNAME}" "VersionMinor" ${VERSIONMINOR}
# There is no option for modifying or repairing the install
WriteRegDWORD HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${FULLNAME}" "NoModify" 1
WriteRegDWORD HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${FULLNAME}" "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\${FULLNAME}" "EstimatedSize" ${INSTALLSIZE}
sectionEnd
section "Add to PYTHONPATH" PythonPathSection
# Set PYTHONPATH for FreeCAD
WriteRegStr HKLM "Software\Python\PythonCore\2.7\PythonPath\${FULLNAME}" "" "$INSTDIR\bin"
sectionEnd
# http://forums.winamp.com/showthread.php?t=255747
function unSelectPythonPath
# Unselect the PYTHONPATH option
!insertmacro UnselectSection ${PythonPathSection}
functionEnd
LangString DESC_PythonPathSection ${LANG_ENGLISH} "Add the FreeCAD installation directory to PYTHONPATH in the registry."
!insertmacro MUI_FUNCTION_DESCRIPTION_BEGIN
!insertmacro MUI_DESCRIPTION_TEXT ${PythonPathSection} $(DESC_PythonPathSection)
!insertmacro MUI_FUNCTION_DESCRIPTION_END
# 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\${FULLNAME}\${APPNAME}.lnk"
Delete "$SMPROGRAMS\${FULLNAME}\Uninstall.lnk"
# Try to remove the Start Menu folder - this will only happen if it is empty
RMDir "$SMPROGRAMS\${FULLNAME}"
# Remove files
RMDir /r "$INSTDIR\bin"
RMDir /r "$INSTDIR\doc"
RMDir /r "$INSTDIR\data"
RMDir /r "$INSTDIR\Mod"
# Always delete uninstaller as the last action
Delete $INSTDIR\uninstall.exe
Delete $INSTDIR\vcredist_x64.exe
# Try to remove the install directory - this will only happen if it is empty
RMDir $INSTDIR
# Access the right location for 64-bit applications
SetRegView 64
# Remove uninstaller information from the registry
DeleteRegKey HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${FULLNAME}"
DeleteRegKey HKLM "Software\Python\PythonCore\2.7\PythonPath\${FULLNAME}"
sectionEnd