dapp 0.5.7 → 0.5.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 34654763ca898b862f3c4d10a4e66856533154d5
4
- data.tar.gz: 3baa8bb73a33553f5292acd9b18d3edeb8c812fb
3
+ metadata.gz: b8a9ec9afc7917a8ecf1ba8d47e65defef16df8f
4
+ data.tar.gz: 50c22e22781a24115fc79514ad9c71410784a75e
5
5
  SHA512:
6
- metadata.gz: ee7f50ac5f2d2253c398fd4501afc0316821fa4b060a951ebd4f9e487cde86cb7eac5864bb53f789371b978406740964390ede146ffb5655d6ba78af475b67d2
7
- data.tar.gz: e7182830cb0cf44f4e3c93cecb5d0ef467c77be0f6249fae433eaa5a8cc7056446efd9fc00573cb43f6178ee44c70aaf72f28159255ed8f8111db0b86d91d28a
6
+ metadata.gz: 919231c2f8a6f6bf78780bcf969921472ddd416dee45fc46404cb9ff84f22848c780e8a76b342aa34d1024986fa651dd19e38d496328caa8610b297ac56d4c80
7
+ data.tar.gz: 929a790d85767cc510136ed9283b6ec86cb473e18cdee69fec205b0277dba81a11952930edf0e6ac28e0d725359156c76a7fea3d390e8b61a51bf02c550575aa
@@ -15,6 +15,16 @@ module Dapp
15
15
  make_path(@build_path, home_path.basename, *path).expand_path.tap { |p| p.parent.mkpath }
16
16
  end
17
17
 
18
+ def project_path
19
+ @project_path ||= begin
20
+ if File.basename(expand_path(home_path, 1)) == '.dapps'
21
+ expand_path(home_path, 2)
22
+ else
23
+ home_path
24
+ end
25
+ end
26
+ end
27
+
18
28
  def container_dapp_path(*path)
19
29
  make_path('/.dapp', *path)
20
30
  end
@@ -28,6 +38,12 @@ module Dapp
28
38
  def make_path(base, *path)
29
39
  path.compact.map(&:to_s).inject(Pathname.new(base), &:+)
30
40
  end
41
+
42
+ def expand_path(path, number = 1)
43
+ path = File.expand_path(path)
44
+ number.times.each { path = File.dirname(path) }
45
+ path
46
+ end
31
47
  end # Path
32
48
  end # Application
33
49
  end # Dapp
@@ -68,7 +68,7 @@ module Dapp
68
68
  credentials += "-o #{owner} " if owner
69
69
  credentials += "-g #{group} " if group
70
70
 
71
- copy_files = lambda do |from_, cwd_, path_ = ''|
71
+ copy_files = proc do |from_, cwd_, path_ = ''|
72
72
  cwd_ = File.expand_path(File.join('/', cwd_))
73
73
  "find #{File.join(from_, cwd_, path_)} -type f -exec bash -ec 'install -D #{credentials} {} " \
74
74
  "#{File.join(to, "$(echo {} | sed -e \"s/#{File.join(from_, cwd_).gsub('/', '\\/')}//g\")")}' \\;"
@@ -7,6 +7,10 @@ module Dapp
7
7
  @prev_stage = InfraInstall.new(application, self)
8
8
  super
9
9
  end
10
+
11
+ def dependencies
12
+ [application.git_artifacts.map(&:paramshash).join]
13
+ end
10
14
  end # Source1ArchiveDependencies
11
15
  end # Stage
12
16
  end # Build
@@ -22,8 +22,6 @@ module Dapp
22
22
  def image
23
23
  super do |image|
24
24
  image.add_volumes_from gitartifact_container
25
- image.add_command 'export PATH=/.dapp/deps/gitartifact/bin:$PATH'
26
-
27
25
  application.git_artifacts.each do |git_artifact|
28
26
  image.add_volume "#{git_artifact.repo.path}:#{git_artifact.repo.container_path}:ro"
29
27
  image.add_command git_artifact.send(apply_command_method, self)
@@ -46,6 +44,10 @@ module Dapp
46
44
  end
47
45
  end
48
46
 
47
+ def git_dappdeps_path
48
+ '/.dapp/deps/gitartifact/bin/git'
49
+ end
50
+
49
51
  protected
50
52
 
51
53
  def gitartifact_container_name # FIXME: hashsum(image) or dockersafe()
@@ -18,7 +18,8 @@ module Dapp
18
18
  protected
19
19
 
20
20
  def dependencies_files_checksum(regs)
21
- unless (files = regs.map { |reg| Dir[File.join(application.home_path, reg)].map { |f| File.read(f) if File.file?(f) } }).empty?
21
+ regs.map! { |reg| File.directory?(File.join(application.project_path, reg)) ? File.join(reg, '**', '*') : reg }
22
+ unless (files = regs.map { |reg| Dir[File.join(application.project_path, reg)].map { |f| File.read(f) if File.file?(f) } }).empty?
22
23
  hashsum files
23
24
  end
24
25
  end
@@ -19,11 +19,10 @@ module Dapp
19
19
  define_method("#{stage}") do |image|
20
20
  unless stage_empty?(stage)
21
21
  image.add_volumes_from(chefdk_container)
22
- image.add_command 'export PATH=/.dapp/deps/chefdk/bin:$PATH',
23
- "export DAPP_BUILD_STAGE=#{stage}"
22
+ image.add_command "export DAPP_BUILD_STAGE=#{stage}"
24
23
 
25
24
  image.add_volume "#{stage_build_path(stage)}:#{container_stage_build_path(stage)}:ro"
26
- image.add_command ['chef-solo',
25
+ image.add_command [chef_solo_dappdeps_path,
27
26
  '--legacy-mode',
28
27
  "-c #{container_stage_config_path(stage)}",
29
28
  "-o #{stage_cookbooks_runlist(stage).join(',')}"].join(' ')
@@ -167,7 +166,7 @@ module Dapp
167
166
  'echo " StrictHostKeyChecking no" >> ~/.ssh/config',
168
167
  'if [ ! -f Berksfile.lock ] ; then echo "Berksfile.lock not found" 1>&2 ; exit 1 ; fi',
169
168
  'cp -a Berksfile.lock /tmp/Berksfile.lock.orig',
170
- '/.dapp/deps/chefdk/bin/berks vendor /tmp/vendored_cookbooks',
169
+ "#{berks_dappdeps_path} vendor /tmp/vendored_cookbooks",
171
170
  'export LOCKDIFF=$(diff -u0 Berksfile.lock /tmp/Berksfile.lock.orig)',
172
171
  ['if [ "$LOCKDIFF" != "" ] ; then ',
173
172
  'cp -a /tmp/Berksfile.lock.orig Berksfile.lock ; ',
@@ -209,7 +208,7 @@ module Dapp
209
208
 
210
209
  # rubocop:disable Metrics/MethodLength, Metrics/AbcSize
211
210
  def install_stage_cookbooks(stage)
212
- select_existing_paths = ->(cookbook_path, paths) do
211
+ select_existing_paths = proc do |cookbook_path, paths|
213
212
  paths.select { |from, _| cookbook_path.join(from).exist? }
214
213
  end
215
214
 
@@ -305,11 +304,11 @@ module Dapp
305
304
  @stage_cookbooks_runlist[stage] ||= begin
306
305
  res = []
307
306
 
308
- does_entry_exist = ->(cookbook, entrypoint) do
307
+ does_entry_exist = proc do |cookbook, entrypoint|
309
308
  stage_cookbooks_path(stage, cookbook, 'recipes', "#{entrypoint}.rb").exist?
310
309
  end
311
310
 
312
- format_entry = ->(cookbook, entrypoint) do
311
+ format_entry = proc do |cookbook, entrypoint|
313
312
  entrypoint = 'void' if entrypoint.nil?
314
313
  "#{cookbook}::#{entrypoint}"
315
314
  end
@@ -382,6 +381,14 @@ module Dapp
382
381
  def container_stage_build_path(_stage, *path)
383
382
  path.compact.map(&:to_s).inject(Pathname.new('/.dapp/chef/build'), &:+)
384
383
  end
384
+
385
+ def chef_solo_dappdeps_path
386
+ '/.dapp/deps/chefdk/bin/chef-solo'
387
+ end
388
+
389
+ def berks_dappdeps_path
390
+ '/.dapp/deps/chefdk/bin/berks'
391
+ end
385
392
  end
386
393
  end
387
394
  end
@@ -15,6 +15,7 @@ module Dapp
15
15
  @branch = branch || repo.application.cli_options[:git_artifact_branch] || repo.branch
16
16
  @commit = commit
17
17
 
18
+ cwd = File.expand_path(File.join('/', cwd))[1..-1] unless cwd.nil? || cwd.empty?
18
19
  @cwd = cwd
19
20
  @paths = paths
20
21
  @owner = owner
@@ -26,7 +27,7 @@ module Dapp
26
27
  credentials = [:owner, :group].map { |attr| "--#{attr}=#{send(attr)}" unless send(attr).nil? }.compact
27
28
 
28
29
  ["install #{credentials.join(' ')} -d #{where_to_add}",
29
- ["git --git-dir=#{repo.container_path} archive #{stage.layer_commit(self)}:#{cwd} #{paths}",
30
+ ["#{stage.git_dappdeps_path} --git-dir=#{repo.container_path} archive #{stage.layer_commit(self)}:#{cwd} #{paths}",
30
31
  "#{sudo}tar -x -C #{where_to_add}"].join(' | ')]
31
32
  end
32
33
 
@@ -35,8 +36,8 @@ module Dapp
35
36
  prev_commit = stage.prev_source_stage.layer_commit(self)
36
37
 
37
38
  if prev_commit != current_commit || any_changes?(prev_commit, current_commit)
38
- [["git --git-dir=#{repo.container_path} #{diff_command(prev_commit, current_commit)}",
39
- "#{sudo}git apply --whitespace=nowarn --directory=#{where_to_add} --unsafe-paths"].join(' | ')]
39
+ [["#{stage.git_dappdeps_path} --git-dir=#{repo.container_path} #{diff_command(prev_commit, current_commit)}",
40
+ "#{sudo}#{stage.git_dappdeps_path} apply --whitespace=nowarn --directory=#{where_to_add} --unsafe-paths"].join(' | ')]
40
41
  else
41
42
  []
42
43
  end
@@ -55,7 +56,7 @@ module Dapp
55
56
  end
56
57
 
57
58
  def paramshash
58
- Digest::SHA256.hexdigest [cwd, paths, owner, group].map(&:to_s).join(':::')
59
+ Digest::SHA256.hexdigest [where_to_add, cwd, paths, owner, group].map(&:to_s).join(':::')
59
60
  end
60
61
 
61
62
  def paths(with_cwd = false)
@@ -1,5 +1,5 @@
1
1
  # Version
2
2
  module Dapp
3
- VERSION = '0.5.7'.freeze
3
+ VERSION = '0.5.8'.freeze
4
4
  BUILD_CACHE_VERSION = 3
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dapp
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.7
4
+ version: 0.5.8
5
5
  platform: ruby
6
6
  authors:
7
7
  - Dmitry Stolyarov
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-08-30 00:00:00.000000000 Z
11
+ date: 2016-08-31 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: mixlib-shellout