dply 0.1.6 → 0.1.7

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: 9116641abdea1ae1e27604cff732fcde2cb8b419
4
- data.tar.gz: 78536afe271e16e664af6aee88a7504367c149cc
3
+ metadata.gz: 78868f8ab27e27eeae74bbf55c79def56dc5005f
4
+ data.tar.gz: d84a93dba3ecfcd349233515cbb39593870c4ea6
5
5
  SHA512:
6
- metadata.gz: 7f443a27744fbf10985c8a7692e0eb1cec4cf0956580f66a43a1d3ea56c8ab99f03a753ad632473b4c9550930fa5b395709acc4d591ba38d13c9370c7ff5da48
7
- data.tar.gz: c595250c790d13933137a7ee88661edbdec5eeb41396900c29f8019f7f195a49d7a42059ea2a5566bc8ce133969e0f4c94bccf16b78050e14863a062dae675ac
6
+ metadata.gz: 0c6cb63cda32f77e803c2cd6ec737711c7899c95eecbb48edeee64ebd597a7abf6a3fbb8bb8b35195dd03219deef179013c0606646439b35e72f0946fde0ce6f
7
+ data.tar.gz: 8af1d7824138f70013f1bdcda916cc8a83e22cc01c6d815fb43981801bd99daca4b0a29cdc7b96f20e8382a611d8e8e4993a51b125963ebd1f1af51315f7c285
data/bin/drake CHANGED
@@ -8,6 +8,8 @@ require 'dply/logger'
8
8
  require 'dply/config'
9
9
  require 'pathname'
10
10
 
11
+ File.umask 0022
12
+
11
13
  logger = ::Dply::Logger.logger
12
14
 
13
15
  options = {}
@@ -26,7 +26,7 @@ module Dply
26
26
 
27
27
  def download_file
28
28
  if File.exists? path
29
- download if not verify_checksum
29
+ download(uri, path) if not verify_checksum
30
30
  else
31
31
  download(uri, path)
32
32
  end
@@ -1,6 +1,5 @@
1
1
  require 'dply/helper'
2
2
  require 'dply/setup'
3
- require 'dply/linker'
4
3
  require 'dply/config_downloader'
5
4
  require 'dply/yum'
6
5
  require 'dply/tasks'
@@ -28,8 +27,7 @@ module Dply
28
27
  Dir.chdir repo_dir do
29
28
  git_step
30
29
  git.clean
31
- link_dirs
32
- link_config
30
+ link_all
33
31
  install_pkgs
34
32
  clean_build_dir
35
33
  link_build_dir
@@ -61,20 +59,9 @@ module Dply
61
59
  end
62
60
  end
63
61
 
64
- def link_dirs
65
- link "#{config.dir}/shared", dir_map
66
- end
67
-
68
- def link_config
69
- link "#{config.dir}/config", config_map
70
- end
71
-
72
- def link(source, map)
73
- return if not map
74
- logger.bullet "symlinking #{source}"
75
- dest = repo_dir
76
- linker = Linker.new(source, dest, map: map)
77
- linker.create_symlinks
62
+ def link_all
63
+ tasks.link "#{config.dir}/shared", dir_map
64
+ tasks.link "#{config.dir}/config", config_map
78
65
  end
79
66
 
80
67
  def install_pkgs
@@ -8,7 +8,22 @@ module Dply
8
8
  include Helper
9
9
 
10
10
  attr_accessor :url, :verify_checksum
11
- attr_reader :name
11
+ attr_writer :name
12
+
13
+ def self.find_or_create(revision, **kwargs)
14
+ release = new(revision, **kwargs)
15
+ name = find_installed_name(revision, **kwargs)
16
+ release.name = name if name
17
+ return release
18
+ end
19
+
20
+ def self.find_installed_name(revision, **kwargs)
21
+ branch = kwargs.fetch(:branch).to_s.gsub(/-/, "_")
22
+ app_name = kwargs.fetch(:app_name).to_s.gsub(/-/, "_")
23
+ name_without_ts = "#{revision}-#{app_name}-#{branch}-"
24
+ latest = Dir["releases/#{name_without_ts}*"].sort_by { |x, y| File.mtime(x) }.first
25
+ latest ? File.basename(latest) : nil
26
+ end
12
27
 
13
28
  def initialize(revision, app_name: nil, branch: nil, url: nil)
14
29
  @revision = revision
@@ -18,25 +33,43 @@ module Dply
18
33
  end
19
34
 
20
35
  def make_current
21
- raise "cannot make not installed release current" if not installed?
22
- raise "release path #{path} doesn't exist" if not File.directory? path
36
+ error "cannot make not installed release current" if not installed?
37
+ error "release path #{path} doesn't exist" if not File.directory? path
23
38
  symlink path, "current"
24
39
  end
25
40
 
41
+ def name
42
+ @name ||= "#{@revision}-#{replace_dashes(@app_name)}-#{replace_dashes(@branch)}-#{timestamp}"
43
+ end
44
+
26
45
  def install
27
- return if installed?
28
- @name = name_without_ts + timestamp
46
+ if installed?
47
+ logger.debug "release #{name} already installed"
48
+ return
49
+ end
29
50
  Dir.mktmpdir "tmp" do |d|
30
51
  path = "#{d}/#{name}"
31
52
  archive.extract_to path
32
- FileUtils.mv path, "releases"
53
+ FileUtils.mv path, "releases/"
33
54
  end
34
- @installed = true
35
55
  archive.clean
36
56
  end
37
57
 
38
58
  def path
39
- @path ||= "releases/#{@name}"
59
+ @path ||= "releases/#{name}"
60
+ end
61
+
62
+ def record_deployment
63
+ FileUtils.touch "#{path}/.deployed"
64
+ end
65
+
66
+ def already_deployed?
67
+ File.exist? "#{path}/.deployed"
68
+ end
69
+
70
+ def current?
71
+ return false if not File.symlink? "current"
72
+ File.basename(File.readlink "current") == name
40
73
  end
41
74
 
42
75
  private
@@ -53,23 +86,8 @@ module Dply
53
86
  Time.now.strftime "%Y%m%d%H%M%S"
54
87
  end
55
88
 
56
- def load_status
57
- name = name_without_ts
58
- latest = Dir["releases/#{name}*"].sort_by { |x, y| File.mtime(x) }.first
59
- if latest
60
- @installed = true
61
- @name = File.basename latest
62
- end
63
- @status_loaded = true
64
- end
65
-
66
89
  def installed?
67
- load_status if not @status_loaded
68
- @installed
69
- end
70
-
71
- def name_without_ts
72
- @name_without_ts ||= "#{@revision}-#{replace_dashes(@app_name)}-#{replace_dashes(@branch)}-"
90
+ File.exist? path
73
91
  end
74
92
 
75
93
  end
@@ -7,12 +7,7 @@ module Dply
7
7
  def libs_to_packages(libs)
8
8
  packages = Set.new
9
9
  libs.each do |l|
10
- lib = "#{l}()(64bit)"
11
- command = %(rpm --queryformat "%{NAME} " -q --whatprovides "#{lib}")
12
- logger.debug command
13
- output = `#{command}`
14
- error "running command #{command}" if not $?.exitstatus == 0
15
- list = output.strip.split.select {|pkg| not filtered? pkg }
10
+ list = whatprovides(l)
16
11
  packages << list if not list.empty?
17
12
  end
18
13
  return packages
@@ -23,5 +18,14 @@ module Dply
23
18
  @filtered.include? pkg.strip
24
19
  end
25
20
 
21
+ def whatprovides(lib)
22
+ lib = "#{lib}()(64bit)"
23
+ command = %(rpm --queryformat "%{NAME} " -q --whatprovides "#{lib}")
24
+ logger.debug command
25
+ output = `#{command}`
26
+ error "running command #{command}" if not $?.exitstatus == 0
27
+ list = output.strip.split.select {|pkg| not filtered? pkg }
28
+ end
29
+
26
30
  end
27
31
  end
@@ -1,7 +1,6 @@
1
1
  require 'dply/helper'
2
2
  require 'dply/tasks'
3
3
  require 'dply/setup'
4
- require 'dply/linker'
5
4
  require 'dply/config_downloader'
6
5
  require 'dply/yum'
7
6
  require 'dply/release'
@@ -27,6 +26,12 @@ module Dply
27
26
 
28
27
  def deploy
29
28
  setup.archive
29
+ if release.already_deployed? && release.current?
30
+ logger.info "revision #{revision} is currently deployed"
31
+ current_version = previous_version = get_release
32
+ tasks.report_changes(current_version, previous_version)
33
+ return
34
+ end
30
35
  download_configs if config_download_url
31
36
  install_release
32
37
  previous_version = get_release
@@ -34,6 +39,7 @@ module Dply
34
39
  Dir.chdir current_dir do
35
40
  tasks.deploy target
36
41
  end
42
+ release.record_deployment
37
43
  current_version = get_release
38
44
  tasks.report_changes(previous_version, current_version)
39
45
  end
@@ -41,8 +47,7 @@ module Dply
41
47
  def reload
42
48
  download_configs if config_download_url
43
49
  Dir.chdir current_dir do
44
- link_dirs
45
- link_config
50
+ link_all
46
51
  tasks.reload target
47
52
  end
48
53
  end
@@ -74,7 +79,7 @@ module Dply
74
79
  end
75
80
 
76
81
  def release
77
- @release ||= Release.new(
82
+ @release ||= Release.find_or_create(
78
83
  revision, branch: branch,
79
84
  app_name: config.name,
80
85
  url: config.build_url
@@ -85,8 +90,7 @@ module Dply
85
90
  release.verify_checksum = config.verify_checksum
86
91
  release.install
87
92
  Dir.chdir release.path do
88
- link_dirs
89
- link_config
93
+ link_all
90
94
  tasks.install_pkgs(use_yum: options[:use_yum])
91
95
  end
92
96
  end
@@ -100,12 +104,9 @@ module Dply
100
104
  end
101
105
  end
102
106
 
103
- def link_dirs
104
- link "#{config.dir}/shared", dir_map
105
- end
106
-
107
- def link_config
108
- link "#{config.dir}/config", config_map
107
+ def link_all
108
+ tasks.link "#{config.dir}/shared", dir_map
109
+ tasks.link "#{config.dir}/config", config_map
109
110
  end
110
111
 
111
112
  def setup
@@ -116,14 +117,6 @@ module Dply
116
117
  @tasks ||= Tasks.new(deployment: true)
117
118
  end
118
119
 
119
- def link(source, map)
120
- return if not map
121
- logger.bullet "symlinking #{source}"
122
- dest = Dir.pwd
123
- linker = Linker.new(source, dest, map: map)
124
- linker.create_symlinks
125
- end
126
-
127
120
  end
128
121
  end
129
122
  end
@@ -1,6 +1,5 @@
1
1
  require 'dply/helper'
2
2
  require 'dply/setup'
3
- require 'dply/linker'
4
3
  require 'dply/config_downloader'
5
4
  require 'dply/yum'
6
5
  require 'dply/tasks'
@@ -31,8 +30,7 @@ module Dply
31
30
  previous_version = git.commit_id
32
31
  git_step
33
32
  current_version = git.commit_id
34
- link_dirs
35
- link_config
33
+ link_all
36
34
  install_pkgs
37
35
  tasks.deploy target
38
36
  tasks.report_changes(previous_version, current_version)
@@ -42,8 +40,7 @@ module Dply
42
40
  def reload
43
41
  download_configs if config_download_url
44
42
  Dir.chdir current_dir do
45
- link_dirs
46
- link_config
43
+ link_all
47
44
  tasks.reload target
48
45
  end
49
46
  end
@@ -78,12 +75,9 @@ module Dply
78
75
  end
79
76
  end
80
77
 
81
- def link_dirs
82
- link "#{config.dir}/shared", dir_map
83
- end
84
-
85
- def link_config
86
- link "#{config.dir}/config", config_map
78
+ def link_all
79
+ tasks.link "#{config.dir}/shared", dir_map
80
+ tasks.link "#{config.dir}/config", config_map
87
81
  end
88
82
 
89
83
  def install_pkgs
@@ -98,14 +92,6 @@ module Dply
98
92
  @tasks ||= Tasks.new(deployment: true)
99
93
  end
100
94
 
101
- def link(source, map)
102
- return if not map
103
- logger.bullet "symlinking #{source}"
104
- dest = current_dir
105
- linker = Linker.new(source, dest, map: map)
106
- linker.create_symlinks
107
- end
108
-
109
95
  end
110
96
  end
111
97
  end
@@ -2,6 +2,7 @@ require 'json'
2
2
  require 'dply/shell'
3
3
  require 'dply/bundle'
4
4
  require 'dply/yum'
5
+ require 'dply/linker'
5
6
  require 'dply/pkgs_config'
6
7
 
7
8
  module Dply
@@ -54,6 +55,14 @@ module Dply
54
55
  end
55
56
  end
56
57
 
58
+ def link(source, map)
59
+ return if not map
60
+ logger.bullet "symlinking #{source}"
61
+ dest = Dir.pwd
62
+ linker = Linker.new(source, dest, map: map)
63
+ linker.create_symlinks
64
+ end
65
+
57
66
  private
58
67
 
59
68
  def bundle
@@ -1,3 +1,3 @@
1
1
  module Dply
2
- VERSION = "0.1.6"
2
+ VERSION = "0.1.7"
3
3
  end
@@ -80,9 +80,9 @@ module Dplyr
80
80
  host = host_info[:host]
81
81
  dir = host_info[:dir]
82
82
  if logger.debug?
83
- %(ssh -tt -oBatchMode=yes -l #{user} #{host} "#{env} drake --remote --debug -d #{dir} #{task} 2>&1")
83
+ %(ssh -tt -oBatchMode=yes -l #{user} #{host} '#{env} drake --remote --debug -d #{dir} #{task} 2>&1')
84
84
  else
85
- %(ssh -tt -oBatchMode=yes -l #{user} #{host} "#{env} drake --remote -d #{dir} #{task} 2>&1" 2>/dev/null)
85
+ %(ssh -tt -oBatchMode=yes -l #{user} #{host} '#{env} drake --remote -d #{dir} #{task} 2>&1' 2>/dev/null)
86
86
  end
87
87
  end
88
88
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dply
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.6
4
+ version: 0.1.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Neeraj
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-03-05 00:00:00.000000000 Z
11
+ date: 2015-03-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: ruby-elf