Commit 65ca70e0e5a7dd5bca2f5a2707202fa561110737

Authored by Braulio Bhavamitra
1 parent f280b3ca

noosfero-plugins: add install command

Enable users to explicitly install plugins' gems.

Also, return error when install/dependencies fail.
@@ -37,9 +37,6 @@ cache: bundler @@ -37,9 +37,6 @@ cache: bundler
37 37
38 before_script: 38 before_script:
39 - mkdir -p tmp/{pids,cache} log 39 - mkdir -p tmp/{pids,cache} log
40 -# workaround for plugins with Gemfile  
41 - - perl -pi -e 's/--local --quiet/install --jobs=3 --retry=3 > \/dev\/null/' script/noosfero-plugins  
42 - - perl -pi -e 's/rm -f \$gemfile/mv "\$gemfile".lock Gemfile.lock; rm -f \$gemfile/' script/noosfero-plugins  
43 - script/noosfero-plugins disableall 40 - script/noosfero-plugins disableall
44 - bundle exec rake makemo &>/dev/null 41 - bundle exec rake makemo &>/dev/null
45 # database 42 # database
@@ -54,7 +51,7 @@ env: @@ -54,7 +51,7 @@ env:
54 - TASK=test:integration 51 - TASK=test:integration
55 - TASK=cucumber 52 - TASK=cucumber
56 - TASK=selenium 53 - TASK=selenium
57 - - TASK=test:noosfero_plugins 54 + - TASK=test:noosfero_plugins BUNDLE_OPTS=install
58 55
59 script: 56 script:
60 - bundle exec rake $TASK 57 - bundle exec rake $TASK
plugins/fb_app/install.rb
1 system "script/noosfero-plugins -q enable oauth_client open_graph" 1 system "script/noosfero-plugins -q enable oauth_client open_graph"
  2 +exit $?.exitstatus
2 3
plugins/open_graph/install.rb
1 system "script/noosfero-plugins -q enable metadata" 1 system "script/noosfero-plugins -q enable metadata"
  2 +exit $?.exitstatus
2 3
plugins/orders/install.rb
1 system "script/noosfero-plugins -q enable delivery" 1 system "script/noosfero-plugins -q enable delivery"
  2 +exit $?.exitstatus
2 3
plugins/orders_cycle/install.rb
1 system "script/noosfero-plugins -q enable orders suppliers" 1 system "script/noosfero-plugins -q enable orders suppliers"
  2 +exit $?.exitstatus
2 3
plugins/shopping_cart/install.rb
1 system "script/noosfero-plugins -q enable orders delivery" 1 system "script/noosfero-plugins -q enable orders delivery"
  2 +exit $?.exitstatus
2 3
script/noosfero-plugins
@@ -77,6 +77,12 @@ run(){ @@ -77,6 +77,12 @@ run(){
77 fi 77 fi
78 } 78 }
79 79
  80 +_install(){
  81 + # export so that recursive enables for dependencies inherit this option too
  82 + export BUNDLE_OPTS='install'
  83 + _enable "$1"
  84 +}
  85 +
80 _enable(){ 86 _enable(){
81 plugin="$1" 87 plugin="$1"
82 88
@@ -113,10 +119,13 @@ _enable(){ @@ -113,10 +119,13 @@ _enable(){
113 if [ -e $source/Gemfile ]; then 119 if [ -e $source/Gemfile ]; then
114 gemfile=$(mktemp --tmpdir=.) 120 gemfile=$(mktemp --tmpdir=.)
115 cat $NOOSFERO_DIR/Gemfile $source/Gemfile > $gemfile 121 cat $NOOSFERO_DIR/Gemfile $source/Gemfile > $gemfile
116 - if ! RUBYOPT='' BUNDLE_GEMFILE="$gemfile" bundle --local --quiet; then 122 + if [ -z "$BUNDLE_OPTS" ]; then BUNDLE_OPTS="--local"; fi
  123 + if ! RUBYOPT='' BUNDLE_GEMFILE="$gemfile" bundle $BUNDLE_OPTS --quiet; then
117 dependencies_ok=false 124 dependencies_ok=false
  125 + else
  126 + mv "$gemfile".lock Gemfile.lock
118 fi 127 fi
119 - rm -f $gemfile $gemfile.lock 128 + rm -f $gemfile
120 fi 129 fi
121 if ! run $dependencies_file; then 130 if ! run $dependencies_file; then
122 dependencies_ok=false 131 dependencies_ok=false
@@ -134,9 +143,11 @@ _enable(){ @@ -134,9 +143,11 @@ _enable(){
134 elif [ "$installation_ok" = false ]; then 143 elif [ "$installation_ok" = false ]; then
135 echo "W: failed to install $plugin; not enabling" 144 echo "W: failed to install $plugin; not enabling"
136 echo 145 echo
  146 + exit 1
137 elif [ "$dependencies_ok" = false ]; then 147 elif [ "$dependencies_ok" = false ]; then
138 echo "W: failed to load dependencies for $plugin; not enabling" 148 echo "W: failed to load dependencies for $plugin; not enabling"
139 echo 149 echo
  150 + exit 2
140 fi 151 fi
141 fi 152 fi
142 } 153 }
@@ -245,7 +256,7 @@ case "$command" in @@ -245,7 +256,7 @@ case "$command" in
245 fi 256 fi
246 _$command 257 _$command
247 ;; 258 ;;
248 - enable|disable|new) 259 + enable|install|disable|new)
249 for plugin in $@; do 260 for plugin in $@; do
250 _$command "$plugin" 261 _$command "$plugin"
251 done 262 done