From df88d98ea05565fa64452c9eb7ab816454849e3a Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Fri, 2 Nov 2012 17:35:13 +0100 Subject: [PATCH] many cleanups to __rvm* types Signed-off-by: Nico Schottelius --- cdist/conf/type/__rvm_gem/gencode-remote | 7 ++-- cdist/conf/type/__rvm_gemset/explorer/state | 6 ++-- cdist/conf/type/__rvm_gemset/gencode-remote | 37 ++++++++++----------- docs/changelog | 2 +- 4 files changed, 25 insertions(+), 27 deletions(-) diff --git a/cdist/conf/type/__rvm_gem/gencode-remote b/cdist/conf/type/__rvm_gem/gencode-remote index 3aef45ef..1fe6e78e 100755 --- a/cdist/conf/type/__rvm_gem/gencode-remote +++ b/cdist/conf/type/__rvm_gem/gencode-remote @@ -1,5 +1,4 @@ -#!/bin/sh -# +#!/bin/sh # # 2012 Evax Software # 2012 Nico Schottelius (nico-cdist at schottelius.org) # @@ -32,12 +31,12 @@ state_should="$(cat "$__object/parameter/state")" case "$state_should" in present) cat << DONE -su - "$user" -c "source \"\\\$HOME/.rvm/scripts/rvm; rvm use $gemset; gem install $gem"\" +su - "$user" -c 'source ~/.rvm/scripts/rvm; rvm use "$gemset"; gem install "$gem"' DONE ;; absent) cat << DONE -su - "$user" -c "source \"\\\$HOME/.rvm/scripts/rvm; rvm use $gemset; gem uninstall $gem"\" +su - "$user" -c 'source ~/.rvm/scripts/rvm; rvm use "$gemset"; gem uninstall "$gem"' DONE ;; esac diff --git a/cdist/conf/type/__rvm_gemset/explorer/state b/cdist/conf/type/__rvm_gemset/explorer/state index fbf11830..c8d573b5 100755 --- a/cdist/conf/type/__rvm_gemset/explorer/state +++ b/cdist/conf/type/__rvm_gemset/explorer/state @@ -22,13 +22,13 @@ gemset="$__object_id" ruby="$(echo "$gemset" | cut -d '@' -f 1)" gemsetname="$(echo "$gemset" | cut -d '@' -f2)" user="$(cat "$__object/parameter/user")" -if su - "$user" -c "[ ! -d \"\$HOME/.rvm\" ]" ; then +if su - "$user" -c "[ ! -d ~/.rvm ]" ; then echo "absent" exit 0 fi -if su - "$user" -c "source \"\$HOME/.rvm/scripts/rvm\" +if su - "$user" -c "source ~/.rvm/scripts/rvm rvm list | grep -q $ruby"; then - if su - "$user" -c "source \"\$HOME/.rvm/scripts/rvm\" + if su - "$user" -c "source ~/.rvm/scripts/rvm rvm use $ruby > /dev/null; rvm gemset list | grep -q $gemsetname"; then echo "present" exit 0 diff --git a/cdist/conf/type/__rvm_gemset/gencode-remote b/cdist/conf/type/__rvm_gemset/gencode-remote index 1604538d..1fd14061 100755 --- a/cdist/conf/type/__rvm_gemset/gencode-remote +++ b/cdist/conf/type/__rvm_gemset/gencode-remote @@ -1,6 +1,7 @@ #!/bin/sh # # 2012 Evax Software +# 2012 Nico Schottelius (nico-cdist at schottelius.org) # # This file is part of cdist. # @@ -25,29 +26,27 @@ state_is="$(cat "$__object/explorer/state")" user="$(cat "$__object/parameter/user")" default="$(cat "$__object/parameter/default" 2>/dev/null || true)" state_should="$(cat "$__object/parameter/state")" -if [ "$state_is" != "$state_should" ]; then - case "$state_should" in - present) - cat << DONE -su - "$user" -c "source \"\\\$HOME/.rvm/scripts/rvm\" -rvm $gemset --create" + +[ "$state_is" = "$state_should" ] && exit 0 + +case "$state_should" in + present) + cat << DONE +su - "$user" -c "source ~/.rvm/scripts/rvm; rvm $gemset --create" DONE - case "$default" in + case "$default" in no) ;; *) - cat << DONE -su - "$user" -c "source \"\\\$HOME/.rvm/scripts/rvm\" -rvm use --default $gemset" + cat << DONE +su - "$user" -c "source ~/.rvm/scripts/rvm; rvm use --default $gemset" DONE ;; - esac - ;; - absent) - cat << DONE -su - "$user" -c "source \"\\\$HOME/.rvm/scripts/rvm\" -rvm use $ruby; rvm --force gemset delete $gemsetname" + esac + ;; + absent) + cat << DONE +su - "$user" -c "source ~/.rvm/scripts/rvm; rvm use $ruby; rvm --force gemset delete $gemsetname" DONE - ;; - esac -fi + ;; +esac diff --git a/docs/changelog b/docs/changelog index e9423925..b91b01c7 100644 --- a/docs/changelog +++ b/docs/changelog @@ -9,7 +9,7 @@ Changelog * Core: Export PYTHONPATH, it's also needed by emulator * Bugfix Type __rvm_ruby: Add clean package dependencies * Bugfix Type __rvm_gem: Run rvm as user, not as root - * Cleanup Type __rvm: Use shortcut version + * Cleanup Type __rvm, __rvm_gemset: Use shortcut version 2.1.0pre5: 2012-11-01 * Core: First round of tests updated to work with multiple configuration directories