1
; Copyright (C) 2010 Olivier Tilloy <olivier@tilloy.net>
3
; This program is free software: you can redistribute it and/or modify
4
; it under the terms of the GNU General Public License as published by
5
; the Free Software Foundation, either version 3 of the License, or
6
; (at your option) any later version.
8
; This program is distributed in the hope that it will be useful,
9
; but WITHOUT ANY WARRANTY; without even the implied warranty of
10
; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11
; GNU General Public License for more details.
13
; You should have received a copy of the GNU General Public License
14
; along with this program. If not, see <http://www.gnu.org/licenses/>.
16
; NSIS installer script for pyexiv2.
19
!include nsDialogs.nsh
22
!define PYEXIV2_VERSION "0.2"
24
Name "pyexiv2 ${PYEXIV2_VERSION}"
25
OutFile "pyexiv2-${PYEXIV2_VERSION}-setup.exe"
26
SetCompressor /SOLID lzma
28
!define MUI_ICON "art\pyexiv2.ico"
29
!define MUI_UNICON "art\pyexiv2.ico"
32
!insertmacro MUI_PAGE_LICENSE "COPYING"
33
Page custom InstallationOptions InstallationOptionsLeave
34
!insertmacro MUI_PAGE_INSTFILES
37
!insertmacro MUI_UNPAGE_CONFIRM
38
!insertmacro MUI_UNPAGE_INSTFILES
40
!insertmacro MUI_LANGUAGE "English"
42
!define PYTHON_MAJOR "2"
43
!define PYTHON_MINOR "6"
44
!define PYTHON_KEY "Software\Python\PythonCore\${PYTHON_MAJOR}.${PYTHON_MINOR}\InstallPath"
45
!define PYEXIV2_KEY "Software\Microsoft\Windows\CurrentVersion\Uninstall\pyexiv2-${PYEXIV2_VERSION}"
47
Var python_install_path
51
; Function called when finishing initialization of the installer
53
; Look for Python system-wide (HKLM)
54
SetShellVarContext all
55
ReadRegStr $python_install_path SHCTX ${PYTHON_KEY} ""
56
StrCmp $python_install_path "" 0 ContinueSystemWide
58
; Look for Python for the current user (HKCU)
59
SetShellVarContext current
60
ReadRegStr $python_install_path SHCTX ${PYTHON_KEY} ""
61
StrCmp $python_install_path "" 0 Continue
63
MessageBox MB_OK|MB_ICONSTOP "Unable to locate Python ${PYTHON_MAJOR}.${PYTHON_MINOR}."
67
; Python was installed for all users
68
; The user needs to be an admin to install pyexiv2
69
userInfo::getAccountType
71
StrCmp $0 "Admin" Continue 0
73
MessageBox MB_OK|MB_ICONSTOP "You need to be an administrator to install $(^Name)."
77
StrCpy $system_wide "$python_install_pathLib\site-packages"
78
StrCpy $user_site "$APPDATA\Python\Python${PYTHON_MAJOR}${PYTHON_MINOR}\site-packages"
81
; Function called when finishing initialization of the uninstaller
83
; Look for pyexiv2 installed system-wide (HKLM)
84
SetShellVarContext all
85
ReadRegStr $INSTDIR SHCTX ${PYEXIV2_KEY} "InstallLocation"
86
StrCmp $INSTDIR "" 0 Continue
88
; Look for pyexiv2 installed for the current user (HKCU)
89
SetShellVarContext current
90
ReadRegStr $INSTDIR SHCTX ${PYEXIV2_KEY} "InstallLocation"
91
StrCmp $INSTDIR "" 0 Continue
93
; Cannot find pyexiv2 in the registry, aborting the uninstallation
94
MessageBox MB_OK|MB_ICONSTOP "Unable to locate $(^Name)."
100
; Custom page initialization for installation options
101
Function InstallationOptions
102
!insertmacro MUI_HEADER_TEXT "Installation options" "Choose where to install pyexiv2."
104
nsDialogs::Create 1018
107
${If} $dialog == error
111
${NSD_CreateRadioButton} 0 0 100% 24u "System wide ($system_wide)"
114
${NSD_SetState} $rb1 ${BST_CHECKED}
116
${NSD_CreateRadioButton} 0 34 100% 24u "User site ($user_site)"
123
; Custom page on-leave callback
124
Function InstallationOptionsLeave
125
${NSD_GetState} $rb1 $0
126
${If} $0 == ${BST_CHECKED}
127
; Install pyexiv2 system wide
128
StrCpy $INSTDIR $system_wide
130
; Install pyexiv2 in the user site directory
131
StrCpy $INSTDIR $user_site
135
; Installation section
138
File build\libexiv2python.pyd
140
SetOutPath $INSTDIR\pyexiv2
141
File src\pyexiv2\__init__.py
142
File src\pyexiv2\metadata.py
143
File src\pyexiv2\exif.py
144
File src\pyexiv2\iptc.py
145
File src\pyexiv2\xmp.py
146
File src\pyexiv2\utils.py
148
; Create the uninstaller and publish it in the registry
149
!define UNINSTALLER "$INSTDIR\pyexiv2-${PYEXIV2_VERSION}-uninstaller.exe"
150
WriteUninstaller ${UNINSTALLER}
151
WriteRegStr SHCTX ${PYEXIV2_KEY} "DisplayName" "pyexiv2 ${PYEXIV2_VERSION}"
152
WriteRegStr SHCTX ${PYEXIV2_KEY} "DisplayVersion" ${PYEXIV2_VERSION}
153
WriteRegStr SHCTX ${PYEXIV2_KEY} "DisplayIcon" "$\"${UNINSTALLER}$\""
154
WriteRegStr SHCTX ${PYEXIV2_KEY} "InstallLocation" $INSTDIR
155
WriteRegStr SHCTX ${PYEXIV2_KEY} "UninstallString" "$\"${UNINSTALLER}$\""
156
WriteRegStr SHCTX ${PYEXIV2_KEY} "QuietUninstallString" "$\"${UNINSTALLER}$\" /S"
157
WriteRegDWORD SHCTX ${PYEXIV2_KEY} "NoModify" 1
158
WriteRegDWORD SHCTX ${PYEXIV2_KEY} "NoRepair" 1
161
; Uninstallation section
163
Delete $INSTDIR\libexiv2python.py*
164
RMDir /r $INSTDIR\pyexiv2
166
DeleteRegKey SHCTX ${PYEXIV2_KEY}
168
Delete $INSTDIR\pyexiv2-${PYEXIV2_VERSION}-uninstaller.exe