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.
.travis.yml
... ... @@ -37,9 +37,6 @@ cache: bundler
37 37  
38 38 before_script:
39 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 40 - script/noosfero-plugins disableall
44 41 - bundle exec rake makemo &>/dev/null
45 42 # database
... ... @@ -54,7 +51,7 @@ env:
54 51 - TASK=test:integration
55 52 - TASK=cucumber
56 53 - TASK=selenium
57   - - TASK=test:noosfero_plugins
  54 + - TASK=test:noosfero_plugins BUNDLE_OPTS=install
58 55  
59 56 script:
60 57 - bundle exec rake $TASK
... ...
plugins/fb_app/install.rb
1 1 system "script/noosfero-plugins -q enable oauth_client open_graph"
  2 +exit $?.exitstatus
2 3  
... ...
plugins/open_graph/install.rb
1 1 system "script/noosfero-plugins -q enable metadata"
  2 +exit $?.exitstatus
2 3  
... ...
plugins/orders/install.rb
1 1 system "script/noosfero-plugins -q enable delivery"
  2 +exit $?.exitstatus
2 3  
... ...
plugins/orders_cycle/install.rb
1 1 system "script/noosfero-plugins -q enable orders suppliers"
  2 +exit $?.exitstatus
2 3  
... ...
plugins/shopping_cart/install.rb
1 1 system "script/noosfero-plugins -q enable orders delivery"
  2 +exit $?.exitstatus
2 3  
... ...
script/noosfero-plugins
... ... @@ -77,6 +77,12 @@ run(){
77 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 86 _enable(){
81 87 plugin="$1"
82 88  
... ... @@ -113,10 +119,13 @@ _enable(){
113 119 if [ -e $source/Gemfile ]; then
114 120 gemfile=$(mktemp --tmpdir=.)
115 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 124 dependencies_ok=false
  125 + else
  126 + mv "$gemfile".lock Gemfile.lock
118 127 fi
119   - rm -f $gemfile $gemfile.lock
  128 + rm -f $gemfile
120 129 fi
121 130 if ! run $dependencies_file; then
122 131 dependencies_ok=false
... ... @@ -134,9 +143,11 @@ _enable(){
134 143 elif [ "$installation_ok" = false ]; then
135 144 echo "W: failed to install $plugin; not enabling"
136 145 echo
  146 + exit 1
137 147 elif [ "$dependencies_ok" = false ]; then
138 148 echo "W: failed to load dependencies for $plugin; not enabling"
139 149 echo
  150 + exit 2
140 151 fi
141 152 fi
142 153 }
... ... @@ -245,7 +256,7 @@ case "$command" in
245 256 fi
246 257 _$command
247 258 ;;
248   - enable|disable|new)
  259 + enable|install|disable|new)
249 260 for plugin in $@; do
250 261 _$command "$plugin"
251 262 done
... ...