vanagon 0.10.0 → 0.11.0

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: f50d333d7dc08205687fc7058b19a3580a0b5028
4
- data.tar.gz: c345a2510f5d6fb4d522a680da59f2aebaa274f3
3
+ metadata.gz: '07341460977d9693423374862c7a7793998b4008'
4
+ data.tar.gz: 2a4a0e66a4fb11bdaa96d1d7fb3aa36d7908c541
5
5
  SHA512:
6
- metadata.gz: 259aac01aa4832879c74a99e3578bc9d59d76e07e283729f78ebd71e4807650c508b306f7a1da13c2d7738b989cb0b40f9583ad629e0fe68ad828a35d74f421e
7
- data.tar.gz: 7b72a6e2947e07cc178fd373cfc381e28f84259715bfa260362334dedda3a6e99a4fe56f1f228ead0f7bbc74d8cdcc41b25e2be9086b55e530bc3a6b30e1d5c4
6
+ metadata.gz: f83beaff1911b965ff21bbaf64ab2087ae9cef078c77b6b5cf3050bde80d59843dbfacb0aef31feb6788241e450e255a06c0728708d3db2152d280bcfd360592
7
+ data.tar.gz: 370382929914b3cdb7dd16d350c66777e5ea0ccf228507c5c5e0e2961f23a18f11f4dd6649f6118f590ec4e14d3c91f9cb9d4dda61784785bb6a3f18d39211d9
data/README.md CHANGED
@@ -1,21 +1,32 @@
1
1
  ![Build Status](https://travis-ci.org/puppetlabs/vanagon.svg?branch=master)
2
- The Vanagon Project
3
- ===
4
- * What is vanagon?
5
- * Runtime requirements
6
- * Configuration and Usage
7
- * Overview
8
- * Contributing
9
- * License
10
- * Maintainers
11
- * Support
12
-
13
- What is vanagon?
14
- ---
2
+ # The Vanagon Project
3
+
4
+ <!-- MarkdownTOC -->
5
+
6
+ - [What is Vanagon?](#what-is-vanagon)
7
+ - [Runtime Requirements](#runtime-requirements)
8
+ - [Local Host:](#local-host)
9
+ - [Remote Build Target:](#remote-build-target)
10
+ - [Configuration and Usage](#configuration-and-usage)
11
+ - [`build` usage](#build-usage)
12
+ - [`inspect` usage](#inspect-usage)
13
+ - [`devkit` usage](#devkit-usage)
14
+ - [Engines](#engines)
15
+ - [Amazon Ec2](#amazon-ec2)
16
+ - [Contributing](#contributing)
17
+ - [License](#license)
18
+ - [Overview](#overview)
19
+ - [Maintainers](#maintainers)
20
+
21
+ <!-- /MarkdownTOC -->
22
+
23
+
24
+ ## What is Vanagon?
25
+
15
26
  Vanagon is a tool to build a single package out of a project, which can itself
16
27
  contain one or more components. This tooling is being used to develop the
17
28
  puppet-agent package, which contains components such as openssl, ruby, and
18
- augeas among others. For a simple example, please see the examples directory.
29
+ augeas among others. For a simple example, please see the project in the `examples/` directory.
19
30
 
20
31
  Vanagon builds up a Makefile and packaging files (specfile for RPM,
21
32
  control/rules/etc for DEB) and copies them to a remote host, where make can be
@@ -28,15 +39,37 @@ creates a master makefile for the project, and configures, builds, and installs
28
39
  all components. The result is an environment where you can work on individual
29
40
  components, then rebuild the project and test the installed artifacts.
30
41
 
31
- Runtime Requirements
32
- ---
33
- Vanagon is self-contained. A recent version of ruby (2.1 or greater) should be
34
- all that is required. Beyond that, ssh, rsync and git are also required on the
35
- host, and ssh-server and rsync is required on the target (package installation
36
- for the target can be customized in the platform config for the target).
42
+ ## Runtime Requirements
43
+
44
+ Vanagon carries two sets of requirements: requirements for the local host where Vanagon is run, and for the remote target where compilation and packaging happens.
45
+
46
+ Also, Vanagon ships with a number of engines which may include additional optional dependencies if you wish to use them. These engines are currently considered experimental, and receive less attention than the `Hardware` or `vmpooler` engines do. If you find a bug in these engines, [please open a ticket](https://tickets.puppetlabs.com/browse/PA) and let us know.
47
+
48
+ ### Local Host:
49
+
50
+ - [Ruby](https://www.ruby-lang.org/en/) (Ruby 2.1.x is the miniumum supported version)
51
+ - [fustigit](https://github.com/mckern/fustigit)
52
+ - [ruby-git](https://github.com/schacon/ruby-git)
53
+ - The command line tool `ssh` ([homepage](https://www.openssh.com/)) available on the local `${PATH}` (any modern version should suffice)
54
+ - The command line tool `rsync` ([homepage](https://rsync.samba.org/)) available on the local `${PATH}` (At least rsync 2.6.x)
55
+ - The command line tool `git` ([homepage](https://git-scm.com/)) available on the local `${PATH}` (Vanagon is tested against Git version 1.8.x but should work with any newer version)
56
+
57
+ #### Optional requirements
58
+
59
+ - [AWS SDK for Ruby](https://github.com/aws/aws-sdk-ruby), if you're using the EC2 engine
60
+ - [Docker](https://www.docker.com/community-edition), if you're using the Docker engine
61
+
62
+ ### Remote Build Target:
63
+
64
+ **Note:** package installation & builder configuration for the remote target can be customized in the `Platform` configuration that defines target provisioning instructions.
65
+
66
+ - GNU Make ([homepage](https://www.gnu.org/software/make/)) (Vanagon specifically targets the feature set provided by [GNU Make 3.81](http://git.savannah.gnu.org/cgit/make.git/tree/NEWS?h=3.81&id=776d8b7bc2ff83f8ebf5d357ec89e3bbe6d83962) but newer versions are known to work -- older versions are specifically known to **not** work!)
67
+ - Bash ([homepage](https://www.gnu.org/software/bash/)) is required by the Makefiles that Vanagon generates
68
+ - An ssh server ([homepage](https://www.openssh.com/)) is required by most engines
69
+ - The command line tool `rsync` ([homepage](https://rsync.samba.org/)) (At least rsync 2.6.x)
70
+
71
+ ## Configuration and Usage
37
72
 
38
- Configuration and Usage
39
- ---
40
73
  Vanagon won't be much use without a project to build. Beyond that, you must
41
74
  define any platforms you want to build for. Vanagon ships with some simple
42
75
  binaries to use, but the one you probably care about is named 'build'.
@@ -44,7 +77,6 @@ binaries to use, but the one you probably care about is named 'build'.
44
77
  ### `build` usage
45
78
  The build command has positional arguments and position independent flags.
46
79
 
47
-
48
80
  #### Arguments (position dependent)
49
81
 
50
82
  ##### project name
@@ -57,7 +89,7 @@ The name of the target platform to build `<project_name>` against; a file named
57
89
  directory. This can also be a comma separated list of platforms such as `platform1,platform2`;
58
90
  note that there are no spaces after the comma.
59
91
 
60
- ##### target host [optional]
92
+ ##### target host <optional>
61
93
  Target host is an optional argument to override the host selection. Instead of using
62
94
  a random VM collected from the pooler (Vanagon's default build engine), the build will
63
95
  attempt connect to the target host over SSH as the `root` user.
@@ -70,13 +102,15 @@ than platforms, the extra platforms will be ignored.
70
102
 
71
103
  Build machines should be cleaned between builds.
72
104
 
73
- #### Flagged arguments (can be anywhere in the command)
105
+ #### Flagged arguments
106
+
107
+ **Note:** command flags can be used anywhere in the command.
74
108
 
75
109
  ##### -w DIR, --workdir DIR
76
110
  Specifies a directory on the local host where the sources should be placed and builds performed.
77
111
  Defaults to a temporary directory created with Ruby's `Dir.mktmpdir` method.
78
112
 
79
- ##### --remote_dir
113
+ ##### -r DIR, --remote-workdir DIR
80
114
  Explicitly specify a directory on the remote target to place sources and perform
81
115
  builds. Components can then be rebuilt manually on the build host for faster iteration. Sources may not be correctly updated if this directory already exists.
82
116
  Defaults to a temporary directory created by running `mktemp -d` on the remote target.
@@ -94,15 +128,17 @@ Currently supported engines are:
94
128
  * `hardware` - Build on a specific taget and lock it in redis
95
129
  * `ec2` - Build on a specific AWS instance.
96
130
 
97
- #### Flags (can be anywhere in the command)
131
+ #### Flags
132
+
133
+ **Note:** command flags can be used anywhere in the command.
98
134
 
99
135
  ##### -p, --preserve
100
136
  Indicates that the host used for building the project should be left intact
101
137
  after the build instead of destroyed. The host is usually destroyed after a
102
138
  successful build, or left after a failed build.
103
139
 
104
- ##### -v, --verbose (not yet implemented)
105
- Increase verbosity of output.
140
+ ##### -v, --verbose
141
+ (Reserved for future implementation) Will increase the verbosity of output, when implemented.
106
142
 
107
143
  ##### -h, --help
108
144
  Display command-line help.
@@ -172,13 +208,15 @@ directory.
172
208
 
173
209
  Platform can also be a comma separated list of platforms such as platform1,platform2.
174
210
 
175
- #### Flagged arguments (can be anywhere in the command)
211
+ #### Flagged arguments
212
+
213
+ **Note:** command flags can be used anywhere in the command.
176
214
 
177
215
  ##### -w DIR, --workdir DIR
178
216
  Specifies a directory where the sources should be placed and builds performed.
179
217
  Defaults to a temporary directory created with Ruby's Dir.mktmpdir.
180
218
 
181
- ##### -c DIR, --configdir DIR
219
+ ##### -c DIR, --configdir DIR <optional>
182
220
  Specifies where project configuration is found. Defaults to $pwd/configs.
183
221
 
184
222
  ##### -e ENGINE, --engine ENGINE
@@ -188,7 +226,9 @@ rendered -- the `inspect` command performs no compilation.
188
226
 
189
227
  Supported engines are the same as the `build` command.
190
228
 
191
- #### Flags (can be anywhere in the command)
229
+ #### Flags
230
+
231
+ **Note:** command flags can be used anywhere in the command.
192
232
 
193
233
  ##### -v, --verbose (not yet implemented)
194
234
  Increase verbosity of output.
@@ -223,20 +263,24 @@ As in `build` arguments.
223
263
  ##### platform name
224
264
  As in `build` arguments.
225
265
 
226
- ##### component names [optional]
266
+ ##### component names <optional>
227
267
  Specifies specific components that should be built. If components are not
228
268
  specified, then all components in the project will be built. If components
229
269
  are specified as arguments, then any in the project that aren't specified
230
270
  as arguments will be retrieved from packages rather than built from source.
231
271
 
232
- #### Flagged arguments (can be anywhere in the command)
272
+ #### Flagged arguments
273
+
274
+ **Note:** command flags can be used anywhere in the command.
233
275
 
234
276
  Supports all flagged arguments from the `build` command.
235
277
 
236
278
  ##### -t HOST, --target HOST
237
279
  As in the `build` target host optional argument.
238
280
 
239
- #### Flags (can be anywhere in the command)
281
+ #### Flags
282
+
283
+ **Note:** command flags can be used anywhere in the command.
240
284
 
241
285
  ##### -h, --help
242
286
  Display command-line help.
@@ -248,7 +292,7 @@ Engines
248
292
 
249
293
  ### Amazon Ec2
250
294
 
251
- Note: If you have the `aws_ami` setup vanagon will default to the ec2 engine.
295
+ Note: If you have the `aws_ami` setup Vanagon will default to the ec2 engine.
252
296
 
253
297
  To use the ec2 engine you should have your credentials set either via your `~/.aws/credentials` or environment variables.
254
298
  After this you can setup your `configs/platforms/<platform>.rb` to use your
@@ -294,7 +338,7 @@ If I wanted to build it for debian wheezy, I would define a platform called
294
338
  wheezy and build my project against it.
295
339
 
296
340
  For more detailed examples of the DSLs available, please see the
297
- [examples](https://github.com/puppetlabs/vanagon/tree/master/examples) directory and the YARD documentation for vanagon.
341
+ [examples](https://github.com/puppetlabs/vanagon/tree/master/examples) directory and the YARD documentation for Vanagon.
298
342
 
299
343
  ## Maintainers
300
344
  See MAINTAINERS file.
data/bin/build CHANGED
@@ -2,7 +2,7 @@
2
2
  load File.expand_path(File.join(File.dirname(__FILE__), "..", "lib", "vanagon.rb"))
3
3
 
4
4
  optparse = Vanagon::OptParse.new("#{File.basename(__FILE__)} <project-name> <platform-name> [<target>] [options]",
5
- [:workdir, :configdir, :engine, :preserve, :verbose, :skipcheck, :only_build, :remote_workdir])
5
+ [:workdir, :configdir, :engine, :preserve, :verbose, :skipcheck, :only_build, :"remote-workdir"])
6
6
  options = optparse.parse! ARGV
7
7
 
8
8
  project = ARGV[0]
@@ -1,5 +1,3 @@
1
- require 'vanagon/environment'
2
-
3
1
  class Makefile
4
2
  # The Rule class defines a single Makefile rule.
5
3
  #
@@ -13,11 +11,6 @@ class Makefile
13
11
  # @return [Array<String>] A list of dependencies that this rule depends on.
14
12
  attr_accessor :dependencies
15
13
 
16
- # @!attribute [rw] environment
17
- # @return [Array<String>] A list of environment variables that this rule
18
- # will export
19
- attr_accessor :environment
20
-
21
14
  # @!attribute [rw] recipe
22
15
  # @return [Array<String>] A list of commands to execute upon invocation of this rule.
23
16
  attr_accessor :recipe
@@ -43,10 +36,9 @@ class Makefile
43
36
  # "make cpplint",
44
37
  # ]
45
38
  # end
46
- def initialize(target, dependencies: [], environment: Vanagon::Environment.new, recipe: [], &block)
39
+ def initialize(target, dependencies: [], recipe: [], &block)
47
40
  @target = target
48
41
  @dependencies = dependencies
49
- @environment = environment
50
42
  @recipe = recipe
51
43
 
52
44
  yield(self) if block
@@ -65,25 +57,11 @@ class Makefile
65
57
  ["#{target}:", dependencies].flatten.compact.join("\s")
66
58
  end
67
59
 
68
- # @return [String] the Makefile target's name, rendered in a format
69
- # suitable for using as a Graphite group -- any periods in the name of
70
- # the component being built will be removed.
71
- # e.g. "ruby-2.1.9-unpack" will become "ruby-219.unpack"
72
- def tokenize_target_name
73
- target_name, _, rule = target.rpartition('-')
74
- [target_name.tr('.', ''), rule]
75
- .select { |s| !(s.nil? || s.empty?) }
76
- .join('.')
77
- end
78
-
79
- def tokenized_environment_variable
80
- "#{target}: export VANAGON_TARGET := #{tokenize_target_name}"
81
- end
82
-
83
- def environment_variables
84
- environment.map { |k, v| "#{k} := #{v}" }.map do |env|
85
- "#{target}: export #{env}"
86
- end
60
+ def compounded_recipe
61
+ Array(recipe)
62
+ .compact
63
+ .map { |line| "\t" + line.gsub("\n", "\n\t") + "\n" }
64
+ .join
87
65
  end
88
66
 
89
67
  # Format this rule as a Makefile rule.
@@ -92,37 +70,9 @@ class Makefile
92
70
  # newline to ensure that the recipe is parsed as part of a single makefile rule.
93
71
  #
94
72
  # @return [String]
95
- def format # rubocop:disable Metrics/AbcSize
96
- # create a base target inside an Array, and construct the rest of
97
- # the rule around that.
98
- t = [base_target]
99
-
100
- # prepend an environment variable that can be used inside a
101
- # given Make rule/target. We have to do it this way instead of
102
- # appending it to #environment because for reasons that I cannot
103
- # work out, the "sane" way results in previous/incorrect names
104
- # being used and objects being recycled. My working theory is
105
- # a corner case between metaprogrammed methods in Component::Rules,
106
- # and Ruby's preference for pass-by-reference.
107
- # Ryan McKern 2017-02-02
108
- t.unshift tokenized_environment_variable
109
-
110
- # prepend any environment variables to the existing target,
111
- # using the target prefix to identify them as such. they should
112
- # end up ahead of the dependencies and the build recipe.
113
- environment_variables.each do |env|
114
- t.unshift env
115
- end
116
-
117
- # finally, append the build recipe after the base target condition.
118
- # also, here's a fun edge case: if one were to call #squeeze on
119
- # the iterator 'line', basically all of the phony make tasks that
120
- # `touch` a file just disapear. Fragility ++.
121
- # - Ryan McKern 2017-02-02
122
- t.push recipe.compact.map { |line| "\t" + line.gsub("\n", "\n\t") + "\n" }.join
123
- t.join("\n")
73
+ def format
74
+ [base_target, compounded_recipe].flatten.join("\n")
124
75
  end
125
-
126
76
  alias to_s format
127
77
  end
128
78
  end
@@ -29,7 +29,8 @@ class Vanagon
29
29
  # that they were cloned to. For the outlying flat files, it'll
30
30
  # end up being defined explicitly as the string './'
31
31
  attr_accessor :dirname
32
- # what special tool should be used to extract the primary source
32
+ # The specific tools or command line invocations that
33
+ # should be used to extract a given component's sources
33
34
  attr_accessor :extract_with
34
35
  # how should this component be configured?
35
36
  attr_accessor :configure
@@ -190,7 +191,7 @@ class Vanagon
190
191
  end
191
192
 
192
193
  # Fetches the primary source for the component. As a side effect, also sets
193
- # \@extract_with, @dirname and @version for the component for use in the
194
+ # @extract_with, @dirname and @version for the component for use in the
194
195
  # makefile template
195
196
  #
196
197
  # @param workdir [String] working directory to put the source into
@@ -200,7 +201,8 @@ class Vanagon
200
201
  @source = Vanagon::Component::Source.source(url, opts)
201
202
  source.fetch
202
203
  source.verify
203
- @extract_with = source.respond_to?(:extract) ? source.extract(platform.tar) : nil
204
+ extract_with << source.extract(platform.tar) if source.respond_to? :extract
205
+
204
206
  @cleanup_source = source.cleanup if source.respond_to?(:cleanup)
205
207
  @dirname = source.dirname
206
208
 
@@ -215,7 +217,7 @@ class Vanagon
215
217
  @dirname = './'
216
218
 
217
219
  # If there is no source, there is nothing to do to extract
218
- @extract_with = ': no source, so nothing to extract'
220
+ extract_with << ': no source, so nothing to extract'
219
221
  end
220
222
  end
221
223
 
@@ -231,16 +233,25 @@ class Vanagon
231
233
  # Fetches secondary sources for the component. These are just dumped into the workdir currently.
232
234
  #
233
235
  # @param workdir [String] working directory to put the source into
234
- def get_sources(workdir)
236
+ def get_sources(workdir) # rubocop:disable Metrics/AbcSize
235
237
  sources.each do |source|
236
238
  src = Vanagon::Component::Source.source(
237
239
  source.url, workdir: workdir, ref: source.ref, sum: source.sum
238
240
  )
239
241
  src.fetch
240
242
  src.verify
243
+ # set src.file to only be populated with the basename instead of entire file path
244
+ src.file = File.basename(src.url)
245
+ extract_with << src.extract(platform.tar) if src.respond_to? :extract
241
246
  end
242
247
  end
243
248
 
249
+ # @return [Array] the specific tool or command line invocations that
250
+ # should be used to extract a given component's primary source
251
+ def extract_with
252
+ @extract_with ||= []
253
+ end
254
+
244
255
  # Fetches patches if any are provided for the project.
245
256
  #
246
257
  # @param workdir [String] working directory to put the patches into
@@ -265,14 +276,17 @@ class Vanagon
265
276
  The #get_environment method will be removed by Vanagon 1.0.0.
266
277
  eos
267
278
 
268
- if @environment.empty?
279
+ if environment.empty?
269
280
  ": no environment variables defined"
270
281
  else
271
- env = @environment.map { |key, value| %(#{key}="#{value}") }
272
- "export #{env.join(' ')}"
282
+ environment_variables
273
283
  end
274
284
  end
275
285
 
286
+ def environment_variables
287
+ environment.map { |key, value| %(export #{key}="#{value}") }
288
+ end
289
+
276
290
  def rules(project, platform)
277
291
  Vanagon::Component::Rules.new(self, project, platform)
278
292
  end
@@ -230,14 +230,14 @@ class Vanagon
230
230
  # upgrade if it has been modified
231
231
  #
232
232
  # @param file [String] name of the configfile
233
- def configfile(file)
233
+ def configfile(file, mode: nil, owner: nil, group: nil)
234
234
  # I AM SO SORRY
235
235
  @component.delete_file file
236
236
  if @component.platform.name =~ /solaris-10|osx/
237
237
  @component.install << "mv '#{file}' '#{file}.pristine'"
238
- @component.add_file Vanagon::Common::Pathname.configfile("#{file}.pristine")
238
+ @component.add_file Vanagon::Common::Pathname.configfile("#{file}.pristine", mode: mode, owner: owner, group: group)
239
239
  else
240
- @component.add_file Vanagon::Common::Pathname.configfile(file)
240
+ @component.add_file Vanagon::Common::Pathname.configfile(file, mode: mode, owner: owner, group: group)
241
241
  end
242
242
  end
243
243
 
@@ -245,9 +245,9 @@ class Vanagon
245
245
  #
246
246
  # @param source [String] path to the configfile to copy
247
247
  # @param target [String] path to the desired target of the configfile
248
- def install_configfile(source, target)
249
- install_file(source, target)
250
- configfile(target)
248
+ def install_configfile(source, target, mode: '0644', owner: nil, group: nil)
249
+ install_file(source, target, mode: mode, owner: owner, group: group)
250
+ configfile(target, mode: mode, owner: owner, group: group)
251
251
  end
252
252
 
253
253
  # link will add a command to the install to create a symlink from source to target
@@ -350,7 +350,7 @@ class Vanagon
350
350
  eos
351
351
  return @component.environment.merge!(env.first)
352
352
  elsif env.size == 2
353
- return @component.environment[env.key] = env.value
353
+ return @component.environment[env.first] = env.last
354
354
  end
355
355
  raise ArgumentError, <<-eos.undent
356
356
  component DSL method #environment only accepts a single Hash (deprecated)