puppet 0.9.2
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of puppet might be problematic. Click here for more details.
- data/CHANGELOG +0 -0
- data/COPYING +340 -0
- data/LICENSE +17 -0
- data/README +24 -0
- data/Rakefile +294 -0
- data/TODO +4 -0
- data/bin/cf2puppet +186 -0
- data/bin/puppet +176 -0
- data/bin/puppetca +213 -0
- data/bin/puppetd +246 -0
- data/bin/puppetdoc +184 -0
- data/bin/puppetmasterd +258 -0
- data/examples/code/allatonce +13 -0
- data/examples/code/assignments +11 -0
- data/examples/code/classing +35 -0
- data/examples/code/components +73 -0
- data/examples/code/execs +16 -0
- data/examples/code/failers/badclassnoparam +10 -0
- data/examples/code/failers/badclassparam +10 -0
- data/examples/code/failers/badcompnoparam +9 -0
- data/examples/code/failers/badcompparam +9 -0
- data/examples/code/failers/badtypeparam +3 -0
- data/examples/code/file.bl +11 -0
- data/examples/code/filedefaults +10 -0
- data/examples/code/fileparsing +116 -0
- data/examples/code/filerecursion +15 -0
- data/examples/code/functions +3 -0
- data/examples/code/groups +7 -0
- data/examples/code/head +30 -0
- data/examples/code/importing +8 -0
- data/examples/code/nodes +20 -0
- data/examples/code/one +8 -0
- data/examples/code/relationships +34 -0
- data/examples/code/selectors +28 -0
- data/examples/code/simpletests +11 -0
- data/examples/code/snippets/argumentdefaults +14 -0
- data/examples/code/snippets/casestatement +39 -0
- data/examples/code/snippets/classheirarchy.pp +15 -0
- data/examples/code/snippets/classincludes.pp +17 -0
- data/examples/code/snippets/classpathtest +11 -0
- data/examples/code/snippets/dirchmod +19 -0
- data/examples/code/snippets/failmissingexecpath.pp +13 -0
- data/examples/code/snippets/falsevalues.pp +3 -0
- data/examples/code/snippets/filecreate +11 -0
- data/examples/code/snippets/implicititeration +15 -0
- data/examples/code/snippets/multipleinstances +7 -0
- data/examples/code/snippets/namevartest +9 -0
- data/examples/code/snippets/scopetest +13 -0
- data/examples/code/snippets/selectorvalues.pp +22 -0
- data/examples/code/snippets/simpledefaults +5 -0
- data/examples/code/snippets/simpleselector +38 -0
- data/examples/code/svncommit +13 -0
- data/examples/root/bin/sleeper +69 -0
- data/examples/root/etc/configfile +0 -0
- data/examples/root/etc/debian-passwd +29 -0
- data/examples/root/etc/debian-syslog.conf +71 -0
- data/examples/root/etc/init.d/sleeper +65 -0
- data/examples/root/etc/otherfile +0 -0
- data/examples/root/etc/puppet/fileserver.conf +3 -0
- data/examples/root/etc/puppet/puppetmasterd.conf +10 -0
- data/ext/module:puppet +195 -0
- data/install.rb +270 -0
- data/lib/puppet.rb +249 -0
- data/lib/puppet/base64.rb +19 -0
- data/lib/puppet/client.rb +519 -0
- data/lib/puppet/config.rb +49 -0
- data/lib/puppet/daemon.rb +208 -0
- data/lib/puppet/element.rb +71 -0
- data/lib/puppet/event.rb +259 -0
- data/lib/puppet/log.rb +321 -0
- data/lib/puppet/metric.rb +250 -0
- data/lib/puppet/parsedfile.rb +38 -0
- data/lib/puppet/parser/ast.rb +1560 -0
- data/lib/puppet/parser/interpreter.rb +150 -0
- data/lib/puppet/parser/lexer.rb +226 -0
- data/lib/puppet/parser/parser.rb +1354 -0
- data/lib/puppet/parser/scope.rb +755 -0
- data/lib/puppet/server.rb +170 -0
- data/lib/puppet/server/authstore.rb +227 -0
- data/lib/puppet/server/ca.rb +140 -0
- data/lib/puppet/server/filebucket.rb +147 -0
- data/lib/puppet/server/fileserver.rb +477 -0
- data/lib/puppet/server/logger.rb +43 -0
- data/lib/puppet/server/master.rb +103 -0
- data/lib/puppet/server/servlet.rb +247 -0
- data/lib/puppet/sslcertificates.rb +737 -0
- data/lib/puppet/statechange.rb +150 -0
- data/lib/puppet/storage.rb +95 -0
- data/lib/puppet/transaction.rb +179 -0
- data/lib/puppet/transportable.rb +151 -0
- data/lib/puppet/type.rb +1354 -0
- data/lib/puppet/type/component.rb +141 -0
- data/lib/puppet/type/cron.rb +543 -0
- data/lib/puppet/type/exec.rb +316 -0
- data/lib/puppet/type/group.rb +152 -0
- data/lib/puppet/type/nameservice.rb +3 -0
- data/lib/puppet/type/nameservice/netinfo.rb +173 -0
- data/lib/puppet/type/nameservice/objectadd.rb +146 -0
- data/lib/puppet/type/nameservice/posix.rb +200 -0
- data/lib/puppet/type/package.rb +420 -0
- data/lib/puppet/type/package/apt.rb +70 -0
- data/lib/puppet/type/package/dpkg.rb +108 -0
- data/lib/puppet/type/package/rpm.rb +81 -0
- data/lib/puppet/type/package/sun.rb +117 -0
- data/lib/puppet/type/package/yum.rb +58 -0
- data/lib/puppet/type/pfile.rb +569 -0
- data/lib/puppet/type/pfile/checksum.rb +219 -0
- data/lib/puppet/type/pfile/create.rb +108 -0
- data/lib/puppet/type/pfile/group.rb +129 -0
- data/lib/puppet/type/pfile/mode.rb +131 -0
- data/lib/puppet/type/pfile/source.rb +264 -0
- data/lib/puppet/type/pfile/type.rb +31 -0
- data/lib/puppet/type/pfile/uid.rb +166 -0
- data/lib/puppet/type/pfilebucket.rb +80 -0
- data/lib/puppet/type/pprocess.rb +97 -0
- data/lib/puppet/type/service.rb +347 -0
- data/lib/puppet/type/service/base.rb +17 -0
- data/lib/puppet/type/service/debian.rb +50 -0
- data/lib/puppet/type/service/init.rb +145 -0
- data/lib/puppet/type/service/smf.rb +29 -0
- data/lib/puppet/type/state.rb +182 -0
- data/lib/puppet/type/symlink.rb +183 -0
- data/lib/puppet/type/tidy.rb +183 -0
- data/lib/puppet/type/typegen.rb +149 -0
- data/lib/puppet/type/typegen/filerecord.rb +243 -0
- data/lib/puppet/type/typegen/filetype.rb +316 -0
- data/lib/puppet/type/user.rb +290 -0
- data/lib/puppet/util.rb +138 -0
- data/test/certmgr/certmgr.rb +265 -0
- data/test/client/client.rb +203 -0
- data/test/executables/puppetbin.rb +53 -0
- data/test/executables/puppetca.rb +79 -0
- data/test/executables/puppetd.rb +71 -0
- data/test/executables/puppetmasterd.rb +153 -0
- data/test/executables/puppetmodule.rb +60 -0
- data/test/language/ast.rb +412 -0
- data/test/language/interpreter.rb +71 -0
- data/test/language/scope.rb +412 -0
- data/test/language/snippets.rb +445 -0
- data/test/other/events.rb +111 -0
- data/test/other/log.rb +195 -0
- data/test/other/metrics.rb +92 -0
- data/test/other/overrides.rb +115 -0
- data/test/other/parsedfile.rb +31 -0
- data/test/other/relationships.rb +113 -0
- data/test/other/state.rb +106 -0
- data/test/other/storage.rb +39 -0
- data/test/other/transactions.rb +235 -0
- data/test/parser/lexer.rb +120 -0
- data/test/parser/parser.rb +180 -0
- data/test/puppet/conffiles.rb +104 -0
- data/test/puppet/defaults.rb +100 -0
- data/test/puppet/error.rb +23 -0
- data/test/puppet/utiltest.rb +120 -0
- data/test/puppettest.rb +774 -0
- data/test/server/authstore.rb +209 -0
- data/test/server/bucket.rb +227 -0
- data/test/server/ca.rb +201 -0
- data/test/server/fileserver.rb +710 -0
- data/test/server/logger.rb +175 -0
- data/test/server/master.rb +150 -0
- data/test/server/server.rb +130 -0
- data/test/tagging/tagging.rb +80 -0
- data/test/test +51 -0
- data/test/types/basic.rb +119 -0
- data/test/types/component.rb +272 -0
- data/test/types/cron.rb +261 -0
- data/test/types/exec.rb +273 -0
- data/test/types/file.rb +616 -0
- data/test/types/filebucket.rb +167 -0
- data/test/types/fileignoresource.rb +287 -0
- data/test/types/filesources.rb +587 -0
- data/test/types/filetype.rb +162 -0
- data/test/types/group.rb +271 -0
- data/test/types/package.rb +205 -0
- data/test/types/query.rb +101 -0
- data/test/types/service.rb +100 -0
- data/test/types/symlink.rb +93 -0
- data/test/types/tidy.rb +124 -0
- data/test/types/type.rb +135 -0
- data/test/types/user.rb +371 -0
- metadata +243 -0
@@ -0,0 +1,71 @@
|
|
1
|
+
# /etc/syslog.conf Configuration file for syslogd.
|
2
|
+
#
|
3
|
+
# For more information see syslog.conf(5)
|
4
|
+
# manpage.
|
5
|
+
|
6
|
+
#
|
7
|
+
# First some standard logfiles. Log by facility.
|
8
|
+
#
|
9
|
+
|
10
|
+
auth,authpriv.* /var/log/auth.log
|
11
|
+
*.*;auth,authpriv.none -/var/log/syslog
|
12
|
+
#cron.* /var/log/cron.log
|
13
|
+
daemon.* -/var/log/daemon.log
|
14
|
+
kern.* -/var/log/kern.log
|
15
|
+
lpr.* -/var/log/lpr.log
|
16
|
+
mail.* -/var/log/mail.log
|
17
|
+
user.* -/var/log/user.log
|
18
|
+
uucp.* /var/log/uucp.log
|
19
|
+
|
20
|
+
#
|
21
|
+
# Logging for the mail system. Split it up so that
|
22
|
+
# it is easy to write scripts to parse these files.
|
23
|
+
#
|
24
|
+
mail.info -/var/log/mail.info
|
25
|
+
mail.warn -/var/log/mail.warn
|
26
|
+
mail.err /var/log/mail.err
|
27
|
+
|
28
|
+
# Logging for INN news system
|
29
|
+
#
|
30
|
+
news.crit /var/log/news/news.crit
|
31
|
+
news.err /var/log/news/news.err
|
32
|
+
news.notice -/var/log/news/news.notice
|
33
|
+
|
34
|
+
#
|
35
|
+
# Some `catch-all' logfiles.
|
36
|
+
#
|
37
|
+
*.=debug;\
|
38
|
+
auth,authpriv.none;\
|
39
|
+
news.none;mail.none -/var/log/debug
|
40
|
+
*.=info;*.=notice;*.=warn;\
|
41
|
+
auth,authpriv.none;\
|
42
|
+
cron,daemon.none;\
|
43
|
+
mail,news.none -/var/log/messages
|
44
|
+
|
45
|
+
#
|
46
|
+
# Emergencies are sent to everybody logged in.
|
47
|
+
#
|
48
|
+
*.emerg *
|
49
|
+
|
50
|
+
#
|
51
|
+
# I like to have messages displayed on the console, but only on a virtual
|
52
|
+
# console I usually leave idle.
|
53
|
+
#
|
54
|
+
#daemon,mail.*;\
|
55
|
+
# news.=crit;news.=err;news.=notice;\
|
56
|
+
# *.=debug;*.=info;\
|
57
|
+
# *.=notice;*.=warn /dev/tty8
|
58
|
+
|
59
|
+
# The named pipe /dev/xconsole is for the `xconsole' utility. To use it,
|
60
|
+
# you must invoke `xconsole' with the `-file' option:
|
61
|
+
#
|
62
|
+
# $ xconsole -file /dev/xconsole [...]
|
63
|
+
#
|
64
|
+
# NOTE: adjust the list below, or you'll go crazy if you have a reasonably
|
65
|
+
# busy site..
|
66
|
+
#
|
67
|
+
daemon.*;mail.*;\
|
68
|
+
news.crit;news.err;news.notice;\
|
69
|
+
*.=debug;*.=info;\
|
70
|
+
*.=notice;*.=warn |/dev/xconsole
|
71
|
+
|
@@ -0,0 +1,65 @@
|
|
1
|
+
#!/bin/bash
|
2
|
+
|
3
|
+
# $Id: sleeper 576 2005-08-23 16:09:14Z luke $
|
4
|
+
|
5
|
+
script=$0
|
6
|
+
path=`echo $script | sed 's/etc..*/bin/'`
|
7
|
+
|
8
|
+
PATH=$PATH:$path
|
9
|
+
|
10
|
+
ps=`facter ps | cut -d ' ' -f3-`
|
11
|
+
|
12
|
+
if [ -z "$ps" ]; then
|
13
|
+
ps="ps -ef"
|
14
|
+
fi
|
15
|
+
|
16
|
+
function start
|
17
|
+
{
|
18
|
+
sleeper
|
19
|
+
}
|
20
|
+
|
21
|
+
function stop
|
22
|
+
{
|
23
|
+
#if [ -n `which pgrep` ]; then
|
24
|
+
# pid=`pgrep sleeper`
|
25
|
+
#else
|
26
|
+
pid=`$ps | grep -v grep | grep sleeper | grep ruby | awk '{print $2}'`
|
27
|
+
#fi
|
28
|
+
if [ -n "$pid" ]; then
|
29
|
+
kill $pid
|
30
|
+
fi
|
31
|
+
}
|
32
|
+
|
33
|
+
function status
|
34
|
+
{
|
35
|
+
#if [ -n `which pgrep` ]; then
|
36
|
+
# cmd="pgrep sleeper"
|
37
|
+
#else
|
38
|
+
#cmd="$ps | grep -v grep | grep sleeper | grep ruby | awk '{print $2}'"
|
39
|
+
#fi
|
40
|
+
#$cmd
|
41
|
+
$ps | grep -v grep | grep sleeper | grep ruby
|
42
|
+
}
|
43
|
+
|
44
|
+
case "$1" in
|
45
|
+
start)
|
46
|
+
start
|
47
|
+
;;
|
48
|
+
stop)
|
49
|
+
stop
|
50
|
+
;;
|
51
|
+
restart)
|
52
|
+
stop; start
|
53
|
+
;;
|
54
|
+
status)
|
55
|
+
output=`status`
|
56
|
+
#status
|
57
|
+
exit $?
|
58
|
+
;;
|
59
|
+
*)
|
60
|
+
echo "Usage: $N {start|stop|restart|force-reload}" >&2
|
61
|
+
exit 1
|
62
|
+
;;
|
63
|
+
esac
|
64
|
+
|
65
|
+
exit 0
|
File without changes
|
data/ext/module:puppet
ADDED
@@ -0,0 +1,195 @@
|
|
1
|
+
#!/usr/bin/ruby
|
2
|
+
|
3
|
+
#
|
4
|
+
# = Synopsis
|
5
|
+
#
|
6
|
+
# Run a +puppet+ script as a cfengine module.
|
7
|
+
#
|
8
|
+
# = Usage
|
9
|
+
#
|
10
|
+
# puppet [-h|--help] [-V|--version] [-d|--debug] [-v|--verbose]
|
11
|
+
# [-l|--logfile <file>] [-p|--parse-only] <file>
|
12
|
+
# [-c|--confdir <configuration directory>] [--vardir <var directory>]
|
13
|
+
#
|
14
|
+
# = Description
|
15
|
+
#
|
16
|
+
# This is the standalone puppet execution script; use it to execute
|
17
|
+
# individual scripts that you write. If you need to execute site-wide
|
18
|
+
# scripts, use +puppetd+ and +puppetmasterd+.
|
19
|
+
#
|
20
|
+
# = Options
|
21
|
+
#
|
22
|
+
# confdir::
|
23
|
+
# The configuration root directory, where +puppetmasterd+ defaults to looking
|
24
|
+
# for all of its configuration files. Defaults to +/etc/puppet+.
|
25
|
+
#
|
26
|
+
# debug::
|
27
|
+
# Enable full debugging.
|
28
|
+
#
|
29
|
+
# help::
|
30
|
+
# Print this help message
|
31
|
+
#
|
32
|
+
# logfile::
|
33
|
+
# Where to send messages. Choose between syslog, the console, and a log file.
|
34
|
+
# Defaults to sending messages to the console.
|
35
|
+
#
|
36
|
+
# parse-only::
|
37
|
+
# Just verify syntax, do not apply anything.
|
38
|
+
#
|
39
|
+
# vardir::
|
40
|
+
# The variable-size directory, used for storing state. Defaults to
|
41
|
+
# /var/puppet.
|
42
|
+
#
|
43
|
+
# verbose::
|
44
|
+
# Print extra information.
|
45
|
+
#
|
46
|
+
# = Author
|
47
|
+
#
|
48
|
+
# Luke Kanies
|
49
|
+
#
|
50
|
+
# = Copyright
|
51
|
+
#
|
52
|
+
# Copyright (c) 2005 Reductive Labs, LLC
|
53
|
+
# Licensed under the GNU Public License
|
54
|
+
|
55
|
+
require 'puppet'
|
56
|
+
require 'puppet/server'
|
57
|
+
require 'puppet/client'
|
58
|
+
require 'getoptlong'
|
59
|
+
|
60
|
+
$haveusage = true
|
61
|
+
|
62
|
+
begin
|
63
|
+
require 'rdoc/usage'
|
64
|
+
rescue LoadError
|
65
|
+
$haveusage = false
|
66
|
+
end
|
67
|
+
|
68
|
+
result = GetoptLong.new(
|
69
|
+
[ "--confdir", "-c", GetoptLong::REQUIRED_ARGUMENT ],
|
70
|
+
[ "--debug", "-d", GetoptLong::NO_ARGUMENT ],
|
71
|
+
[ "--help", "-h", GetoptLong::NO_ARGUMENT ],
|
72
|
+
[ "--logdest", "-l", GetoptLong::REQUIRED_ARGUMENT ],
|
73
|
+
[ "--verbose", "-v", GetoptLong::NO_ARGUMENT ],
|
74
|
+
[ "--noop", "-n", GetoptLong::NO_ARGUMENT ],
|
75
|
+
[ "--use-nodes", GetoptLong::NO_ARGUMENT ],
|
76
|
+
[ "--parse-only", "-p", GetoptLong::NO_ARGUMENT ],
|
77
|
+
[ "--vardir", GetoptLong::REQUIRED_ARGUMENT ],
|
78
|
+
[ "--version", "-V", GetoptLong::NO_ARGUMENT ]
|
79
|
+
)
|
80
|
+
|
81
|
+
debug = false
|
82
|
+
verbose = false
|
83
|
+
noop = false
|
84
|
+
logfile = false
|
85
|
+
parseonly = false
|
86
|
+
|
87
|
+
master = {
|
88
|
+
:Local => true
|
89
|
+
}
|
90
|
+
|
91
|
+
# We default to a non-console log destination, because we assume this is being
|
92
|
+
# run non-interactively.
|
93
|
+
#Puppet[:logdest] = :console
|
94
|
+
|
95
|
+
begin
|
96
|
+
result.each { |opt,arg|
|
97
|
+
case opt
|
98
|
+
when "--confdir"
|
99
|
+
Puppet[:puppetconf] = arg
|
100
|
+
when "--version"
|
101
|
+
puts "%s" % Puppet.version
|
102
|
+
exit
|
103
|
+
when "--help"
|
104
|
+
if $haveusage
|
105
|
+
RDoc::usage && exit
|
106
|
+
else
|
107
|
+
puts "No help available unless you have RDoc::usage installed"
|
108
|
+
exit
|
109
|
+
end
|
110
|
+
when "--noop"
|
111
|
+
Puppet[:noop] = true
|
112
|
+
when "--use-nodes"
|
113
|
+
master[:UseNodes] = true
|
114
|
+
when "--verbose"
|
115
|
+
verbose = true
|
116
|
+
when "--parse-only"
|
117
|
+
parseonly = true
|
118
|
+
when "--debug"
|
119
|
+
debug = true
|
120
|
+
when "--logdest"
|
121
|
+
begin
|
122
|
+
Puppet[:logdest] = arg
|
123
|
+
rescue => detail
|
124
|
+
$stderr.puts detail.to_s
|
125
|
+
end
|
126
|
+
when "--vardir"
|
127
|
+
Puppet[:puppetvar] = arg
|
128
|
+
end
|
129
|
+
}
|
130
|
+
rescue GetoptLong::InvalidOption => detail
|
131
|
+
$stderr.puts "Try '#{$0} --help'"
|
132
|
+
#if $haveusage
|
133
|
+
# RDoc::usage(1,'usage')
|
134
|
+
#end
|
135
|
+
exit(1)
|
136
|
+
end
|
137
|
+
|
138
|
+
if debug
|
139
|
+
Puppet[:loglevel] = :debug
|
140
|
+
elsif verbose
|
141
|
+
Puppet[:loglevel] = :info
|
142
|
+
end
|
143
|
+
|
144
|
+
unless ARGV.length > 0
|
145
|
+
$stderr.puts "You must pass a script to parse"
|
146
|
+
exit(14)
|
147
|
+
end
|
148
|
+
|
149
|
+
master[:File] = ARGV.shift
|
150
|
+
|
151
|
+
unless ENV.include?("CFALLCLASSES")
|
152
|
+
$stderr.puts "Cfengine classes must be passed to the module"
|
153
|
+
exit(15)
|
154
|
+
end
|
155
|
+
|
156
|
+
master[:UseNodes] = false
|
157
|
+
|
158
|
+
classes = ENV["CFALLCLASSES"].split(":")
|
159
|
+
|
160
|
+
if classes.empty?
|
161
|
+
$stderr.puts "Could not find any cfengine classes"
|
162
|
+
exit(16)
|
163
|
+
end
|
164
|
+
|
165
|
+
master[:Classes] = classes
|
166
|
+
|
167
|
+
begin
|
168
|
+
server = Puppet::Server::Master.new(master)
|
169
|
+
rescue => detail
|
170
|
+
$stderr.puts detail
|
171
|
+
exit(1)
|
172
|
+
end
|
173
|
+
|
174
|
+
begin
|
175
|
+
client = Puppet::Client::MasterClient.new(
|
176
|
+
:Master => server,
|
177
|
+
:Cache => false
|
178
|
+
)
|
179
|
+
rescue => detail
|
180
|
+
$stderr.puts detail
|
181
|
+
exit(1)
|
182
|
+
end
|
183
|
+
|
184
|
+
|
185
|
+
if parseonly
|
186
|
+
exit(0)
|
187
|
+
end
|
188
|
+
|
189
|
+
begin
|
190
|
+
client.getconfig
|
191
|
+
client.apply
|
192
|
+
rescue => detail
|
193
|
+
Puppet.err detail
|
194
|
+
exit(1)
|
195
|
+
end
|
data/install.rb
ADDED
@@ -0,0 +1,270 @@
|
|
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
|
+
# tests/ # unit tests
|
18
|
+
#
|
19
|
+
# The default behaviour:
|
20
|
+
# 1) Run all unit test files (ending in .rb) found in all directories under
|
21
|
+
# tests/.
|
22
|
+
# 2) Build Rdoc documentation from all files in bin/ (excluding .bat and .cmd),
|
23
|
+
# all .rb files in lib/, ./README, ./ChangeLog, and ./Install.
|
24
|
+
# 3) Build ri documentation from all files in bin/ (excluding .bat and .cmd),
|
25
|
+
# and all .rb files in lib/. This is disabled by default on Win32.
|
26
|
+
# 4) Install commands from bin/ into the Ruby bin directory. On Windows, if a
|
27
|
+
# if a corresponding batch file (.bat or .cmd) exists in the bin directory,
|
28
|
+
# it will be copied over as well. Otherwise, a batch file (always .bat) will
|
29
|
+
# be created to run the specified command.
|
30
|
+
# 5) Install all library files ending in .rb from lib/ into Ruby's
|
31
|
+
# site_lib/version directory.
|
32
|
+
#
|
33
|
+
# $Id: install.rb 576 2005-08-23 16:09:14Z luke $
|
34
|
+
#++
|
35
|
+
|
36
|
+
require 'rbconfig'
|
37
|
+
require 'find'
|
38
|
+
require 'fileutils'
|
39
|
+
require 'rdoc/rdoc'
|
40
|
+
require 'optparse'
|
41
|
+
require 'ostruct'
|
42
|
+
|
43
|
+
InstallOptions = OpenStruct.new
|
44
|
+
|
45
|
+
def glob(list)
|
46
|
+
g = list.map { |i| Dir.glob(i) }
|
47
|
+
g.flatten!
|
48
|
+
g.compact!
|
49
|
+
g.reject! { |e| e =~ /\.svn/ }
|
50
|
+
g
|
51
|
+
end
|
52
|
+
|
53
|
+
# Set these values to what you want installed.
|
54
|
+
bins = glob(%w{bin/**/*})
|
55
|
+
rdoc = glob(%w{bin/**/* lib/**/*.rb README README-library CHANGELOG TODO Install}).reject { |e| e=~ /\.(bat|cmd)$/ }
|
56
|
+
ri = glob(%w(bin/**/*.rb lib/**/*.rb)).reject { |e| e=~ /\.(bat|cmd)$/ }
|
57
|
+
libs = glob(%w{lib/**/*.rb})
|
58
|
+
tests = glob(%w{tests/**/*.rb})
|
59
|
+
|
60
|
+
def do_bins(bins, target, strip = 'bin/')
|
61
|
+
bins.each do |bf|
|
62
|
+
obf = bf.gsub(/#{strip}/, '')
|
63
|
+
install_binfile(bf, obf, target)
|
64
|
+
end
|
65
|
+
end
|
66
|
+
|
67
|
+
def do_libs(libs, strip = 'lib/')
|
68
|
+
libs.each do |lf|
|
69
|
+
olf = File.join(InstallOptions.site_dir, lf.gsub(/#{strip}/, ''))
|
70
|
+
op = File.dirname(olf)
|
71
|
+
File.makedirs(op, true)
|
72
|
+
File.chmod(0755, op)
|
73
|
+
File.install(lf, olf, 0755, true)
|
74
|
+
end
|
75
|
+
end
|
76
|
+
|
77
|
+
##
|
78
|
+
# Prepare the file installation.
|
79
|
+
#
|
80
|
+
def prepare_installation
|
81
|
+
InstallOptions.rdoc = true
|
82
|
+
if RUBY_PLATFORM == "i386-mswin32"
|
83
|
+
InstallOptions.ri = false
|
84
|
+
else
|
85
|
+
InstallOptions.ri = true
|
86
|
+
end
|
87
|
+
InstallOptions.tests = true
|
88
|
+
|
89
|
+
ARGV.options do |opts|
|
90
|
+
opts.banner = "Usage: #{File.basename($0)} [options]"
|
91
|
+
opts.separator ""
|
92
|
+
opts.on('--[no-]rdoc', 'Prevents the creation of RDoc output.', 'Default on.') do |onrdoc|
|
93
|
+
InstallOptions.rdoc = onrdoc
|
94
|
+
end
|
95
|
+
opts.on('--[no-]ri', 'Prevents the creation of RI output.', 'Default off on mswin32.') do |onri|
|
96
|
+
InstallOptions.ri = onri
|
97
|
+
end
|
98
|
+
opts.on('--[no-]tests', 'Prevents the execution of unit tests.', 'Default on.') do |ontest|
|
99
|
+
InstallOptions.tests = ontest
|
100
|
+
end
|
101
|
+
opts.on('--quick', 'Performs a quick installation. Only the', 'installation is done.') do |quick|
|
102
|
+
InstallOptions.rdoc = false
|
103
|
+
InstallOptions.ri = false
|
104
|
+
InstallOptions.tests = false
|
105
|
+
end
|
106
|
+
opts.on('--full', 'Performs a full installation. All', 'optional installation steps are run.') do |full|
|
107
|
+
InstallOptions.rdoc = true
|
108
|
+
InstallOptions.ri = true
|
109
|
+
InstallOptions.tests = true
|
110
|
+
end
|
111
|
+
opts.separator("")
|
112
|
+
opts.on_tail('--help', "Shows this help text.") do
|
113
|
+
$stderr.puts opts
|
114
|
+
exit
|
115
|
+
end
|
116
|
+
|
117
|
+
opts.parse!
|
118
|
+
end
|
119
|
+
|
120
|
+
bds = [".", ENV['TMP'], ENV['TEMP']]
|
121
|
+
|
122
|
+
version = [Config::CONFIG["MAJOR"], Config::CONFIG["MINOR"]].join(".")
|
123
|
+
ld = File.join(Config::CONFIG["libdir"], "ruby", version)
|
124
|
+
|
125
|
+
sd = Config::CONFIG["sitelibdir"]
|
126
|
+
if sd.nil?
|
127
|
+
sd = $:.find { |x| x =~ /site_ruby/ }
|
128
|
+
if sd.nil?
|
129
|
+
sd = File.join(ld, "site_ruby")
|
130
|
+
elsif sd !~ Regexp.quote(version)
|
131
|
+
sd = File.join(sd, version)
|
132
|
+
end
|
133
|
+
end
|
134
|
+
|
135
|
+
if (destdir = ENV['DESTDIR'])
|
136
|
+
bd = "#{destdir}#{Config::CONFIG['bindir']}"
|
137
|
+
sd = "#{destdir}#{sd}"
|
138
|
+
bds << bd
|
139
|
+
|
140
|
+
FileUtils.makedirs(bd)
|
141
|
+
FileUtils.makedirs(sd)
|
142
|
+
else
|
143
|
+
bds << Config::CONFIG['bindir']
|
144
|
+
end
|
145
|
+
|
146
|
+
InstallOptions.bin_dirs = bds.compact
|
147
|
+
InstallOptions.site_dir = sd
|
148
|
+
InstallOptions.bin_dir = bd
|
149
|
+
InstallOptions.lib_dir = ld
|
150
|
+
end
|
151
|
+
|
152
|
+
##
|
153
|
+
# Build the rdoc documentation. Also, try to build the RI documentation.
|
154
|
+
#
|
155
|
+
def build_rdoc(files)
|
156
|
+
r = RDoc::RDoc.new
|
157
|
+
r.document(["--main", "README", "--title", "Puppet -- Site Configuration Management",
|
158
|
+
"--line-numbers"] + files)
|
159
|
+
|
160
|
+
rescue RDoc::RDocError => e
|
161
|
+
$stderr.puts e.message
|
162
|
+
rescue Exception => e
|
163
|
+
$stderr.puts "Couldn't build RDoc documentation\n#{e.message}"
|
164
|
+
end
|
165
|
+
|
166
|
+
def build_ri(files)
|
167
|
+
ri = RDoc::RDoc.new
|
168
|
+
#ri.document (["--ri-site", "--merge"] + files)
|
169
|
+
ri.document(["--ri-site"] + files)
|
170
|
+
rescue RDoc::RDocError => e
|
171
|
+
$stderr.puts e.message
|
172
|
+
rescue Exception => e
|
173
|
+
$stderr.puts "Couldn't build Ri documentation\n#{e.message}"
|
174
|
+
$stderr.puts "Continuing with install..."
|
175
|
+
end
|
176
|
+
|
177
|
+
def run_tests(test_list)
|
178
|
+
begin
|
179
|
+
require 'test/unit/ui/console/testrunner'
|
180
|
+
$:.unshift "lib"
|
181
|
+
test_list.each do |test|
|
182
|
+
next if File.directory?(test)
|
183
|
+
require test
|
184
|
+
end
|
185
|
+
|
186
|
+
tests = []
|
187
|
+
ObjectSpace.each_object { |o| tests << o if o.kind_of?(Class) }
|
188
|
+
tests.delete_if { |o| !o.ancestors.include?(Test::Unit::TestCase) }
|
189
|
+
tests.delete_if { |o| o == Test::Unit::TestCase }
|
190
|
+
|
191
|
+
tests.each { |test| Test::Unit::UI::Console::TestRunner.run(test) }
|
192
|
+
$:.shift
|
193
|
+
rescue LoadError
|
194
|
+
puts "Missing testrunner library; skipping tests"
|
195
|
+
end
|
196
|
+
end
|
197
|
+
|
198
|
+
##
|
199
|
+
# Install file(s) from ./bin to Config::CONFIG['bindir']. Patch it on the way
|
200
|
+
# to insert a #! line; on a Unix install, the command is named as expected
|
201
|
+
# (e.g., bin/rdoc becomes rdoc); the shebang line handles running it. Under
|
202
|
+
# windows, we add an '.rb' extension and let file associations do their stuff.
|
203
|
+
def install_binfile(from, op_file, target)
|
204
|
+
tmp_dir = nil
|
205
|
+
InstallOptions.bin_dirs.each do |t|
|
206
|
+
if File.directory?(t) and File.writable?(t)
|
207
|
+
tmp_dir = t
|
208
|
+
break
|
209
|
+
end
|
210
|
+
end
|
211
|
+
|
212
|
+
fail "Cannot find a temporary directory" unless tmp_dir
|
213
|
+
tmp_file = File.join(tmp_dir, '_tmp')
|
214
|
+
ruby = File.join(Config::CONFIG['bindir'], Config::CONFIG['ruby_install_name'])
|
215
|
+
|
216
|
+
File.open(from) do |ip|
|
217
|
+
File.open(tmp_file, "w") do |op|
|
218
|
+
ruby = File.join(Config::CONFIG['bindir'], Config::CONFIG['ruby_install_name'])
|
219
|
+
op.puts "#!#{ruby}"
|
220
|
+
op.write ip.read
|
221
|
+
end
|
222
|
+
end
|
223
|
+
|
224
|
+
if Config::CONFIG["target_os"] =~ /win/io
|
225
|
+
installed_wrapper = false
|
226
|
+
|
227
|
+
if File.exists?("#{from}.bat")
|
228
|
+
FileUtils.install("#{from}.bat", File.join(target, "#{op_file}.bat"), :mode => 0755, :verbose => true)
|
229
|
+
installed_wrapper = true
|
230
|
+
end
|
231
|
+
|
232
|
+
if File.exists?("#{from}.cmd")
|
233
|
+
FileUtils.install("#{from}.cmd", File.join(target, "#{op_file}.cmd"), :mode => 0755, :verbose => true)
|
234
|
+
installed_wrapper = true
|
235
|
+
end
|
236
|
+
|
237
|
+
if not installed_wrapper
|
238
|
+
tmp_file2 = File.join(tmp_dir, '_tmp_wrapper')
|
239
|
+
cwn = File.join(Config::CONFIG['bindir'], op_file)
|
240
|
+
cwv = CMD_WRAPPER.gsub('<ruby>', ruby.gsub(%r{/}) { "\\" }).gsub!('<command>', cwn.gsub(%r{/}) { "\\" } )
|
241
|
+
|
242
|
+
File.open(tmp_file2, "wb") { |cw| cw.puts cwv }
|
243
|
+
FileUtils.install(tmp_file2, File.join(target, "#{op_file}.bat"), :mode => 0755, :verbose => true)
|
244
|
+
|
245
|
+
File.unlink(tmp_file2)
|
246
|
+
installed_wrapper = true
|
247
|
+
end
|
248
|
+
end
|
249
|
+
FileUtils.install(tmp_file, File.join(target, op_file), :mode => 0755, :verbose => true)
|
250
|
+
File.unlink(tmp_file)
|
251
|
+
end
|
252
|
+
|
253
|
+
CMD_WRAPPER = <<-EOS
|
254
|
+
@echo off
|
255
|
+
if "%OS%"=="Windows_NT" goto WinNT
|
256
|
+
<ruby> -x "<command>" %1 %2 %3 %4 %5 %6 %7 %8 %9
|
257
|
+
goto done
|
258
|
+
:WinNT
|
259
|
+
<ruby> -x "<command>" %*
|
260
|
+
goto done
|
261
|
+
:done
|
262
|
+
EOS
|
263
|
+
|
264
|
+
prepare_installation
|
265
|
+
|
266
|
+
run_tests(tests) if InstallOptions.tests
|
267
|
+
build_rdoc(rdoc) if InstallOptions.rdoc
|
268
|
+
build_ri(ri) if InstallOptions.ri
|
269
|
+
do_bins(bins, Config::CONFIG['bindir'])
|
270
|
+
do_libs(libs)
|