forked from puppetlabs/puppet
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathenvpuppet
executable file
·139 lines (115 loc) · 4.16 KB
/
envpuppet
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
#! /bin/sh
#
# Jeff McCune <[email protected]>
# 2010-10-20
#
# Copyright (c) 2010, Puppet Labs
# License: BSD 3-clause license
#
# This script provides a simple way to execute puppet and related tools
# directly from a git clone of the upstream repositories. This allows you to
# quickly switch branches and test different versions of code without much
# friction.
#
# NOTE: There may be issues if puppet, facter, etc... are already installed
# into RUBY's site_ruby directory. If you run into strange problems, make sure
# the correct ruby libraries are being loaded...
#
# Sample Usage:
# =============
# cd ~/src
# git clone git://github.com/puppetlabs/puppet.git
# git clone git://github.com/puppetlabs/facter.git
# pushd puppet
# git checkout tags/2.6.1
# popd
# pushd facter
# git checkout tags/1.5.8
# export ENVPUPPET_BASEDIR=/home/jeff/src
# envpuppet puppet --version
# 2.6.1
# envpuppet facter --version
# 1.5.8
set -e
set -u
if [ "${1:-}" = "--help" ]; then
cat <<EO_HELP
This command reconfigures the environment once for development.
It is designed to wrap around any other command, specifically puppet
Jeff McCune <[email protected]>
2011-02-09
Puppet should not be installed in site_ruby because all of \$LOAD_PATH
is searched by puppet when loading libraries and the installed version
will taint the development version
The following enviornment variables configure the behavior of envpuppet
ENVPUPPET_BASEDIR=${HOME}/src
the base directory where puppet, facter, etc... live.
ENVPUPPET_BLEEDING=true Enables bleeding edge prototypes like
puppet-interfaces
The PATH and RUBYLIB are the primary environment variables modified by
the envpuppet script.
If no arguments are given, the environment variables are printed to STDOUT
allowing the output to be sourced. For example:
eval \$(envpuppet)
EO_HELP
exit 0
fi
if test -d puppet -o -d facter; then
(
echo " WARNING!"
echo " Strange things happen if puppet or facter are in the"
echo " current working directory"
echo " (import errors from ruby are a prime example)"
echo " WARNING!"
echo ""
echo "I suggest changing to ~ or /tmp or something..."
echo ""
echo "Sleeping 2 seconds."
echo ""
) 1>&2
sleep 2
fi
# Set this to where you check out puppet and facter
: ${ENVPUPPET_BASEDIR:="${HOME}/src"}
# Are we bleeding edge?
: ${ENVPUPPET_BLEEDING:='false'}
# git://github.com/puppetlabs/puppet.git
mypath="${ENVPUPPET_BASEDIR}/puppet/sbin:${ENVPUPPET_BASEDIR}/puppet/bin"
myrubylib="${ENVPUPPET_BASEDIR}/puppet/lib"
# git://github.com/puppetlabs/facter.git
mypath="${mypath}:${ENVPUPPET_BASEDIR}/facter/bin"
myrubylib="${myrubylib}:${ENVPUPPET_BASEDIR}/facter/lib"
# git://github.com/puppetlabs/hiera.git
mypath="${mypath}:${ENVPUPPET_BASEDIR}/hiera/bin"
myrubylib="${myrubylib}:${ENVPUPPET_BASEDIR}/hiera/lib"
if [ "${ENVPUPPET_BLEEDING:-}" = "true" ]; then
# git://github.com/puppetlabs/facter.git
mypath="${mypath}:${ENVPUPPET_BASEDIR}/puppet-interfaces/bin"
myrubylib="${myrubylib}:${ENVPUPPET_BASEDIR}/puppet-interfaces/lib"
fi
# http://github.com/jamtur01/puppet-scaffold.git
mypath="${mypath}:${ENVPUPPET_BASEDIR}/puppet-scaffold/bin"
myrubylib="${myrubylib}:${ENVPUPPET_BASEDIR}/puppet-scaffold/lib"
# http://github.com/puppetlabs/puppet-module-tool.git
# Also known as "pmt" Will become "puppet module"
mypath="${mypath}:${ENVPUPPET_BASEDIR}/puppet-module-tool/bin"
myrubylib="${myrubylib}:${ENVPUPPET_BASEDIR}/puppet-module-tool/lib"
# Use the existing environment, if present.
# Default to no value to prevent unbound variable issues
mypath="${mypath}:${PATH:-}"
myrubylib="${myrubylib}:${RUBYLIB:-}"
export ENVPUPPET_OLD_PATH="${PATH:-}"
export ENVPUPPET_OLD_RUBYLIB="${RUBYLIB:-}"
# Trim any trailing colons from the path list.
export PATH="${mypath%%:}"
export RUBYLIB="${myrubylib%%:}"
if [ $# -eq 0 ]; then
echo "export ENVPUPPET_OLD_PATH='${ENVPUPPET_OLD_PATH}'"
echo "export ENVPUPPET_OLD_RUBYLIB='${ENVPUPPET_OLD_RUBYLIB}'"
echo "export ENVPUPPET_BASEDIR='${ENVPUPPET_BASEDIR}'"
echo "export ENVPUPPET_BLEEDING='${ENVPUPPET_BLEEDING}'"
echo "export PATH='${PATH}'"
echo "export RUBYLIB='${RUBYLIB}'"
else
exec "$@"
fi