stem 0.6.0 → 0.7.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -4,13 +4,18 @@ module Stem
4
4
  include Util
5
5
  attr_reader :family, :sha1, :source_ami, :time
6
6
 
7
- def initialize(family, config, userdata)
7
+ def initialize(family, config, options = {})
8
8
  aggregate_hash_options_for_ami!(config)
9
9
  @time = Time.now.utc
10
10
  @family = family
11
- @sha1 = Family.image_hash(config, userdata)
11
+ @sha1 = if options[:userdata]
12
+ Family.image_hash(config, options.delete(:userdata))
13
+ elsif options[:sha1]
14
+ options.delete(:sha1)
15
+ else
16
+ raise ArgumentError.new("Must specify either userdata or sha1")
17
+ end
12
18
  @source_ami = config['ami']
13
- @userdata = userdata
14
19
  end
15
20
 
16
21
  def ==(member)
@@ -23,12 +28,16 @@ module Stem
23
28
  !Stem::Image.tagged(:family => family, :sha1 => sha1).empty?
24
29
  end
25
30
 
31
+ def architecture
32
+ Stem::Image.describe(source_ami)['architecture']
33
+ end
34
+
26
35
  def capture(instance_id)
27
36
  Stem::Image.create(name, instance_id, tags)
28
37
  end
29
38
 
30
39
  def name
31
- "#{family}-#{timestamp.gsub(':', '_')}"
40
+ [family, timestamp.gsub(':', '_'), architecture].join('-')
32
41
  end
33
42
 
34
43
  def tags
data/lib/stem/userdata.rb CHANGED
@@ -18,7 +18,6 @@ module Stem
18
18
  process_mustache(opts[:mustache_vars])
19
19
  raise "must contain a userdata.sh" unless File.exists?("userdata.sh")
20
20
  # Set constant timestamps for all files to guarantee hashing consistency
21
- set_all_timestamps(tmp_path, "200210272016")
22
21
  make_zip_shell
23
22
  end
24
23
  end
@@ -61,21 +60,8 @@ cd $UD
61
60
  exec bash userdata.sh
62
61
  #### THE END
63
62
  SHELL
64
- header + %x{tar --exclude \\*.stem -cv . | bzip2 --best -}
63
+ header + %x{find . -print0 | sort -z | tar -cv --no-recursion --null --owner=0 --group=0 --mtime='2002-10-28 04:27:00Z' --exclude \\*.stem -T - | bzip2 --best -}
65
64
  end
66
-
67
- def set_all_timestamps(file_or_dir, time)
68
- Dir.foreach(file_or_dir) do |item|
69
- path = file_or_dir + '/' + item
70
- if File.directory?(path) && item != '.'
71
- next if item == '..'
72
- set_all_timestamps(path, time)
73
- else
74
- `touch -t #{time} #{path}`
75
- end
76
- end
77
- end
78
-
79
65
  end
80
66
  end
81
67
 
metadata CHANGED
@@ -2,7 +2,7 @@
2
2
  name: stem
3
3
  version: !ruby/object:Gem::Version
4
4
  prerelease:
5
- version: 0.6.0
5
+ version: 0.7.0
6
6
  platform: ruby
7
7
  authors:
8
8
  - Peter van Hardenberg
@@ -12,7 +12,7 @@ autorequire:
12
12
  bindir: bin
13
13
  cert_chain: []
14
14
 
15
- date: 2011-04-01 00:00:00 -07:00
15
+ date: 2011-04-23 00:00:00 -07:00
16
16
  default_executable:
17
17
  dependencies:
18
18
  - !ruby/object:Gem::Dependency