bricky 0.0.11 → 0.0.12

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,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- MDNlNzA0N2E2MTkyMTdjNTEwZGI5ODRkZjJlODk3NzVkY2EyMjgyOQ==
4
+ NzY4ZjIwODYzODQ0OGIyN2JlMGJmOTdkYTdhYjliMzgzMmM4N2U1OA==
5
5
  data.tar.gz: !binary |-
6
- NWUyNWNkMjc2NmIzNjYzOWNkODA5ZDc0ZTllMDg2ZDc5NDIzNDU1OQ==
6
+ ZmIyN2U4ODdkYmExMTJiZTFkZDNjMWM1MjhiMDczMzQ3OTE2OGI0MQ==
7
7
  SHA512:
8
8
  metadata.gz: !binary |-
9
- ZWE3YTE0MGY0ZTM3NDhkYmI1MWU5NWUyZmMzYzllOTMxZTRiODVlNzY1MmRj
10
- NjMxN2Q2ZGRjYzA4ZWE1OGY2ZTdkYmJjNzRjOTA3YmRlNmE0NDhhYjY1MTVk
11
- YTJhNDhkMTBlYTIwOGZhYjA4OTI0MDBiMjQzNjIyN2MyYTkxNWQ=
9
+ YzZjNjRiZDk1OTUxMGNiYWQzZGJlODY4ZGU0Yjg4YmIyMmQ1YjZlMDBmM2Mz
10
+ MmMyMTY2MTQ1ZjQ0MWYxZmY2ZjM2OTQzZmM4YzA4M2ZmOTFhMTMyMGJmYTdi
11
+ MmMwZDE1YTg1NTU1MGFjN2VhYjhkOTE3N2Y4ZjM0OTQ4ZDU1NTM=
12
12
  data.tar.gz: !binary |-
13
- YmY4NmY2MmU1YmFkZWZhMGJjNTFlZWY0OWU3MjQ1ZDRkODNjYzI2N2M0ZjJh
14
- NTJjNGMxMWM5Mjg3OWYyZTNmZTMzMDk4MDQ1ZTA5MWE1OTMwNjA1MTZlYTU1
15
- OTAzZGRmYjEwZDg2ODIwNjMwNDFlMGRkMjlmZmQ3Mjc3MGExZGQ=
13
+ MWVhNzkyODFmOTIxM2M1MzE5OWRhZjNmMmZiYTQ2NThmNzRhMjEwZGI1ZTE3
14
+ OTE3NjhlMDA4ZTMyNTI1Y2ViMjhiMmY0MzBjYTFmYjYzODk4NTdjNDAzNmFh
15
+ NTNkZWIxMGI3NzAwMDhiODM5Y2RmNDYyNzk3YTUwYzliMThhMjc=
@@ -12,9 +12,6 @@ debian() {
12
12
  info 'Moving deb files to volume'
13
13
  rm -Rf /builded/*
14
14
  mv /opt/workspace/*.deb /builded/
15
-
16
- info 'Recreating local debian packages index'
17
- dpkg-scanpackages /builded/ | gzip > /builded/Packages.gz
18
15
  }
19
16
 
20
17
  suexec debian
@@ -5,5 +5,21 @@
5
5
  suexec() {
6
6
  name=$1
7
7
  export -f $name
8
+
9
+ if [[ $BRICKS_LINUX == "true" ]]
10
+ then
11
+ execute_linux $name
12
+ else
13
+ execute_other $name
14
+ fi
15
+ }
16
+
17
+ execute_other() {
18
+ name=$1
19
+ execute $name
20
+ }
21
+
22
+ execute_linux() {
23
+ name=$1
8
24
  su builder -m -c "bash -ec 'execute $name'"
9
25
  }
@@ -7,7 +7,7 @@ bricky:
7
7
  ignore:
8
8
  - source/log
9
9
  - source/tmp
10
- - source/.git
10
+ - source/vendor/bundle
11
11
  bundle:
12
12
  cache: true
13
13
  without: development:test
data/lib/bricky.rb CHANGED
@@ -1,4 +1,5 @@
1
1
  require "bricky/config"
2
+ require "bricky/logger"
2
3
  require "bricky/command"
3
4
  require "bricky/version"
4
5
 
@@ -12,4 +13,8 @@ module Bricky
12
13
  def config
13
14
  @config ||= Bricky::Config.new
14
15
  end
16
+
17
+ def logger
18
+ @logger ||= Bricky::Logger.new
19
+ end
15
20
  end
data/lib/bricky/bricks.rb CHANGED
@@ -16,15 +16,13 @@ module Bricky
16
16
  end.uniq
17
17
  end
18
18
 
19
- def resolve_and_initialize(name, config)
20
- return Bricky::Bricks::Bundle.new(config) if name.eql? "bundle"
21
- return Bricky::Bricks::Debian.new(config) if name.eql? "debian"
22
- return Bricky::Bricks::Mounts.new(config) if name.eql? "mounts"
23
- end
24
-
25
19
  private
26
20
  def default_bricks
27
21
  [Bricky::Bricks::Helper.new({})]
28
22
  end
23
+
24
+ def resolve_and_initialize(name, config)
25
+ Bricky::Bricks.const_get("#{name.to_s.capitalize}").new(config)
26
+ end
29
27
  end
30
28
  end
@@ -7,6 +7,9 @@ module Bricky
7
7
  self.config = config
8
8
  end
9
9
 
10
+ def arguments
11
+ end
12
+
10
13
  def entrypoint
11
14
  end
12
15
 
@@ -25,7 +25,7 @@ module Bricky
25
25
  end
26
26
 
27
27
  def local_path
28
- path = "#{Bricky.config.tmp_path}/cache/#{digest}"
28
+ path = "#{Bricky.config.cache_path}/bundle/#{digest}"
29
29
  FileUtils::mkdir_p(path)
30
30
  path
31
31
  end
@@ -6,8 +6,14 @@ module Bricky
6
6
  end
7
7
 
8
8
  def environments
9
- ["-e BRICKS_HOME=/bricks/helper"]
9
+ ["-e BRICKS_LINUX=#{linux}",
10
+ "-e BRICKS_HOME=/bricks/helper"]
10
11
  end
12
+
13
+ private
14
+ def linux
15
+ RUBY_PLATFORM.include?("linux")
16
+ end
11
17
  end
12
18
  end
13
19
  end
@@ -16,18 +16,11 @@ module Bricky
16
16
  dispatch(:install)
17
17
  end
18
18
 
19
- desc :bootstrap, "bootstrap builder images"
20
- def bootstrap
21
- requirements.check_and_execute do
22
- dispatch(:bootstrap)
23
- end
24
- end
25
-
26
19
  desc :builder, "build project"
27
20
  method_option :shell, :type => :boolean, :aliases => "-s"
28
21
  def builder
29
22
  requirements.check_and_execute do
30
- dispatch(:builder)
23
+ dispatch(:bootstrap) && dispatch(:builder)
31
24
  end
32
25
  end
33
26
 
@@ -38,8 +31,7 @@ module Bricky
38
31
 
39
32
  def dispatch(name)
40
33
  clazz = Bricky::Commands.const_get("#{name.to_s.capitalize}")
41
- command = clazz.new(options)
42
- command.execute
34
+ clazz.new(options).execute
43
35
  end
44
36
  end
45
37
  end
@@ -8,6 +8,10 @@ module Bricky
8
8
  def initialize(options)
9
9
  @options = options
10
10
  end
11
+
12
+ def logger
13
+ Bricky.logger
14
+ end
11
15
  end
12
16
  end
13
17
  end
@@ -5,8 +5,13 @@ module Bricky
5
5
  module Commands
6
6
  class Bootstrap < Base
7
7
  def execute
8
- puts "Boostraping images".colorize(:light_blue)
9
- images.each {|image| build(image)}
8
+ logger.important "Boostraping images"
9
+
10
+ if need_rebuild?
11
+ build(image)
12
+ else
13
+ logger.message "Skipping bootstrap process"
14
+ end
10
15
  end
11
16
 
12
17
  private
@@ -15,14 +20,15 @@ module Bricky
15
20
  hack = command(image.name, create_hack_image(image))
16
21
 
17
22
  [base, hack].each do |code|
18
- puts "Processing '#{image.name}' image: ".colorize(:blue) + code
23
+ logger.message "Processing '#{image.name}' image: ", code
19
24
 
20
25
  unless system(code)
21
- puts "~~~~~~~~~~~ Problems building image ~~~~~~~~~~~".colorize(:white).on_red
26
+ logger.failure "~~~~~~~~~~~ Problems building image ~~~~~~~~~~~"
22
27
  return false
23
28
  end
24
29
  end
25
30
 
31
+ make_cache!
26
32
  true
27
33
  end
28
34
 
@@ -30,8 +36,8 @@ module Bricky
30
36
  "docker build -t #{template_name} #{image_path}"
31
37
  end
32
38
 
33
- def images
34
- ["builder"].collect {|image| Bricky::Image.new(image) }
39
+ def image
40
+ @image ||= Bricky::Image.new("builder")
35
41
  end
36
42
 
37
43
  def create_hack_image(image)
@@ -52,6 +58,25 @@ module Bricky
52
58
 
53
59
  parser.result(variables.get_binding)
54
60
  end
61
+
62
+ def cache_file
63
+ "#{Bricky.config.cache_path}/builder"
64
+ end
65
+
66
+ def need_rebuild?
67
+ cache_digest = open(cache_file).read rescue "dummy"
68
+ image_digest = Digest::MD5.file(image.full_path).hexdigest
69
+
70
+ return false if cache_digest.eql?(image_digest)
71
+ true
72
+ end
73
+
74
+ def make_cache!
75
+ FileUtils::mkdir_p(Bricky.config.cache_path)
76
+ open(cache_file, 'w') do |file|
77
+ file.write Digest::MD5.file(image.full_path).hexdigest
78
+ end
79
+ end
55
80
  end
56
81
  end
57
82
  end
@@ -4,17 +4,17 @@ module Bricky
4
4
  module Commands
5
5
  class Builder < Base
6
6
  def execute
7
- puts "Building Project".colorize(:light_blue)
7
+ logger.important 'Building Project'
8
8
  build(Bricky::Image.new("builder"))
9
9
  end
10
10
 
11
11
  private
12
12
  def build(images)
13
13
  code = command(images)
14
- puts format(code)
14
+ logger.debug format(code)
15
15
 
16
16
  unless system(code)
17
- puts "~~~~~~~~~~~ Problems building image ~~~~~~~~~~~".colorize(:white).on_red
17
+ logger.failure '~~~~~~~~~~~ Problems building image ~~~~~~~~~~~'
18
18
  return false
19
19
  end
20
20
 
@@ -26,7 +26,7 @@ module Bricky
26
26
  end
27
27
 
28
28
  def format(command)
29
- ["-v ", "-i ", "-e "].inject(command) do |result, param|
29
+ ['-v ', '-i ', '-e '].inject(command) do |result, param|
30
30
  result.split(param).join("\n\t #{param}")
31
31
  end
32
32
  end
@@ -43,11 +43,11 @@ module Bricky
43
43
  end
44
44
 
45
45
  def arguments
46
- args = bricks.collect(&:arguments).uniq.join(" ")
46
+ args = bricks.collect(&:arguments).uniq.join(' ')
47
47
  end
48
48
 
49
49
  def entrypoints
50
- bricks.collect(&:entrypoint).compact.uniq.join(" && ")
50
+ bricks.collect(&:entrypoint).compact.uniq.join(' && ')
51
51
  end
52
52
  end
53
53
  end
@@ -1,7 +1,11 @@
1
+ require "thor"
2
+ require "thor/group"
3
+
1
4
  module Bricky
2
5
  module Commands
3
6
  class Install < Base
4
7
  def execute
8
+ logger.important 'Setup bricky configuration files'
5
9
  installer = InstallThor.new
6
10
  installer.execute
7
11
  end
@@ -11,13 +15,12 @@ module Bricky
11
15
  include Thor::Actions
12
16
 
13
17
  def execute
14
- puts "Setup bricky configuration files".colorize(:light_blue)
15
- directory "bricky"
16
- copy_file "Brickyfile"
18
+ directory 'bricky'
19
+ copy_file 'Brickyfile'
17
20
  end
18
21
 
19
22
  def self.source_root
20
- File.expand_path("../../../../etc/templates", __FILE__)
23
+ File.expand_path('../../../../etc/templates', __FILE__)
21
24
  end
22
25
  end
23
26
  end
data/lib/bricky/config.rb CHANGED
@@ -14,6 +14,10 @@ module Bricky
14
14
  self.bricks = config["bricks"]
15
15
  end
16
16
 
17
+ def cache_path
18
+ "#{tmp_path}/cache"
19
+ end
20
+
17
21
  def bricks_path
18
22
  File.expand_path("#{base_path}/etc/bricks", __FILE__)
19
23
  end
data/lib/bricky/image.rb CHANGED
@@ -8,6 +8,10 @@ module Bricky
8
8
  self.path = format_path(image)
9
9
  end
10
10
 
11
+ def full_path
12
+ "#{path}/Dockerfile"
13
+ end
14
+
11
15
  private
12
16
  def format_name(image)
13
17
  "#{Bricky.config.name}/#{image}"
@@ -0,0 +1,30 @@
1
+ require "logger"
2
+
3
+ module Bricky
4
+ class Logger < ::Logger
5
+ def initialize
6
+ super(STDOUT)
7
+ self.level = INFO
8
+ self.formatter = proc do |severity, datetime, progname, msg|
9
+ "#{msg}\n"
10
+ end
11
+ end
12
+
13
+ def message(*args)
14
+ info colorize_first(args, :blue)
15
+ end
16
+
17
+ def failure(*args)
18
+ error colorize_first(args, :white).on_red
19
+ end
20
+
21
+ def important(*args)
22
+ info colorize_first(args, :light_blue)
23
+ end
24
+
25
+ private
26
+ def colorize_first(args, color)
27
+ [args.first.colorize(color), args[1..-1]].join
28
+ end
29
+ end
30
+ end
@@ -1,23 +1,25 @@
1
1
  module Bricky
2
2
  class Requirements
3
3
  def check_and_execute
4
- if pending_requirements
4
+ if pending?
5
5
  print "Make sure you have the following requirements: "
6
- puts requirements.join(',').colorize(:red)
6
+ puts requirements.join(', ').colorize(:red)
7
7
  else
8
8
  yield
9
9
  end
10
10
  end
11
11
 
12
12
  private
13
- def requirements
14
- ["docker"]
15
- end
16
-
17
- def pending_requirements
13
+ def pending?
18
14
  requirements.detect do |command|
19
15
  not system("which #{command} > /dev/null 2>&1")
20
16
  end
21
17
  end
18
+
19
+ def requirements
20
+ requirements = ["docker"]
21
+ requirements << "boot2docker" unless RUBY_PLATFORM.include?("linux")
22
+ requirements
23
+ end
22
24
  end
23
25
  end
@@ -1,3 +1,3 @@
1
1
  module Bricky
2
- VERSION = "0.0.11"
2
+ VERSION = "0.0.12"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bricky
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.11
4
+ version: 0.0.12
5
5
  platform: ruby
6
6
  authors:
7
7
  - andrerocker
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-05-19 00:00:00.000000000 Z
11
+ date: 2015-05-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -115,6 +115,7 @@ files:
115
115
  - lib/bricky/commands/install.rb
116
116
  - lib/bricky/config.rb
117
117
  - lib/bricky/image.rb
118
+ - lib/bricky/logger.rb
118
119
  - lib/bricky/requirements.rb
119
120
  - lib/bricky/setup.rb
120
121
  - lib/bricky/version.rb
@@ -138,7 +139,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
138
139
  version: '0'
139
140
  requirements: []
140
141
  rubyforge_project:
141
- rubygems_version: 2.4.3
142
+ rubygems_version: 2.4.4
142
143
  signing_key:
143
144
  specification_version: 4
144
145
  summary: a smart way to build software packages