ViewVC Help
View File | Revision Log | Show Annotations | Download File | View Changeset | Root Listing
root/repos/RubyInstaller/ruby-installer.nsi
Revision: 1094
Committed: 2008-09-26T04:36:42-07:00 (16 years, 8 months ago) by douglas
File size: 4833 byte(s)
Log Message:
Seems to work.

File Contents

# User Rev Content
1 douglas 1092 ; Ruby Installer
2     ;
3     ; Douglas Thrift
4     ;
5     ; $Id$
6    
7 douglas 1094 !ifndef RUBY_VERSION | GEMS_VERSION | BASE
8     !error "RUBY_VERSION, GEMS_VERSION, and BASE must be defined"
9     !endif
10 douglas 1092
11 douglas 1094 InstallDir "C:\ruby"
12     Name "Ruby"
13 douglas 1092 OutFile "ruby-${RUBY_VERSION}-rubygems-${GEMS_VERSION}.exe"
14     SetCompressor /SOLID lzma
15     ShowInstDetails show
16     ShowUninstDetails show
17     XPStyle on
18 douglas 1094
19     !define RUBY "Ruby ${RUBY_VERSION}"
20    
21     !define UNINST_REG "Software\Microsoft\Windows\CurrentVersion\Uninstall\$(^Name)"
22     !define UNINST_EXE "ruby-rubygems-uninst.exe"
23    
24     !include "EnvVarUpdate.nsh"
25     !include "MUI2.nsh"
26    
27     !define MUI_FINISHPAGE_NOAUTOCLOSE
28     !define MUI_UNFINISHPAGE_NOAUTOCLOSE
29    
30     !insertmacro MUI_PAGE_WELCOME
31     !insertmacro MUI_PAGE_LICENSE "ruby\doc\ruby\ruby-${RUBY_VERSION}\COPYING"
32     !insertmacro MUI_PAGE_DIRECTORY
33     !insertmacro MUI_PAGE_INSTFILES
34     !insertmacro MUI_PAGE_FINISH
35    
36     !insertmacro MUI_UNPAGE_WELCOME
37     !insertmacro MUI_UNPAGE_CONFIRM
38     !insertmacro MUI_UNPAGE_INSTFILES
39     !insertmacro MUI_UNPAGE_FINISH
40    
41     !insertmacro MUI_LANGUAGE "English"
42    
43     !include "WordFunc.nsh"
44    
45     !insertmacro WordReplace
46    
47     Section "-Uninstall Previous"
48     SetShellVarContext all
49     SetOutPath "$TEMP"
50     ReadRegStr $0 HKLM "${UNINST_REG}" "UninstallString"
51     ReadRegStr $1 HKLM "${UNINST_REG}" "InstallLocation"
52     IfErrors 0 +2
53     Return
54     ${WordReplace} "$0" '"' '' '{}' $0
55     CopyFiles /SILENT $0 "$TEMP\${UNINST_EXE}"
56     ExecWait '"$TEMP\${UNINST_EXE}" /S _?=$1'
57     Delete "$TEMP\${UNINST_EXE}"
58     SectionEnd
59    
60     Var base
61    
62     Section "$(^Name)"
63     SetOutPath "$INSTDIR"
64     WriteUninstaller "$INSTDIR\${UNINST_EXE}"
65     WriteRegStr HKLM "${UNINST_REG}" "DisplayName" "${RUBY} RubyGems ${GEMS_VERSION}"
66     WriteRegStr HKLM "${UNINST_REG}" "DisplayVersion" "${RUBY_VERSION} ${GEMS_VERSION}"
67     WriteRegStr HKLM "${UNINST_REG}" "InstallLocation" "$INSTDIR"
68     WriteRegStr HKLM "${UNINST_REG}" "Publisher" "Douglas Thrift"
69     WriteRegStr HKLM "${UNINST_REG}" "URLInfoAbout" "http://code.douglasthrift.net/trac/repos/browser/RubyInstaller"
70     WriteRegStr HKLM "${UNINST_REG}" "UninstallString" "$INSTDIR\${UNINST_EXE}"
71     WriteRegDWORD HKLM "${UNINST_REG}" "NoModify" 1
72     WriteRegDWORD HKLM "${UNINST_REG}" "NoRepair" 1
73     File "*.ico"
74     File /r "ruby\*"
75     ${WordReplace} "$INSTDIR" "\" "/" "+" $base
76     Push "$INSTDIR\bin\gem"
77     Call Replace
78     Push "$INSTDIR\bin\gem.bat"
79     Call Replace
80     WriteRegStr HKCR ".rb" "" "Ruby.File"
81     WriteRegStr HKCR ".rbw" "" "Ruby.NoConFile"
82     WriteRegStr HKCR "Ruby.File" "" "Ruby File"
83     WriteRegStr HKCR "Ruby.File\DefaultIcon" "" "$INSTDIR\rubyw.ico,0"
84     WriteRegStr HKCR "Ruby.File\Shell" "" "open"
85     WriteRegStr HKCR "Ruby.File\Shell\open\command" "" '"$INSTDIR\bin\ruby.exe" "%1" %*'
86     WriteRegStr HKCR "Ruby.NoConFile" "" "Ruby File (no console)"
87     WriteRegStr HKCR "Ruby.NoConFile\DefaultIcon" "" "$INSTDIR\rubyw.ico,0"
88     WriteRegStr HKCR "Ruby.NoConFile\Shell" "" "open"
89     WriteRegStr HKCR "Ruby.NoConFile\Shell\open\command" "" '"$INSTDIR\bin\rubyw.exe" "%1" %*'
90     ${EnvVarUpdate} $0 "PATH" "A" "HKLM" "$INSTDIR\bin"
91     ${EnvVarUpdate} $0 "PATHEXT" "A" "HKLM" ".rb"
92     ${EnvVarUpdate} $0 "PATHEXT" "A" "HKLM" ".rbw"
93     ${EnvVarUpdate} $0 "RUBYOPT" "A" "HKLM" "-rubygems"
94     SectionEnd
95    
96     SectionGroup /e "Shortcuts"
97     Section "Start Menu"
98     SetOutPath "$SMPROGRAMS\${RUBY}"
99     CreateShortCut "Ruby Interactive Shell.lnk" "$INSTDIR\bin\irb.bat" "" "$INSTDIR\Ruby.ico" 0
100     WriteINIStr "$SMPROGRAMS\${RUBY}\Why's (Poignant) Guide to Ruby.url" "InternetShortCut" "URL" "http://poignantguide.net/ruby/"
101     DetailPrint "Create shortcut: Why's (Poignant) Guide to Ruby.url"
102     SectionEnd
103     SectionGroupEnd
104    
105     Section "un.^(Name)"
106     RMDir /r /REBOOTOK "$SMPROGRAMS\${RUBY}"
107     RMDir /r /REBOOTOK "$INSTDIR\bin"
108     RMDir /r /REBOOTOK "$INSTDIR\doc"
109     RMDir /r /REBOOTOK "$INSTDIR\lib"
110     RMDir /r /REBOOTOK "$INSTDIR\man"
111     RMDir /r /REBOOTOK "$INSTDIR\share"
112     Delete /REBOOTOK "$INSTDIR\MANIFEST"
113     Delete /REBOOTOK "$INSTDIR\README.1st"
114     Delete /REBOOTOK "$INSTDIR\ruby.ico"
115     Delete /REBOOTOK "$INSTDIR\rubyw.ico"
116     Delete /REBOOTOK "$INSTDIR\${UNINST_EXE}"
117     RMDir /REBOOTOK "$INSTDIR"
118     DeleteRegKey HKLM "${UNINST_REG}"
119     DeleteRegKey HKCR ".rb"
120     DeleteRegKey HKCR ".rbw"
121     DeleteRegKey HKCR "Ruby.File"
122     DeleteRegKey HKCR "Ruby.NoConFile"
123     ${un.EnvVarUpdate} $0 "PATH" "R" "HKLM" "$INSTDIR\bin"
124     ${un.EnvVarUpdate} $0 "PATHEXT" "R" "HKLM" ".rb"
125     ${un.EnvVarUpdate} $0 "PATHEXT" "R" "HKLM" ".rbw"
126     ${un.EnvVarUpdate} $0 "RUBYOPT" "R" "HKLM" "-rubygems"
127     SectionEnd
128    
129     Function Replace
130     Pop $0
131     DetailPrint "Replace: ${BASE}->$base in $0"
132     ClearErrors
133     FileOpen $1 $0 r
134     IfErrors fail
135     FileOpen $2 "$0.new" w
136     IfErrors fail loop
137    
138     fail:
139     Abort
140    
141     loop:
142     FileRead $1 $3
143     IfErrors done
144     ${WordReplace} "$3" "${BASE}" "$base" "+" $3
145     FileWrite $2 $3
146     Goto loop
147    
148     done:
149     FileClose $1
150     FileClose $2
151     Delete $0
152     Rename "$0.new" $0
153     FunctionEnd

Properties

Name Value
svn:keywords Id
svn:mergeinfo