omnibus 5.4.0 → 5.5.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +2 -3
- data/CHANGELOG.md +21 -0
- data/Gemfile +8 -5
- data/README.md +3 -1
- data/Rakefile +20 -13
- data/appveyor.yml +4 -3
- data/bin/omnibus +3 -3
- data/features/commands/manifest.feature +19 -5
- data/features/step_definitions/generator_steps.rb +5 -6
- data/features/support/env.rb +4 -4
- data/lib/omnibus/build_version.rb +14 -14
- data/lib/omnibus/build_version_dsl.rb +3 -3
- data/lib/omnibus/builder.rb +50 -61
- data/lib/omnibus/changelog.rb +2 -2
- data/lib/omnibus/changelog_printer.rb +4 -4
- data/lib/omnibus/cleaner.rb +4 -4
- data/lib/omnibus/cli/base.rb +15 -15
- data/lib/omnibus/cli/cache.rb +13 -13
- data/lib/omnibus/cli/changelog.rb +8 -9
- data/lib/omnibus/cli/publish.rb +12 -13
- data/lib/omnibus/cli.rb +26 -27
- data/lib/omnibus/compressor.rb +6 -6
- data/lib/omnibus/compressors/base.rb +7 -2
- data/lib/omnibus/compressors/dmg.rb +12 -12
- data/lib/omnibus/compressors/null.rb +1 -1
- data/lib/omnibus/compressors/tgz.rb +8 -8
- data/lib/omnibus/config.rb +37 -26
- data/lib/omnibus/core_extensions/open_uri.rb +3 -3
- data/lib/omnibus/core_extensions.rb +1 -1
- data/lib/omnibus/digestable.rb +5 -4
- data/lib/omnibus/download_helpers.rb +7 -6
- data/lib/omnibus/exceptions.rb +29 -13
- data/lib/omnibus/fetcher.rb +0 -1
- data/lib/omnibus/fetchers/git_fetcher.rb +7 -7
- data/lib/omnibus/fetchers/net_fetcher.rb +19 -19
- data/lib/omnibus/fetchers/path_fetcher.rb +1 -1
- data/lib/omnibus/file_syncer.rb +3 -3
- data/lib/omnibus/generator.rb +60 -47
- data/lib/omnibus/git_cache.rb +33 -22
- data/lib/omnibus/git_repository.rb +5 -5
- data/lib/omnibus/health_check.rb +122 -119
- data/lib/omnibus/instrumentation.rb +1 -1
- data/lib/omnibus/licensing.rb +348 -60
- data/lib/omnibus/logger.rb +12 -9
- data/lib/omnibus/logging.rb +1 -1
- data/lib/omnibus/manifest.rb +4 -4
- data/lib/omnibus/manifest_diff.rb +6 -7
- data/lib/omnibus/manifest_entry.rb +1 -1
- data/lib/omnibus/metadata.rb +36 -36
- data/lib/omnibus/ohai.rb +6 -7
- data/lib/omnibus/package.rb +1 -1
- data/lib/omnibus/packager.rb +37 -28
- data/lib/omnibus/packagers/appx.rb +86 -0
- data/lib/omnibus/packagers/base.rb +21 -18
- data/lib/omnibus/packagers/bff.rb +22 -24
- data/lib/omnibus/packagers/deb.rb +20 -20
- data/lib/omnibus/packagers/ips.rb +18 -17
- data/lib/omnibus/packagers/makeself.rb +7 -7
- data/lib/omnibus/packagers/msi.rb +38 -193
- data/lib/omnibus/packagers/pkg.rb +16 -16
- data/lib/omnibus/packagers/rpm.rb +53 -54
- data/lib/omnibus/packagers/solaris.rb +14 -14
- data/lib/omnibus/packagers/windows_base.rb +192 -0
- data/lib/omnibus/project.rb +45 -43
- data/lib/omnibus/publisher.rb +3 -3
- data/lib/omnibus/publishers/artifactory_publisher.rb +39 -39
- data/lib/omnibus/publishers/s3_publisher.rb +7 -7
- data/lib/omnibus/reports.rb +10 -10
- data/lib/omnibus/s3_cache.rb +7 -7
- data/lib/omnibus/s3_helpers.rb +8 -7
- data/lib/omnibus/semantic_version.rb +1 -1
- data/lib/omnibus/software.rb +131 -81
- data/lib/omnibus/sugarable.rb +10 -10
- data/lib/omnibus/templating.rb +5 -5
- data/lib/omnibus/thread_pool.rb +1 -1
- data/lib/omnibus/util.rb +5 -5
- data/lib/omnibus/version.rb +1 -1
- data/lib/omnibus.rb +65 -65
- data/omnibus.gemspec +34 -32
- data/resources/appx/AppxManifest.xml.erb +18 -0
- data/resources/appx/assets/clear.png +0 -0
- data/spec/fixtures/licensing/license_scout/snoopy/ruby_bundler-bundler-audit-0.5.0-COPYING.txt +674 -0
- data/spec/fixtures/licensing/license_scout/snoopy/ruby_bundler-inifile-3.0.0-README.md +215 -0
- data/spec/fixtures/licensing/license_scout/snoopy/snoopy-dependency-licenses.json +24 -0
- data/spec/fixtures/licensing/license_scout/zlib/ruby_bundler-inifile-3.0.0-README.md +215 -0
- data/spec/fixtures/licensing/license_scout/zlib/ruby_bundler-mime-types-3.1-Licence.rdoc +25 -0
- data/spec/fixtures/licensing/license_scout/zlib/ruby_bundler-mini_portile2-2.1.0-LICENSE.txt +20 -0
- data/spec/fixtures/licensing/license_scout/zlib/zlib-dependency-licenses.json +32 -0
- data/spec/functional/builder_spec.rb +149 -150
- data/spec/functional/fetchers/git_fetcher_spec.rb +69 -71
- data/spec/functional/fetchers/net_fetcher_spec.rb +79 -79
- data/spec/functional/fetchers/path_fetcher_spec.rb +19 -20
- data/spec/functional/file_syncer_spec.rb +74 -74
- data/spec/functional/licensing_spec.rb +344 -35
- data/spec/functional/templating_spec.rb +17 -17
- data/spec/spec_helper.rb +20 -20
- data/spec/support/examples.rb +21 -15
- data/spec/support/file_helpers.rb +1 -1
- data/spec/support/git_helpers.rb +37 -37
- data/spec/support/matchers.rb +3 -3
- data/spec/support/ohai_helpers.rb +4 -4
- data/spec/support/path_helpers.rb +2 -2
- data/spec/support/shell_helpers.rb +2 -2
- data/spec/unit/build_version_dsl_spec.rb +5 -5
- data/spec/unit/build_version_spec.rb +63 -63
- data/spec/unit/builder_spec.rb +86 -70
- data/spec/unit/changelog_spec.rb +4 -4
- data/spec/unit/changelogprinter_spec.rb +130 -0
- data/spec/unit/cleanroom_spec.rb +11 -11
- data/spec/unit/compressor_spec.rb +16 -16
- data/spec/unit/compressors/base_spec.rb +6 -6
- data/spec/unit/compressors/dmg_spec.rb +76 -76
- data/spec/unit/compressors/null_spec.rb +4 -4
- data/spec/unit/compressors/tgz_spec.rb +20 -20
- data/spec/unit/config_spec.rb +44 -43
- data/spec/unit/digestable_spec.rb +13 -13
- data/spec/unit/fetcher_spec.rb +11 -12
- data/spec/unit/fetchers/git_fetcher_spec.rb +31 -31
- data/spec/unit/fetchers/net_fetcher_spec.rb +172 -173
- data/spec/unit/fetchers/path_fetcher_spec.rb +18 -18
- data/spec/unit/generator_spec.rb +38 -38
- data/spec/unit/git_cache_spec.rb +56 -54
- data/spec/unit/git_repository_spec.rb +2 -2
- data/spec/unit/health_check_spec.rb +40 -40
- data/spec/unit/library_spec.rb +35 -35
- data/spec/unit/manifest_diff_spec.rb +10 -11
- data/spec/unit/manifest_spec.rb +17 -17
- data/spec/unit/metadata_spec.rb +152 -152
- data/spec/unit/ohai_spec.rb +5 -5
- data/spec/unit/omnibus_spec.rb +31 -31
- data/spec/unit/package_spec.rb +20 -20
- data/spec/unit/packager_spec.rb +48 -42
- data/spec/unit/packagers/appx_spec.rb +165 -0
- data/spec/unit/packagers/base_spec.rb +34 -34
- data/spec/unit/packagers/bff_spec.rb +60 -60
- data/spec/unit/packagers/deb_spec.rb +71 -71
- data/spec/unit/packagers/ips_spec.rb +45 -45
- data/spec/unit/packagers/makeself_spec.rb +22 -22
- data/spec/unit/packagers/msi_spec.rb +141 -147
- data/spec/unit/packagers/pkg_spec.rb +59 -60
- data/spec/unit/packagers/rpm_spec.rb +125 -126
- data/spec/unit/packagers/solaris_spec.rb +52 -52
- data/spec/unit/project_spec.rb +137 -135
- data/spec/unit/publisher_spec.rb +70 -70
- data/spec/unit/publishers/artifactory_publisher_spec.rb +85 -85
- data/spec/unit/publishers/s3_publisher_spec.rb +36 -36
- data/spec/unit/s3_cacher_spec.rb +34 -34
- data/spec/unit/s3_helpers_spec.rb +6 -6
- data/spec/unit/semantic_version_spec.rb +2 -2
- data/spec/unit/software_spec.rb +346 -384
- data/spec/unit/sugarable_spec.rb +10 -10
- data/spec/unit/util_spec.rb +60 -60
- metadata +54 -6
- data/.rubocop.yml +0 -48
data/lib/omnibus/exceptions.rb
CHANGED
@@ -46,9 +46,9 @@ EOH
|
|
46
46
|
end
|
47
47
|
|
48
48
|
class MissingRequiredAttribute < Error
|
49
|
-
def initialize(instance, name, sample =
|
49
|
+
def initialize(instance, name, sample = "<VALUE>")
|
50
50
|
@instance, @name, @sample = instance, name, sample
|
51
|
-
@class = instance.class.name.split(
|
51
|
+
@class = instance.class.name.split("::").last
|
52
52
|
end
|
53
53
|
|
54
54
|
def to_s
|
@@ -105,7 +105,7 @@ EOH
|
|
105
105
|
<<-EOH
|
106
106
|
I could not find a project named `#{@name}' in any of the project locations:"
|
107
107
|
|
108
|
-
#{@possible_paths.map { |path| " #{path}"}.join("\n")}
|
108
|
+
#{@possible_paths.map { |path| " #{path}" }.join("\n")}
|
109
109
|
EOH
|
110
110
|
end
|
111
111
|
end
|
@@ -120,7 +120,7 @@ EOH
|
|
120
120
|
<<-EOH
|
121
121
|
I could not find a software named `#{@name}' in any of the software locations:"
|
122
122
|
|
123
|
-
#{@possible_paths.map { |path| " #{path}"}.join("\n")}
|
123
|
+
#{@possible_paths.map { |path| " #{path}" }.join("\n")}
|
124
124
|
EOH
|
125
125
|
end
|
126
126
|
end
|
@@ -249,14 +249,14 @@ EOH
|
|
249
249
|
if cmd.environment.nil? || cmd.environment.empty?
|
250
250
|
env = nil
|
251
251
|
else
|
252
|
-
env = cmd.environment.sort.map { |k,v| "#{k}=#{v}" }.join(
|
252
|
+
env = cmd.environment.sort.map { |k, v| "#{k}=#{v}" }.join(" ")
|
253
253
|
end
|
254
254
|
|
255
255
|
command = cmd.command
|
256
|
-
command_with_env = [env, command].compact.join(
|
256
|
+
command_with_env = [env, command].compact.join(" ")
|
257
257
|
|
258
|
-
stdout = cmd.stdout.empty? ?
|
259
|
-
stderr = cmd.stderr.empty? ?
|
258
|
+
stdout = cmd.stdout.empty? ? "(nothing)" : cmd.stdout.strip
|
259
|
+
stderr = cmd.stderr.empty? ? "(nothing)" : cmd.stderr.strip
|
260
260
|
|
261
261
|
super <<-EOH
|
262
262
|
The following shell command exited with status #{status}:
|
@@ -281,13 +281,13 @@ EOH
|
|
281
281
|
if cmd.environment.nil? || cmd.environment.empty?
|
282
282
|
env = nil
|
283
283
|
else
|
284
|
-
env = cmd.environment.sort.map { |k,v| "#{k}=#{v}" }.join(
|
284
|
+
env = cmd.environment.sort.map { |k, v| "#{k}=#{v}" }.join(" ")
|
285
285
|
end
|
286
286
|
|
287
287
|
command = cmd.command
|
288
|
-
command_with_env = [env, command].compact.join(
|
288
|
+
command_with_env = [env, command].compact.join(" ")
|
289
289
|
|
290
|
-
timeout = cmd.timeout.to_s.reverse.gsub(/...(?=.)/,'\&,').reverse
|
290
|
+
timeout = cmd.timeout.to_s.reverse.gsub(/...(?=.)/, '\&,').reverse
|
291
291
|
|
292
292
|
super <<-EOH
|
293
293
|
The following shell command timed out at #{timeout} seconds:
|
@@ -330,9 +330,25 @@ EOF
|
|
330
330
|
end
|
331
331
|
end
|
332
332
|
|
333
|
-
class
|
333
|
+
class FailedToSignWindowsPackage < Error
|
334
334
|
def initialize
|
335
|
-
super("Failed to
|
335
|
+
super("Failed to sign Windows Package.")
|
336
|
+
end
|
337
|
+
end
|
338
|
+
|
339
|
+
class LicensingError < Error
|
340
|
+
def initialize(errors)
|
341
|
+
@errors = errors
|
342
|
+
end
|
343
|
+
|
344
|
+
def to_s
|
345
|
+
<<-EOH
|
346
|
+
Encountered error(s) with project's licensing information.
|
347
|
+
Failing the build because :fatal_licensing_warnings is set in the configuration.
|
348
|
+
Error(s):
|
349
|
+
|
350
|
+
#{@errors.join("\n ")}
|
351
|
+
EOH
|
336
352
|
end
|
337
353
|
end
|
338
354
|
end
|
data/lib/omnibus/fetcher.rb
CHANGED
@@ -46,9 +46,9 @@ module Omnibus
|
|
46
46
|
# git checkout/clean.
|
47
47
|
#
|
48
48
|
def clean
|
49
|
-
log.info(log_key) {
|
49
|
+
log.info(log_key) { "Cleaning existing clone" }
|
50
50
|
git_checkout
|
51
|
-
git(
|
51
|
+
git("clean -fdx")
|
52
52
|
true
|
53
53
|
end
|
54
54
|
|
@@ -114,7 +114,7 @@ module Omnibus
|
|
114
114
|
# @return [true, false]
|
115
115
|
#
|
116
116
|
def dir_empty?(dir)
|
117
|
-
Dir.entries(dir).reject {|d| [
|
117
|
+
Dir.entries(dir).reject { |d| [".", ".."].include?(d) }.empty?
|
118
118
|
end
|
119
119
|
|
120
120
|
#
|
@@ -164,7 +164,7 @@ module Omnibus
|
|
164
164
|
#
|
165
165
|
def git_fetch
|
166
166
|
fetch_cmd = "fetch #{source_url} #{described_version}"
|
167
|
-
fetch_cmd <<
|
167
|
+
fetch_cmd << " --recurse-submodules=on-demand" if clone_submodules?
|
168
168
|
git(fetch_cmd)
|
169
169
|
end
|
170
170
|
|
@@ -174,7 +174,7 @@ module Omnibus
|
|
174
174
|
# @return [String]
|
175
175
|
#
|
176
176
|
def current_revision
|
177
|
-
cmd = git(
|
177
|
+
cmd = git("rev-parse HEAD")
|
178
178
|
cmd.stdout.strip
|
179
179
|
rescue CommandFailed
|
180
180
|
log.debug(log_key) { "unable to determine current revision" }
|
@@ -188,7 +188,7 @@ module Omnibus
|
|
188
188
|
#
|
189
189
|
def contains_revision?(rev)
|
190
190
|
cmd = git("cat-file -t #{rev}")
|
191
|
-
cmd.stdout.strip ==
|
191
|
+
cmd.stdout.strip == "commit"
|
192
192
|
rescue CommandFailed
|
193
193
|
log.debug(log_key) { "unable to determine presence of commit #{rev}" }
|
194
194
|
false
|
@@ -230,7 +230,7 @@ module Omnibus
|
|
230
230
|
# Only when the service is specifically configured with
|
231
231
|
# uploadpack.allowReachableSHA1InWant is there any guarantee that it
|
232
232
|
# considers "naked" wants.
|
233
|
-
log.warn(log_key) {
|
233
|
+
log.warn(log_key) { "git fetch on a sha1 is not guaranteed to work" }
|
234
234
|
log.warn(log_key) { "Specify a ref name instead of #{ref} on #{source}" }
|
235
235
|
ref
|
236
236
|
else
|
@@ -14,19 +14,19 @@
|
|
14
14
|
# limitations under the License.
|
15
15
|
#
|
16
16
|
|
17
|
-
require
|
18
|
-
require
|
17
|
+
require "fileutils"
|
18
|
+
require "omnibus/download_helpers"
|
19
19
|
|
20
20
|
module Omnibus
|
21
21
|
class NetFetcher < Fetcher
|
22
22
|
include DownloadHelpers
|
23
23
|
|
24
24
|
# Use 7-zip to extract 7z/zip for Windows
|
25
|
-
WIN_7Z_EXTENSIONS = %w
|
25
|
+
WIN_7Z_EXTENSIONS = %w{.7z .zip}
|
26
26
|
|
27
27
|
# tar probably has compression scheme linked in, otherwise for tarballs
|
28
|
-
COMPRESSED_TAR_EXTENSIONS = %w
|
29
|
-
TAR_EXTENSIONS = COMPRESSED_TAR_EXTENSIONS + [
|
28
|
+
COMPRESSED_TAR_EXTENSIONS = %w{.tar.gz .tgz tar.bz2 .tar.xz .txz .tar.lzma}
|
29
|
+
TAR_EXTENSIONS = COMPRESSED_TAR_EXTENSIONS + [".tar"]
|
30
30
|
|
31
31
|
ALL_EXTENSIONS = WIN_7Z_EXTENSIONS + TAR_EXTENSIONS
|
32
32
|
|
@@ -118,7 +118,7 @@ module Omnibus
|
|
118
118
|
# @return [String]
|
119
119
|
#
|
120
120
|
def downloaded_file
|
121
|
-
filename = File.basename(source[:url],
|
121
|
+
filename = File.basename(source[:url], "?*")
|
122
122
|
File.join(Config.cache_dir, filename)
|
123
123
|
end
|
124
124
|
|
@@ -168,7 +168,7 @@ module Omnibus
|
|
168
168
|
end
|
169
169
|
|
170
170
|
# Set the cookie if one was given
|
171
|
-
options[
|
171
|
+
options["Cookie"] = source[:cookie] if source[:cookie]
|
172
172
|
|
173
173
|
download_file!(download_url, downloaded_file, options)
|
174
174
|
end
|
@@ -229,18 +229,18 @@ module Omnibus
|
|
229
229
|
#
|
230
230
|
def extract
|
231
231
|
# Only used by tar
|
232
|
-
compression_switch =
|
233
|
-
compression_switch =
|
234
|
-
compression_switch =
|
235
|
-
compression_switch =
|
236
|
-
compression_switch =
|
232
|
+
compression_switch = ""
|
233
|
+
compression_switch = "z" if downloaded_file.end_with?("gz")
|
234
|
+
compression_switch = "--lzma -" if downloaded_file.end_with?("lzma")
|
235
|
+
compression_switch = "j" if downloaded_file.end_with?("bz2")
|
236
|
+
compression_switch = "J" if downloaded_file.end_with?("xz")
|
237
237
|
|
238
|
-
if Ohai[
|
238
|
+
if Ohai["platform"] == "windows"
|
239
239
|
if downloaded_file.end_with?(*TAR_EXTENSIONS) && source[:extract] != :seven_zip
|
240
240
|
returns = [0]
|
241
241
|
returns << 1 if source[:extract] == :lax_tar
|
242
242
|
|
243
|
-
shellout!("tar
|
243
|
+
shellout!("tar #{compression_switch}xf #{safe_downloaded_file} -C#{safe_project_dir}", returns: returns)
|
244
244
|
elsif downloaded_file.end_with?(*COMPRESSED_TAR_EXTENSIONS)
|
245
245
|
Dir.mktmpdir do |temp_dir|
|
246
246
|
log.debug(log_key) { "Temporarily extracting `#{safe_downloaded_file}' to `#{temp_dir}'" }
|
@@ -248,7 +248,7 @@ module Omnibus
|
|
248
248
|
shellout!("7z.exe x #{safe_downloaded_file} -o#{windows_safe_path(temp_dir)} -r -y")
|
249
249
|
|
250
250
|
fname = File.basename(downloaded_file, File.extname(downloaded_file))
|
251
|
-
fname << ".tar" if downloaded_file.end_with?(
|
251
|
+
fname << ".tar" if downloaded_file.end_with?("tgz", "txz")
|
252
252
|
next_file = windows_safe_path(File.join(temp_dir, fname))
|
253
253
|
|
254
254
|
log.debug(log_key) { "Temporarily extracting `#{next_file}' to `#{safe_project_dir}'" }
|
@@ -257,9 +257,9 @@ module Omnibus
|
|
257
257
|
else
|
258
258
|
shellout!("7z.exe x #{safe_downloaded_file} -o#{safe_project_dir} -r -y")
|
259
259
|
end
|
260
|
-
elsif downloaded_file.end_with?(
|
260
|
+
elsif downloaded_file.end_with?(".7z")
|
261
261
|
shellout!("7z x #{safe_downloaded_file} -o#{safe_project_dir} -r -y")
|
262
|
-
elsif downloaded_file.end_with?(
|
262
|
+
elsif downloaded_file.end_with?(".zip")
|
263
263
|
shellout!("unzip #{safe_downloaded_file} -d #{safe_project_dir}")
|
264
264
|
else
|
265
265
|
shellout!("#{tar} #{compression_switch}xf #{safe_downloaded_file} -C#{safe_project_dir}")
|
@@ -288,7 +288,7 @@ module Omnibus
|
|
288
288
|
# if the checksum does not match
|
289
289
|
#
|
290
290
|
def verify_checksum!
|
291
|
-
log.info(log_key) {
|
291
|
+
log.info(log_key) { "Verifying checksum" }
|
292
292
|
|
293
293
|
expected = checksum
|
294
294
|
actual = digest(downloaded_file, digest_type)
|
@@ -321,7 +321,7 @@ module Omnibus
|
|
321
321
|
# @return [String]
|
322
322
|
#
|
323
323
|
def tar
|
324
|
-
Omnibus.which(
|
324
|
+
Omnibus.which("gtar") ? "gtar" : "tar"
|
325
325
|
end
|
326
326
|
end
|
327
327
|
end
|
data/lib/omnibus/file_syncer.rb
CHANGED
@@ -14,14 +14,14 @@
|
|
14
14
|
# limitations under the License.
|
15
15
|
#
|
16
16
|
|
17
|
-
require
|
17
|
+
require "fileutils"
|
18
18
|
|
19
19
|
module Omnibus
|
20
20
|
module FileSyncer
|
21
21
|
extend self
|
22
22
|
|
23
23
|
# Files to be ignored during a directory globbing
|
24
|
-
IGNORED_FILES = %w
|
24
|
+
IGNORED_FILES = %w{. ..}.freeze
|
25
25
|
|
26
26
|
#
|
27
27
|
# Glob across the given pattern, accounting for dotfiles, removing Ruby's
|
@@ -58,7 +58,7 @@ module Omnibus
|
|
58
58
|
[exclude, "#{exclude}/*"]
|
59
59
|
end.flatten
|
60
60
|
|
61
|
-
source_files = glob(File.join(source,
|
61
|
+
source_files = glob(File.join(source, "**/*"))
|
62
62
|
source_files = source_files.reject do |source_file|
|
63
63
|
basename = relative_path_for(source_file, source)
|
64
64
|
excludes.any? { |exclude| File.fnmatch?(exclude, basename, File::FNM_DOTMATCH) }
|
data/lib/omnibus/generator.rb
CHANGED
@@ -14,7 +14,7 @@
|
|
14
14
|
# limitations under the License.
|
15
15
|
#
|
16
16
|
|
17
|
-
require
|
17
|
+
require "thor"
|
18
18
|
|
19
19
|
module Omnibus
|
20
20
|
class Generator < Thor::Group
|
@@ -23,78 +23,83 @@ module Omnibus
|
|
23
23
|
namespace :new
|
24
24
|
|
25
25
|
argument :name,
|
26
|
-
banner:
|
27
|
-
desc:
|
26
|
+
banner: "NAME",
|
27
|
+
desc: "The name of the Omnibus project",
|
28
28
|
type: :string,
|
29
29
|
required: true
|
30
30
|
|
31
31
|
class_option :path,
|
32
|
-
banner:
|
33
|
-
aliases:
|
34
|
-
desc:
|
32
|
+
banner: "PATH",
|
33
|
+
aliases: "-p",
|
34
|
+
desc: "The path to create the Omnibus project",
|
35
35
|
type: :string,
|
36
|
-
default:
|
36
|
+
default: "."
|
37
|
+
|
38
|
+
class_option :appx_assets,
|
39
|
+
desc: "Generate Windows APPX assets",
|
40
|
+
type: :boolean,
|
41
|
+
default: false
|
37
42
|
|
38
43
|
class_option :bff_assets,
|
39
|
-
desc:
|
44
|
+
desc: "Generate AIX bff assets",
|
40
45
|
type: :boolean,
|
41
46
|
default: false
|
42
47
|
|
43
48
|
class_option :deb_assets,
|
44
|
-
desc:
|
49
|
+
desc: "Generate Debian deb assets",
|
45
50
|
type: :boolean,
|
46
51
|
default: false
|
47
52
|
|
48
53
|
class_option :dmg_assets,
|
49
|
-
desc:
|
54
|
+
desc: "Generate Mac OS X dmg assets",
|
50
55
|
type: :boolean,
|
51
56
|
default: false
|
52
57
|
|
53
58
|
class_option :msi_assets,
|
54
|
-
desc:
|
59
|
+
desc: "Generate Windows MSI assets",
|
55
60
|
type: :boolean,
|
56
61
|
default: false
|
57
62
|
|
58
63
|
class_option :pkg_assets,
|
59
|
-
desc:
|
64
|
+
desc: "Generate Mac OS X pkg assets",
|
60
65
|
type: :boolean,
|
61
66
|
default: false
|
62
67
|
|
63
68
|
class_option :rpm_assets,
|
64
|
-
desc:
|
69
|
+
desc: "Generate RHEL/CentOS rpm assets",
|
65
70
|
type: :boolean,
|
66
71
|
default: false
|
67
72
|
|
68
73
|
class << self
|
69
74
|
# Set the source root for Thor
|
70
75
|
def source_root
|
71
|
-
File.expand_path(
|
76
|
+
File.expand_path("../generator_files", __FILE__)
|
72
77
|
end
|
73
78
|
end
|
74
79
|
|
75
80
|
def create_project_files
|
76
|
-
template(
|
77
|
-
template(
|
78
|
-
template(
|
79
|
-
template(
|
81
|
+
template("Gemfile.erb", "#{target}/Gemfile", template_options)
|
82
|
+
template("gitignore.erb", "#{target}/.gitignore", template_options)
|
83
|
+
template("README.md.erb", "#{target}/README.md", template_options)
|
84
|
+
template("omnibus.rb.erb", "#{target}/omnibus.rb", template_options)
|
80
85
|
end
|
81
86
|
|
82
87
|
def create_project_definition
|
83
|
-
template(
|
88
|
+
template("config/projects/project.rb.erb", "#{target}/config/projects/#{name}.rb", template_options)
|
84
89
|
end
|
85
90
|
|
86
91
|
def create_example_software_definitions
|
87
|
-
template(
|
92
|
+
template("config/software/zlib.rb.erb", "#{target}/config/software/#{name}-zlib.rb", template_options)
|
88
93
|
end
|
89
94
|
|
90
95
|
def create_kitchen_files
|
91
|
-
template(
|
92
|
-
template(
|
93
|
-
template(
|
96
|
+
template(".kitchen.local.yml.erb", "#{target}/.kitchen.local.yml", template_options)
|
97
|
+
template(".kitchen.yml.erb", "#{target}/.kitchen.yml", template_options)
|
98
|
+
template("Berksfile.erb", "#{target}/Berksfile", template_options)
|
94
99
|
end
|
95
100
|
|
96
101
|
def create_package_scripts
|
97
|
-
%w
|
102
|
+
%w{preinst prerm postinst postrm}.each do |package_script|
|
98
103
|
script_path = "#{target}/package-scripts/#{name}/#{package_script}"
|
99
104
|
template("package_scripts/#{package_script}.erb", script_path, template_options)
|
100
105
|
|
@@ -103,58 +108,66 @@ module Omnibus
|
|
103
108
|
end
|
104
109
|
end
|
105
110
|
|
111
|
+
def create_appx_assets
|
112
|
+
return unless options[:appx_assets]
|
113
|
+
|
114
|
+
copy_file(resource_path("appx/AppxManifest.xml.erb"), "#{target}/resources/#{name}/appx/AppxManifest.xml.erb")
|
115
|
+
copy_file(resource_path("appx/assets/clear.png"), "#{target}/resources/#{name}/appx/assets/clear.png")
|
116
|
+
end
|
117
|
+
|
106
118
|
def create_bff_assets
|
107
119
|
return unless options[:bff_assets]
|
108
120
|
|
109
|
-
copy_file(resource_path(
|
121
|
+
copy_file(resource_path("bff/gen.template.erb"), "#{target}/resources/#{name}/bff/gen.template.erb")
|
110
122
|
end
|
111
123
|
|
112
124
|
def create_deb_assets
|
113
125
|
return unless options[:deb_assets]
|
114
126
|
|
115
|
-
copy_file(resource_path(
|
116
|
-
copy_file(resource_path(
|
117
|
-
copy_file(resource_path(
|
127
|
+
copy_file(resource_path("deb/conffiles.erb"), "#{target}/resources/#{name}/deb/conffiles.erb")
|
128
|
+
copy_file(resource_path("deb/control.erb"), "#{target}/resources/#{name}/deb/control.erb")
|
129
|
+
copy_file(resource_path("deb/md5sums.erb"), "#{target}/resources/#{name}/deb/md5sums.erb")
|
118
130
|
end
|
119
131
|
|
120
132
|
def create_dmg_assets
|
121
133
|
return unless options[:dmg_assets]
|
122
134
|
|
123
|
-
copy_file(resource_path(
|
124
|
-
copy_file(resource_path(
|
135
|
+
copy_file(resource_path("dmg/background.png"), "#{target}/resources/#{name}/dmg/background.png")
|
136
|
+
copy_file(resource_path("dmg/icon.png"), "#{target}/resources/#{name}/dmg/icon.png")
|
125
137
|
end
|
126
138
|
|
127
139
|
def create_msi_assets
|
128
140
|
return unless options[:msi_assets]
|
129
141
|
|
130
|
-
copy_file(resource_path(
|
131
|
-
copy_file(resource_path(
|
132
|
-
copy_file(resource_path(
|
142
|
+
copy_file(resource_path("msi/localization-en-us.wxl.erb"), "#{target}/resources/#{name}/msi/localization-en-us.wxl.erb")
|
143
|
+
copy_file(resource_path("msi/parameters.wxi.erb"), "#{target}/resources/#{name}/msi/parameters.wxi.erb")
|
144
|
+
copy_file(resource_path("msi/source.wxs.erb"), "#{target}/resources/#{name}/msi/source.wxs.erb")
|
133
145
|
|
134
|
-
copy_file(resource_path(
|
135
|
-
copy_file(resource_path(
|
136
|
-
copy_file(resource_path(
|
137
|
-
copy_file(resource_path(
|
138
|
-
copy_file(resource_path(
|
139
|
-
copy_file(resource_path(
|
146
|
+
copy_file(resource_path("msi/assets/LICENSE.rtf"), "#{target}/resources/#{name}/msi/assets/LICENSE.rtf")
|
147
|
+
copy_file(resource_path("msi/assets/banner_background.bmp"), "#{target}/resources/#{name}/msi/assets/banner_background.bmp")
|
148
|
+
copy_file(resource_path("msi/assets/dialog_background.bmp"), "#{target}/resources/#{name}/msi/assets/dialog_background.bmp")
|
149
|
+
copy_file(resource_path("msi/assets/project.ico"), "#{target}/resources/#{name}/msi/assets/project.ico")
|
150
|
+
copy_file(resource_path("msi/assets/project_16x16.ico"), "#{target}/resources/#{name}/msi/assets/project_16x16.ico")
|
151
|
+
copy_file(resource_path("msi/assets/project_32x32.ico"), "#{target}/resources/#{name}/msi/assets/project_32x32.ico")
|
140
152
|
end
|
141
153
|
|
142
154
|
def create_pkg_assets
|
143
155
|
return unless options[:pkg_assets]
|
144
156
|
|
145
|
-
copy_file(resource_path(
|
146
|
-
copy_file(resource_path(
|
147
|
-
copy_file(resource_path(
|
148
|
-
copy_file(resource_path(
|
157
|
+
copy_file(resource_path("pkg/background.png"), "#{target}/resources/#{name}/pkg/background.png")
|
158
|
+
copy_file(resource_path("pkg/license.html.erb"), "#{target}/resources/#{name}/pkg/license.html.erb")
|
159
|
+
copy_file(resource_path("pkg/welcome.html.erb"), "#{target}/resources/#{name}/pkg/welcome.html.erb")
|
160
|
+
copy_file(resource_path("pkg/distribution.xml.erb"), "#{target}/resources/#{name}/pkg/distribution.xml.erb")
|
149
161
|
end
|
150
162
|
|
151
163
|
def create_rpm_assets
|
152
164
|
return unless options[:rpm_assets]
|
153
165
|
|
154
|
-
copy_file(resource_path(
|
155
|
-
copy_file(resource_path(
|
156
|
-
copy_file(resource_path(
|
166
|
+
copy_file(resource_path("rpm/rpmmacros.erb"), "#{target}/resources/#{name}/rpm/rpmmacros.erb")
|
167
|
+
copy_file(resource_path("rpm/signing.erb"), "#{target}/resources/#{name}/rpm/signing.erb")
|
168
|
+
copy_file(resource_path("rpm/spec.erb"), "#{target}/resources/#{name}/rpm/spec.erb")
|
157
169
|
end
|
170
|
+
|
158
171
|
private
|
159
172
|
|
160
173
|
#
|
@@ -184,7 +197,7 @@ module Omnibus
|
|
184
197
|
# @return [String]
|
185
198
|
#
|
186
199
|
def resource_path(*args)
|
187
|
-
Omnibus.source_root.join(
|
200
|
+
Omnibus.source_root.join("resources", *args).to_s
|
188
201
|
end
|
189
202
|
end
|
190
203
|
end
|
data/lib/omnibus/git_cache.rb
CHANGED
@@ -14,22 +14,33 @@
|
|
14
14
|
# limitations under the License.
|
15
15
|
#
|
16
16
|
|
17
|
-
require
|
18
|
-
require
|
17
|
+
require "digest"
|
18
|
+
require "fileutils"
|
19
19
|
|
20
20
|
module Omnibus
|
21
21
|
class GitCache
|
22
22
|
include Util
|
23
23
|
include Logging
|
24
24
|
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
25
|
+
# The serial number represents compatibility of a cache entry with the
|
26
|
+
# current version of the omnibus code base. Any time a change is made to
|
27
|
+
# omnibus that makes the code incompatible with any cache entries created
|
28
|
+
# before the code change, the serial number should be incremented.
|
29
|
+
#
|
30
|
+
# For example, if a code change generates content in the `install_dir`
|
31
|
+
# before cache snapshots are taken, any snapshots created before upgrade
|
32
|
+
# will not have the generated content, so these snapshots would be
|
33
|
+
# incompatible with the current omnibus codebase. Incrementing the serial
|
34
|
+
# number ensures these old shapshots will not be used in subsequent builds.
|
35
|
+
SERIAL_NUMBER = 1
|
36
|
+
|
37
|
+
REQUIRED_GIT_FILES = %w{
|
38
|
+
HEAD
|
39
|
+
description
|
40
|
+
hooks
|
41
|
+
info
|
42
|
+
objects
|
43
|
+
refs}.freeze
|
33
44
|
|
34
45
|
#
|
35
46
|
# @return [Software]
|
@@ -64,7 +75,7 @@ module Omnibus
|
|
64
75
|
false
|
65
76
|
else
|
66
77
|
create_directory(File.dirname(cache_path))
|
67
|
-
git_cmd(
|
78
|
+
git_cmd("init -q")
|
68
79
|
true
|
69
80
|
end
|
70
81
|
end
|
@@ -98,8 +109,8 @@ module Omnibus
|
|
98
109
|
# This is the list of all the unqiue shasums of all the software build
|
99
110
|
# dependencies, including the on currently being acted upon.
|
100
111
|
shasums = [dep_list.map(&:shasum), software.shasum].flatten
|
101
|
-
suffix = Digest::SHA256.hexdigest(shasums.join(
|
102
|
-
@tag = "#{software.name}-#{suffix}"
|
112
|
+
suffix = Digest::SHA256.hexdigest(shasums.join("|"))
|
113
|
+
@tag = "#{software.name}-#{suffix}-#{SERIAL_NUMBER}"
|
103
114
|
|
104
115
|
log.internal(log_key) { "tag: #{@tag}" }
|
105
116
|
|
@@ -108,29 +119,29 @@ module Omnibus
|
|
108
119
|
|
109
120
|
# Create an incremental install path cache for the software step
|
110
121
|
def incremental
|
111
|
-
log.internal(log_key) {
|
122
|
+
log.internal(log_key) { "Performing incremental cache" }
|
112
123
|
|
113
124
|
create_cache_path
|
114
125
|
remove_git_dirs
|
115
126
|
|
116
|
-
git_cmd(
|
127
|
+
git_cmd("add -A -f")
|
117
128
|
|
118
129
|
begin
|
119
|
-
git_cmd(%Q
|
130
|
+
git_cmd(%Q{commit -q -m "Backup of #{tag}"})
|
120
131
|
rescue CommandFailed => e
|
121
|
-
raise unless e.message.include?(
|
132
|
+
raise unless e.message.include?("nothing to commit")
|
122
133
|
end
|
123
134
|
|
124
|
-
git_cmd(%Q
|
135
|
+
git_cmd(%Q{tag -f "#{tag}"})
|
125
136
|
end
|
126
137
|
|
127
138
|
def restore
|
128
|
-
log.internal(log_key) {
|
139
|
+
log.internal(log_key) { "Performing cache restoration" }
|
129
140
|
|
130
141
|
create_cache_path
|
131
142
|
|
132
143
|
restore_me = false
|
133
|
-
cmd = git_cmd(%Q
|
144
|
+
cmd = git_cmd(%Q{tag -l "#{tag}"})
|
134
145
|
|
135
146
|
cmd.stdout.each_line do |line|
|
136
147
|
restore_me = true if tag == line.chomp
|
@@ -138,7 +149,7 @@ module Omnibus
|
|
138
149
|
|
139
150
|
if restore_me
|
140
151
|
log.internal(log_key) { "Detected tag `#{tag}' can be restored, restoring" }
|
141
|
-
git_cmd(%Q
|
152
|
+
git_cmd(%Q{checkout -f "#{tag}"})
|
142
153
|
true
|
143
154
|
else
|
144
155
|
log.internal(log_key) { "Could not find tag `#{tag}', skipping restore" }
|
@@ -190,7 +201,7 @@ module Omnibus
|
|
190
201
|
# @return [String]
|
191
202
|
#
|
192
203
|
def install_dir
|
193
|
-
@install_dir ||= software.project.install_dir.sub(/^([A-Za-z]:)/,
|
204
|
+
@install_dir ||= software.project.install_dir.sub(/^([A-Za-z]:)/, "")
|
194
205
|
end
|
195
206
|
|
196
207
|
# Override the log_key for this class to include the software name
|