vanagon 0.14.3 → 0.15.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (39) hide show
  1. checksums.yaml +4 -4
  2. data/bin/build +1 -1
  3. data/bin/build_host_info +1 -1
  4. data/bin/inspect +1 -1
  5. data/bin/render +1 -1
  6. data/bin/ship +1 -1
  7. data/lib/vanagon/component/dsl.rb +4 -4
  8. data/lib/vanagon/component/source/git.rb +7 -7
  9. data/lib/vanagon/component/source/http.rb +2 -2
  10. data/lib/vanagon/component/source/local.rb +4 -4
  11. data/lib/vanagon/component.rb +10 -10
  12. data/lib/vanagon/driver.rb +8 -8
  13. data/lib/vanagon/engine/base.rb +1 -1
  14. data/lib/vanagon/engine/docker.rb +1 -1
  15. data/lib/vanagon/engine/ec2.rb +5 -5
  16. data/lib/vanagon/engine/hardware.rb +3 -3
  17. data/lib/vanagon/engine/pooler.rb +3 -3
  18. data/lib/vanagon/environment.rb +4 -4
  19. data/lib/vanagon/platform/deb.rb +10 -1
  20. data/lib/vanagon/platform/dsl.rb +14 -0
  21. data/lib/vanagon/platform/osx.rb +1 -0
  22. data/lib/vanagon/platform/rpm/aix.rb +1 -0
  23. data/lib/vanagon/platform/rpm/wrl.rb +1 -1
  24. data/lib/vanagon/platform/rpm.rb +0 -3
  25. data/lib/vanagon/platform/solaris_10.rb +3 -2
  26. data/lib/vanagon/platform.rb +54 -10
  27. data/lib/vanagon/project/dsl.rb +1 -1
  28. data/lib/vanagon/project.rb +25 -7
  29. data/lib/vanagon/utilities.rb +4 -4
  30. data/lib/vanagon.rb +2 -2
  31. data/resources/Makefile.erb +2 -2
  32. data/resources/deb/control.erb +3 -3
  33. data/resources/rpm/project.spec.erb +18 -8
  34. data/spec/lib/vanagon/component/dsl_spec.rb +10 -0
  35. data/spec/lib/vanagon/platform/osx_spec.rb +21 -0
  36. data/spec/lib/vanagon/platform/rpm/aix_spec.rb +1 -1
  37. data/spec/lib/vanagon/platform/solaris_10_spec.rb +29 -0
  38. data/spec/lib/vanagon/project/dsl_spec.rb +164 -16
  39. metadata +6 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: dfdf9e485d076f8615fb5dec7ee3659bdb30cadf
4
- data.tar.gz: 11c28aee93eaa0c737ceb44fc6152bef2d5fe421
3
+ metadata.gz: 29674503cd814cb61b44c6077a9f92b921e0a3a9
4
+ data.tar.gz: 41bc417df34897e2f7b934c7a2dc8015d150c020
5
5
  SHA512:
6
- metadata.gz: d88904c2f719cbd894784ef42792b78dbcf7c407eea7320f80e208780de4e60858aad4835109a94018a956b3596732226c48131488efd6b10dc95ae54ca816bf
7
- data.tar.gz: a934492d38471190d3c984d2ff35a6d87bbf459ade415d44e39a68a2c48639845e7c7831bb360f4c99bb09e06b9478642dc18f07ef619186a1e44c50d84ecf54
6
+ metadata.gz: 7f56c460a3243eef19ccf1344e1e02e6cf0d746f9f7358f0457fb6e08be08c8e07aef31d9494792d7c0340c11c4506f148b78d0608b4edcc7d52397f069800b2
7
+ data.tar.gz: 2f910455c317ab05665d70561207d251c1fd29dc942797b9fa4e57b5ac617a4f40314ad83d7af377011eaafe2ebe26152bc3d9486f897e6be09b34ffbb4183f5
data/bin/build CHANGED
@@ -11,7 +11,7 @@ targets = ARGV[2]
11
11
 
12
12
  if project.nil? or platforms.nil?
13
13
  warn "project and platform are both required arguments."
14
- $stderr.puts optparse
14
+ warn optparse
15
15
  exit 1
16
16
  end
17
17
 
data/bin/build_host_info CHANGED
@@ -11,7 +11,7 @@ platforms = ARGV[1]
11
11
 
12
12
  if project.nil? or platforms.nil?
13
13
  warn "project and platform are both required arguments."
14
- $stderr.puts optparse
14
+ warn optparse
15
15
  exit 1
16
16
  end
17
17
 
data/bin/inspect CHANGED
@@ -14,7 +14,7 @@ platforms = ARGV[1]
14
14
 
15
15
  unless project or platforms
16
16
  warn "project and platform are both required arguments."
17
- $stderr.puts optparse
17
+ warn optparse
18
18
  exit 1
19
19
  end
20
20
 
data/bin/render CHANGED
@@ -13,7 +13,7 @@ targets = ARGV[2]
13
13
 
14
14
  if project.nil? or platforms.nil?
15
15
  warn "project and platform are both required arguments."
16
- $stderr.puts optparse
16
+ warn optparse
17
17
  exit 1
18
18
  end
19
19
 
data/bin/ship CHANGED
@@ -26,7 +26,7 @@ else
26
26
  Pkg::Util::RakeUtils.invoke_task('pl:jenkins:ship_to_artifactory', 'output')
27
27
  rescue LoadError
28
28
  warn artifactory_warning
29
- rescue
29
+ rescue StandardError
30
30
  warn artifactory_warning
31
31
  end
32
32
  end
@@ -397,23 +397,23 @@ class Vanagon
397
397
  # @param env [Hash] mapping of keys to values to add to the environment for the component
398
398
  def environment(*env) # rubocop:disable Metrics/AbcSize
399
399
  if env.size == 1 && env.first.is_a?(Hash)
400
- warn <<-eos.undent
400
+ warn <<-WARNING.undent
401
401
  the component DSL method signature #environment({Key => Value}) is deprecated
402
402
  and will be removed by Vanagon 1.0.0.
403
403
 
404
404
  Please update your project configurations to use the form:
405
405
  #environment(key, value)
406
- eos
406
+ WARNING
407
407
  return @component.environment.merge!(env.first)
408
408
  elsif env.size == 2
409
409
  return @component.environment[env.first] = env.last
410
410
  end
411
- raise ArgumentError, <<-eos.undent
411
+ raise ArgumentError, <<-WARNING.undent
412
412
  component DSL method #environment only accepts a single Hash (deprecated)
413
413
  or a key-value pair (preferred):
414
414
  environment({"KEY" => "value"})
415
415
  environment("KEY", "value")
416
- eos
416
+ WARNING
417
417
  end
418
418
 
419
419
  # Checks that the array of pkg_state is valid (install AND/OR upgrade).
@@ -29,7 +29,7 @@ class Vanagon
29
29
 
30
30
  # Default options used when cloning; this may expand
31
31
  # or change over time.
32
- def default_options
32
+ def default_options # rubocop:disable Lint/DuplicateMethods
33
33
  @default_options ||= { ref: "HEAD" }
34
34
  end
35
35
  private :default_options
@@ -71,7 +71,7 @@ class Vanagon
71
71
  # There is no md5 to manually verify here, so this is a noop.
72
72
  def verify
73
73
  # nothing to do here, so just tell users that and return
74
- $stderr.puts "Nothing to verify for '#{dirname}' (using Git reference '#{ref}')"
74
+ warn "Nothing to verify for '#{dirname}' (using Git reference '#{ref}')"
75
75
  end
76
76
 
77
77
  # The dirname to reference when building from the repo
@@ -82,7 +82,7 @@ class Vanagon
82
82
  end
83
83
 
84
84
  # Use `git describe` to lazy-load a version for this component
85
- def version
85
+ def version # rubocop:disable Lint/DuplicateMethods
86
86
  @version ||= describe
87
87
  end
88
88
 
@@ -117,8 +117,8 @@ class Vanagon
117
117
  # Clone a remote repo, make noise about it, and fail entirely
118
118
  # if we're unable to retrieve the remote repo
119
119
  def clone!
120
- $stderr.puts "Cloning Git repo '#{url}'"
121
- $stderr.puts "Successfully cloned '#{dirname}'" if clone
120
+ warn "Cloning Git repo '#{url}'"
121
+ warn "Successfully cloned '#{dirname}'" if clone
122
122
  rescue ::Git::GitExecuteError
123
123
  raise Vanagon::InvalidRepo, "Unable to clone from '#{url}'"
124
124
  end
@@ -127,7 +127,7 @@ class Vanagon
127
127
  # Checkout desired ref/sha, make noise about it, and fail
128
128
  # entirely if we're unable to checkout that given ref/sha
129
129
  def checkout!
130
- $stderr.puts "Checking out '#{ref}'' from Git repo '#{dirname}'"
130
+ warn "Checking out '#{ref}'' from Git repo '#{dirname}'"
131
131
  clone.checkout(ref)
132
132
  rescue ::Git::GitExecuteError
133
133
  raise Vanagon::CheckoutFailed, "unable to checkout #{ref} from '#{url}'"
@@ -137,7 +137,7 @@ class Vanagon
137
137
  # Attempt to update submodules, and do not panic
138
138
  # if there are no submodules to initialize
139
139
  def update_submodules
140
- $stderr.puts "Attempting to update submodules for repo '#{dirname}'"
140
+ warn "Attempting to update submodules for repo '#{dirname}'"
141
141
  clone.update_submodules(init: true)
142
142
  end
143
143
  private :update_submodules
@@ -93,7 +93,7 @@ class Vanagon
93
93
  #
94
94
  # @raise [RuntimeError] an exception is raised if the sum does not match the sum of the file
95
95
  def verify # rubocop:disable Metrics/AbcSize
96
- $stderr.puts "Verifying file: #{file} against sum: '#{sum}'"
96
+ warn "Verifying file: #{file} against sum: '#{sum}'"
97
97
  actual = get_sum(File.join(workdir, file), sum_type)
98
98
  return true if sum == actual
99
99
 
@@ -107,7 +107,7 @@ class Vanagon
107
107
  uri = URI.parse(target_url.to_s)
108
108
  target_file ||= File.basename(uri.path)
109
109
 
110
- $stderr.puts "Downloading file '#{target_file}' from url '#{target_url}'"
110
+ warn "Downloading file '#{target_file}' from url '#{target_url}'"
111
111
 
112
112
  Net::HTTP.start(uri.host, uri.port, use_ssl: uri.scheme == 'https') do |http|
113
113
  http.request(Net::HTTP::Get.new(uri, headers)) do |response|
@@ -57,17 +57,17 @@ class Vanagon
57
57
  #
58
58
  # @raise [RuntimeError, Vanagon::Error] an exception is raised if the URI scheme cannot be handled
59
59
  def copy
60
- $stderr.puts "Copying file '#{url.basename}' to workdir"
60
+ warn "Copying file '#{url.basename}' to workdir"
61
61
 
62
62
  FileUtils.cp_r(url, file)
63
63
  end
64
64
  alias_method :fetch, :copy
65
65
 
66
- def file
66
+ def file # rubocop:disable Lint/DuplicateMethods
67
67
  @file ||= workdir + File.basename(url)
68
68
  end
69
69
 
70
- def extension
70
+ def extension # rubocop:disable Lint/DuplicateMethods
71
71
  @extension ||= extname
72
72
  end
73
73
 
@@ -117,7 +117,7 @@ class Vanagon
117
117
  #
118
118
  # @return [String] command to cleanup the source
119
119
  # @raise [RuntimeError] an exception is raised if there is no known extraction method for @extension
120
- def cleanup
120
+ def cleanup # rubocop:disable Lint/DuplicateMethods
121
121
  archive? ? "rm #{file}; rm -r #{dirname}" : "rm #{file}"
122
122
  end
123
123
 
@@ -134,10 +134,10 @@ class Vanagon
134
134
  dsl = Vanagon::Component::DSL.new(name, settings, platform)
135
135
  dsl.instance_eval(File.read(compfile), compfile, 1)
136
136
  dsl._component
137
- rescue => e
138
- $stderr.puts "Error loading project '#{name}' using '#{compfile}':"
139
- $stderr.puts e
140
- $stderr.puts e.backtrace.join("\n")
137
+ rescue StandardError => e
138
+ warn "Error loading project '#{name}' using '#{compfile}':"
139
+ warn e
140
+ warn e.backtrace.join("\n")
141
141
  raise e
142
142
  end
143
143
 
@@ -215,7 +215,7 @@ class Vanagon
215
215
  # whatever URI was defined for #uri. If no mirrors are set and the
216
216
  # deprecated rewrite system has been configured, this will return
217
217
  # rewritten URIs
218
- def mirrors
218
+ def mirrors # rubocop:disable Lint/DuplicateMethods
219
219
  @mirrors ||= Set.new [deprecated_rewrite_url].compact
220
220
  end
221
221
 
@@ -232,7 +232,7 @@ class Vanagon
232
232
  def fetch_mirrors(options)
233
233
  mirrors.to_a.shuffle.each do |mirror|
234
234
  begin
235
- $stderr.puts %(Attempting to fetch from mirror URL "#{mirror}")
235
+ warn %(Attempting to fetch from mirror URL "#{mirror}")
236
236
  @source = Vanagon::Component::Source.source(mirror, options)
237
237
  return true if source.fetch
238
238
  rescue SocketError
@@ -255,7 +255,7 @@ class Vanagon
255
255
  # @return [Boolean] return True if the source can be retrieved,
256
256
  # or False otherwise
257
257
  def fetch_url(options)
258
- $stderr.puts %(Attempting to fetch from canonical URL "#{url}")
258
+ warn %(Attempting to fetch from canonical URL "#{url}")
259
259
  @source = Vanagon::Component::Source.source(url, options)
260
260
  # Explicitly coerce the return value of #source.fetch,
261
261
  # because each subclass of Vanagon::Component::Source returns
@@ -334,7 +334,7 @@ class Vanagon
334
334
 
335
335
  # @return [Array] the specific tool or command line invocations that
336
336
  # should be used to extract a given component's primary source
337
- def extract_with
337
+ def extract_with # rubocop:disable Lint/DuplicateMethods
338
338
  @extract_with ||= []
339
339
  end
340
340
 
@@ -356,11 +356,11 @@ class Vanagon
356
356
  # @return [String] environment suitable for inclusion in a Makefile
357
357
  # @deprecated
358
358
  def get_environment
359
- warn <<-eos.undent
359
+ warn <<-WARNING.undent
360
360
  #get_environment is deprecated; environment variables have been moved
361
361
  into the Makefile, and should not be used within a Makefile's recipe.
362
362
  The #get_environment method will be removed by Vanagon 1.0.0.
363
- eos
363
+ WARNING
364
364
 
365
365
  if environment.empty?
366
366
  ": no environment variables defined"
@@ -43,8 +43,8 @@ class Vanagon
43
43
  # flatten all the results in to one array and set project.components to that.
44
44
  @project.components = only_build.flat_map { |comp| @project.filter_component(comp) }.uniq
45
45
  if @verbose
46
- $stderr.puts "Only building:"
47
- @project.components.each { |comp| $stderr.puts comp.name }
46
+ warn "Only building:"
47
+ @project.components.each { |comp| warn comp.name }
48
48
  end
49
49
  end
50
50
 
@@ -66,7 +66,7 @@ class Vanagon
66
66
  def load_engine_object(engine_type, platform, target)
67
67
  require "vanagon/engine/#{engine_type}"
68
68
  @engine = Object::const_get("Vanagon::Engine::#{camelize(engine_type)}").new(platform, target, remote_workdir: remote_workdir)
69
- rescue
69
+ rescue StandardError
70
70
  fail "No such engine '#{camelize(engine_type)}'"
71
71
  end
72
72
 
@@ -117,7 +117,7 @@ class Vanagon
117
117
 
118
118
  @engine.startup(workdir)
119
119
 
120
- $stderr.puts "Target is #{@engine.target}"
120
+ warn "Target is #{@engine.target}"
121
121
  retry_task { install_build_dependencies }
122
122
  retry_task { @project.fetch_sources(workdir) }
123
123
 
@@ -133,13 +133,13 @@ class Vanagon
133
133
  @engine.teardown
134
134
  cleanup_workdir
135
135
  end
136
- rescue => e
136
+ rescue StandardError => e
137
137
  if [:never].include? @preserve
138
138
  @engine.teardown
139
139
  cleanup_workdir
140
140
  end
141
- $stderr.puts e
142
- $stderr.puts e.backtrace.join("\n")
141
+ warn e
142
+ warn e.backtrace.join("\n")
143
143
  raise e
144
144
  ensure
145
145
  if ["hardware", "ec2"].include?(@engine.name)
@@ -153,7 +153,7 @@ class Vanagon
153
153
  raise Vanagon::Error, "Project requires a version set, all is lost."
154
154
  end
155
155
 
156
- $stderr.puts "rendering Makefile"
156
+ warn "rendering Makefile"
157
157
  retry_task { @project.fetch_sources(workdir) }
158
158
  @project.make_bill_of_materials(workdir)
159
159
  @project.generate_packaging_artifacts(workdir)
@@ -63,7 +63,7 @@ class Vanagon
63
63
  dispatch("mkdir -p #{@remote_workdir_path}", true)
64
64
  @remote_workdir = @remote_workdir_path
65
65
  else
66
- @remote_workdir = dispatch("mktemp -d -p /var/tmp 2>/dev/null || mktemp -d -t 'tmp'", true)
66
+ @remote_workdir = dispatch("#{@platform.mktemp} 2>/dev/null", true)
67
67
  end
68
68
  end
69
69
  @remote_workdir
@@ -38,7 +38,7 @@ class Vanagon
38
38
  Vanagon::Utilities.retry_with_timeout do
39
39
  Vanagon::Utilities.remote_ssh_command("#{@target_user}@#{@target}", 'exit', @platform.ssh_port)
40
40
  end
41
- rescue => e
41
+ rescue StandardError => e
42
42
  raise Vanagon::Error.wrap(e, "Something went wrong getting a target vm to build on using docker. Ssh was not up in the container after 5 seconds.")
43
43
  end
44
44
 
@@ -6,7 +6,7 @@ require 'vanagon/engine/base'
6
6
  class Vanagon
7
7
  class Engine
8
8
  class Ec2 < Base
9
- attr_accessor :ami, :key_name, :userdata, :key, :key_name, :shutdown_behavior
9
+ attr_accessor :ami, :key_name, :userdata, :key, :shutdown_behavior
10
10
  attr_accessor :subnet_id, :instance_type
11
11
 
12
12
  def initialize(platform, target = nil, **opts) # rubocop:disable Metrics/AbcSize
@@ -57,17 +57,17 @@ class Vanagon
57
57
  end
58
58
 
59
59
  def select_target
60
- $stderr.puts "Instance created id: #{instance.id}"
61
- $stderr.puts "Created instance waiting for status ok"
60
+ warn "Instance created id: #{instance.id}"
61
+ warn "Created instance waiting for status ok"
62
62
  @ec2.wait_until(:instance_status_ok, instance_ids: [instance.id])
63
- $stderr.puts "Instance running"
63
+ warn "Instance running"
64
64
  @target = instance.private_ip_address
65
65
  rescue ::Aws::Waiters::Errors::WaiterFailed => error
66
66
  fail "Failed to wait for ec2 instance to start got error #{error}"
67
67
  end
68
68
 
69
69
  def teardown
70
- $stderr.puts "Destroying instance on AWS id: #{instance.id}"
70
+ warn "Destroying instance on AWS id: #{instance.id}"
71
71
  instances.batch_terminate!
72
72
  end
73
73
  end
@@ -23,7 +23,7 @@ class Vanagon
23
23
  Vanagon::Driver.logger.info "Polling for a lock on #{host}."
24
24
  @lockman.polling_lock(host, VANAGON_LOCK_USER, "Vanagon automated lock")
25
25
  Vanagon::Driver.logger.info "Lock acquired on #{host}."
26
- $stderr.puts "Lock acquired on #{host} for #{VANAGON_LOCK_USER}."
26
+ warn "Lock acquired on #{host} for #{VANAGON_LOCK_USER}."
27
27
  host
28
28
  end
29
29
 
@@ -33,7 +33,7 @@ class Vanagon
33
33
  Vanagon::Driver.logger.info "Attempting to lock #{h}."
34
34
  if @lockman.lock(h, VANAGON_LOCK_USER, "Vanagon automated lock")
35
35
  Vanagon::Driver.logger.info "Lock acquired on #{h}."
36
- $stderr.puts "Lock acquired on #{h} for #{VANAGON_LOCK_USER}."
36
+ warn "Lock acquired on #{h} for #{VANAGON_LOCK_USER}."
37
37
  return h
38
38
  end
39
39
  end
@@ -45,7 +45,7 @@ class Vanagon
45
45
  # complete. In this case, we'll attempt to unlock the hardware
46
46
  def teardown
47
47
  Vanagon::Driver.logger.info "Removing lock on #{@target}."
48
- $stderr.puts "Removing lock on #{@target}."
48
+ warn "Removing lock on #{@target}."
49
49
  @lockman.unlock(@target, VANAGON_LOCK_USER)
50
50
  end
51
51
 
@@ -56,7 +56,7 @@ class Vanagon
56
56
  absolute_path = File.expand_path(path)
57
57
  return nil unless File.exist?(absolute_path)
58
58
 
59
- $stderr.puts "Reading vmpooler token from: #{path}"
59
+ warn "Reading vmpooler token from: #{path}"
60
60
  File.read(absolute_path).chomp
61
61
  end
62
62
  private :read_vanagon_token
@@ -70,7 +70,7 @@ class Vanagon
70
70
  absolute_path = File.expand_path(path)
71
71
  return nil unless File.exist?(absolute_path)
72
72
 
73
- $stderr.puts "Reading vmpooler token from: #{path}"
73
+ warn "Reading vmpooler token from: #{path}"
74
74
  YAML.load_file(absolute_path)['token']
75
75
  end
76
76
  private :read_vmfloaty_token
@@ -141,7 +141,7 @@ class Vanagon
141
141
  )
142
142
  if response and response["ok"]
143
143
  Vanagon::Driver.logger.info "#{@target} has been destroyed"
144
- $stderr.puts "#{@target} has been destroyed"
144
+ warn "#{@target} has been destroyed"
145
145
  else
146
146
  Vanagon::Driver.logger.info "#{@target} could not be destroyed"
147
147
  warn "#{@target} could not be destroyed"
@@ -141,11 +141,11 @@ class Vanagon
141
141
 
142
142
  warning = [%(Value "#{str}" looks like it's escaping one or more values for subshell interpolation.)]
143
143
  escaped_variables.each { |v| warning.push %(\t"$$(#{v})" will be coerced to "$(shell #{v})") }
144
- warning.push <<-eos.undent
144
+ warning.push <<-WARNING.undent
145
145
  All environment variables will now be resolved by Make before they're executed
146
146
  by the shell. These variables will be mangled for you for now, but you should
147
147
  update your project's parameters.
148
- eos
148
+ WARNING
149
149
 
150
150
  warn warning.join("\n")
151
151
  str.gsub(pattern, '$(shell \1)')
@@ -159,11 +159,11 @@ class Vanagon
159
159
 
160
160
  warning = [%(Value "#{str}" looks like it's escaping one or more shell variable names for shell interpolation.)]
161
161
  escaped_variables.each { |v| warning.push %(\t"$$#{v}" will be coerced to "$(#{v})") }
162
- warning.push <<-eos.undent
162
+ warning.push <<-WARNING.undent
163
163
  All environment variables will now be resolved by Make before they're executed
164
164
  by the shell. These variables will be mangled for you for now, but you should
165
165
  update your project's parameters.
166
- eos
166
+ WARNING
167
167
 
168
168
  warn warning.join("\n")
169
169
  str.gsub(pattern, '$(\1)')
@@ -19,7 +19,7 @@ class Vanagon
19
19
  "cat file-list >> debian/install",
20
20
  "cp -pr debian $(tempdir)/#{project.name}-#{project.version}",
21
21
  "gunzip -c #{project.name}-#{project.version}.tar.gz | '#{@tar}' -C '$(tempdir)/#{project.name}-#{project.version}' --strip-components 1 -xf -",
22
- "sed -i 's/\ /?/g' $(tempdir)/#{project.name}-#{project.version}/debian/install",
22
+ "#{sed} -i 's/\ /?/g' $(tempdir)/#{project.name}-#{project.version}/debian/install",
23
23
  "(cd $(tempdir)/#{project.name}-#{project.version}; debuild --no-lintian #{pkg_arch_opt} -uc -us)",
24
24
  "cp $(tempdir)/#{copy_extensions} ./output/#{target_dir}"]
25
25
  end
@@ -122,6 +122,14 @@ class Vanagon
122
122
  project.package_overrides << var
123
123
  end
124
124
 
125
+ def version_munger(version_string, default: '=')
126
+ operator, version = super.split(' ')
127
+ if operator =~ /^[<>]$/
128
+ operator = "#{operator}#{operator}"
129
+ end
130
+
131
+ "#{operator} #{version}"
132
+ end
125
133
  # Constructor. Sets up some defaults for the debian platform and calls the parent constructor
126
134
  #
127
135
  # @param name [String] name of the platform
@@ -132,6 +140,7 @@ class Vanagon
132
140
  @tar = "tar"
133
141
  @patch = "/usr/bin/patch"
134
142
  @num_cores = "/usr/bin/nproc"
143
+ @valid_operators = ['<', '>', '<=', '>=', '=', '<<', '>>']
135
144
  super(name)
136
145
  end
137
146
  end
@@ -129,6 +129,13 @@ class Vanagon
129
129
  @platform.find = find_cmd
130
130
  end
131
131
 
132
+ # Set the path to sed for the platform
133
+ #
134
+ # @param command [String] full path to the sed command for the platform
135
+ def sed(command)
136
+ @platform.sed = command
137
+ end
138
+
132
139
  # Set the path to sort for the platform
133
140
  #
134
141
  # @param sort_cmd [String] Full path to the sort command for the platform
@@ -170,6 +177,13 @@ class Vanagon
170
177
  @platform.install = install_cmd
171
178
  end
172
179
 
180
+ # Set the path and options for the mktemp command
181
+ # @param command [String] Full path (if needed) for the mktemp command with arguments to
182
+ # be used by default
183
+ def mktemp(command)
184
+ @platform.mktemp = command
185
+ end
186
+
173
187
  # Set the path to patch for the platform
174
188
  #
175
189
  # @param patch_cmd [String] Full path to the patch command for the platform
@@ -107,6 +107,7 @@ class Vanagon
107
107
  @hdiutil = "/usr/bin/hdiutil"
108
108
  @patch = "/usr/bin/patch"
109
109
  @num_cores = "/usr/sbin/sysctl -n hw.physicalcpu"
110
+ @mktemp = "mktemp -d -t 'tmp'"
110
111
  super(name)
111
112
  end
112
113
  end
@@ -17,6 +17,7 @@ class Vanagon
17
17
  @make = "/usr/bin/gmake"
18
18
  @tar = "/opt/freeware/bin/tar"
19
19
  @patch = "/opt/freeware/bin/patch"
20
+ @sed = "/opt/freeware/bin/sed"
20
21
  @shasum = "/opt/freeware/bin/sha1sum"
21
22
  @num_cores = "lsdev -Cc processor |wc -l"
22
23
  @install = "/opt/freeware/bin/install"
@@ -18,7 +18,7 @@ class Vanagon
18
18
  def install_build_dependencies(build_dependencies)
19
19
  commands = []
20
20
  unless build_dependencies.empty?
21
- commands << "tmpdir=$(mktemp -p /var/tmp -d)"
21
+ commands << "tmpdir=$(#{mktemp})"
22
22
  commands << "cd ${tmpdir}"
23
23
  build_dependencies.each do |build_dependency|
24
24
  if build_dependency =~ /^http.*\.rpm$/
@@ -1,6 +1,3 @@
1
- require 'vanagon/utilities'
2
- include Vanagon::Utilities
3
-
4
1
  class Vanagon
5
2
  class Platform
6
3
  class RPM < Vanagon::Platform
@@ -62,7 +62,7 @@ class Vanagon
62
62
  $$1 ~ /^d$$/ && (#{explicit_search_string}) {print "d",$$2,$$3,"0755 root sys";} \
63
63
  $$1 ~ /^s$$/ {print;} \
64
64
  $$1 ~ /^f$$/ {print "f",$$2,$$3,$$4,"root sys";} \
65
- $$1 !~ /^[dfs]$$/ {print;} ' | /opt/csw/bin/gsed \
65
+ $$1 !~ /^[dfs]$$/ {print;} ' | #{sed} \
66
66
  -e '/^[fd] [^ ]\\+ .*[/]s\\?bin[^ ]\\+/ {s/root sys$$/root bin/}' \
67
67
  -e '/^[fd] [^ ]\\+ .*[/]lib[/][^ ]\\+/ {s/root sys$$/root bin/}' \
68
68
  -e '/^[fd] [^ ]\\+ .*[/][^ ]\\+[.]so/ {s/root sys$$/root bin/}' >> ../packaging/proto)),
@@ -156,7 +156,7 @@ class Vanagon
156
156
  if build_dependency =~ /^http.*\.gz/
157
157
  # Fetch, unpack, install...this assumes curl is present.
158
158
  package = build_dependency.sub(/^http.*\//, '')
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)"
159
+ http << "tmpdir=$(#{mktemp}); (cd ${tmpdir} && curl -O #{build_dependency} && gunzip -c #{package} | pkgadd -d /dev/stdin -a /var/tmp/noask all)"
160
160
  else
161
161
  # Opencsw dependencies. At this point we assume that pkgutil is installed.
162
162
  pkgutil << build_dependency
@@ -185,6 +185,7 @@ class Vanagon
185
185
  @make = "/opt/csw/bin/gmake"
186
186
  @tar = "/usr/sfw/bin/gtar"
187
187
  @patch = "/usr/bin/gpatch"
188
+ @sed = "/opt/csw/bin/gsed"
188
189
  @shasum = "/opt/csw/bin/shasum"
189
190
  # solaris 10
190
191
  @num_cores = "/usr/bin/kstat cpu_info | awk '{print $$1}' | grep '^core_id$$' | wc -l"