vanagon 0.6.3 → 0.7.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: 6f430d963bf116d91cbf83256331875e5e335201
4
- data.tar.gz: 1aa6339e0badadb4007b47f2220bade631525dd9
3
+ metadata.gz: 00aa7997dec07d58c44cb6d6076dd2560822d042
4
+ data.tar.gz: 79b4904349d110f3eb55f007db5b8cd3c907ae37
5
5
  SHA512:
6
- metadata.gz: a9cc2b608f290d1c562edcba2044be400cc26e32d32dc36c5c58904d319cc210a6774e170ab863ccbe183460ceee00b3f3dbb2c600ba5fef16bc7505d3060a3e
7
- data.tar.gz: 6e22988b5a57b7e73a56f48e3748afe11f2d261cb26fd9257a210c5cab2f5c48173639d390358d9022b6d2fa73e121dd13d1fb72e6eb80d52017a05737c9aeb7
6
+ metadata.gz: db753395aaf5db11fff64523b0ae2385e1d0919d53612e4b8d6a4402817bb4ee56919adf918845078e5c6459ac91dbdaa3429131495febc50111e6e1a313760f
7
+ data.tar.gz: 1521d569ad2be537fb72dd56ea21b4907c4bd365205312682b933b16262a5b456470f40799a76b9c782c2dc6f0dfb2c095f64e2a57b8c491c4d89da2f3e19cfe
@@ -1,10 +1,8 @@
1
1
  class Makefile
2
-
3
2
  # The Rule class defines a single Makefile rule.
4
3
  #
5
4
  # @see http://www.gnu.org/software/make/manual/make.html#Rule-Introduction
6
5
  class Rule
7
-
8
6
  # @!attribute [rw] target
9
7
  # @return [String] The target generated by this rule.
10
8
  attr_accessor :target
@@ -43,7 +41,7 @@ class Makefile
43
41
  @dependencies = dependencies
44
42
  @recipe = recipe
45
43
 
46
- block.call(self) if block
44
+ yield(self) if block
47
45
  end
48
46
 
49
47
  # Format this rule as a Makefile rule.
@@ -44,7 +44,7 @@ class Vanagon
44
44
  # @example Create a new Vanagon::Common::Pathname, marked as a file.
45
45
  # Vanagon::Common::Pathname.file('/etc/puppet/puppet/puppet.conf')
46
46
  def self.file(path, **args)
47
- new(path, **args.merge!({ config: false}))
47
+ new(path, **args.merge!({ config: false }))
48
48
  end
49
49
 
50
50
  # An alias to {Vanagon::Common::Pathname}'s constructor method,
@@ -54,7 +54,7 @@ class Vanagon
54
54
  # @example Create a new configuration file, marked as a configuration file.
55
55
  # Vanagon::Common::Pathname.configfile('/etc/puppet/puppet/puppet.conf')
56
56
  def self.configfile(path, **args)
57
- new(path, **args.merge!({ config: true}))
57
+ new(path, **args.merge!({ config: true }))
58
58
  end
59
59
 
60
60
  # @return [Boolean] true if a self is marked as a configuration file.
@@ -13,7 +13,7 @@ class Vanagon
13
13
  # Equality. How does it even work?
14
14
  #
15
15
  # @return [true, false] true if all attributes have equal values. false otherwise.
16
- def ==(other)
16
+ def ==(other) # rubocop:disable Metrics/AbcSize
17
17
  other.name == self.name && \
18
18
  other.group == self.group && \
19
19
  other.shell == self.shell && \
@@ -41,7 +41,7 @@ class Vanagon
41
41
  # @param settings [Hash] the settings to be used in the component
42
42
  # @param platform [Vanagon::Platform] the platform to build the component for
43
43
  # @return [Vanagon::Component] the component with the given settings and platform
44
- def initialize(name, settings, platform)
44
+ def initialize(name, settings, platform) # rubocop:disable Metrics/AbcSize
45
45
  @name = name
46
46
  @settings = settings
47
47
  @platform = platform
@@ -22,7 +22,7 @@ class Vanagon
22
22
  # @param name [String] name of the componennt
23
23
  # @param block [Proc] DSL definition of the component to call
24
24
  def component(name, &block)
25
- block.call(self, @component.settings, @component.platform)
25
+ yield(self, @component.settings, @component.platform)
26
26
  end
27
27
 
28
28
  # Accessor for the component.
@@ -54,35 +54,28 @@ class Vanagon
54
54
  #
55
55
  # @param block [Proc] the command(s) required to configure the component
56
56
  def configure(&block)
57
- @component.configure << block.call
57
+ @component.configure << yield
58
58
  end
59
59
 
60
60
  # Set or add to the build call for the component. The commands required to build the component before testing/installing it.
61
61
  #
62
62
  # @param block [Proc] the command(s) required to build the component
63
63
  def build(&block)
64
- @component.build << block.call
64
+ @component.build << yield
65
65
  end
66
66
 
67
67
  # Set or add to the check call for the component. The commands required to test the component before installing it.
68
68
  #
69
69
  # @param block [Proc] the command(s) required to test the component
70
70
  def check(&block)
71
- @component.check << block.call
71
+ @component.check << yield
72
72
  end
73
73
 
74
74
  # Set or add to the install call for the component. The commands required to install the component.
75
75
  #
76
76
  # @param block [Proc] the command(s) required to install the component
77
77
  def install(&block)
78
- @component.install << block.call
79
- end
80
-
81
- # Setup any specific environment required to configure, build or install the component
82
- #
83
- # @param block [Proc] the environment required to configure, build or install the component
84
- def environment(&block)
85
- @component.environment = block.call
78
+ @component.install << yield
86
79
  end
87
80
 
88
81
  # Add a patch to the list of patches to apply to the component's source after unpacking
@@ -168,7 +161,7 @@ class Vanagon
168
161
  # @param default_file [String] path to the default file relative to the source
169
162
  # @param service_name [String] name of the service
170
163
  # @param service_type [String] type of the service (network, application, system, etc)
171
- def install_service(service_file, default_file = nil, service_name = @component.name, service_type: nil)
164
+ def install_service(service_file, default_file = nil, service_name = @component.name, service_type: nil) # rubocop:disable Metrics/AbcSize
172
165
  case @component.platform.servicetype
173
166
  when "sysv"
174
167
  target_service_file = File.join(@component.platform.servicedir, service_name)
@@ -223,7 +216,7 @@ class Vanagon
223
216
  # @param target [String] path to the desired target of the file
224
217
  # @param owner [String] owner of the file
225
218
  # @param group [String] group owner of the file
226
- def install_file(source, target, mode: '0644', owner: nil, group: nil)
219
+ def install_file(source, target, mode: '0644', owner: nil, group: nil)
227
220
  @component.install << "#{@component.platform.install} -d '#{File.dirname(target)}'"
228
221
  @component.install << "#{@component.platform.copy} -p '#{source}' '#{target}'"
229
222
  @component.add_file Vanagon::Common::Pathname.file(target, mode: mode, owner: owner, group: group)
@@ -235,7 +228,7 @@ class Vanagon
235
228
  # @param file [String] name of the configfile
236
229
  def configfile(file)
237
230
  # I AM SO SORRY
238
- @component.delete_file "#{file}"
231
+ @component.delete_file file
239
232
  if @component.platform.name =~ /solaris-10|osx/
240
233
  @component.install << "mv '#{file}' '#{file}.pristine'"
241
234
  @component.add_file Vanagon::Common::Pathname.configfile("#{file}.pristine")
@@ -6,7 +6,6 @@ class Vanagon
6
6
  class Component
7
7
  # Vanagon::Component::Rules creates all Makefile rules for a given component.
8
8
  class Rules
9
-
10
9
  include Vanagon::Utilities::ShellUtilities
11
10
 
12
11
  # Create methods that generate Makefile rules.
@@ -67,7 +66,7 @@ class Vanagon
67
66
  #
68
67
  # @return [Makefile::Rule]
69
68
  def component_rule
70
- Makefile::Rule.new("#{@component.name}", dependencies: ["#{@component.name}-install"])
69
+ Makefile::Rule.new(@component.name, dependencies: ["#{@component.name}-install"])
71
70
  end
72
71
 
73
72
  # Unpack the source for this component. The unpacking behavior depends on
@@ -5,7 +5,7 @@ require 'vanagon/component/source/local'
5
5
  class Vanagon
6
6
  class Component
7
7
  class Source
8
- SUPPORTED_PROTOCOLS = ['file', 'http', 'git']
8
+ SUPPORTED_PROTOCOLS = ['file', 'http', 'git'].freeze
9
9
  @@rewrite_rule = {}
10
10
 
11
11
  def self.register_rewrite_rule(protocol, rule)
@@ -10,7 +10,7 @@ class Vanagon
10
10
  attr_accessor :url, :sum, :file, :extension, :workdir, :cleanup
11
11
 
12
12
  # Extensions for files we intend to unpack during the build
13
- ARCHIVE_EXTENSIONS = '.tar.gz', '.tgz', '.zip'
13
+ ARCHIVE_EXTENSIONS = ['.tar.gz', '.tgz', '.zip'].freeze
14
14
 
15
15
  # Constructor for the Http source type
16
16
  #
@@ -48,7 +48,7 @@ class Vanagon
48
48
  # Downloads the file from @url into the @workdir
49
49
  # @param target_url [String, URI, Addressable::URI] url of an http source to retrieve with GET
50
50
  # @raise [RuntimeError, Vanagon::Error] an exception is raised if the URI scheme cannot be handled
51
- def download(target_url, target_file = nil)
51
+ def download(target_url, target_file = nil) # rubocop:disable Metrics/AbcSize
52
52
  uri = URI.parse(target_url.to_s)
53
53
  target_file ||= File.basename(uri.path)
54
54
 
@@ -93,7 +93,7 @@ class Vanagon
93
93
  when ".tar.gz", ".tgz"
94
94
  return "gunzip -c '#{@file}' | '#{tar}' xf -"
95
95
  when ".zip"
96
- return "unzip '#{@file}' || 7za x -r -tzip -o'#{File.basename(@file, ".zip")}' '#{@file}'"
96
+ return "unzip '#{@file}' || 7za x -r -tzip -o'#{File.basename(@file, '.zip')}' '#{@file}'"
97
97
  end
98
98
  else
99
99
  # Extension does not appear to be an archive
@@ -10,7 +10,7 @@ class Vanagon
10
10
  attr_accessor :url, :file, :extension, :workdir, :cleanup
11
11
 
12
12
  # Extensions for files we intend to unpack during the build
13
- ARCHIVE_EXTENSIONS = '.tar.gz', '.tgz', '.zip'
13
+ ARCHIVE_EXTENSIONS = ['.tar.gz', '.tgz', '.zip'].freeze
14
14
 
15
15
  # Constructor for the File source type
16
16
  #
@@ -51,7 +51,6 @@ class Vanagon
51
51
  end
52
52
 
53
53
  target_file
54
-
55
54
  end
56
55
 
57
56
  # Gets the command to extract the archive given if needed (uses @extension)
@@ -65,7 +64,7 @@ class Vanagon
65
64
  when ".tar.gz", ".tgz"
66
65
  return "gunzip -c '#{@file}' | '#{tar}' xf -"
67
66
  when ".zip"
68
- return "unzip '#{@file}' || 7za x -r -tzip -o'#{File.basename(@file, ".zip")}' '#{@file}'"
67
+ return "unzip '#{@file}' || 7za x -r -tzip -o'#{File.basename(@file, '.zip')}' '#{@file}'"
69
68
  end
70
69
  else
71
70
  # Extension does not appear to be an archive
@@ -116,4 +115,4 @@ class Vanagon
116
115
  end
117
116
  end
118
117
  end
119
- end
118
+ end
@@ -13,7 +13,7 @@ class Vanagon
13
13
  attr_accessor :platform, :project, :target, :workdir, :verbose, :preserve
14
14
  attr_accessor :timeout, :retry_count
15
15
 
16
- def initialize(platform, project, options = { :configdir => nil, :target => nil, :engine => nil, :components => nil, :skipcheck => false, :verbose => false, :preserve => false })
16
+ def initialize(platform, project, options = { :configdir => nil, :target => nil, :engine => nil, :components => nil, :skipcheck => false, :verbose => false, :preserve => false }) # rubocop:disable Metrics/AbcSize
17
17
  @verbose = options[:verbose]
18
18
  @preserve = options[:preserve]
19
19
 
@@ -74,7 +74,7 @@ class Vanagon
74
74
  @project.components.map(&:build_requires).flatten.uniq - @project.components.map(&:name)
75
75
  end
76
76
 
77
- def install_build_dependencies
77
+ def install_build_dependencies # rubocop:disable Metrics/AbcSize
78
78
  unless list_build_dependencies.empty?
79
79
  if @platform.build_dependencies && @platform.build_dependencies.command && !@platform.build_dependencies.command.empty?
80
80
  @engine.dispatch("#{@platform.build_dependencies.command} #{list_build_dependencies.join(' ')} #{@platform.build_dependencies.suffix}")
@@ -86,7 +86,7 @@ class Vanagon
86
86
  end
87
87
  end
88
88
 
89
- def run
89
+ def run # rubocop:disable Metrics/AbcSize
90
90
  # Simple sanity check for the project
91
91
  if @project.version.nil? or @project.version.empty?
92
92
  raise Vanagon::Error, "Project requires a version set, all is lost."
@@ -115,7 +115,7 @@ class Vanagon
115
115
  end
116
116
  end
117
117
 
118
- def prepare(workdir = nil)
118
+ def prepare(workdir = nil) # rubocop:disable Metrics/AbcSize
119
119
  @workdir = workdir ? FileUtils.mkdir_p(workdir).first : Dir.mktmpdir
120
120
  @engine.startup(@workdir)
121
121
 
@@ -76,7 +76,7 @@ class Vanagon
76
76
  def validate_platform
77
77
  missing_attrs = []
78
78
  @required_attributes.each do |attr|
79
- if (!@platform.instance_variables.include?("@#{attr}".to_sym)) or @platform.instance_variable_get("@#{attr}".to_sym).nil?
79
+ if !@platform.instance_variables.include?("@#{attr}".to_sym) || @platform.instance_variable_get("@#{attr}".to_sym).nil?
80
80
  missing_attrs << attr
81
81
  end
82
82
  end
@@ -9,7 +9,7 @@ class Vanagon
9
9
  attr_accessor :ami, :key_name, :userdata, :key, :key_name, :shutdown_behavior
10
10
  attr_accessor :subnet_id, :instance_type
11
11
 
12
- def initialize(platform, target = nil)
12
+ def initialize(platform, target = nil) # rubocop:disable Metrics/AbcSize
13
13
  super
14
14
 
15
15
  @ami = @platform.aws_ami
@@ -12,7 +12,6 @@ class Vanagon
12
12
  # Class to use when building on a hardware device (e.g. AIX, Switch, etc)
13
13
  #
14
14
  class Hardware < Base
15
-
16
15
  # This method is used to obtain a vm to build upon
17
16
  # For the base class we just return the target that was passed in
18
17
  def select_target
@@ -5,7 +5,6 @@ require 'vanagon/errors'
5
5
  class Vanagon
6
6
  class Engine
7
7
  class Local < Base
8
-
9
8
  def initialize(platform, target = nil)
10
9
  # local engine can't be used with a target
11
10
  super(platform, 'local machine')
@@ -38,14 +37,13 @@ class Vanagon
38
37
  end
39
38
 
40
39
  def ship_workdir(workdir)
41
- FileUtils.cp_r(Dir.glob("#{workdir}/*"), "#{@remote_workdir}")
40
+ FileUtils.cp_r(Dir.glob("#{workdir}/*"), @remote_workdir)
42
41
  end
43
42
 
44
43
  def retrieve_built_artifact
45
44
  FileUtils.mkdir_p("output")
46
45
  FileUtils.cp_r(Dir.glob("#{@remote_workdir}/output/*"), "output/")
47
46
  end
48
-
49
47
  end
50
48
  end
51
49
  end
@@ -46,7 +46,7 @@ class Vanagon
46
46
  # This method is used to obtain a vm to build upon using the Puppet Labs'
47
47
  # vmpooler (https://github.com/puppetlabs/vmpooler)
48
48
  # @raise [Vanagon::Error] if a target cannot be obtained
49
- def select_target
49
+ def select_target # rubocop:disable Metrics/AbcSize
50
50
  response = Vanagon::Utilities.http_request(
51
51
  "#{@pooler}/vm",
52
52
  'POST',
@@ -1,5 +1,4 @@
1
1
  class Vanagon
2
-
3
2
  # An error class that accepts a wrapped error message
4
3
  #
5
4
  class Error < StandardError
@@ -2,7 +2,6 @@ require 'optparse'
2
2
 
3
3
  class Vanagon
4
4
  class OptParse
5
-
6
5
  FLAGS = {
7
6
  :workdir => ['-w DIR', '--workdir DIR', "Working directory where build source should be put (defaults to a tmpdir)"],
8
7
  :configdir => ['-c', '--configdir DIR', 'Configs dir (defaults to $pwd/configs)'],
@@ -11,7 +10,7 @@ class Vanagon
11
10
  :skipcheck => ['--skipcheck', 'Skip the `check` stage when building components'],
12
11
  :preserve => ['-p', '--preserve', 'Whether to tear down the VM on success or not (defaults to false)'],
13
12
  :verbose => ['-v', '--verbose', 'Verbose output (does nothing)'],
14
- }
13
+ }.freeze
15
14
 
16
15
  def initialize(banner, options = [])
17
16
  @options = Hash[options.map { |v| [v, nil] }]
@@ -2,7 +2,6 @@ require 'vanagon/errors'
2
2
 
3
3
  class Vanagon
4
4
  class Patch
5
-
6
5
  # @!attribute [r] path
7
6
  # @return [String] The path to the patch
8
7
  attr_reader :path
@@ -8,7 +8,7 @@ class Vanagon
8
8
  attr_accessor :docker_image, :ssh_port, :rpmbuild, :install, :platform_triple
9
9
  attr_accessor :target_user, :package_type, :find, :sort, :build_hosts, :copy, :cross_compiled
10
10
  attr_accessor :aws_ami, :aws_user_data, :aws_shutdown_behavior, :aws_key_name, :aws_region, :aws_key
11
- attr_accessor :aws_instance_type, :aws_vpc_id, :aws_subnet_id
11
+ attr_accessor :aws_instance_type, :aws_vpc_id, :aws_subnet_id, :output_dir
12
12
 
13
13
  # Platform names currently contain some information about the platform. Fields
14
14
  # within the name are delimited by the '-' character, and this regex can be used to
@@ -60,7 +60,7 @@ class Vanagon
60
60
  #
61
61
  # @param user [Vanagon::Common::User] the user to create
62
62
  # @return [String] the commands required to add a user to the system
63
- def add_user(user)
63
+ def add_user(user) # rubocop:disable Metrics/AbcSize
64
64
  cmd_args = ["'#{user.name}'"]
65
65
  cmd_args.unshift "--home '#{user.homedir}'" if user.homedir
66
66
  if user.shell
@@ -95,7 +95,7 @@ class Vanagon
95
95
  #
96
96
  # @param name [String] name of the platform
97
97
  # @return [Vanagon::Platform] the platform with the given name
98
- def initialize(name)
98
+ def initialize(name) # rubocop:disable Metrics/AbcSize
99
99
  @name = name
100
100
  @os_name = os_name
101
101
  @os_version = os_version
@@ -117,6 +117,16 @@ class Vanagon
117
117
  end
118
118
  end
119
119
 
120
+ # Get the output dir for packages. If the output_dir was defined already (by
121
+ # the platform config) then don't change it.
122
+ #
123
+ # @param target_repo [String] optional repo target for built packages defined
124
+ # at the project level
125
+ # @return [String] relative path to where packages should be output to
126
+ def output_dir(target_repo = "")
127
+ @output_dir ||= File.join(@os_name, @os_version, target_repo, @architecture)
128
+ end
129
+
120
130
  # Sets and gets the name of the operating system for the platform.
121
131
  # Also has the side effect of setting the @os_name instance attribute
122
132
  #
@@ -5,7 +5,7 @@ class Vanagon
5
5
  #
6
6
  # @param project [Vanagon::Project] project to build a debian package of
7
7
  # @return [Array] list of commands required to build a debian package for the given project from a tarball
8
- def generate_package(project)
8
+ def generate_package(project) # rubocop:disable Metrics/AbcSize
9
9
  target_dir = project.repo ? output_dir(project.repo) : output_dir
10
10
  pkg_arch_opt = project.noarch ? "" : "-a#{@architecture}"
11
11
  ["mkdir -p output/#{target_dir}",
@@ -47,14 +47,6 @@ class Vanagon
47
47
  "#{project.name}_#{project.version}-#{project.release}#{@codename}_#{project.noarch ? 'all' : @architecture}.deb"
48
48
  end
49
49
 
50
- # Get the expected output dir for the debian packages. This allows us to
51
- # use some standard tools to ship internally.
52
- #
53
- # @return [String] relative path to where debian packages should be staged
54
- def output_dir(target_repo = "")
55
- File.join("deb", @codename, target_repo)
56
- end
57
-
58
50
  # Returns the string to add a target repo to the platforms' provisioning
59
51
  #
60
52
  # @param definition [URI] A URI to a deb or list file
@@ -50,7 +50,7 @@ class Vanagon
50
50
  fail "Platform not implemented for '#{@name}' yet. Please go do so..."
51
51
  end
52
52
 
53
- block.call(self)
53
+ yield(self)
54
54
  @platform
55
55
  end
56
56
 
@@ -313,6 +313,10 @@ class Vanagon
313
313
  @platform.codename = name
314
314
  end
315
315
 
316
+ def output_dir(directory)
317
+ @platform.output_dir = directory
318
+ end
319
+
316
320
  # Helper to setup a apt repository on a target system
317
321
  #
318
322
  # @param definition [String] the repo setup file, must be a valid uri, fetched with curl
@@ -5,7 +5,7 @@ class Vanagon
5
5
  #
6
6
  # @param project [Vanagon::Project] project to build a osx package of
7
7
  # @return [Array] list of commands required to build a osx package for the given project from a tarball
8
- def generate_package(project)
8
+ def generate_package(project) # rubocop:disable Metrics/AbcSize
9
9
  target_dir = project.repo ? output_dir(project.repo) : output_dir
10
10
 
11
11
  # Here we maintain backward compatibility with older vanagon versions
@@ -13,10 +13,11 @@ class Vanagon
13
13
  # in favor of just letting the makefile deliver the bill-of-materials
14
14
  # to the correct directory. This shouldn't be required at all then.
15
15
  if project.bill_of_materials.nil?
16
- bom_install = [# Move bill-of-materials into a docdir
17
- "mkdir -p $(tempdir)/osx/build/root/#{project.name}-#{project.version}/usr/local/share/doc/#{project.name}",
18
- "mv $(tempdir)/osx/build/root/#{project.name}-#{project.version}/bill-of-materials $(tempdir)/osx/build/root/#{project.name}-#{project.version}/usr/local/share/doc/#{project.name}/bill-of-materials",]
19
-
16
+ bom_install = [
17
+ # Move bill-of-materials into a docdir
18
+ "mkdir -p $(tempdir)/osx/build/root/#{project.name}-#{project.version}/usr/local/share/doc/#{project.name}",
19
+ "mv $(tempdir)/osx/build/root/#{project.name}-#{project.version}/bill-of-materials $(tempdir)/osx/build/root/#{project.name}-#{project.version}/usr/local/share/doc/#{project.name}/bill-of-materials",
20
+ ]
20
21
  else
21
22
  bom_install = []
22
23
  end
@@ -63,7 +64,7 @@ class Vanagon
63
64
  # @param workdir [String] working directory to stage the evaluated templates in
64
65
  # @param name [String] name of the project
65
66
  # @param binding [Binding] binding to use in evaluating the packaging templates
66
- def generate_packaging_artifacts(workdir, name, binding)
67
+ def generate_packaging_artifacts(workdir, name, binding) # rubocop:disable Metrics/AbcSize
67
68
  resources_dir = File.join(workdir, "resources", "osx")
68
69
  FileUtils.mkdir_p(resources_dir)
69
70
  script_dir = File.join(workdir, "scripts")
@@ -91,14 +92,6 @@ class Vanagon
91
92
  "#{project.name}-#{project.version}-#{project.release}.#{@os_name}#{@os_version}.dmg"
92
93
  end
93
94
 
94
- # Get the expected output dir for the osx packages. This allows us to
95
- # use some standard tools to ship internally.
96
- #
97
- # @return [String] relative path to where osx packages should be staged
98
- def output_dir(target_repo = "")
99
- File.join("apple", @os_version, target_repo, @architecture)
100
- end
101
-
102
95
  # Constructor. Sets up some defaults for the osx platform and calls the parent constructor
103
96
  #
104
97
  # @param name [String] name of the platform
@@ -36,22 +36,14 @@ class Vanagon
36
36
  "#{project.name}-#{project.version}-#{project.release}.#{project.noarch ? 'noarch' : @architecture}.rpm"
37
37
  end
38
38
 
39
- # Get the expected output dir for the rpm packages. This allows us to
40
- # use some standard tools to ship internally.
41
- #
42
- # @return [String] relative path to where rpm packages should be staged
43
- def output_dir(target_repo = "products")
44
- File.join(@os_name, @os_version, target_repo, @architecture)
45
- end
46
-
47
39
  def rpm_defines
48
40
  defines = %(--define '_topdir $(tempdir)/rpmbuild' )
49
41
  # RPM doesn't allow dashes in the os_name. This was added to
50
42
  # convert cisco-wrlinux to cisco_wrlinux
51
- defines << %(--define 'dist .#{@os_name.gsub('-', '_')}#{@os_version}' )
43
+ defines << %(--define 'dist .#{@os_name.tr('-', '_')}#{@os_version}' )
52
44
  end
53
45
 
54
- def add_repository(definition)
46
+ def add_repository(definition) # rubocop:disable Metrics/AbcSize
55
47
  definition = URI.parse(definition)
56
48
 
57
49
  commands = ["rpm -q curl > /dev/null || yum -y install curl"]
@@ -21,7 +21,7 @@ class Vanagon
21
21
  commands << "tmpdir=$(mktemp -p /var/tmp -d)"
22
22
  commands << "cd ${tmpdir}"
23
23
  build_dependencies.each do |build_dependency|
24
- if build_dependency.match(/^http.*\.rpm$/)
24
+ if build_dependency =~ /^http.*\.rpm$/
25
25
  # We're downloading each package individually so
26
26
  # failures are easier to troubleshoot
27
27
  commands << %(curl --remote-name --location --fail --silent #{build_dependency} && echo "Successfully downloaded #{build_dependency}")
@@ -5,7 +5,7 @@ class Vanagon
5
5
  #
6
6
  # @param project [Vanagon::Project] project to build a solaris package of
7
7
  # @return [Array] list of commands required to build a solaris package for the given project from a tarball
8
- def generate_package(project)
8
+ def generate_package(project) # rubocop:disable Metrics/AbcSize
9
9
  target_dir = project.repo ? output_dir(project.repo) : output_dir
10
10
  name_and_version = "#{project.name}-#{project.version}"
11
11
  pkg_name = package_name(project)
@@ -28,9 +28,11 @@ class Vanagon
28
28
  # in favor of just letting the makefile deliver the bill-of-materials
29
29
  # to the correct directory. This shouldn't be required at all then.
30
30
  if project.bill_of_materials.nil?
31
- bom_install = [# Move bill-of-materials into a docdir
32
- "mkdir -p $(tempdir)/#{name_and_version}/usr/share/doc/#{project.name}",
33
- "mv $(tempdir)/#{name_and_version}/bill-of-materials $(tempdir)/#{name_and_version}/usr/share/doc/#{project.name}/bill-of-materials",]
31
+ bom_install = [
32
+ # Move bill-of-materials into a docdir
33
+ "mkdir -p $(tempdir)/#{name_and_version}/usr/share/doc/#{project.name}",
34
+ "mv $(tempdir)/#{name_and_version}/bill-of-materials $(tempdir)/#{name_and_version}/usr/share/doc/#{project.name}/bill-of-materials",
35
+ ]
34
36
  else
35
37
  bom_install = []
36
38
  end
@@ -106,7 +108,7 @@ class Vanagon
106
108
  #
107
109
  # @param user [Vanagon::Common::User] the user to create
108
110
  # @return [String] the commands required to add a user to the system
109
- def add_user(user)
111
+ def add_user(user) # rubocop:disable Metrics/AbcSize
110
112
  # NB: system users aren't supported on solaris 10
111
113
  # Solaris 10 also doesn't support long flags
112
114
  cmd_args = ["'#{user.name}'"]
@@ -138,28 +140,20 @@ class Vanagon
138
140
  "#{project.name}-#{project.version}-#{project.release}.#{@architecture}.pkg.gz"
139
141
  end
140
142
 
141
- # Get the expected output dir for the solaris 10 packages. This allows us to
142
- # use some standard tools to ship internally.
143
- #
144
- # @return [String] relative path to where solaris 10 packages should be staged
145
- def output_dir(target_repo = "")
146
- File.join("solaris", @os_version, target_repo)
147
- end
148
-
149
143
  # Because solaris has multiple terrible ways to install packages, we have
150
144
  # this method which generates a shell script to be executed on the system
151
145
  # which will install all of the build dependencies
152
146
  #
153
147
  # @param build_dependencies [Array] list of all build dependencies to install
154
148
  # @return [String] a command to install all of the build dependencies
155
- def install_build_dependencies(build_dependencies)
149
+ def install_build_dependencies(build_dependencies) # rubocop:disable Metrics/AbcSize
156
150
  http = []
157
151
  pkgutil = []
158
152
  noasks = ["instance=overwrite", "partial=nocheck", "runlevel=nocheck", "idepend=nocheck", "rdepend=nocheck", "space=nocheck", "setuid=nocheck", "conflict=nocheck", "action=nocheck", "basedir=default"]
159
153
  noask_command = noasks.map { |noask| "echo '#{noask}' >> /var/tmp/noask" }.join('; ')
160
154
 
161
155
  build_dependencies.each do |build_dependency|
162
- if build_dependency.match(/^http.*\.gz/)
156
+ if build_dependency =~ /^http.*\.gz/
163
157
  # Fetch, unpack, install...this assumes curl is present.
164
158
  package = build_dependency.sub(/^http.*\//, '')
165
159
  http << "tmpdir=$(mktemp -p /var/tmp -d); (cd ${tmpdir} && curl -O #{build_dependency} && gunzip -c #{package} | pkgadd -d /dev/stdin -a /var/tmp/noask all)"
@@ -5,7 +5,7 @@ class Vanagon
5
5
  #
6
6
  # @param project [Vanagon::Project] project to build a solaris package of
7
7
  # @return [Array] list of commands required to build a solaris package for the given project from a tarball
8
- def generate_package(project)
8
+ def generate_package(project) # rubocop:disable Metrics/AbcSize
9
9
  target_dir = project.repo ? output_dir(project.repo) : output_dir
10
10
  name_and_version = "#{project.name}-#{project.version}"
11
11
  pkg_name = package_name(project)
@@ -106,14 +106,6 @@ class Vanagon
106
106
  "#{version},5.11-#{release}"
107
107
  end
108
108
 
109
- # Get the expected output dir for the solaris 11 packages. This allows us to
110
- # use some standard tools to ship internally.
111
- #
112
- # @return [String] relative path to where solaris 11 packages should be staged
113
- def output_dir(target_repo = "")
114
- File.join("solaris", @os_version, target_repo)
115
- end
116
-
117
109
  # Constructor. Sets up some defaults for the solaris 11 platform and calls the parent constructor
118
110
  #
119
111
  # @param name [String] name of the platform
@@ -77,7 +77,7 @@ class Vanagon
77
77
  # @param vanagon_root [String] Vanagon wix resources directory
78
78
  # @param destination [String] Destination directory
79
79
  # @param verbose [String] True or false
80
- def merge_defaults_from_vanagon(vanagon_root, destination, verbose: false)
80
+ def merge_defaults_from_vanagon(vanagon_root, destination, verbose: false) # rubocop:disable Metrics/AbcSize
81
81
  # Will use this Pathname object for relative path calculations in loop below.
82
82
  vanagon_path = Pathname.new(vanagon_root)
83
83
  files = Dir.glob(File.join(vanagon_root, "**/*.*"))
@@ -140,7 +140,7 @@ class Vanagon
140
140
  # @param project [Vanagon::Project] project to build a nuget package of
141
141
  # @return [Array] list of commands required to build a nuget package for
142
142
  # the given project from a tarball
143
- def generate_nuget_package(project)
143
+ def generate_nuget_package(project) # rubocop:disable Metrics/AbcSize
144
144
  target_dir = project.repo ? output_dir(project.repo) : output_dir
145
145
  ["mkdir -p output/#{target_dir}",
146
146
  "mkdir -p $(tempdir)/#{project.name}/tools",
@@ -161,7 +161,7 @@ class Vanagon
161
161
  #
162
162
  # @param project [Vanagon::Project] project to build a msi package of
163
163
  # @return [Array] list of commands required to build an msi package for the given project from a tarball
164
- def generate_msi_package(project)
164
+ def generate_msi_package(project) # rubocop:disable Metrics/AbcSize
165
165
  target_dir = project.repo ? output_dir(project.repo) : output_dir
166
166
  wix_extensions = "-ext WiXUtilExtension -ext WixUIExtension"
167
167
  # Heat command documentation at: http://wixtoolset.org/documentation/manual/v3/overview/heat.html
@@ -186,7 +186,8 @@ class Vanagon
186
186
  # "Misc Dir for versions.txt, License file and Icon file"
187
187
  misc_dir = "SourceDir/#{project.settings[:base_dir]}/#{project.settings[:company_id]}/#{project.settings[:product_id]}/misc"
188
188
  # Actual array of commands to be written to the Makefile
189
- ["mkdir -p output/#{target_dir}",
189
+ [
190
+ "mkdir -p output/#{target_dir}",
190
191
  "mkdir -p $(tempdir)/{SourceDir,wix/wixobj}",
191
192
  "#{@copy} -r wix/* $(tempdir)/wix/",
192
193
  "gunzip -c #{project.name}-#{project.version}.tar.gz | '#{@tar}' -C '$(tempdir)/SourceDir' --strip-components 1 -xf -",
@@ -204,7 +205,7 @@ class Vanagon
204
205
  # the -b flag simply points light to where the SourceDir location is
205
206
  # -loc is required for the UI localization it points to the actual localization .wxl
206
207
  "cd $(tempdir)/wix/wixobj; \"$$WIX/bin/light.exe\" #{light_flags} -b $$(cygpath -aw $(tempdir)) -loc $$(cygpath -aw $(tempdir)/wix/localization/puppet_en-us.wxl) -out $$(cygpath -aw $(workdir)/output/#{target_dir}/#{msi_package_name(project)}) *.wixobj",
207
- ]
208
+ ]
208
209
  end
209
210
 
210
211
  # Method to derive the msi (Windows Installer) package name for the project.
@@ -213,10 +214,7 @@ class Vanagon
213
214
  # @return [String] name of the windows package for this project
214
215
  def msi_package_name(project)
215
216
  # Decided to use native project version in hope msi versioning doesn't have same resrictions as nuget
216
- # SPECIAL NOTE: as a way for us to create two side by side msis for comparison between
217
- # pftw and vanagon, we are putting in VANAGON to the filename so the names will
218
- # be different. When pftw is deprecated, so should this convention
219
- "#{project.name}-#{project.version}.#{project.release}-#{@architecture}_VANAGON.msi"
217
+ "#{project.name}-#{project.version}.#{project.release}-#{@architecture}.msi"
220
218
  end
221
219
 
222
220
  # Method to derive the package name for the project.
@@ -287,7 +285,7 @@ class Vanagon
287
285
  if File.extname(definition.path) == '.ps1'
288
286
  commands << %(powershell.exe -NoProfile -ExecutionPolicy Bypass -Command 'iex ((new-object net.webclient).DownloadString(\"#{definition}\"))')
289
287
  else
290
- commands << %(C:/ProgramData/chocolatey/bin/choco.exe source add -n #{definition.host}-#{definition.path.gsub('/', '-')} -s "#{definition}" --debug || echo "Oops, it seems that you don't have chocolatey installed on this system. Please ensure it's there by adding something like 'plat.add_repository 'https://chocolatey.org/install.ps1'' to your platform definition.")
288
+ commands << %(C:/ProgramData/chocolatey/bin/choco.exe source add -n #{definition.host}-#{definition.path.tr('/', '-')} -s "#{definition}" --debug || echo "Oops, it seems that you don't have chocolatey installed on this system. Please ensure it's there by adding something like 'plat.add_repository 'https://chocolatey.org/install.ps1'' to your platform definition.")
291
289
  end
292
290
  else
293
291
  raise Vanagon::Error, "Invalid repo specification #{definition}"
@@ -296,16 +294,6 @@ class Vanagon
296
294
  commands
297
295
  end
298
296
 
299
- # Get the expected output dir for the windows packages. This allows us to
300
- # use some standard tools to ship internally.
301
- #
302
- # @param target_repo [String] optional repo target for built packages defined
303
- # at the project level
304
- # @return [String] relative path to where windows packages should be staged
305
- def output_dir(target_repo = "")
306
- File.join("windows", target_repo, @architecture)
307
- end
308
-
309
297
  # Generate the underlying directory structure of
310
298
  # any binary files referenced in services. note that
311
299
  # this function does not generate the structure of
@@ -335,12 +323,14 @@ class Vanagon
335
323
  # iterate over all paths specified and break each one
336
324
  # in to its specific directories. This will generate_wix_dirs
337
325
  # an n-ary tree structure matching the specs from the input
338
- items.each do |item|
326
+ items.each_with_index do |item, item_idx|
339
327
  # Always start at the beginning
340
328
  curr = root
341
329
  names = item[:path].split(File::SEPARATOR)
342
- names.each do |name|
343
- curr = insert_child(curr, name)
330
+ names.each_with_index do |name, names_idx|
331
+ # We concat the indexes of each loop to name to ensure the ids of all
332
+ # elements will be unique.
333
+ curr = insert_child(curr, name, "#{name}_#{item_idx}_#{names_idx}")
344
334
  end
345
335
  # at this point, curr will be the top dir, override the id if
346
336
  # id exists
@@ -356,9 +346,9 @@ class Vanagon
356
346
  # @param [HASH] curr, current object we are on
357
347
  # @param [string] name, name of new object we are to search for and
358
348
  # create if necessary
359
- def insert_child(curr, name)
349
+ def insert_child(curr, name, id)
360
350
  #The Id field will default to name, but be overridden later
361
- new_obj = { :name => name, :id => name, :elements_to_add => [], :children => [] }
351
+ new_obj = { :name => name, :id => id, :elements_to_add => [], :children => [] }
362
352
  if (child_index = index_of_child(new_obj, curr[:children]))
363
353
  curr = curr[:children][child_index]
364
354
  else
@@ -374,7 +364,7 @@ class Vanagon
374
364
  # @param [string] path string of directory
375
365
  # @param [@project] project object
376
366
  def strip_and_format_path(path, project)
377
- formatted_path = path.gsub(/\\/, "\/")
367
+ formatted_path = path.tr('\\', '\/')
378
368
  path_regex = /\/?SourceDir\/#{project.settings[:base_dir]}\/#{project.settings[:company_id]}\/#{project.settings[:product_id]}\//
379
369
  File.dirname(formatted_path.sub(path_regex, ''))
380
370
  end
@@ -394,14 +384,14 @@ class Vanagon
394
384
  string = ''
395
385
  unless root[:children].empty?
396
386
  root[:children].each do |child|
397
- string += ("<Directory Name=\"#{child[:name]}\" Id=\"#{child[:id]}\">\n")
387
+ string += "<Directory Name=\"#{child[:name]}\" Id=\"#{child[:id]}\">\n"
398
388
  unless child[:elements_to_add].empty?
399
389
  child[:elements_to_add].each do |element|
400
390
  string += element
401
391
  end
402
392
  end
403
393
  string += generate_wix_from_graph(child)
404
- string += ("</Directory>\n")
394
+ string += "</Directory>\n"
405
395
  end
406
396
  return string
407
397
  end
@@ -55,7 +55,7 @@ class Vanagon
55
55
 
56
56
  # Magic getter to retrieve settings in the project
57
57
  def method_missing(method, *args)
58
- if @settings.has_key?(method)
58
+ if @settings.key?(method)
59
59
  return @settings[method]
60
60
  end
61
61
  end
@@ -236,7 +236,7 @@ class Vanagon
236
236
  # Gets the highest level directories declared by the project
237
237
  #
238
238
  # @return [Array] the highest level directories that have been declared by the project
239
- def get_root_directories
239
+ def get_root_directories # rubocop:disable Metrics/AbcSize
240
240
  dirs = get_directories.map { |dir| dir.path.split('/') }
241
241
  dirs.sort! { |dir1, dir2| dir1.length <=> dir2.length }
242
242
  ret_dirs = []
@@ -23,7 +23,7 @@ class Vanagon
23
23
  # @param name [String] name of the project
24
24
  # @param block [Proc] DSL definition of the project to call
25
25
  def project(name, &block)
26
- block.call(self)
26
+ yield(self)
27
27
  end
28
28
 
29
29
  # Accessor for the project.
@@ -49,7 +49,7 @@ class Vanagon
49
49
  if attribute_match
50
50
  attribute = attribute_match.captures.first
51
51
  @project.send(attribute)
52
- elsif @project.settings.has_key?(method)
52
+ elsif @project.settings.key?(method)
53
53
  return @project.settings[method]
54
54
  else
55
55
  super
@@ -129,7 +129,7 @@ class Vanagon
129
129
  #
130
130
  # @param ver [String] version of the project
131
131
  def version(ver)
132
- @project.version = ver.gsub('-', '.')
132
+ @project.version = ver.tr('-', '.')
133
133
  end
134
134
 
135
135
  # Sets the release for the project. Mainly for use in packaging.
@@ -9,7 +9,6 @@ require 'vanagon/extensions/string'
9
9
 
10
10
  class Vanagon
11
11
  module Utilities
12
-
13
12
  # Utility to get the md5 sum of a file
14
13
  #
15
14
  # @param file [String] file to md5sum
@@ -46,7 +45,7 @@ class Vanagon
46
45
  # @raise [RuntimeError, Vanagon::Error] an exception is raised if the
47
46
  # action is not supported, or if there is a problem with the http request,
48
47
  # or if the response is not JSON
49
- def http_request(url, type, payload = {}.to_json, header = nil)
48
+ def http_request(url, type, payload = {}.to_json, header = nil) # rubocop:disable Metrics/AbcSize
50
49
  uri = URI.parse(url)
51
50
  http = Net::HTTP.new(uri.host, uri.port)
52
51
 
@@ -93,7 +92,7 @@ class Vanagon
93
92
  # @return [String] The standard output of the executed command
94
93
  # @raise [Vanagon::Error] If the command fails an exception is raised
95
94
  def ex(command)
96
- ret = `#{command}`
95
+ ret = %x(#{command})
97
96
  unless $?.success?
98
97
  raise Vanagon::Error, "'#{command}' did not succeed"
99
98
  end
@@ -133,7 +132,7 @@ class Vanagon
133
132
  tries.to_i.times do
134
133
  Timeout::timeout(timeout.to_i) do
135
134
  begin
136
- blk.call
135
+ yield
137
136
  return true
138
137
  rescue => e
139
138
  warn 'An error was encountered evaluating block. Retrying..'
@@ -2,11 +2,12 @@
2
2
 
3
3
  # Turn off the brp-python-bytecompile script
4
4
  %global __os_install_post %(echo '%{__os_install_post}' | sed -e 's!/usr/lib[^[:space:]]*/brp-python-bytecompile[[:space:]].*$!!g')
5
+ <% if @platform.is_cross_compiled_linux? -%>
5
6
  # Disable brp-strip-static-archive, which on EL platforms causes
6
7
  # cross-compiled static libs to end up with "no machine" as their
7
8
  # architure, breaking builds:
8
9
  %global __os_install_post %(echo '%{__os_install_post}' | sed -e 's!/usr/lib[^[:space:]]*/brp-strip-static-archive[[:space:]].*$!!g')
9
- #
10
+ <% end -%>
10
11
 
11
12
  Name: <%= @name %>
12
13
  Version: <%= @version %>
@@ -8,8 +8,6 @@ describe "Vanagon::Platform::DEB" do
8
8
  :os_name => "ubuntu",
9
9
  :os_version => "10.04",
10
10
  :architecture => "i386",
11
- :output_dir => "deb/lucid/",
12
- :output_dir_with_target => "deb/lucid/thing",
13
11
  :codename => "lucid",
14
12
  },
15
13
  {
@@ -17,44 +15,10 @@ describe "Vanagon::Platform::DEB" do
17
15
  :os_name => "debian",
18
16
  :os_version => "7",
19
17
  :architecture => "amd64",
20
- :output_dir => "deb/wheezy/",
21
- :output_dir_with_target => "deb/wheezy/thing",
22
18
  :codename => "wheezy",
23
19
  },
24
20
  ]
25
21
  end
26
-
27
- describe "#output_dir" do
28
- it "returns an output dir consistent with the packaging repo" do
29
- platforms.each do |plat|
30
-
31
- plat_block = %Q[
32
- platform "#{plat[:name]}" do |plat|
33
- plat.codename "#{plat[:codename]}"
34
- end
35
- ]
36
-
37
- cur_plat = Vanagon::Platform::DSL.new(plat[:name])
38
- cur_plat.instance_eval(plat_block)
39
- expect(cur_plat._platform.output_dir).to eq(plat[:output_dir])
40
- end
41
- end
42
-
43
- it "adds the target repo in the right place" do
44
- platforms.each do |plat|
45
-
46
- plat_block = %Q[
47
- platform "#{plat[:name]}" do |plat|
48
- plat.codename "#{plat[:codename]}"
49
- end
50
- ]
51
-
52
- cur_plat = Vanagon::Platform::DSL.new(plat[:name])
53
- cur_plat.instance_eval(plat_block)
54
- expect(cur_plat._platform.output_dir('thing')).to eq(plat[:output_dir_with_target])
55
- end
56
- end
57
- end
58
22
  end
59
23
 
60
24
 
@@ -7,8 +7,6 @@ describe "Vanagon::Platform::RPM" do
7
7
  :os_name => "el",
8
8
  :os_version => "5",
9
9
  :architecture => "i386",
10
- :output_dir => "el/5/products/i386",
11
- :output_dir_with_target => "el/5/thing/i386",
12
10
  :block => %Q[ platform "el-5-i386" do |plat| end ]
13
11
  },
14
12
  {
@@ -16,8 +14,6 @@ describe "Vanagon::Platform::RPM" do
16
14
  :os_name => "fedora",
17
15
  :os_version => "21",
18
16
  :architecture => "x86_64",
19
- :output_dir => "fedora/21/products/x86_64",
20
- :output_dir_with_target => "fedora/21/thing/x86_64",
21
17
  :block => %Q[ platform "fedora-21-x86_64" do |plat| end ]
22
18
  },
23
19
  {
@@ -25,8 +21,6 @@ describe "Vanagon::Platform::RPM" do
25
21
  :os_name => "fedora",
26
22
  :os_version => "21",
27
23
  :architecture => "x86_64",
28
- :output_dir => "cisco-wrlinux/7/products/x86_64",
29
- :output_dir_with_target => "cisco-wrlinux/7/thing/x86_64",
30
24
  :block => %Q[ platform "cisco-wrlinux-7-x86_64" do |plat| end ]
31
25
  },
32
26
  ]
@@ -40,16 +34,6 @@ describe "Vanagon::Platform::RPM" do
40
34
  cur_plat.instance_eval(plat[:block])
41
35
  end
42
36
 
43
- describe "#output_dir" do
44
- it "returns an output dir consistent with the packaging repo" do
45
- expect(cur_plat._platform.output_dir).to eq(plat[:output_dir])
46
- end
47
-
48
- it "adds the target repo in the right way" do
49
- expect(cur_plat._platform.output_dir('thing')).to eq(plat[:output_dir_with_target])
50
- end
51
- end
52
-
53
37
  describe '#rpm_defines' do
54
38
  it "removes dashes from the dist macro" do
55
39
  expected_dist = "--define 'dist .#{cur_plat._platform.os_name.gsub('-', '_')}#{cur_plat._platform.os_version}'"
@@ -25,8 +25,6 @@ describe "Vanagon::Platform::Windows" do
25
25
  :os_name => "windows",
26
26
  :os_version => "2012r2",
27
27
  :architecture => "x64",
28
- :output_dir => "windows/x64",
29
- :output_dir_with_target => "windows/thing/x64",
30
28
  :target_user => "Administrator",
31
29
  :projname => "test-proj",
32
30
  :block => %Q[ platform "windows-2012r2-x64" do |plat| plat.servicetype 'windows' end ]
@@ -52,16 +50,6 @@ HERE
52
50
  cur_plat.instance_eval(plat[:block])
53
51
  end
54
52
 
55
- describe "#output_dir" do
56
- it "returns an output dir consistent with the packaging repo" do
57
- expect(cur_plat._platform.output_dir).to eq(plat[:output_dir])
58
- end
59
-
60
- it "adds the target repo in the right way" do
61
- expect(cur_plat._platform.output_dir('thing')).to eq(plat[:output_dir_with_target])
62
- end
63
- end
64
-
65
53
  describe '#target_user' do
66
54
  it "sets the target_user to 'Administrator'" do
67
55
  expect(cur_plat._platform.target_user).to eq(plat[:target_user])
@@ -194,7 +182,7 @@ HERE
194
182
  comp.install_service('SourceDir/ProgramFilesFolder/TestID/TestProduct/opt/bin.exe')
195
183
  expect(cur_plat._platform.generate_service_bin_dirs([comp._component.service].flatten.compact, proj._project)).to eq( \
196
184
  <<-HERE
197
- <Directory Name="opt" Id="opt">
185
+ <Directory Name="opt" Id="opt_0_0">
198
186
  <Directory Id="SERVICETESTBINDIR" />
199
187
  </Directory>
200
188
  HERE
@@ -210,7 +198,7 @@ HERE
210
198
  expect(cur_plat._platform.generate_service_bin_dirs([comp._component.service].flatten.compact, proj._project)).to eq( \
211
199
 
212
200
  <<-HERE
213
- <Directory Name="opt" Id="opt">
201
+ <Directory Name="opt" Id="opt_0_0">
214
202
  <Directory Id="SERVICETEST2BINDIR" />
215
203
  </Directory>
216
204
  HERE
@@ -226,8 +214,8 @@ HERE
226
214
  expect(cur_plat._platform.generate_service_bin_dirs([comp._component.service].flatten.compact, proj._project)).to eq( \
227
215
 
228
216
  <<-HERE
229
- <Directory Name="somedir" Id="somedir">
230
- <Directory Name="someotherdir" Id="someotherdir">
217
+ <Directory Name="somedir" Id="somedir_0_0">
218
+ <Directory Name="someotherdir" Id="someotherdir_0_1">
231
219
  <Directory Id="SERVICETESTBINDIR" />
232
220
  </Directory>
233
221
  </Directory>
@@ -247,7 +235,7 @@ HERE
247
235
  comp2.install_service('SourceDir\\ProgramFilesFolder\\TestID\\TestProduct\\somedir\\bin.exe')
248
236
  expect(cur_plat._platform.generate_service_bin_dirs([comp._component.service, comp2._component.service].flatten.compact, proj._project)).to eq( \
249
237
  <<-HERE
250
- <Directory Name="somedir" Id="somedir">
238
+ <Directory Name="somedir" Id="somedir_0_0">
251
239
  <Directory Id="SERVICETESTBINDIR" />
252
240
  <Directory Id="SERVICETEST2BINDIR" />
253
241
  </Directory>
@@ -267,17 +255,17 @@ HERE
267
255
  comp3.install_service('SourceDir\\ProgramFilesFolder\\TestID\\TestProduct\\somedir\\oneUpAgain\\twoUpAgain\\bin.exe')
268
256
  expect(cur_plat._platform.generate_service_bin_dirs([comp._component.service, comp2._component.service, comp3._component.service].flatten.compact, proj._project)).to eq( \
269
257
  <<-HERE
270
- <Directory Name="somedir" Id="somedir">
271
- <Directory Name="oneUp" Id="oneUp">
272
- <Directory Name="twoUp" Id="twoUp">
258
+ <Directory Name="somedir" Id="somedir_0_0">
259
+ <Directory Name="oneUp" Id="oneUp_0_1">
260
+ <Directory Name="twoUp" Id="twoUp_0_2">
273
261
  <Directory Id="SERVICETEST1BINDIR" />
274
262
  </Directory>
275
263
  </Directory>
276
- <Directory Name="oneUpAgain" Id="oneUpAgain">
277
- <Directory Name="twoUp" Id="twoUp">
264
+ <Directory Name="oneUpAgain" Id="oneUpAgain_1_1">
265
+ <Directory Name="twoUp" Id="twoUp_1_2">
278
266
  <Directory Id="SERVICETEST2BINDIR" />
279
267
  </Directory>
280
- <Directory Name="twoUpAgain" Id="twoUpAgain">
268
+ <Directory Name="twoUpAgain" Id="twoUpAgain_2_2">
281
269
  <Directory Id="SERVICETEST3BINDIR" />
282
270
  </Directory>
283
271
  </Directory>
@@ -4,22 +4,31 @@ describe "Vanagon::Platform" do
4
4
  let(:platforms) do
5
5
  [
6
6
  {
7
- :name => "debian-6-i386",
8
- :os_name => "debian",
9
- :os_version => "6",
10
- :architecture => "i386",
7
+ :name => "debian-6-i386",
8
+ :os_name => "debian",
9
+ :os_version => "6",
10
+ :architecture => "i386",
11
+ :output_dir => "debian/6/i386",
12
+ :output_dir_with_target => "debian/6/thing/i386",
13
+ :block => %Q[ platform "debian-6-i386" do |plat| end ],
11
14
  },
12
15
  {
13
- :name => "el-5-i386",
14
- :os_name => "el",
15
- :os_version => "5",
16
- :architecture => "i386",
16
+ :name => "el-5-i386",
17
+ :os_name => "el",
18
+ :os_version => "5",
19
+ :architecture => "i386",
20
+ :output_dir => "el/5/i386",
21
+ :output_dir_with_target => "el/5/thing/i386",
22
+ :block => %Q[ platform "el-5-i386" do |plat| end ],
17
23
  },
18
24
  {
19
- :name => "CumulusLinux-2.2-amd64",
20
- :os_name => "CumulusLinux",
21
- :os_version => "2.2",
22
- :architecture => "amd64",
25
+ :name => "debian-6-i386",
26
+ :os_name => "debian",
27
+ :os_version => "6",
28
+ :architecture => "i386",
29
+ :output_dir => "updated/output",
30
+ :output_dir_with_target => "updated/output",
31
+ :block => %Q[ platform "debian-6-i386" do |plat| plat.output_dir "updated/output" end ],
23
32
  },
24
33
  ]
25
34
  end
@@ -42,6 +51,24 @@ describe "Vanagon::Platform" do
42
51
  end
43
52
  end
44
53
 
54
+ describe "#output_dir" do
55
+ it "returns correct output dir" do
56
+ platforms.each do |plat|
57
+ cur_plat = Vanagon::Platform::DSL.new(plat[:name])
58
+ cur_plat.instance_eval(plat[:block])
59
+ expect(cur_plat._platform.output_dir).to eq(plat[:output_dir])
60
+ end
61
+ end
62
+
63
+ it "adds the target repo in the right way" do
64
+ platforms.each do |plat|
65
+ cur_plat = Vanagon::Platform::DSL.new(plat[:name])
66
+ cur_plat.instance_eval(plat[:block])
67
+ expect(cur_plat._platform.output_dir('thing')).to eq(plat[:output_dir_with_target])
68
+ end
69
+ end
70
+ end
71
+
45
72
  describe "#architecture" do
46
73
  it "returns the architecture for the platform" do
47
74
  platforms.each do |plat|
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: vanagon
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.3
4
+ version: 0.7.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Puppet Labs
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-06-29 00:00:00.000000000 Z
11
+ date: 2016-07-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rspec
@@ -214,7 +214,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
214
214
  version: '0'
215
215
  requirements: []
216
216
  rubyforge_project:
217
- rubygems_version: 2.6.6
217
+ rubygems_version: 2.4.6
218
218
  signing_key:
219
219
  specification_version: 3
220
220
  summary: All of your packages will fit into this van with this one simple trick.
@@ -251,4 +251,3 @@ test_files:
251
251
  - spec/lib/vanagon/project_spec.rb
252
252
  - spec/lib/vanagon/utilities/shell_utilities_spec.rb
253
253
  - spec/lib/vanagon/utilities_spec.rb
254
- has_rdoc: