This patch add three features to the envpuppet helper script.

First, if --help is passed as the first argument, a helpful message is
printed.

Second, if ENVPUPPET_BLEEDING=true when envpuppet is executed,
additional repositories are enabled.  The only addition at this time is
puppet-interfaces, which heavily modifies the behavior of Puppet itself
and may or may not be desired.

Third, if no arguments are passed to the script, bourne compatible shell
statements are printed to STDOUT which may be directly evaluated in the
current shell.  This is to help people who prefer to directly set
RUBYLIB and PATH in their development workflows, which I've noticed to
be the case for many people.

For example:

    eval $(envpuppet)

Signed-off-by: Jeff McCune <[email protected]>
---
 ext/envpuppet |   57 +++++++++++++++++++++++++++++++++++++++++++++++++++++++--
 1 files changed, 55 insertions(+), 2 deletions(-)

diff --git a/ext/envpuppet b/ext/envpuppet
index d921a19..33e6b39 100755
--- a/ext/envpuppet
+++ b/ext/envpuppet
@@ -11,7 +11,7 @@
 # quickly switch branches and test different versions of code without much
 # friction.
 #
-# NOTE: There may be issues if puppet, facter, etc... are already installed
+# 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...
 #
@@ -34,6 +34,38 @@
 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"
@@ -50,6 +82,8 @@ 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/reductivelabs/puppet.git
 mypath="${ENVPUPPET_BASEDIR}/puppet/sbin:${ENVPUPPET_BASEDIR}/puppet/bin"
@@ -59,6 +93,12 @@ myrubylib="${ENVPUPPET_BASEDIR}/puppet/lib"
 mypath="${mypath}:${ENVPUPPET_BASEDIR}/facter/bin"
 myrubylib="${myrubylib}:${ENVPUPPET_BASEDIR}/facter/lib"
 
+if [[ "${ENVPUPPET_BLEEDING:-}" == "true" ]]; then
+  # git://github.com/reductivelabs/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"
@@ -73,8 +113,21 @@ 
myrubylib="${myrubylib}:${ENVPUPPET_BASEDIR}/puppet-module-tool/lib"
 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%%:}"
 
-exec "$@"
+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
+
-- 
1.7.5

-- 
You received this message because you are subscribed to the Google Groups 
"Puppet Developers" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/puppet-dev?hl=en.

Reply via email to