buildozer 1.0.0 → 1.0.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,3 +1,13 @@
1
- # 1.0.0 (unreleased)
1
+ # 1.0.2 (unreleased)
2
2
 
3
- * Initial commit
3
+ # 1.0.1 (March 26th, 2013)
4
+
5
+ * Added architecture field in package DSL
6
+ * Added option flag `-n, --dry-run` to RPM command
7
+ This will show the command that would be executed without executing them.
8
+
9
+ # 1.0.0 (February 20th, 2013)
10
+
11
+ * RPM command implementation
12
+ * Package DSL implementation
13
+ * Definition DSL implementation
data/README.md CHANGED
@@ -13,10 +13,137 @@ Use this command to install buildozer:
13
13
 
14
14
  gem install buildozer
15
15
 
16
+ ## Versioning
17
+
18
+ A small note about versioning of this project. Backward compatibility
19
+ for users will be kept for major version. That means that your definition
20
+ files are guaranteed to work for version `1.y.z`. The day we release
21
+ `2.y.z`, it will not be backward compatible with major version lower
22
+ than 2.
23
+
24
+ Internal representation will be backward compatible for minor version.
25
+ That means that if your are using buildozer as a library, you can follow
26
+ `x.1.z` whitout fear of breaking your code. However, changing from `x.1.z`
27
+ to `x.2.z` will likely requires changes on your part.
28
+
29
+ Finally, new additions and changes that are backward compatible for users
30
+ and developers will be made on the revision version. For example, `x.y.3`
31
+ will be compatible with `x.y.4`.
32
+
16
33
  ## Usage
17
34
 
18
- Coming soon ...
35
+ The meats that feeds every buildozer command is the definition. The
36
+ definition file (always ending with `.bd.rb`) is defined using a custom
37
+ DSL based on ruby that ease packages definition. Each definition can
38
+ contains `0` to `N` packages.
39
+
40
+ For each package, you defined some basic information about it like
41
+ the name of the package, it's version, the url where sources can be found
42
+ and many others including what the package provides and its dependencies.
43
+
44
+ For now, each definition if more or less platform specific but I hope
45
+ this will change overtime to have platform agnostic package definition.
46
+
47
+ Here a sample build definition for `erlang` (Important note, the build
48
+ definition is fake for now, will update it with real stuff at some
49
+ points):
50
+
51
+ ```ruby
52
+ # Buildozer package definition
53
+ # Architecture: x86
54
+ # Platform: CentOS 5.9
55
+
56
+ package "erlang" do
57
+ url "http://www.erlang.org/download/otp_src_R15B03-1.tar.gz"
58
+ version "R15B03"
59
+ maintainer "Matthieu Vachon"
60
+
61
+ architecture "i686"
62
+
63
+ provides "erlang"
64
+
65
+ depends "libc.so6"
66
+
67
+ includes "usr/bin"
68
+ end
69
+
70
+ package "erlang-devel" do
71
+ url "http://www.erlang.org/download/otp_src_R15B03-1.tar.gz"
72
+ version "R15B03"
73
+ maintainer "Matthieu Vachon"
74
+
75
+ architecture "i686"
76
+
77
+ provides "erlang-devel"
78
+
79
+ depends "libc.so6"
80
+
81
+ includes "usr/include"
82
+ end
83
+ ```
84
+
85
+ A definition can contain multiple package definition. This is useful
86
+ to define at the same time normal package and a development package.
87
+ In the future, we plan to reduce duplication of package information
88
+ maybe be specifying a inheritance mechanisms, ideas are welcome :)
89
+
90
+ Here the list of valid options for a package
91
+
92
+ * `url` -
93
+ The url where the package can be downloaded.
94
+
95
+ * `version` -
96
+ The current version of the package
97
+
98
+ * `maintainer` (optional) -
99
+ The name of the maintainer of this package. This is NOT the author but
100
+ rather the one who build the package.
101
+
102
+ * `architecture` (optional) -
103
+ The target architecture of the package. If left blank, the architecture of
104
+ the machine is used. If set, it must be `:auto` or a non-empty string value.
105
+
106
+ * `provides` -
107
+ An artifact that the package provides. Usually, this is binaries and
108
+ libraries generated by the package when built. This can be call multiple
109
+ times, each time adding a new provided artifact.
110
+
111
+ * `depends` -
112
+ An artifact that the package depends on. Usually, this will be some libraries
113
+ or binaries needed to run the package. This can be call multiple
114
+ times, each time adding a new dependency artifact.
115
+
116
+ * `includes` -
117
+ A list of folders that will be packaged when building an archive for the package
118
+ like a rpm. This can be call multiple times, each time adding a new included
119
+ folder.
120
+
121
+ ### Commands
122
+
123
+ When you have a build definition, let's call it `erlang.bd.rb`, you pass it to
124
+ the various commands to do something useful with it.
125
+
126
+ #### Command RPM
127
+
128
+ The command rpm can be used to generate rpms from a definition file. The command
129
+ will produce a single rpm for each package defined in the definition file.
130
+
131
+ > buildozer rpm -d "/path/to/built/package" erlang.bd.rb
132
+
133
+ It is important to note that you will need `rpm_build` on your machine for this
134
+ to work. The command will fail if it's not the case.
135
+
136
+ In its internals, buildozer uses `fpm` to produce the rpm archive file. You can
137
+ see the commands that would be executed by doing a dry-run. This will print
138
+ the commands to the standard ouput instead of executing them.
139
+
140
+ > buildozer rpm -n -d "/path/to/built/package" erlang.bd.rb
19
141
 
20
142
  ## Contributing & Support
21
143
 
22
- There is no direct way to contribute right now.
144
+ To contribute, simply fork the repository, make the changes you want and submit
145
+ a pull request. Also, you can start an issue without a pull request if you would
146
+ like some features or you have found some bugs.
147
+
148
+ You can also creates an issue just to discuss potential ideas and future directions
149
+ for the project.
@@ -1,5 +1,4 @@
1
1
  #!/usr/bin/env ruby
2
-
3
2
  require 'buildozer/cli/buildozer'
4
3
 
5
4
  Buildozer::Cli::Buildozer.start()
@@ -15,6 +15,10 @@ module Buildozer
15
15
  system(command())
16
16
  end
17
17
 
18
+ def show()
19
+ puts(command())
20
+ end
21
+
18
22
  def command()
19
23
  buffer = StringIO.new
20
24
 
@@ -26,6 +30,10 @@ module Buildozer
26
30
 
27
31
  buffer << " -m \"#{@package.maintainer}\"" if @package.maintainer
28
32
 
33
+ if @package.architecture and not @package.architecture == :auto
34
+ buffer << " -a \"#{@package.architecture}\""
35
+ end
36
+
29
37
  @package.provides.each do |provide|
30
38
  buffer << " --provides \"#{provide}\""
31
39
  end
@@ -47,7 +55,7 @@ module Buildozer
47
55
 
48
56
  def validate()
49
57
  if @package.includes.empty?()
50
- raise Builder::InvalidRpmPackage, "Invalid rpm package, must have at least on 'includes'"
58
+ raise Builder::InvalidRpmPackage, "Invalid rpm package, must have at least one 'includes'"
51
59
  end
52
60
  end
53
61
  end
@@ -6,14 +6,17 @@ module Buildozer
6
6
  module Cli
7
7
  class Buildozer < Thor
8
8
 
9
- desc "rpm FILE", "Build a rpm package using fpm"
10
- method_option :dir, :aliases => "-d", :default => ".", :desc => "Directory where package files are located"
11
- def rpm(file)
12
- definition = Dsl.compile(file)
9
+ desc "rpm DEFINITION_FILE", "Build a rpm package using fpm"
10
+ method_option :dir, :aliases => "-d", :default => ".", :type => :string, :desc => "Directory where package files are located"
11
+ method_option :"dry-run", :aliases => "-n", :default => false, :type => :boolean, :desc => "Only show commands that would be exectued without actually running them"
12
+ def rpm(definition_file)
13
+ definition = Dsl.compile(definition_file)
13
14
 
14
15
  definition.packages.each do |package|
15
16
  builder = Builder::Rpm.new(package, File.expand_path(options[:dir]))
16
- puts builder.build()
17
+
18
+ builder.build() if not options[:"dry-run"]
19
+ builder.show() if options[:"dry-run"]
17
20
  end
18
21
  end
19
22
  end
@@ -12,6 +12,11 @@ module Buildozer
12
12
  send("compile_#{fragment.type()}", fragment)
13
13
  end
14
14
 
15
+ ##
16
+ # Function that receives a dsl definition and compile
17
+ # it to a model definition. This compilation is done
18
+ # mainly to report user-friendly error when dsl
19
+ # definition is invalid
15
20
  def self.compile_definition(definition)
16
21
  Validator.validate_definition(definition);
17
22
 
@@ -21,6 +26,11 @@ module Buildozer
21
26
  })
22
27
  end
23
28
 
29
+ ##
30
+ # Function that receives a dsl package and compile
31
+ # it to a model package. This compilation is done
32
+ # mainly to report user-friendly error when dsl
33
+ # package is invalid
24
34
  def self.compile_package(package)
25
35
  Validator.validate_package(package);
26
36
 
@@ -45,6 +45,20 @@ module Buildozer
45
45
  if not options.has_key?(:url)
46
46
  raise InvalidDslPackage, "Invalid package, must have an 'url'"
47
47
  end
48
+
49
+ if options.has_key?(:architecture)
50
+ architecture = options[:architecture]
51
+
52
+ validate_architecture(architecture)
53
+ end
54
+ end
55
+
56
+ def self.validate_architecture(architecture)
57
+ if architecture == :auto or (architecture.kind_of?(String) and not architecture == "")
58
+ return
59
+ end
60
+
61
+ raise InvalidDslPackage, "Invalid package, architecture must be :auto or a non-empty String, currently [#{architecture}]"
48
62
  end
49
63
  end
50
64
  end
@@ -5,6 +5,9 @@ module Buildozer
5
5
  class Package < Fragment
6
6
  def initialize(name, &block)
7
7
  @name = name
8
+
9
+ @architecture = :auto
10
+
8
11
  @provides = []
9
12
  @depends = []
10
13
  @includes = []
@@ -30,6 +33,10 @@ module Buildozer
30
33
  @maintainer = maintainer
31
34
  end
32
35
 
36
+ def architecture(architecture)
37
+ @architecture = architecture
38
+ end
39
+
33
40
  def depends(package)
34
41
  @depends << package
35
42
  end
@@ -2,7 +2,7 @@ module Buildozer
2
2
  module Model
3
3
  class Package
4
4
  attr_accessor :name, :version, :revision, :archive, :url,
5
- :maintainer,
5
+ :maintainer, :architecture,
6
6
  :provides, :depends,
7
7
  :includes
8
8
 
@@ -13,6 +13,8 @@ module Buildozer
13
13
  @archive = options.fetch(:archive, "#{@name}-#{@version}")
14
14
  @url = options.fetch(:url)
15
15
 
16
+ @architecture = options.fetch(:architecture, :auto)
17
+
16
18
  @maintainer = options.fetch(:maintainer, nil)
17
19
 
18
20
  @provides = options.fetch(:provides, [])
@@ -1,3 +1,3 @@
1
1
  module Buildozer
2
- VERSION = "1.0.0"
2
+ VERSION = "1.0.1"
3
3
  end
@@ -20,18 +20,39 @@ module Buildozer
20
20
  Model::Package.new(@defaults.merge(options))
21
21
  end
22
22
 
23
+ def test_command_without_architecture()
24
+ package = base_package()
25
+ command = Builder::Rpm.new(package, ".").command()
26
+
27
+ assert(command !~ /-a/, "Architecture flag [-a] should NOT be present in #{command}")
28
+ end
29
+
30
+ def test_command_with_architecture()
31
+ package = base_package({:architecture => "i989"})
32
+ command = Builder::Rpm.new(package, ".").command()
33
+
34
+ assert(command =~ /-a "i989"/, "Architecture flag [-a i989] should be present in #{command}")
35
+ end
36
+
37
+ def test_command_with_architecture_auto()
38
+ package = base_package({:architecture => :auto})
39
+ command = Builder::Rpm.new(package, ".").command()
40
+
41
+ assert(command !~ /-a/, "Architecture flag [-a] should NOT be present in #{command}")
42
+ end
43
+
23
44
  def test_command_without_maintainer()
24
45
  package = base_package()
25
46
  command = Builder::Rpm.new(package, ".").command()
26
47
 
27
- assert(command !~ /-m/)
48
+ assert(command !~ /-m/, "Maintainer flag [-m] should NOT be present in #{command}")
28
49
  end
29
50
 
30
51
  def test_command_with_maintainer()
31
52
  package = base_package({:maintainer => "Joe Armstrong"})
32
53
  command = Builder::Rpm.new(package, ".").command()
33
54
 
34
- assert(command =~ /-m "Joe Armstrong"/)
55
+ assert(command =~ /-m "Joe Armstrong"/, "Maintainer flag [-m Joe Armstrong] should be present in #{command}")
35
56
  end
36
57
 
37
58
  def test_package_no_includes()
@@ -26,6 +26,7 @@ module Buildozer
26
26
  assert_equal("http://www.erlang.org/download/otp_src_R15B03-1.tar.gz", package.url)
27
27
  assert_equal("R15B03", package.version)
28
28
  assert_equal("erlang-R15B03", package.archive)
29
+ assert_equal("i989", package.architecture)
29
30
  assert_equal("Nu Echo (Matthieu Vachon)", package.maintainer)
30
31
  end
31
32
 
@@ -53,6 +54,21 @@ module Buildozer
53
54
 
54
55
  assert_equal([], package.includes)
55
56
  end
57
+
58
+ def test_architecture_auto()
59
+ definition = compile("definition_architecture_auto.bd.rb")
60
+ packages = definition.packages
61
+ assert_equal(1, packages.size())
62
+
63
+ package = packages[0]
64
+ assert_equal(:auto, package.architecture)
65
+ end
66
+
67
+ def test_invalid_architecture()
68
+ assert_raise(Compiler::InvalidDslPackage) do
69
+ compile("definition_invalid_architecture.bd.rb")
70
+ end
71
+ end
56
72
  end
57
73
 
58
74
  class FakeFragment < Fragment
@@ -0,0 +1,12 @@
1
+
2
+ package "erlang" do
3
+ url "http://www.erlang.org/download/otp_src_R15B03-1.tar.gz"
4
+ version "R15B03"
5
+ maintainer "Nu Echo (Matthieu Vachon)"
6
+
7
+ architecture :auto
8
+
9
+ provides "erlang"
10
+
11
+ depends "libc.so6"
12
+ end
@@ -1,9 +1,14 @@
1
+ # Buildozer package definition for Erlang
2
+ # Architecture: x86
3
+ # Platform: CentOS 5.9
1
4
 
2
5
  package "erlang" do
3
6
  url "http://www.erlang.org/download/otp_src_R15B03-1.tar.gz"
4
7
  version "R15B03"
5
8
  maintainer "Nu Echo (Matthieu Vachon)"
6
9
 
10
+ architecture "i989"
11
+
7
12
  provides "erlang"
8
13
 
9
14
  depends "libc.so6"
@@ -0,0 +1,11 @@
1
+
2
+ package "erlang" do
3
+ url "http://www.erlang.org/download/otp_src_R15B03-1.tar.gz"
4
+ version "R15B03"
5
+ maintainer "Nu Echo (Matthieu Vachon)"
6
+ architecture 15
7
+
8
+ provides "erlang"
9
+
10
+ depends "libc.so6"
11
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: buildozer
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 1.0.1
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-02-21 00:00:00.000000000 Z
12
+ date: 2013-03-27 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: fpm
@@ -97,7 +97,9 @@ files:
97
97
  - lib/buildozer/version.rb
98
98
  - test/lib/buildozer/builder/test_rpm.rb
99
99
  - test/lib/buildozer/dsl/test_compiler.rb
100
+ - test/resources/definition_architecture_auto.bd.rb
100
101
  - test/resources/definition_full.bd.rb
102
+ - test/resources/definition_invalid_architecture.bd.rb
101
103
  - test/resources/definition_no_includes.bd.rb
102
104
  homepage: https://github.com/maoueh/buildozer
103
105
  licenses: []
@@ -111,18 +113,12 @@ required_ruby_version: !ruby/object:Gem::Requirement
111
113
  - - ! '>='
112
114
  - !ruby/object:Gem::Version
113
115
  version: '0'
114
- segments:
115
- - 0
116
- hash: 181030610370950058
117
116
  required_rubygems_version: !ruby/object:Gem::Requirement
118
117
  none: false
119
118
  requirements:
120
119
  - - ! '>='
121
120
  - !ruby/object:Gem::Version
122
121
  version: '0'
123
- segments:
124
- - 0
125
- hash: 181030610370950058
126
122
  requirements: []
127
123
  rubyforge_project:
128
124
  rubygems_version: 1.8.24
@@ -132,5 +128,7 @@ summary: Application to build and package software.
132
128
  test_files:
133
129
  - test/lib/buildozer/builder/test_rpm.rb
134
130
  - test/lib/buildozer/dsl/test_compiler.rb
131
+ - test/resources/definition_architecture_auto.bd.rb
135
132
  - test/resources/definition_full.bd.rb
133
+ - test/resources/definition_invalid_architecture.bd.rb
136
134
  - test/resources/definition_no_includes.bd.rb