~osomon/pyexiv2/pyexiv2-0.3

« back to all changes in this revision

Viewing changes to win32-installer.nsi

  • Committer: Olivier Tilloy
  • Date: 2010-03-23 16:04:26 UTC
  • mfrom: (279.2.6 cross-compilation)
  • Revision ID: olivier@tilloy.net-20100323160426-mylufzwbm4tzt9tl
Script to cross compile pyexiv2 for Windows on Linux,
and NSIS installer script.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
; Copyright (C) 2010 Olivier Tilloy <olivier@tilloy.net>
 
2
;
 
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.
 
7
;
 
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.
 
12
;
 
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/>.
 
15
 
 
16
; NSIS installer script for pyexiv2.
 
17
 
 
18
!include MUI.nsh
 
19
!include nsDialogs.nsh
 
20
!include LogicLib.nsh
 
21
 
 
22
!define PYEXIV2_VERSION "0.2"
 
23
 
 
24
Name "pyexiv2 ${PYEXIV2_VERSION}"
 
25
OutFile "pyexiv2-${PYEXIV2_VERSION}-setup.exe"
 
26
SetCompressor /SOLID lzma
 
27
 
 
28
!define MUI_ICON "art\pyexiv2.ico"
 
29
!define MUI_UNICON "art\pyexiv2.ico"
 
30
 
 
31
; Installer pages
 
32
!insertmacro MUI_PAGE_LICENSE "COPYING"
 
33
Page custom InstallationOptions InstallationOptionsLeave
 
34
!insertmacro MUI_PAGE_INSTFILES
 
35
 
 
36
; Uninstaller pages
 
37
!insertmacro MUI_UNPAGE_CONFIRM
 
38
!insertmacro MUI_UNPAGE_INSTFILES
 
39
 
 
40
!insertmacro MUI_LANGUAGE "English"
 
41
 
 
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}"
 
46
 
 
47
Var python_install_path
 
48
Var system_wide
 
49
Var user_site
 
50
 
 
51
; Function called when finishing initialization of the installer
 
52
Function .onInit
 
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
 
57
 
 
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
 
62
 
 
63
  MessageBox MB_OK|MB_ICONSTOP "Unable to locate Python ${PYTHON_MAJOR}.${PYTHON_MINOR}."
 
64
  Quit
 
65
 
 
66
  ContinueSystemWide:
 
67
    ; Python was installed for all users
 
68
    ; The user needs to be an admin to install pyexiv2
 
69
    userInfo::getAccountType
 
70
    pop $0
 
71
    StrCmp $0 "Admin" Continue 0
 
72
 
 
73
    MessageBox MB_OK|MB_ICONSTOP "You need to be an administrator to install $(^Name)."
 
74
    Quit
 
75
 
 
76
  Continue:
 
77
    StrCpy $system_wide "$python_install_pathLib\site-packages"
 
78
    StrCpy $user_site "$APPDATA\Python\Python${PYTHON_MAJOR}${PYTHON_MINOR}\site-packages"
 
79
FunctionEnd
 
80
 
 
81
; Function called when finishing initialization of the uninstaller
 
82
Function un.onInit
 
83
  ; Look for pyexiv2 installed system-wide (HKLM)
 
84
  SetShellVarContext all
 
85
  ReadRegStr $INSTDIR SHCTX ${PYEXIV2_KEY} "InstallLocation"
 
86
  StrCmp $INSTDIR "" 0 Continue
 
87
 
 
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
 
92
 
 
93
  ; Cannot find pyexiv2 in the registry, aborting the uninstallation
 
94
  MessageBox MB_OK|MB_ICONSTOP "Unable to locate $(^Name)."
 
95
  Quit
 
96
 
 
97
  Continue:
 
98
FunctionEnd
 
99
 
 
100
; Custom page initialization for installation options
 
101
Function InstallationOptions
 
102
  !insertmacro MUI_HEADER_TEXT "Installation options" "Choose where to install pyexiv2."
 
103
 
 
104
  nsDialogs::Create 1018
 
105
  Var /GLOBAL dialog
 
106
  Pop $dialog
 
107
  ${If} $dialog == error
 
108
    Abort
 
109
  ${EndIf}
 
110
 
 
111
  ${NSD_CreateRadioButton} 0 0 100% 24u "System wide ($system_wide)"
 
112
  Var /GLOBAL rb1
 
113
  Pop $rb1
 
114
  ${NSD_SetState} $rb1 ${BST_CHECKED}
 
115
 
 
116
  ${NSD_CreateRadioButton} 0 34 100% 24u "User site ($user_site)"
 
117
  Var /GLOBAL rb2
 
118
  Pop $rb2
 
119
 
 
120
  nsDialogs::Show
 
121
FunctionEnd
 
122
 
 
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
 
129
  ${Else}
 
130
    ; Install pyexiv2 in the user site directory
 
131
    StrCpy $INSTDIR $user_site
 
132
  ${EndIf}
 
133
FunctionEnd
 
134
 
 
135
; Installation section
 
136
Section "pyexiv2"
 
137
  SetOutPath $INSTDIR
 
138
  File build\libexiv2python.pyd
 
139
 
 
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
 
147
 
 
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
 
159
SectionEnd
 
160
 
 
161
; Uninstallation section
 
162
Section "Uninstall"
 
163
  Delete $INSTDIR\libexiv2python.py*
 
164
  RMDir /r $INSTDIR\pyexiv2
 
165
 
 
166
  DeleteRegKey SHCTX ${PYEXIV2_KEY}
 
167
 
 
168
  Delete $INSTDIR\pyexiv2-${PYEXIV2_VERSION}-uninstaller.exe
 
169
SectionEnd
 
170