Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100755 486 lines (437 sloc) 15.972 kb
fc68910 removing dos EOL chars
luke authored
1 #! /usr/bin/env ruby
2 #--
3 # Copyright 2004 Austin Ziegler <ruby-install@halostatue.ca>
4 # Install utility. Based on the original installation script for rdoc by the
5 # Pragmatic Programmers.
6 #
7 # This program is free software. It may be redistributed and/or modified under
8 # the terms of the GPL version 2 (or later) or the Ruby licence.
9 #
10 # Usage
11 # -----
12 # In most cases, if you have a typical project layout, you will need to do
13 # absolutely nothing to make this work for you. This layout is:
14 #
15 # bin/ # executable files -- "commands"
16 # lib/ # the source of the library
17 #
18 # The default behaviour:
806a404 @haus (maint) Remove unused tests bits from install.rb
haus authored
19 # 1) Build Rdoc documentation from all files in bin/ (excluding .bat and .cmd),
fc68910 removing dos EOL chars
luke authored
20 # all .rb files in lib/, ./README, ./ChangeLog, and ./Install.
806a404 @haus (maint) Remove unused tests bits from install.rb
haus authored
21 # 2) Build ri documentation from all files in bin/ (excluding .bat and .cmd),
77f8599 @MarkusQ Code smell: Win32 --> MS_windows
MarkusQ authored
22 # and all .rb files in lib/. This is disabled by default on Microsoft Windows.
806a404 @haus (maint) Remove unused tests bits from install.rb
haus authored
23 # 3) Install commands from bin/ into the Ruby bin directory. On Windows, if a
fc68910 removing dos EOL chars
luke authored
24 # if a corresponding batch file (.bat or .cmd) exists in the bin directory,
25 # it will be copied over as well. Otherwise, a batch file (always .bat) will
26 # be created to run the specified command.
806a404 @haus (maint) Remove unused tests bits from install.rb
haus authored
27 # 4) Install all library files ending in .rb from lib/ into Ruby's
fc68910 removing dos EOL chars
luke authored
28 # site_lib/version directory.
29 #
30 #++
31
32 require 'rbconfig'
33 require 'find'
34 require 'fileutils'
51fa666 @joshcooper (#12363) Use Tempfile to generate temp files
joshcooper authored
35 require 'tempfile'
19e98f9 @jamtur01 Fixed #2608 - install.rb will not run on ruby 1.9.1 due to ftools bei…
jamtur01 authored
36 begin
3180b9d @MarkusQ Code smell: Two space indentation
MarkusQ authored
37 require 'ftools' # apparently on some system ftools doesn't get loaded
38 $haveftools = true
19e98f9 @jamtur01 Fixed #2608 - install.rb will not run on ruby 1.9.1 due to ftools bei…
jamtur01 authored
39 rescue LoadError
3180b9d @MarkusQ Code smell: Two space indentation
MarkusQ authored
40 puts "ftools not found. Using FileUtils instead.."
41 $haveftools = false
19e98f9 @jamtur01 Fixed #2608 - install.rb will not run on ruby 1.9.1 due to ftools bei…
jamtur01 authored
42 end
fc68910 removing dos EOL chars
luke authored
43 require 'optparse'
44 require 'ostruct'
45
46 begin
3180b9d @MarkusQ Code smell: Two space indentation
MarkusQ authored
47 require 'rdoc/rdoc'
48 $haverdoc = true
fc68910 removing dos EOL chars
luke authored
49 rescue LoadError
3180b9d @MarkusQ Code smell: Two space indentation
MarkusQ authored
50 puts "Missing rdoc; skipping documentation"
51 $haverdoc = false
fc68910 removing dos EOL chars
luke authored
52 end
53
8b48219 @MosesMendoza (PUP-530) Make install.rb check for hiera before installing
MosesMendoza authored
54 PREREQS = %w{openssl facter cgi hiera}
a7306e1 @jamtur01 Fixed #1553 - Puppet and Facter cannot both install the plist module …
jamtur01 authored
55 MIN_FACTER_VERSION = 1.5
fc68910 removing dos EOL chars
luke authored
56
57 InstallOptions = OpenStruct.new
58
59 def glob(list)
3180b9d @MarkusQ Code smell: Two space indentation
MarkusQ authored
60 g = list.map { |i| Dir.glob(i) }
61 g.flatten!
62 g.compact!
63 g
fc68910 removing dos EOL chars
luke authored
64 end
65
eee1a9c @nigelkersten (#5424) Ship auth.conf as part of installing from source
nigelkersten authored
66 def do_configs(configs, target, strip = 'conf/')
67 Dir.mkdir(target) unless File.directory? target
68 configs.each do |cf|
69 ocf = File.join(InstallOptions.config_dir, cf.gsub(/#{strip}/, ''))
3e7ebbb @jamtur01 Fixed #6554 - Missing $haveftool if/else conditional in install.rb br…
jamtur01 authored
70 if $haveftools
71 File.install(cf, ocf, 0644, true)
72 else
0cc80ad @tmzullinger Preserve timestamps when installing files
tmzullinger authored
73 FileUtils.install(cf, ocf, {:mode => 0644, :preserve => true, :verbose => true})
3e7ebbb @jamtur01 Fixed #6554 - Missing $haveftool if/else conditional in install.rb br…
jamtur01 authored
74 end
f0625ef @joshcooper (#12392) Created Windows eventlog message resource dll
joshcooper authored
75 end
76
77 if $operatingsystem == 'windows'
f2e8ee0 @MosesMendoza Move all packaging artifacts from conf to ext
MosesMendoza authored
78 src_dll = 'ext/windows/eventlog/puppetres.dll'
f0625ef @joshcooper (#12392) Created Windows eventlog message resource dll
joshcooper authored
79 dst_dll = File.join(InstallOptions.bin_dir, 'puppetres.dll')
80 if $haveftools
81 File.install(src_dll, dst_dll, 0644, true)
82 else
0cc80ad @tmzullinger Preserve timestamps when installing files
tmzullinger authored
83 FileUtils.install(src_dll, dst_dll, {:mode => 0644, :preserve => true, :verbose => true})
f0625ef @joshcooper (#12392) Created Windows eventlog message resource dll
joshcooper authored
84 end
85
86 require 'win32/registry'
87 include Win32::Registry::Constants
88
89 begin
90 Win32::Registry::HKEY_LOCAL_MACHINE.create('SYSTEM\CurrentControlSet\services\eventlog\Application\Puppet', KEY_ALL_ACCESS | 0x0100) do |reg|
91 reg.write_s('EventMessageFile', dst_dll.tr('/', '\\'))
92 reg.write_i('TypesSupported', 0x7)
93 end
94 rescue Win32::Registry::Error => e
95 warn "Failed to create puppet eventlog registry key: #{e}"
96 end
97 end
eee1a9c @nigelkersten (#5424) Ship auth.conf as part of installing from source
nigelkersten authored
98 end
99
4aef0ba Fixing #323 -- puppetd and puppetmasterd are now in sbin; packages st…
luke authored
100 def do_bins(bins, target, strip = 's?bin/')
021359b @nicklewis Fix for #4644: install.rb works properly on Windows
nicklewis authored
101 Dir.mkdir(target) unless File.directory? target
3180b9d @MarkusQ Code smell: Two space indentation
MarkusQ authored
102 bins.each do |bf|
103 obf = bf.gsub(/#{strip}/, '')
104 install_binfile(bf, obf, target)
105 end
fc68910 removing dos EOL chars
luke authored
106 end
107
108 def do_libs(libs, strip = 'lib/')
3180b9d @MarkusQ Code smell: Two space indentation
MarkusQ authored
109 libs.each do |lf|
73d5742 @jjulien (#7911) Simplified libs section of installer
jjulien authored
110 next if File.directory? lf
40f2744 @pcarlisle Fix installation of vendored libs
pcarlisle authored
111 olf = File.join(InstallOptions.site_dir, lf.sub(/^#{strip}/, ''))
3180b9d @MarkusQ Code smell: Two space indentation
MarkusQ authored
112 op = File.dirname(olf)
113 if $haveftools
114 File.makedirs(op, true)
115 File.chmod(0755, op)
116 File.install(lf, olf, 0644, true)
117 else
118 FileUtils.makedirs(op, {:mode => 0755, :verbose => true})
119 FileUtils.chmod(0755, op)
0cc80ad @tmzullinger Preserve timestamps when installing files
tmzullinger authored
120 FileUtils.install(lf, olf, {:mode => 0644, :preserve => true, :verbose => true})
19e98f9 @jamtur01 Fixed #2608 - install.rb will not run on ruby 1.9.1 due to ftools bei…
jamtur01 authored
121 end
3180b9d @MarkusQ Code smell: Two space indentation
MarkusQ authored
122 end
fc68910 removing dos EOL chars
luke authored
123 end
124
5a31959 @jamtur01 Added man pages and man page creation logic to install.rb
jamtur01 authored
125 def do_man(man, strip = 'man/')
3180b9d @MarkusQ Code smell: Two space indentation
MarkusQ authored
126 man.each do |mf|
127 omf = File.join(InstallOptions.man_dir, mf.gsub(/#{strip}/, ''))
128 om = File.dirname(omf)
129 if $haveftools
130 File.makedirs(om, true)
131 File.chmod(0755, om)
132 File.install(mf, omf, 0644, true)
133 else
134 FileUtils.makedirs(om, {:mode => 0755, :verbose => true})
135 FileUtils.chmod(0755, om)
0cc80ad @tmzullinger Preserve timestamps when installing files
tmzullinger authored
136 FileUtils.install(mf, omf, {:mode => 0644, :preserve => true, :verbose => true})
19e98f9 @jamtur01 Fixed #2608 - install.rb will not run on ruby 1.9.1 due to ftools bei…
jamtur01 authored
137 end
3180b9d @MarkusQ Code smell: Two space indentation
MarkusQ authored
138 gzip = %x{which gzip}
139 gzip.chomp!
140 %x{#{gzip} -f #{omf}}
141 end
5a31959 @jamtur01 Added man pages and man page creation logic to install.rb
jamtur01 authored
142 end
143
fc68910 removing dos EOL chars
luke authored
144 # Verify that all of the prereqs are installed
145 def check_prereqs
3180b9d @MarkusQ Code smell: Two space indentation
MarkusQ authored
146 PREREQS.each { |pre|
147 begin
148 require pre
149 if pre == "facter"
150 # to_f isn't quite exact for strings like "1.5.1" but is good
151 # enough for this purpose.
152 facter_version = Facter.version.to_f
153 if facter_version < MIN_FACTER_VERSION
154 puts "Facter version: #{facter_version}; minimum required: #{MIN_FACTER_VERSION}; cannot install"
155 exit -1
fc68910 removing dos EOL chars
luke authored
156 end
3180b9d @MarkusQ Code smell: Two space indentation
MarkusQ authored
157 end
158 rescue LoadError
159 puts "Could not load #{pre}; cannot install"
160 exit -1
161 end
162 }
fc68910 removing dos EOL chars
luke authored
163 end
164
165 ##
166 # Prepare the file installation.
167 #
168 def prepare_installation
ff4fee2 @peterhuene (maint) Replace Facter[].value calls with just Facter.value.
peterhuene authored
169 $operatingsystem = Facter.value :operatingsystem
021359b @nicklewis Fix for #4644: install.rb works properly on Windows
nicklewis authored
170
eee1a9c @nigelkersten (#5424) Ship auth.conf as part of installing from source
nigelkersten authored
171 InstallOptions.configs = true
172
3180b9d @MarkusQ Code smell: Two space indentation
MarkusQ authored
173 # Only try to do docs if we're sure they have rdoc
174 if $haverdoc
175 InstallOptions.rdoc = true
021359b @nicklewis Fix for #4644: install.rb works properly on Windows
nicklewis authored
176 InstallOptions.ri = $operatingsystem != "windows"
3180b9d @MarkusQ Code smell: Two space indentation
MarkusQ authored
177 else
178 InstallOptions.rdoc = false
179 InstallOptions.ri = false
180 end
181
182
183 ARGV.options do |opts|
184 opts.banner = "Usage: #{File.basename($0)} [options]"
185 opts.separator ""
186 opts.on('--[no-]rdoc', 'Prevents the creation of RDoc output.', 'Default on.') do |onrdoc|
187 InstallOptions.rdoc = onrdoc
469c5fe @nigelkersten Feature #1476: Allow specification of --bindir --sbindir --sitelibdir…
nigelkersten authored
188 end
3180b9d @MarkusQ Code smell: Two space indentation
MarkusQ authored
189 opts.on('--[no-]ri', 'Prevents the creation of RI output.', 'Default off on mswin32.') do |onri|
190 InstallOptions.ri = onri
469c5fe @nigelkersten Feature #1476: Allow specification of --bindir --sbindir --sitelibdir…
nigelkersten authored
191 end
fbd859f @haus Warn when using --[no-]tests flags in install.rb
haus authored
192 opts.on('--[no-]tests', 'Prevents the execution of unit tests.', 'Default off.') do |ontest|
3180b9d @MarkusQ Code smell: Two space indentation
MarkusQ authored
193 InstallOptions.tests = ontest
fbd859f @haus Warn when using --[no-]tests flags in install.rb
haus authored
194 warn "The tests flag is no longer functional in Puppet and is deprecated as of Dec 19, 2012. It will be removed in a future version of Puppet."
469c5fe @nigelkersten Feature #1476: Allow specification of --bindir --sbindir --sitelibdir…
nigelkersten authored
195 end
eee1a9c @nigelkersten (#5424) Ship auth.conf as part of installing from source
nigelkersten authored
196 opts.on('--[no-]configs', 'Prevents the installation of config files', 'Default off.') do |ontest|
197 InstallOptions.configs = ontest
198 end
3180b9d @MarkusQ Code smell: Two space indentation
MarkusQ authored
199 opts.on('--destdir[=OPTIONAL]', 'Installation prefix for all targets', 'Default essentially /') do |destdir|
200 InstallOptions.destdir = destdir
fc68910 removing dos EOL chars
luke authored
201 end
80edccb @joshcooper (PUP-3632) Move confdir to /etc/puppetlabs/puppet
joshcooper authored
202 opts.on('--configdir[=OPTIONAL]', 'Installation directory for config files', 'Default /etc/puppetlabs/puppet') do |configdir|
eee1a9c @nigelkersten (#5424) Ship auth.conf as part of installing from source
nigelkersten authored
203 InstallOptions.configdir = configdir
204 end
e825945 @joshcooper (PUP-3632) Install codedir in /etc/puppetlabs/code
joshcooper authored
205 opts.on('--codedir[=OPTIONAL]', 'Installation directory for code files', 'Default /etc/puppetlabs/code') do |codedir|
206 InstallOptions.codedir = codedir
207 end
5c73655 @joshcooper (PUP-3632) Install vardir, rundir, logdir to new locations
joshcooper authored
208 opts.on('--vardir[=OPTIONAL]', 'Installation directory for var files', 'Default /opt/puppetlabs/puppet/cache') do |vardir|
209 InstallOptions.vardir = vardir
210 end
211 opts.on('--rundir[=OPTIONAL]', 'Installation directory for state files', 'Default /var/run/puppetlabs') do |rundir|
212 InstallOptions.rundir = rundir
213 end
f90dfc0 @joshcooper (PUP-4194) Move `logdir` default to /var/log/puppetlabs/puppet
joshcooper authored
214 opts.on('--logdir[=OPTIONAL]', 'Installation directory for log files', 'Default /var/log/puppetlabs/puppet') do |logdir|
5c73655 @joshcooper (PUP-3632) Install vardir, rundir, logdir to new locations
joshcooper authored
215 InstallOptions.logdir = logdir
216 end
0f0fe3d @haus Replace Config::CONFIG with RbConfig::CONFIG
haus authored
217 opts.on('--bindir[=OPTIONAL]', 'Installation directory for binaries', 'overrides RbConfig::CONFIG["bindir"]') do |bindir|
3180b9d @MarkusQ Code smell: Two space indentation
MarkusQ authored
218 InstallOptions.bindir = bindir
fc68910 removing dos EOL chars
luke authored
219 end
be2816d @haus Add --ruby flag to install.rb
haus authored
220 opts.on('--ruby[=OPTIONAL]', 'Ruby interpreter to use with installation', 'overrides ruby used to call install.rb') do |ruby|
221 InstallOptions.ruby = ruby
fc68910 removing dos EOL chars
luke authored
222 end
0f0fe3d @haus Replace Config::CONFIG with RbConfig::CONFIG
haus authored
223 opts.on('--sitelibdir[=OPTIONAL]', 'Installation directory for libraries', 'overrides RbConfig::CONFIG["sitelibdir"]') do |sitelibdir|
3180b9d @MarkusQ Code smell: Two space indentation
MarkusQ authored
224 InstallOptions.sitelibdir = sitelibdir
225 end
0f0fe3d @haus Replace Config::CONFIG with RbConfig::CONFIG
haus authored
226 opts.on('--mandir[=OPTIONAL]', 'Installation directory for man pages', 'overrides RbConfig::CONFIG["mandir"]') do |mandir|
3180b9d @MarkusQ Code smell: Two space indentation
MarkusQ authored
227 InstallOptions.mandir = mandir
228 end
229 opts.on('--quick', 'Performs a quick installation. Only the', 'installation is done.') do |quick|
eee1a9c @nigelkersten (#5424) Ship auth.conf as part of installing from source
nigelkersten authored
230 InstallOptions.rdoc = false
231 InstallOptions.ri = false
232 InstallOptions.configs = true
3180b9d @MarkusQ Code smell: Two space indentation
MarkusQ authored
233 end
234 opts.on('--full', 'Performs a full installation. All', 'optional installation steps are run.') do |full|
eee1a9c @nigelkersten (#5424) Ship auth.conf as part of installing from source
nigelkersten authored
235 InstallOptions.rdoc = true
236 InstallOptions.ri = true
237 InstallOptions.configs = true
3180b9d @MarkusQ Code smell: Two space indentation
MarkusQ authored
238 end
239 opts.separator("")
240 opts.on_tail('--help', "Shows this help text.") do
241 $stderr.puts opts
242 exit
469c5fe @nigelkersten Feature #1476: Allow specification of --bindir --sbindir --sitelibdir…
nigelkersten authored
243 end
9ee56f2 @MarkusQ Code smell: Inconsistent indentation and related formatting issues
MarkusQ authored
244
3180b9d @MarkusQ Code smell: Two space indentation
MarkusQ authored
245 opts.parse!
246 end
247
0f0fe3d @haus Replace Config::CONFIG with RbConfig::CONFIG
haus authored
248 version = [RbConfig::CONFIG["MAJOR"], RbConfig::CONFIG["MINOR"]].join(".")
249 libdir = File.join(RbConfig::CONFIG["libdir"], "ruby", version)
3180b9d @MarkusQ Code smell: Two space indentation
MarkusQ authored
250
0c4dadd @haus Remove sbin references from install.rb
haus authored
251 # Mac OS X 10.5 and higher declare bindir
3180b9d @MarkusQ Code smell: Two space indentation
MarkusQ authored
252 # /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/bin
253 # which is not generally where people expect executables to be installed
254 # These settings are appropriate defaults for all OS X versions.
255 if RUBY_PLATFORM =~ /^universal-darwin[\d\.]+$/
0f0fe3d @haus Replace Config::CONFIG with RbConfig::CONFIG
haus authored
256 RbConfig::CONFIG['bindir'] = "/usr/bin"
3180b9d @MarkusQ Code smell: Two space indentation
MarkusQ authored
257 end
258
2270553 @whopper Revert "(PUP-3632) Update paths and defaults for the unified agent la…
whopper authored
259 if not InstallOptions.configdir.nil?
260 configdir = InstallOptions.configdir
261 elsif $operatingsystem == "windows"
4274e15 @nicklewis (#9174) Provide a helpful error when missing a gem and installing on …
nicklewis authored
262 begin
263 require 'win32/dir'
264 rescue LoadError => e
480f036 @Iristyle (PUP-392) Remove sys-admin gem
Iristyle authored
265 puts "Cannot run on Microsoft Windows without the win32-process, win32-dir & win32-service gems: #{e}"
4274e15 @nicklewis (#9174) Provide a helpful error when missing a gem and installing on …
nicklewis authored
266 exit -1
267 end
088c7ac @joshcooper (#8660) Default config dir to %PROGRAMDATA% on Windows
joshcooper authored
268 configdir = File.join(Dir::COMMON_APPDATA, "PuppetLabs", "puppet", "etc")
eee1a9c @nigelkersten (#5424) Ship auth.conf as part of installing from source
nigelkersten authored
269 else
80edccb @joshcooper (PUP-3632) Move confdir to /etc/puppetlabs/puppet
joshcooper authored
270 configdir = "/etc/puppetlabs/puppet"
eee1a9c @nigelkersten (#5424) Ship auth.conf as part of installing from source
nigelkersten authored
271 end
272
e825945 @joshcooper (PUP-3632) Install codedir in /etc/puppetlabs/code
joshcooper authored
273 if not InstallOptions.codedir.nil?
274 codedir = InstallOptions.codedir
275 elsif $operatingsystem == "windows"
5d41bbf @Iristyle (PUP-4050) Windows changes to codedir / vardir
Iristyle authored
276 codedir = File.join(Dir::COMMON_APPDATA, "PuppetLabs", "code")
e825945 @joshcooper (PUP-3632) Install codedir in /etc/puppetlabs/code
joshcooper authored
277 else
278 codedir = "/etc/puppetlabs/code"
279 end
280
5c73655 @joshcooper (PUP-3632) Install vardir, rundir, logdir to new locations
joshcooper authored
281 if not InstallOptions.vardir.nil?
282 vardir = InstallOptions.vardir
283 elsif $operatingsystem == "windows"
5d41bbf @Iristyle (PUP-4050) Windows changes to codedir / vardir
Iristyle authored
284 vardir = File.join(Dir::COMMON_APPDATA, "PuppetLabs", "puppet", "cache")
5c73655 @joshcooper (PUP-3632) Install vardir, rundir, logdir to new locations
joshcooper authored
285 else
286 vardir = "/opt/puppetlabs/puppet/cache"
287 end
288
289 if not InstallOptions.rundir.nil?
290 rundir = InstallOptions.rundir
291 elsif $operatingsystem == "windows"
292 rundir = File.join(Dir::COMMON_APPDATA, "PuppetLabs", "puppet", "var", "run")
293 else
294 rundir = "/var/run/puppetlabs"
295 end
296
297 if not InstallOptions.logdir.nil?
298 logdir = InstallOptions.logdir
299 elsif $operatingsystem == "windows"
300 logdir = File.join(Dir::COMMON_APPDATA, "PuppetLabs", "puppet", "var", "log")
301 else
f90dfc0 @joshcooper (PUP-4194) Move `logdir` default to /var/log/puppetlabs/puppet
joshcooper authored
302 logdir = "/var/log/puppetlabs/puppet"
5c73655 @joshcooper (PUP-3632) Install vardir, rundir, logdir to new locations
joshcooper authored
303 end
304
3180b9d @MarkusQ Code smell: Two space indentation
MarkusQ authored
305 if not InstallOptions.bindir.nil?
306 bindir = InstallOptions.bindir
307 else
0f0fe3d @haus Replace Config::CONFIG with RbConfig::CONFIG
haus authored
308 bindir = RbConfig::CONFIG['bindir']
3180b9d @MarkusQ Code smell: Two space indentation
MarkusQ authored
309 end
310
311 if not InstallOptions.sitelibdir.nil?
312 sitelibdir = InstallOptions.sitelibdir
313 else
0f0fe3d @haus Replace Config::CONFIG with RbConfig::CONFIG
haus authored
314 sitelibdir = RbConfig::CONFIG["sitelibdir"]
3180b9d @MarkusQ Code smell: Two space indentation
MarkusQ authored
315 if sitelibdir.nil?
316 sitelibdir = $LOAD_PATH.find { |x| x =~ /site_ruby/ }
317 if sitelibdir.nil?
318 sitelibdir = File.join(libdir, "site_ruby")
319 elsif sitelibdir !~ Regexp.quote(version)
320 sitelibdir = File.join(sitelibdir, version)
321 end
322 end
323 end
324
325 if not InstallOptions.mandir.nil?
326 mandir = InstallOptions.mandir
327 else
0f0fe3d @haus Replace Config::CONFIG with RbConfig::CONFIG
haus authored
328 mandir = RbConfig::CONFIG['mandir']
3180b9d @MarkusQ Code smell: Two space indentation
MarkusQ authored
329 end
330
331 # This is the new way forward
f4a0af1 Refactoring duplicate code and logic in prep for DESTDIR deprecation.
Elias Lutfallah authored
332 if not InstallOptions.destdir.nil?
333 destdir = InstallOptions.destdir
3180b9d @MarkusQ Code smell: Two space indentation
MarkusQ authored
334 # To be deprecated once people move over to using --destdir option
328eaa2 @joshcooper (#8660) Fix destdir option on Windows
joshcooper authored
335 elsif not ENV['DESTDIR'].nil?
f4a0af1 Refactoring duplicate code and logic in prep for DESTDIR deprecation.
Elias Lutfallah authored
336 destdir = ENV['DESTDIR']
1b1e803 (5724) Prep for deprecation of DESTDIR
Elias Lutfallah authored
337 warn "DESTDIR is deprecated. Use --destdir instead."
f4a0af1 Refactoring duplicate code and logic in prep for DESTDIR deprecation.
Elias Lutfallah authored
338 else
339 destdir = ''
3180b9d @MarkusQ Code smell: Two space indentation
MarkusQ authored
340 end
341
328eaa2 @joshcooper (#8660) Fix destdir option on Windows
joshcooper authored
342 configdir = join(destdir, configdir)
e825945 @joshcooper (PUP-3632) Install codedir in /etc/puppetlabs/code
joshcooper authored
343 codedir = join(destdir, codedir)
5c73655 @joshcooper (PUP-3632) Install vardir, rundir, logdir to new locations
joshcooper authored
344 vardir = join(destdir, vardir)
345 rundir = join(destdir, rundir)
346 logdir = join(destdir, logdir)
328eaa2 @joshcooper (#8660) Fix destdir option on Windows
joshcooper authored
347 bindir = join(destdir, bindir)
348 mandir = join(destdir, mandir)
349 sitelibdir = join(destdir, sitelibdir)
3180b9d @MarkusQ Code smell: Two space indentation
MarkusQ authored
350
f4a0af1 Refactoring duplicate code and logic in prep for DESTDIR deprecation.
Elias Lutfallah authored
351 FileUtils.makedirs(configdir) if InstallOptions.configs
e825945 @joshcooper (PUP-3632) Install codedir in /etc/puppetlabs/code
joshcooper authored
352 FileUtils.makedirs(codedir)
f4a0af1 Refactoring duplicate code and logic in prep for DESTDIR deprecation.
Elias Lutfallah authored
353 FileUtils.makedirs(bindir)
354 FileUtils.makedirs(mandir)
355 FileUtils.makedirs(sitelibdir)
5c73655 @joshcooper (PUP-3632) Install vardir, rundir, logdir to new locations
joshcooper authored
356 FileUtils.makedirs(vardir)
357 FileUtils.makedirs(rundir)
358 FileUtils.makedirs(logdir)
3180b9d @MarkusQ Code smell: Two space indentation
MarkusQ authored
359
360 InstallOptions.site_dir = sitelibdir
e825945 @joshcooper (PUP-3632) Install codedir in /etc/puppetlabs/code
joshcooper authored
361 InstallOptions.codedir = codedir
eee1a9c @nigelkersten (#5424) Ship auth.conf as part of installing from source
nigelkersten authored
362 InstallOptions.config_dir = configdir
5c73655 @joshcooper (PUP-3632) Install vardir, rundir, logdir to new locations
joshcooper authored
363 InstallOptions.bin_dir = bindir
364 InstallOptions.lib_dir = libdir
365 InstallOptions.man_dir = mandir
366 InstallOptions.var_dir = vardir
367 InstallOptions.run_dir = rundir
368 InstallOptions.log_dir = logdir
fc68910 removing dos EOL chars
luke authored
369 end
370
371 ##
328eaa2 @joshcooper (#8660) Fix destdir option on Windows
joshcooper authored
372 # Join two paths. On Windows, dir must be converted to a relative path,
373 # by stripping the drive letter, but only if the basedir is not empty.
374 #
375 def join(basedir, dir)
376 return "#{basedir}#{dir[2..-1]}" if $operatingsystem == "windows" and basedir.length > 0 and dir.length > 2
377
378 "#{basedir}#{dir}"
379 end
380
381 ##
fc68910 removing dos EOL chars
luke authored
382 # Build the rdoc documentation. Also, try to build the RI documentation.
383 #
384 def build_rdoc(files)
3180b9d @MarkusQ Code smell: Two space indentation
MarkusQ authored
385 return unless $haverdoc
386 begin
387 r = RDoc::RDoc.new
388 r.document(["--main", "README", "--title", "Puppet -- Site Configuration Management", "--line-numbers"] + files)
389 rescue RDoc::RDocError => e
390 $stderr.puts e.message
391 rescue Exception => e
392 $stderr.puts "Couldn't build RDoc documentation\n#{e.message}"
393 end
fc68910 removing dos EOL chars
luke authored
394 end
395
396 def build_ri(files)
3180b9d @MarkusQ Code smell: Two space indentation
MarkusQ authored
397 return unless $haverdoc
398 begin
399 ri = RDoc::RDoc.new
400 #ri.document(["--ri-site", "--merge"] + files)
401 ri.document(["--ri-site"] + files)
402 rescue RDoc::RDocError => e
403 $stderr.puts e.message
404 rescue Exception => e
405 $stderr.puts "Couldn't build Ri documentation\n#{e.message}"
406 $stderr.puts "Continuing with install..."
407 end
fc68910 removing dos EOL chars
luke authored
408 end
409
410 ##
0f0fe3d @haus Replace Config::CONFIG with RbConfig::CONFIG
haus authored
411 # Install file(s) from ./bin to RbConfig::CONFIG['bindir']. Patch it on the way
fc68910 removing dos EOL chars
luke authored
412 # to insert a #! line; on a Unix install, the command is named as expected
413 # (e.g., bin/rdoc becomes rdoc); the shebang line handles running it. Under
414 # windows, we add an '.rb' extension and let file associations do their stuff.
415 def install_binfile(from, op_file, target)
51fa666 @joshcooper (#12363) Use Tempfile to generate temp files
joshcooper authored
416 tmp_file = Tempfile.new('puppet-binfile')
be2816d @haus Add --ruby flag to install.rb
haus authored
417
418 if not InstallOptions.ruby.nil?
419 ruby = InstallOptions.ruby
420 else
421 ruby = File.join(RbConfig::CONFIG['bindir'], RbConfig::CONFIG['ruby_install_name'])
422 end
3180b9d @MarkusQ Code smell: Two space indentation
MarkusQ authored
423
424 File.open(from) do |ip|
51fa666 @joshcooper (#12363) Use Tempfile to generate temp files
joshcooper authored
425 File.open(tmp_file.path, "w") do |op|
3180b9d @MarkusQ Code smell: Two space indentation
MarkusQ authored
426 op.puts "#!#{ruby}"
427 contents = ip.readlines
428 contents.shift if contents[0] =~ /^#!/
429 op.write contents.join
fc68910 removing dos EOL chars
luke authored
430 end
3180b9d @MarkusQ Code smell: Two space indentation
MarkusQ authored
431 end
fc68910 removing dos EOL chars
luke authored
432
021359b @nicklewis Fix for #4644: install.rb works properly on Windows
nicklewis authored
433 if $operatingsystem == "windows"
3180b9d @MarkusQ Code smell: Two space indentation
MarkusQ authored
434 installed_wrapper = false
fc68910 removing dos EOL chars
luke authored
435
3180b9d @MarkusQ Code smell: Two space indentation
MarkusQ authored
436 if File.exists?("#{from}.bat")
0cc80ad @tmzullinger Preserve timestamps when installing files
tmzullinger authored
437 FileUtils.install("#{from}.bat", File.join(target, "#{op_file}.bat"), :mode => 0755, :preserve => true, :verbose => true)
3180b9d @MarkusQ Code smell: Two space indentation
MarkusQ authored
438 installed_wrapper = true
439 end
fc68910 removing dos EOL chars
luke authored
440
3180b9d @MarkusQ Code smell: Two space indentation
MarkusQ authored
441 if File.exists?("#{from}.cmd")
0cc80ad @tmzullinger Preserve timestamps when installing files
tmzullinger authored
442 FileUtils.install("#{from}.cmd", File.join(target, "#{op_file}.cmd"), :mode => 0755, :preserve => true, :verbose => true)
3180b9d @MarkusQ Code smell: Two space indentation
MarkusQ authored
443 installed_wrapper = true
444 end
fc68910 removing dos EOL chars
luke authored
445
3180b9d @MarkusQ Code smell: Two space indentation
MarkusQ authored
446 if not installed_wrapper
51fa666 @joshcooper (#12363) Use Tempfile to generate temp files
joshcooper authored
447 tmp_file2 = Tempfile.new('puppet-wrapper')
220f2ba @joshcooper (#10799) Regexp escaping too much
joshcooper authored
448 cwv = <<-EOS
449 @echo off
7edaed5 @joshcooper (#11847) Don't hard code ruby install paths in Windows batch files
joshcooper authored
450 setlocal
451 set RUBY_BIN=%~dp0
452 set RUBY_BIN=%RUBY_BIN:\\=/%
453 "%RUBY_BIN%ruby.exe" -x "%RUBY_BIN%puppet" %*
220f2ba @joshcooper (#10799) Regexp escaping too much
joshcooper authored
454 EOS
51fa666 @joshcooper (#12363) Use Tempfile to generate temp files
joshcooper authored
455 File.open(tmp_file2.path, "w") { |cw| cw.puts cwv }
0cc80ad @tmzullinger Preserve timestamps when installing files
tmzullinger authored
456 FileUtils.install(tmp_file2.path, File.join(target, "#{op_file}.bat"), :mode => 0755, :preserve => true, :verbose => true)
fc68910 removing dos EOL chars
luke authored
457
51fa666 @joshcooper (#12363) Use Tempfile to generate temp files
joshcooper authored
458 tmp_file2.unlink
3180b9d @MarkusQ Code smell: Two space indentation
MarkusQ authored
459 installed_wrapper = true
fc68910 removing dos EOL chars
luke authored
460 end
3180b9d @MarkusQ Code smell: Two space indentation
MarkusQ authored
461 end
0cc80ad @tmzullinger Preserve timestamps when installing files
tmzullinger authored
462 FileUtils.install(tmp_file.path, File.join(target, op_file), :mode => 0755, :preserve => true, :verbose => true)
51fa666 @joshcooper (#12363) Use Tempfile to generate temp files
joshcooper authored
463 tmp_file.unlink
fc68910 removing dos EOL chars
luke authored
464 end
465
2ca239f @haus (#17853) Allow install.rb to execute from outside of source root
haus authored
466 # Change directory into the puppet root so we don't get the wrong files for install.
467 FileUtils.cd File.dirname(__FILE__) do
468 # Set these values to what you want installed.
ce5bdfc @haus (PUP-3632) Also install puppet.conf in install.rb
haus authored
469 configs = glob(%w{conf/auth.conf conf/puppet.conf})
2ca239f @haus (#17853) Allow install.rb to execute from outside of source root
haus authored
470 bins = glob(%w{bin/*})
09e353e @haus Remove nonexistent files from the rdoc glob
haus authored
471 rdoc = glob(%w{bin/* lib/**/*.rb README* }).reject { |e| e=~ /\.(bat|cmd)$/ }
2ca239f @haus (#17853) Allow install.rb to execute from outside of source root
haus authored
472 ri = glob(%w{bin/*.rb lib/**/*.rb}).reject { |e| e=~ /\.(bat|cmd)$/ }
473 man = glob(%w{man/man[0-9]/*})
73d5742 @jjulien (#7911) Simplified libs section of installer
jjulien authored
474 libs = glob(%w{lib/**/*})
2ca239f @haus (#17853) Allow install.rb to execute from outside of source root
haus authored
475
476 check_prereqs
477 prepare_installation
478
479 #build_rdoc(rdoc) if InstallOptions.rdoc
480 #build_ri(ri) if InstallOptions.ri
481 do_configs(configs, InstallOptions.config_dir) if InstallOptions.configs
482 do_bins(bins, InstallOptions.bin_dir)
483 do_libs(libs)
484 do_man(man) unless $operatingsystem == "windows"
485 end
Something went wrong with that request. Please try again.