luban 0.9.2 → 0.9.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: dca8fcb876590469dc26cde8d96ac98005d359ba
4
- data.tar.gz: 09eb04a2e533f65e76eea153a7c58756060161c4
3
+ metadata.gz: e7a3cfbc9249fac2f651aaabc6ed1ba12812e5fd
4
+ data.tar.gz: 9bd71c0b02c5980ad4b2ecdfaba22d11102b9a68
5
5
  SHA512:
6
- metadata.gz: 38a19f7fee773f5ce14f375cc204a96d1e8c186bd7c2ceb931104471d2f8bb7a4e65591850760671bd75069f2ed37aa2ecc5ac92cf1cb5229a80f38247552478
7
- data.tar.gz: 4d1c3ee0509c66fb65fed17069ae622ae925ec76e0a17b55000adf0e9948368876914beaaef237c7e9b05c175425d373bfef844802f515742dfbc8ff14748e12
6
+ metadata.gz: 315eac49c38cffab66de6163303843f75db7252fbb6842c659119144a2b3ce818dab01d46f9828c16c57d43b112bf75afd4b42712eb0b77a2aa6da94b1cff364
7
+ data.tar.gz: 908d2fd0049c95613b3fa8efa054314a53314678d6abd5193323fbd7b631862d2ba244fd9efee7a12da6b3bb69f35ea172970e404e56cf05db3ed7971b2b2c05
data/CHANGELOG.md CHANGED
@@ -1,5 +1,20 @@
1
1
  # Change log
2
2
 
3
+ ## Version 0.9.3 (Oct 17, 2016)
4
+
5
+ New feature:
6
+ * Supported Rubygems-update for Ruby version 1.9.3 or above
7
+
8
+ Minor enhancements:
9
+ * Refactored gem installer and applied changes to gem installers for Bundler and RubygemsUpdates
10
+ * Added abstract methods to get latest version in Package::Base
11
+ * Retrieved latest package version if the version is specified as "latest"
12
+ * Upgraded Bundler to 1.13.5 in Ruby
13
+
14
+ Bug fixes:
15
+ * Fixed a bug in adding host to a given role
16
+ * Ensured symlink for archived logs path to be created for profile-based application publication
17
+
3
18
  ## Version 0.9.2 (Oct 13, 2016)
4
19
 
5
20
  Bug fixes:
@@ -119,6 +119,7 @@ module Luban
119
119
 
120
120
  def create_profile_symlinks
121
121
  create_release_symlink(shared_path)
122
+ create_symlinks_for_archived_logs
122
123
  end
123
124
 
124
125
  def create_app_symlinks
@@ -126,6 +127,7 @@ module Luban
126
127
  assure_linked_dirs
127
128
  create_symlinks_for_linked_dirs
128
129
  create_symlinks_for_linked_files
130
+ create_symlinks_for_archived_logs
129
131
  end
130
132
 
131
133
  def create_release_symlink(target_dir)
@@ -134,13 +136,16 @@ module Luban
134
136
 
135
137
  def create_symlinks_for_linked_dirs
136
138
  create_linked_dirs(linked_dirs, from: shared_path, to: release_path)
137
- assure_symlink(archived_logs_path, log_path.join(archived_logs_path.basename))
138
139
  end
139
140
 
140
141
  def create_symlinks_for_linked_files
141
142
  create_linked_files(linked_files, from: profile_path, to: release_path.join('config'))
142
143
  end
143
144
 
145
+ def create_symlinks_for_archived_logs
146
+ assure_symlink(archived_logs_path, log_path.join(archived_logs_path.basename))
147
+ end
148
+
144
149
  def update_releases_log
145
150
  execute %{echo "[$(date -u)][#{user}] #{release_log_message}" >> #{releases_log_path}}
146
151
  end
@@ -52,6 +52,18 @@ module Luban
52
52
  { major_version: version, patch_level: '' }
53
53
  end
54
54
 
55
+ def version_mutex; @version_mutex ||= Mutex.new; end
56
+
57
+ def latest_version
58
+ version_mutex.synchronize do
59
+ @latest_version ||= get_latest_version
60
+ end
61
+ end
62
+
63
+ def get_latest_version
64
+ raise NotImplementedError, "#{self.class.name}#get_latest_version is an abstract method."
65
+ end
66
+
55
67
  protected
56
68
 
57
69
  def package_require_path(package_name)
@@ -84,6 +96,7 @@ module Luban
84
96
 
85
97
  def update_package_options(version, **opts)
86
98
  unless has_version?(version)
99
+ version = self.class.package_class(name).latest_version if version == 'latest'
87
100
  package_options[version] =
88
101
  { name: name.to_s }.merge!(self.class.decompose_version(version))
89
102
  end
@@ -195,6 +195,7 @@ module Luban
195
195
  required_packages[type].each do |d|
196
196
  version = task.opts.send(d.name) || d.version
197
197
  next if version == 'default'
198
+ version = self.class.package_class(d.name).latest_version if version == 'latest'
198
199
  self.class.worker_class(:installer, package: d.name).new(
199
200
  config: config, backend: backend,
200
201
  cmd: cmd, args: {},
@@ -37,7 +37,7 @@ module Luban
37
37
  end.tap do |s|
38
38
  s.roles.each do |role|
39
39
  @servers[role] ||= []
40
- @servers[role] << new_server
40
+ @servers[role] << s unless @servers[role].include?(s)
41
41
  end
42
42
  end
43
43
  end
@@ -1,46 +1,12 @@
1
+ require_relative 'gem'
2
+
1
3
  module Luban
2
4
  module Deployment
3
5
  module Packages
4
- class Bundler < Luban::Deployment::Package::Base
5
- protected
6
-
7
- def setup_provision_tasks
8
- super
9
- provision_tasks[:install].switch :install_doc, "Install Bundler document"
10
- end
11
-
12
- class Installer < Luban::Deployment::Package::Installer
13
- def install_doc?
14
- task.opts.install_doc
15
- end
16
-
17
- def package_path
18
- parent.package_path
19
- end
20
-
21
- def install_path
22
- parent.install_path
23
- end
24
-
6
+ class Bundler < Gem
7
+ class Installer < Gem::Installer
25
8
  define_executable 'bundler'
26
9
 
27
- def gem_executable
28
- parent.gem_executable
29
- end
30
-
31
- def src_file_extname
32
- @src_file_extname ||= 'gem'
33
- end
34
-
35
- def source_repo
36
- #@source_repo ||= "http://production.cf.rubygems.org"
37
- @source_repo ||= "https://rubygems.org"
38
- end
39
-
40
- def source_url_root
41
- @source_url_root ||= "downloads"
42
- end
43
-
44
10
  def installed?
45
11
  return false unless file?(bundler_executable)
46
12
  match?("#{bundler_executable} -v", package_version)
@@ -48,39 +14,13 @@ module Luban
48
14
 
49
15
  protected
50
16
 
51
- def validate
52
- if parent.nil?
53
- abort "Aborted! Parent package for Bundler MUST be provided."
54
- end
55
- unless parent.is_a?(Ruby::Installer)
56
- abort "Aborted! Parent package for Bundler MUST be an instance of #{Ruby::Installer.name}"
57
- end
58
- end
59
-
60
- def uncompress_package; end
61
- def configure_package; end
62
- def make_package; end
63
- def build_package; install_package; end
64
- def update_binstubs!; end
65
-
66
- def install_package!
17
+ def build_package
67
18
  if file?(bundler_executable)
68
- uninstall_bundler! and install_bundler!
19
+ uninstall_gem! and super
69
20
  else
70
- install_bundler!
21
+ super
71
22
  end
72
23
  end
73
-
74
- def uninstall_bundler!
75
- test("#{gem_executable} uninstall bundler -a -x -I >> #{install_log_file_path} 2>&1")
76
- end
77
-
78
- def install_bundler!
79
- install_opts = ['--local']
80
- #install_opts << "--no-document" unless install_doc?
81
- install_opts << "--no-rdoc --no-ri" unless install_doc?
82
- test("#{gem_executable} install #{install_opts.join(' ')} #{src_cache_path} >> #{install_log_file_path} 2>&1")
83
- end
84
24
  end
85
25
  end
86
26
  end
@@ -0,0 +1,71 @@
1
+ module Luban
2
+ module Deployment
3
+ module Packages
4
+ class Gem < Luban::Deployment::Package::Base
5
+ class << self
6
+ using Luban::CLI::CoreRefinements
7
+
8
+ def gem_name
9
+ @gem_name ||= name.split('::').last.snakecase.gsub('_', '-')
10
+ end
11
+
12
+ protected
13
+
14
+ def get_latest_version
15
+ require 'json'
16
+ JSON.parse(`curl https://rubygems.org/api/v1/versions/#{gem_name}/latest.json 2>/dev/null`)['version']
17
+ end
18
+ end
19
+
20
+ protected
21
+
22
+ def setup_provision_tasks
23
+ super
24
+ provision_tasks[:install].switch :install_doc, "Install #{self.class.gem_name} document"
25
+ end
26
+
27
+ class Installer < Luban::Deployment::Package::Installer
28
+ def install_doc?; task.opts.install_doc; end
29
+ def package_path; parent.package_path; end
30
+ def install_path; parent.install_path; end
31
+ def gem_executable; parent.gem_executable; end
32
+ def src_file_extname; @src_file_extname ||= 'gem'; end
33
+ def source_repo; @source_repo ||= "https://rubygems.org"; end
34
+ def source_url_root; @source_url_root ||= "downloads"; end
35
+
36
+ protected
37
+
38
+ def validate
39
+ if parent.nil?
40
+ abort "Aborted! Parent package for #{package_name} MUST be provided."
41
+ end
42
+ unless parent.is_a?(Ruby::Installer)
43
+ abort "Aborted! Parent package for #{package_name} MUST be an instance of #{Ruby::Installer.name}"
44
+ end
45
+ end
46
+
47
+ def uncompress_package; end
48
+ def configure_package; end
49
+ def make_package; end
50
+ def build_package; install_gem!; end
51
+ def update_binstubs; end
52
+
53
+ def install_opts
54
+ install_opts = ['--local']
55
+ #install_opts << "--no-document" unless install_doc?
56
+ install_opts << "--no-rdoc --no-ri" unless install_doc?
57
+ install_opts
58
+ end
59
+
60
+ def install_gem!
61
+ test("#{gem_executable} install #{install_opts.join(' ')} #{src_cache_path} >> #{install_log_file_path} 2>&1")
62
+ end
63
+
64
+ def uninstall_gem!
65
+ test("#{gem_executable} uninstall #{package_name} -a -x -I >> #{install_log_file_path} 2>&1")
66
+ end
67
+ end
68
+ end
69
+ end
70
+ end
71
+ end
@@ -47,14 +47,16 @@ module Luban
47
47
  apply_to '>= 1.9.3' do
48
48
  before_install do
49
49
  depend_on 'openssl', version: '1.0.2j'
50
- depend_on 'rubygems', version: '2.6.7'
51
50
  #depend_on 'yaml', version: '0.1.6'
52
51
  end
52
+ after_install do
53
+ depend_on 'rubygems-update', version: 'latest'
54
+ end
53
55
  end
54
56
 
55
57
  apply_to :all do
56
58
  after_install do
57
- depend_on 'bundler', version: '1.13.3'
59
+ depend_on 'bundler', version: '1.13.5'
58
60
  end
59
61
  end
60
62
 
@@ -124,6 +126,10 @@ module Luban
124
126
 
125
127
  protected
126
128
 
129
+ def create_task(task)
130
+ super.tap { |t| t.opts.send("rubygems-update=", t.opts.rubygems) }
131
+ end
132
+
127
133
  def configure_build_options
128
134
  super
129
135
  @configure_opts.unshift("--disable-install-doc") unless install_doc?
@@ -0,0 +1,29 @@
1
+ require_relative 'gem'
2
+
3
+ module Luban
4
+ module Deployment
5
+ module Packages
6
+ class RubygemsUpdate < Gem
7
+ class Installer < Gem::Installer
8
+ define_executable 'update_rubygems'
9
+
10
+ def installed?
11
+ return false unless file?(gem_executable)
12
+ match?("#{gem_executable} -v", package_version)
13
+ end
14
+
15
+ protected
16
+
17
+ def build_package
18
+ super and update_rubygems! and uninstall_gem!
19
+ end
20
+
21
+ def update_rubygems!
22
+ update_opts = "--no-rdoc --no-ri" unless install_doc?
23
+ test("#{update_rubygems_executable} #{update_opts} >> #{install_log_file_path} 2>&1")
24
+ end
25
+ end
26
+ end
27
+ end
28
+ end
29
+ end
@@ -4,6 +4,8 @@ module Luban
4
4
  class Rubygems < Luban::Deployment::Package::Base
5
5
  protected
6
6
 
7
+ def self.get_latest_version; RubygemsUpdate.get_latest_version; end
8
+
7
9
  def setup_provision_tasks
8
10
  super
9
11
  provision_tasks[:install].switch :install_doc, "Install Rubygems document"
@@ -1,5 +1,5 @@
1
1
  module Luban
2
2
  module Deployment
3
- VERSION = "0.9.2"
3
+ VERSION = "0.9.3"
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: luban
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.9.2
4
+ version: 0.9.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Rubyist Lei
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2016-10-12 00:00:00.000000000 Z
11
+ date: 2016-10-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: luban-cli
@@ -142,11 +142,13 @@ files:
142
142
  - lib/luban/deployment/helpers/linked_paths.rb
143
143
  - lib/luban/deployment/helpers/utils.rb
144
144
  - lib/luban/deployment/packages/bundler.rb
145
+ - lib/luban/deployment/packages/gem.rb
145
146
  - lib/luban/deployment/packages/git.rb
146
147
  - lib/luban/deployment/packages/logrotate.rb
147
148
  - lib/luban/deployment/packages/openssl.rb
148
149
  - lib/luban/deployment/packages/popt.rb
149
150
  - lib/luban/deployment/packages/ruby.rb
151
+ - lib/luban/deployment/packages/rubygems-update.rb
150
152
  - lib/luban/deployment/packages/rubygems.rb
151
153
  - lib/luban/deployment/packages/yaml.rb
152
154
  - lib/luban/deployment/parameters.rb