alcapon 0.3.2 → 0.4.0

Sign up to get free protection for your applications and to get access to all the features.
data/README.md CHANGED
@@ -10,6 +10,14 @@ it on a preproduction environment before going further. Please also do read the
10
10
 
11
11
  ## Changelog
12
12
 
13
+ ### 0.4.x
14
+
15
+ - added eZ Publish 5.x support for ezpublish_legacy. This means that version
16
+ of eZ Publish must be known by alcapon. You can either set ezpublish_version
17
+ (accepted values are 4 or 5) in your Capfile or add `-S ezpublish_version=4`
18
+ or `-S ezpublish_version=5` after your command line call, like this :
19
+ cap production deploy -S ezpublish_version=5
20
+
13
21
  ### 0.3.x
14
22
 
15
23
  - added the possibility to trigger rename and in-file replace operations
data/bin/capezit CHANGED
@@ -41,6 +41,8 @@ end
41
41
  files = {
42
42
  "Capfile" => unindent(<<-FILE),
43
43
  set :alcapon_path, \"#{alcapon_path}\"
44
+ set :ezpublish_version, 4
45
+
44
46
  load 'deploy' if respond_to?(:namespace) # cap2 differentiator
45
47
  Dir['vendor/gems/*/recipes/*.rb','vendor/plugins/*/recipes/*.rb'].each { |plugin| load(plugin) }
46
48
 
data/lib/capez.rb CHANGED
@@ -1,7 +1,20 @@
1
- load_paths.push File.expand_path('../', __FILE__)
2
- load 'db.rb'
3
1
  require 'colored'
4
- require 'md5'
2
+
3
+ load_paths.push File.expand_path('../', __FILE__)
4
+ load "utils"
5
+
6
+ if( fetch( :ezpublish_version, nil ) == nil )
7
+ alcapon_message( "I am now able to manage versions 4 & 5 of eZ Publish but you
8
+ have to set :ezpublish_version
9
+ - in your Capfile like this : set :ezpublish_version, <ezpublish_version>
10
+ - as a command line option : -S ezpublish_version=<ezpublish_version>
11
+ where <ezpublish_version> can be either 4 or 5." )
12
+ abort
13
+ else
14
+ fetch(:ezpublish_version) == 4 || fetch(:ezpublish_version) == 5 || abort( "Version #{ezpublish_version} not supported".red )
15
+ load "db"
16
+ load "ezpublish#{ezpublish_version}"
17
+ end
5
18
 
6
19
  # This will simply do chmod g+w on all dir
7
20
  # See task :setup
@@ -42,10 +55,10 @@ before "deploy:finalize_update" do
42
55
  # Needed if you want to create extra shared directories under var/ with
43
56
  # set :shared_children, [ "var/something",
44
57
  # "var/something_else" ]
45
- # Note that :shared_children creates a folder within shared which name is
58
+ # Note that :shared_children creates a folder within /shared which name is
46
59
  # the last path element (ie: something or something_else) => that's why
47
- # we cannot use it to create siteaccess storages (var/siteaccess/storage)
48
- run( "mkdir #{latest_release}/var" )
60
+ # we cannot use it to create siteaccess' storage folder (var/siteaccess/storage)
61
+ run( "mkdir -p #{latest_release}/#{ezp_legacy_path('var')}" )
49
62
  end
50
63
 
51
64
  after "deploy:finalize_update" do
@@ -118,7 +131,7 @@ namespace :capez do
118
131
 
119
132
  unless !(file_changes = get_file_changes) then
120
133
 
121
- path = options[:locally] ? "" : "#{latest_release}/"
134
+ path = options[:locally] ? "" : fetch( :latest_release )
122
135
 
123
136
  changes = 0
124
137
  renames = 0
@@ -141,7 +154,7 @@ namespace :capez do
141
154
  if operations.has_key?("rename")
142
155
  if( target_filename != operations['rename'] )
143
156
  target_filename = operations['rename']
144
- cmd = "if [ -f #{path}#{filename} ]; then cp #{path}#{filename} #{path}#{target_filename}; fi;"
157
+ cmd = "if [ -f #{path}/#{filename} ]; then cp #{path}/#{filename} #{path}/#{target_filename}; fi;"
145
158
  options[:locally] ? run_locally( "#{cmd}" ) : run( "#{cmd}" )
146
159
  renames += 1
147
160
  else
@@ -155,15 +168,14 @@ namespace :capez do
155
168
  when 'rename'
156
169
  when 'replace'
157
170
 
158
- if( value.count > 0 )
171
+ if( value.count > 0 && !dry_run)
159
172
 
160
173
  # download file if necessary
161
174
  if options[:locally]
162
175
  tmp_filename = target_filename
163
176
  else
164
177
  tmp_filename = target_filename+".tmp"
165
- tmp_filename = MD5.new( tmp_filename ).to_s
166
- get "#{path}#{target_filename}", tmp_filename
178
+ get "#{path}/#{target_filename}", tmp_filename
167
179
  end
168
180
 
169
181
  text = File.read(tmp_filename)
@@ -176,7 +188,7 @@ namespace :capez do
176
188
  # upload and remove temporary file
177
189
  if !options[:locally]
178
190
  run( "if [ -f #{target_filename} ]; then rm #{target_filename}; fi;" )
179
- upload( tmp_filename, "#{path}#{target_filename}" )
191
+ upload( tmp_filename, "#{path}/#{target_filename}" )
180
192
  run_locally( "rm #{tmp_filename}" )
181
193
  end
182
194
  end
@@ -230,7 +242,7 @@ namespace :capez do
230
242
  puts( "\n--> Clearing caches #{'with --purge'.red if cache_purge}" )
231
243
  cache_list.each { |cache_tag|
232
244
  print_dotted( "#{cache_tag}" )
233
- capture "cd #{current_path} && sudo -u #{webserver_user} php bin/php/ezcache.php --clear-tag=#{cache_tag}#{' --purge' if cache_purge}"
245
+ capture "cd #{current_path}/#{ezpublish_legacy} && sudo -u #{webserver_user} php bin/php/ezcache.php --clear-tag=#{cache_tag}#{' --purge' if cache_purge}"
234
246
  puts( " OK".green )
235
247
  }
236
248
  end
@@ -267,18 +279,23 @@ namespace :capez do
267
279
  task :init_release, :roles => :web do
268
280
  puts( "\n--> Release directories" )
269
281
 
282
+ if( ezp5? )
283
+ run( "chown -R #{fetch(:webserver_user,:user)}:#{fetch(:webserver_group,:user)} #{latest_release}/ezpublish/{cache,logs,config} web" )
284
+ run( "chmod -R g+wx #{latest_release}/ezpublish/{cache,logs} web" )
285
+ end
286
+
270
287
  # creates a storage dir for elements specified by :storage_directories
271
288
  storage_directories.each{ |sd|
272
289
  print_dotted( "var/#{sd}/storage" )
273
- run( "mkdir #{latest_release}/var/#{sd}" )
290
+ run( "mkdir #{latest_release}/" + ezp_legacy_path( "var/#{sd}" ) )
274
291
  puts( " OK".green )
275
292
  }
276
293
 
277
294
  # makes sure the webserver can write into var/
278
- run( "chmod -R g+w #{latest_release}/var")
279
- run( "chown -R #{fetch(:webserver_user,:user)}:#{fetch(:webserver_group,:user)} #{latest_release}/var")
295
+ run( "chmod -R g+w #{latest_release}/" + ezp_legacy_path( "var" ) )
296
+ run( "chown -R #{fetch(:webserver_user,:user)}:#{fetch(:webserver_group,:user)} #{latest_release}/" + ezp_legacy_path( "var" ) )
280
297
  # needed even if we just want to run 'bin/php/ezpgenerateautoloads.php' with --extension
281
- run( "chown -R #{fetch(:webserver_user,:user)}:#{fetch(:webserver_group,:user)} #{latest_release}/autoload")
298
+ run( "chown -R #{fetch(:webserver_user,:user)}:#{fetch(:webserver_group,:user)} #{latest_release}/" + ezp_legacy_path( "autoload" ) )
282
299
  end
283
300
 
284
301
  desc <<-DESC
@@ -288,17 +305,17 @@ namespace :capez do
288
305
  puts( "\n--> Symlinks" )
289
306
 
290
307
  print_dotted( "var/storage" )
291
- run( "ln -s #{shared_path}/var/storage #{latest_release}/var/storage" )
308
+ run( "ln -s #{shared_path}/var/storage #{latest_release}/" + ezp_legacy_path( "var/storage" ) )
292
309
  puts( " OK".green )
293
310
 
294
311
  storage_directories.each{ |sd|
295
312
  print_dotted( "var/#{sd}/storage" )
296
- run( "ln -s #{shared_path}/var/#{sd}/storage #{latest_release}/var/#{sd}/storage", :as => webserver_user )
313
+ run( "ln -s #{shared_path}/var/#{sd}/storage #{latest_release}/" + ezp_legacy_path( "var/#{sd}/storage" ), :as => webserver_user )
297
314
  #run( "chmod -h g+w #{latest_release}/var/#{sd}/storage")
298
315
  puts( " OK".green )
299
316
  }
300
317
 
301
- run( "chmod -R g+w #{latest_release}/var")
318
+ run( "chmod -R g+w #{latest_release}/" + ezp_legacy_path( "var" ) )
302
319
  run( "chown -R #{fetch(:webserver_user,:user)}:#{fetch(:webserver_group,:user)} #{shared_path}/var")
303
320
  end
304
321
 
@@ -319,7 +336,7 @@ namespace :capez do
319
336
  exclude_string << "--exclude '#{item}' "
320
337
  }
321
338
 
322
- run_locally( "rsync -az #{exclude_string} #{user}@#{shared_host}:#{shared_path}/var/* var/" )
339
+ run_locally( "rsync -az #{exclude_string} #{user}@#{shared_host}:#{shared_path}/var/* " + ezp_legacy_path( "var/" ) )
323
340
  end
324
341
 
325
342
  desc <<-DESC
@@ -340,7 +357,7 @@ namespace :capez do
340
357
  }
341
358
 
342
359
  try_sudo( "chown -R #{user}:#{webserver_user} #{shared_path}/var/*" )
343
- run_locally( "rsync -az #{exclude_string} var/* #{user}@#{shared_host}:#{shared_path}/var/ " )
360
+ run_locally( "rsync -az #{exclude_string} #{ezp_legacy_path('var')}/* #{user}@#{shared_host}:#{shared_path}/var/ " )
344
361
  try_sudo( "chown -R #{webserver_user} #{shared_path}/var/*" )
345
362
  try_sudo( "chmod -R ug+rwx #{shared_path}/var/*" )
346
363
  end
@@ -361,7 +378,7 @@ namespace :capez do
361
378
  puts( "\n--> eZ Publish autoloads " )
362
379
  autoload_list.each { |autoload|
363
380
  print_dotted( "#{autoload}" )
364
- capture( "cd #{latest_release} && sudo -u #{webserver_user} php bin/php/ezpgenerateautoloads.php --#{autoload}" )
381
+ capture( "cd #{latest_release}/#{ezp_legacy_path} && sudo -u #{webserver_user} php bin/php/ezpgenerateautoloads.php --#{autoload}" )
365
382
  puts( " OK".green )
366
383
  }
367
384
  end
@@ -448,29 +465,4 @@ namespace :capez do
448
465
  end
449
466
  end
450
467
 
451
-
452
- end
453
-
454
- def print_dotted( message, options={} )
455
- defaults_options = { :eol => false,
456
- :sol => false,
457
- :max_length => 40,
458
- :eol_msg => false }
459
-
460
- options = defaults_options.merge( options )
461
- message = "#{message} " + "." * [0,options[:max_length]-message.length-1].max
462
-
463
- if options[:sol]
464
- message = "\n#{message}"
465
- end
466
-
467
- if options[:eol_msg]
468
- message += " #{options[:eol_msg]}"
469
- end
470
-
471
- if options[:eol]
472
- puts message
473
- else
474
- print message
475
- end
476
468
  end
data/lib/ezpublish4.rb ADDED
@@ -0,0 +1,3 @@
1
+ puts "Running AlCapON for eZ Publish 4"
2
+
3
+ set :ezp_legacy, ""
data/lib/ezpublish5.rb ADDED
@@ -0,0 +1,4 @@
1
+ puts "Running AlCapON for eZ Publish 5"
2
+
3
+ set :ezp_legacy, "ezpublish_legacy"
4
+ set :ezp_app, "ezpublish"
data/lib/utils.rb ADDED
@@ -0,0 +1,50 @@
1
+ def unindent(string)
2
+ indentation = string[/\A\s*/]
3
+ string.strip.gsub(/^#{indentation}/, "")
4
+ end
5
+
6
+ def print_dotted( message, options={} )
7
+ defaults_options = { :eol => false,
8
+ :sol => false,
9
+ :max_length => 40,
10
+ :eol_msg => false }
11
+
12
+ options = defaults_options.merge( options )
13
+ message = "#{message} " + "." * [0,options[:max_length]-message.length-1].max
14
+
15
+ if options[:sol]
16
+ message = "\n#{message}"
17
+ end
18
+
19
+ if options[:eol_msg]
20
+ message += " #{options[:eol_msg]}"
21
+ end
22
+
23
+ if options[:eol]
24
+ puts message
25
+ else
26
+ print message
27
+ end
28
+ end
29
+
30
+ def ezp5?
31
+ return ( fetch( :ezpublish_version, nil ) == 5 )
32
+ end
33
+
34
+ def ezp_legacy_path(path='')
35
+ elements = Array.new
36
+
37
+ if( fetch( :ezp_legacy, "" ) != "" )
38
+ elements += [ "#{ezp_legacy}" ]
39
+ end
40
+
41
+ if( path != '' )
42
+ elements += [ "#{path}" ]
43
+ end
44
+
45
+ return File.join( elements )
46
+ end
47
+
48
+ def alcapon_message(string)
49
+ puts( "[alcapon]".green+" #{string}" )
50
+ end
metadata CHANGED
@@ -4,9 +4,9 @@ version: !ruby/object:Gem::Version
4
4
  prerelease: false
5
5
  segments:
6
6
  - 0
7
- - 3
8
- - 2
9
- version: 0.3.2
7
+ - 4
8
+ - 0
9
+ version: 0.4.0
10
10
  platform: ruby
11
11
  authors:
12
12
  - Arnaud Lafon
@@ -57,6 +57,9 @@ files:
57
57
  - lib/capez.rb
58
58
  - lib/db.rb
59
59
  - lib/ext/spinner.rb
60
+ - lib/ezpublish4.rb
61
+ - lib/ezpublish5.rb
62
+ - lib/utils.rb
60
63
  - README.md
61
64
  - LICENSE.md
62
65
  has_rdoc: true