blob: edcec4a469e137853d7e682fccb675f74c3a45a2 (
plain) (
blame)
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
|
; NSIS installer script for pyexiv2 0.2.
!include MUI.nsh
!include nsDialogs.nsh
!include LogicLib.nsh
!define PYEXIV2_VERSION "0.2"
Name "pyexiv2 ${PYEXIV2_VERSION}"
OutFile "pyexiv2-${PYEXIV2_VERSION}-setup.exe"
SetCompressor /SOLID lzma
!define MUI_ICON "art\pyexiv2.ico"
!define MUI_UNICON "art\pyexiv2.ico"
; Installer pages
!insertmacro MUI_PAGE_LICENSE "COPYING"
Page custom InstallationOptions InstallationOptionsLeave
!insertmacro MUI_PAGE_INSTFILES
; Uninstaller pages
!insertmacro MUI_UNPAGE_CONFIRM
!insertmacro MUI_UNPAGE_INSTFILES
!insertmacro MUI_LANGUAGE "English"
!define PYTHON_MAJOR "2"
!define PYTHON_MINOR "6"
!define PYTHON_KEY "Software\Python\PythonCore\${PYTHON_MAJOR}.${PYTHON_MINOR}\InstallPath"
!define PYEXIV2_KEY "Software\Microsoft\Windows\CurrentVersion\Uninstall\pyexiv2-${PYEXIV2_VERSION}"
Var python_install_path
Var system_wide
Var user_site
; Function called when finishing initialization of the installer
Function .onInit
; Look for Python system-wide (HKLM)
SetShellVarContext all
ReadRegStr $python_install_path SHCTX ${PYTHON_KEY} ""
StrCmp $python_install_path "" 0 Continue
; Look for Python for the current user (HKCU)
SetShellVarContext current
ReadRegStr $python_install_path SHCTX ${PYTHON_KEY} ""
StrCmp $python_install_path "" 0 Continue
MessageBox MB_OK|MB_ICONSTOP "Unable to locate Python ${PYTHON_MAJOR}.${PYTHON_MINOR}."
Quit
Continue:
StrCpy $system_wide "$python_install_pathLib\site-packages"
StrCpy $user_site "$APPDATA\Python\Python${PYTHON_MAJOR}${PYTHON_MINOR}\site-packages"
FunctionEnd
; Function called when finishing initialization of the uninstaller
Function un.onInit
; Look for pyexiv2 installed system-wide (HKLM)
SetShellVarContext all
ReadRegStr $INSTDIR SHCTX ${PYEXIV2_KEY} "InstallLocation"
StrCmp $INSTDIR "" 0 Continue
; Look for pyexiv2 installed for the current user (HKCU)
SetShellVarContext current
ReadRegStr $INSTDIR SHCTX ${PYEXIV2_KEY} "InstallLocation"
StrCmp $INSTDIR "" 0 Continue
; Cannot find pyexiv2 in the registry, aborting the uninstallation
MessageBox MB_OK|MB_ICONSTOP "Unable to locate $(^Name)."
Quit
Continue:
FunctionEnd
; Custom page initialization for installation options
Function InstallationOptions
!insertmacro MUI_HEADER_TEXT "Installation options" "Choose where to install pyexiv2."
nsDialogs::Create 1018
Var /GLOBAL dialog
Pop $dialog
${If} $dialog == error
Abort
${EndIf}
${NSD_CreateRadioButton} 0 0 100% 24u "System wide ($system_wide)"
Var /GLOBAL rb1
Pop $rb1
${NSD_SetState} $rb1 ${BST_CHECKED}
${NSD_CreateRadioButton} 0 34 100% 24u "User site ($user_site)"
Var /GLOBAL rb2
Pop $rb2
nsDialogs::Show
FunctionEnd
; Custom page on-leave callback
Function InstallationOptionsLeave
${NSD_GetState} $rb1 $0
${If} $0 == ${BST_CHECKED}
; Install pyexiv2 system wide
StrCpy $INSTDIR $system_wide
${Else}
; Install pyexiv2 in the user site directory
StrCpy $INSTDIR $user_site
${EndIf}
FunctionEnd
; Installation section
Section "pyexiv2"
SetOutPath $INSTDIR
File build\libexiv2python.pyd
SetOutPath $INSTDIR\pyexiv2
File src\pyexiv2\__init__.py
File src\pyexiv2\metadata.py
File src\pyexiv2\exif.py
File src\pyexiv2\iptc.py
File src\pyexiv2\xmp.py
File src\pyexiv2\utils.py
; Create the uninstaller and publish it in the registry
!define UNINSTALLER "$INSTDIR\pyexiv2-${PYEXIV2_VERSION}-uninstaller.exe"
WriteUninstaller ${UNINSTALLER}
WriteRegStr SHCTX ${PYEXIV2_KEY} "DisplayName" "pyexiv2 ${PYEXIV2_VERSION}"
WriteRegStr SHCTX ${PYEXIV2_KEY} "DisplayVersion" ${PYEXIV2_VERSION}
WriteRegStr SHCTX ${PYEXIV2_KEY} "DisplayIcon" "$\"${UNINSTALLER}$\""
WriteRegStr SHCTX ${PYEXIV2_KEY} "InstallLocation" $INSTDIR
WriteRegStr SHCTX ${PYEXIV2_KEY} "UninstallString" "$\"${UNINSTALLER}$\""
WriteRegStr SHCTX ${PYEXIV2_KEY} "QuietUninstallString" "$\"${UNINSTALLER}$\" /S"
WriteRegDWORD SHCTX ${PYEXIV2_KEY} "NoModify" 1
WriteRegDWORD SHCTX ${PYEXIV2_KEY} "NoRepair" 1
SectionEnd
; Uninstallation section
Section "Uninstall"
Delete $INSTDIR\libexiv2python.py*
RMDir /r $INSTDIR\pyexiv2
DeleteRegKey SHCTX ${PYEXIV2_KEY}
Delete $INSTDIR\pyexiv2-${PYEXIV2_VERSION}-uninstaller.exe
SectionEnd
|