omnibus 4.0.0 → 4.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +8 -0
- data/.travis.yml +3 -11
- data/CHANGELOG.md +50 -0
- data/MAINTAINERS.md +26 -0
- data/README.md +61 -4
- data/appveyor.yml +35 -0
- data/docs/Build Cache.md +28 -3
- data/docs/Building on RHEL.md +1 -1
- data/features/commands/publish.feature +4 -9
- data/features/step_definitions/generator_steps.rb +14 -1
- data/features/support/env.rb +5 -3
- data/lib/omnibus.rb +10 -0
- data/lib/omnibus/build_version.rb +34 -25
- data/lib/omnibus/build_version_dsl.rb +43 -4
- data/lib/omnibus/builder.rb +30 -11
- data/lib/omnibus/changelog.rb +52 -0
- data/lib/omnibus/changelog_printer.rb +77 -0
- data/lib/omnibus/cli.rb +37 -2
- data/lib/omnibus/cli/changelog.rb +149 -0
- data/lib/omnibus/cli/publish.rb +30 -10
- data/lib/omnibus/config.rb +41 -2
- data/lib/omnibus/digestable.rb +6 -1
- data/lib/omnibus/exceptions.rb +15 -1
- data/lib/omnibus/fetcher.rb +78 -34
- data/lib/omnibus/fetchers/git_fetcher.rb +84 -42
- data/lib/omnibus/fetchers/net_fetcher.rb +64 -13
- data/lib/omnibus/fetchers/null_fetcher.rb +8 -1
- data/lib/omnibus/fetchers/path_fetcher.rb +24 -1
- data/lib/omnibus/file_syncer.rb +52 -1
- data/lib/omnibus/generator.rb +22 -21
- data/lib/omnibus/generator_files/.kitchen.yml.erb +8 -12
- data/lib/omnibus/generator_files/Berksfile.erb +4 -4
- data/lib/omnibus/generator_files/Gemfile.erb +3 -3
- data/lib/omnibus/generator_files/README.md.erb +17 -0
- data/lib/omnibus/generator_files/omnibus.rb.erb +6 -0
- data/lib/omnibus/git_repository.rb +43 -0
- data/lib/omnibus/health_check.rb +5 -1
- data/lib/omnibus/manifest.rb +134 -0
- data/lib/omnibus/manifest_diff.rb +88 -0
- data/lib/omnibus/manifest_entry.rb +43 -0
- data/lib/omnibus/metadata.rb +19 -1
- data/lib/omnibus/package.rb +9 -0
- data/lib/omnibus/packagers/base.rb +1 -1
- data/lib/omnibus/packagers/bff.rb +5 -5
- data/lib/omnibus/packagers/deb.rb +11 -4
- data/lib/omnibus/packagers/msi.rb +243 -2
- data/lib/omnibus/packagers/rpm.rb +68 -14
- data/lib/omnibus/packagers/solaris.rb +17 -23
- data/lib/omnibus/project.rb +129 -16
- data/lib/omnibus/publisher.rb +62 -49
- data/lib/omnibus/publishers/artifactory_publisher.rb +96 -5
- data/lib/omnibus/publishers/s3_publisher.rb +20 -25
- data/lib/omnibus/s3_cache.rb +13 -34
- data/lib/omnibus/s3_helpers.rb +119 -0
- data/lib/omnibus/semantic_version.rb +57 -0
- data/lib/omnibus/software.rb +87 -28
- data/lib/omnibus/sugarable.rb +18 -0
- data/lib/omnibus/templating.rb +8 -1
- data/lib/omnibus/version.rb +1 -1
- data/omnibus.gemspec +10 -7
- data/resources/bff/gen.template.erb +1 -1
- data/resources/msi/bundle.wxs.erb +17 -0
- data/resources/msi/localization-en-us.wxl.erb +1 -1
- data/resources/rpm/spec.erb +1 -1
- data/spec/functional/builder_spec.rb +15 -7
- data/spec/functional/fetchers/git_fetcher_spec.rb +44 -12
- data/spec/functional/fetchers/net_fetcher_spec.rb +171 -20
- data/spec/functional/fetchers/path_fetcher_spec.rb +16 -1
- data/spec/functional/file_syncer_spec.rb +58 -5
- data/spec/functional/templating_spec.rb +17 -6
- data/spec/spec_helper.rb +17 -0
- data/spec/support/file_helpers.rb +12 -2
- data/spec/support/git_helpers.rb +23 -18
- data/spec/support/matchers.rb +22 -0
- data/spec/support/output_helpers.rb +29 -0
- data/spec/unit/build_version_dsl_spec.rb +31 -4
- data/spec/unit/build_version_spec.rb +11 -4
- data/spec/unit/builder_spec.rb +33 -0
- data/spec/unit/changelog_spec.rb +55 -0
- data/spec/unit/cleanroom_spec.rb +1 -1
- data/spec/unit/compressors/dmg_spec.rb +3 -3
- data/spec/unit/compressors/tgz_spec.rb +3 -3
- data/spec/unit/config_spec.rb +3 -1
- data/spec/unit/fetcher_spec.rb +35 -0
- data/spec/unit/fetchers/git_fetcher_spec.rb +28 -14
- data/spec/unit/fetchers/net_fetcher_spec.rb +178 -24
- data/spec/unit/fetchers/path_fetcher_spec.rb +8 -7
- data/spec/unit/generator_spec.rb +22 -21
- data/spec/unit/git_repository_spec.rb +60 -0
- data/spec/unit/manifest_diff_spec.rb +75 -0
- data/spec/unit/manifest_spec.rb +116 -0
- data/spec/unit/metadata_spec.rb +11 -0
- data/spec/unit/omnibus_spec.rb +9 -6
- data/spec/unit/package_spec.rb +1 -1
- data/spec/unit/packagers/base_spec.rb +8 -18
- data/spec/unit/packagers/bff_spec.rb +9 -5
- data/spec/unit/packagers/deb_spec.rb +44 -12
- data/spec/unit/packagers/makeself_spec.rb +4 -4
- data/spec/unit/packagers/msi_spec.rb +122 -6
- data/spec/unit/packagers/pkg_spec.rb +3 -3
- data/spec/unit/packagers/rpm_spec.rb +37 -12
- data/spec/unit/project_spec.rb +18 -1
- data/spec/unit/publisher_spec.rb +65 -0
- data/spec/unit/publishers/artifactory_publisher_spec.rb +26 -20
- data/spec/unit/publishers/s3_publisher_spec.rb +14 -30
- data/spec/unit/s3_cacher_spec.rb +1 -1
- data/spec/unit/s3_helpers_spec.rb +32 -0
- data/spec/unit/semantic_version_spec.rb +55 -0
- data/spec/unit/software_spec.rb +112 -4
- metadata +86 -16
@@ -18,28 +18,20 @@ module Omnibus
|
|
18
18
|
class Packager::Solaris < Packager::Base
|
19
19
|
id :solaris
|
20
20
|
|
21
|
-
setup do
|
22
|
-
remove_directory('/tmp/pkgmk')
|
23
|
-
create_directory('/tmp/pkgmk')
|
24
|
-
end
|
25
|
-
|
26
21
|
build do
|
27
|
-
|
28
|
-
|
29
|
-
end
|
22
|
+
shellout! "cd #{install_dirname} && find #{install_basename} -print > #{staging_dir_path('files')}"
|
23
|
+
|
30
24
|
|
31
25
|
write_prototype_content
|
32
26
|
|
33
27
|
write_pkginfo_content
|
34
28
|
|
35
|
-
copy_file("#{project.package_scripts_path}/postinst", '
|
36
|
-
copy_file("#{project.package_scripts_path}/postrm", '
|
29
|
+
copy_file("#{project.package_scripts_path}/postinst", staging_dir_path('postinstall'))
|
30
|
+
copy_file("#{project.package_scripts_path}/postrm", staging_dir_path('postremove'))
|
37
31
|
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
shellout! "pkgtrans /tmp/pkgmk /var/cache/omnibus/pkg/#{package_name} #{project.package_name}"
|
42
|
-
end
|
32
|
+
shellout! "pkgmk -o -r #{install_dirname} -d #{staging_dir} -f #{staging_dir_path('Prototype')}"
|
33
|
+
shellout! "pkgchk -vd #{staging_dir} #{project.package_name}"
|
34
|
+
shellout! "pkgtrans #{staging_dir} #{package_path} #{project.package_name}"
|
43
35
|
end
|
44
36
|
|
45
37
|
# @see Base#package_name
|
@@ -58,6 +50,10 @@ module Omnibus
|
|
58
50
|
def install_basename
|
59
51
|
File.basename(project.install_dir)
|
60
52
|
end
|
53
|
+
|
54
|
+
def staging_dir_path(file_name)
|
55
|
+
File.join(staging_dir, file_name)
|
56
|
+
end
|
61
57
|
|
62
58
|
#
|
63
59
|
# Generate a Prototype file for solaris build
|
@@ -70,17 +66,15 @@ module Omnibus
|
|
70
66
|
EOF
|
71
67
|
|
72
68
|
# generate list of control files
|
73
|
-
File.open '
|
69
|
+
File.open staging_dir_path('Prototype'), 'w+' do |f|
|
74
70
|
f.write prototype_content
|
75
71
|
end
|
76
72
|
|
77
|
-
|
78
|
-
|
79
|
-
shellout! "cd #{install_dirname} && pkgproto < /tmp/pkgmk/files > /tmp/pkgmk/Prototype.files"
|
73
|
+
# generate the prototype's file list
|
74
|
+
shellout! "cd #{install_dirname} && pkgproto < #{staging_dir_path('files')} > #{staging_dir_path('Prototype.files')}"
|
80
75
|
|
81
|
-
|
82
|
-
|
83
|
-
end
|
76
|
+
# fix up the user and group in the file list to root
|
77
|
+
shellout! "awk '{ $5 = \"root\"; $6 = \"root\"; print }' < #{staging_dir_path('Prototype.files')} >> #{staging_dir_path('Prototype')}"
|
84
78
|
end
|
85
79
|
|
86
80
|
#
|
@@ -102,7 +96,7 @@ module Omnibus
|
|
102
96
|
EMAIL=#{project.maintainer}
|
103
97
|
PSTAMP=#{`hostname`.chomp + Time.now.utc.iso8601}
|
104
98
|
EOF
|
105
|
-
File.open '
|
99
|
+
File.open staging_dir_path('pkginfo'), 'w+' do |f|
|
106
100
|
f.write pkginfo_content
|
107
101
|
end
|
108
102
|
end
|
data/lib/omnibus/project.rb
CHANGED
@@ -17,6 +17,9 @@
|
|
17
17
|
|
18
18
|
require 'time'
|
19
19
|
require 'json'
|
20
|
+
require 'omnibus/manifest'
|
21
|
+
require 'omnibus/manifest_entry'
|
22
|
+
require 'omnibus/reports'
|
20
23
|
|
21
24
|
module Omnibus
|
22
25
|
class Project
|
@@ -27,7 +30,7 @@ module Omnibus
|
|
27
30
|
#
|
28
31
|
# @return [Project]
|
29
32
|
#
|
30
|
-
def load(name)
|
33
|
+
def load(name, manifest=nil)
|
31
34
|
loaded_projects[name] ||= begin
|
32
35
|
filepath = Omnibus.project_path(name)
|
33
36
|
|
@@ -39,7 +42,7 @@ module Omnibus
|
|
39
42
|
end
|
40
43
|
end
|
41
44
|
|
42
|
-
instance = new(filepath)
|
45
|
+
instance = new(filepath, manifest)
|
43
46
|
instance.evaluate_file(filepath)
|
44
47
|
instance.load_dependencies
|
45
48
|
instance
|
@@ -58,6 +61,8 @@ module Omnibus
|
|
58
61
|
end
|
59
62
|
end
|
60
63
|
|
64
|
+
attr_reader :manifest
|
65
|
+
|
61
66
|
include Cleanroom
|
62
67
|
include Digestable
|
63
68
|
include Logging
|
@@ -65,8 +70,9 @@ module Omnibus
|
|
65
70
|
include Sugarable
|
66
71
|
include Util
|
67
72
|
|
68
|
-
def initialize(filepath = nil)
|
73
|
+
def initialize(filepath = nil, manifest=nil)
|
69
74
|
@filepath = filepath
|
75
|
+
@manifest = manifest
|
70
76
|
end
|
71
77
|
|
72
78
|
#
|
@@ -370,6 +376,24 @@ module Omnibus
|
|
370
376
|
end
|
371
377
|
expose :build_version
|
372
378
|
|
379
|
+
|
380
|
+
#
|
381
|
+
# Set or retrieve the git revision of the omnibus
|
382
|
+
# project being built.
|
383
|
+
#
|
384
|
+
# If not set by the user, and the current workding directory is a
|
385
|
+
# git directory, it will return the revision of the current
|
386
|
+
# working directory.
|
387
|
+
#
|
388
|
+
def build_git_revision(val = NULL)
|
389
|
+
if null?(val)
|
390
|
+
@build_git_revision ||= get_local_revision
|
391
|
+
else
|
392
|
+
@build_git_revision = val
|
393
|
+
end
|
394
|
+
end
|
395
|
+
expose :build_git_revision
|
396
|
+
|
373
397
|
#
|
374
398
|
# Set or retrieve the build iteration of the project. Defaults to +1+ if not
|
375
399
|
# otherwise set.
|
@@ -667,6 +691,46 @@ module Omnibus
|
|
667
691
|
end
|
668
692
|
expose :ohai
|
669
693
|
|
694
|
+
#
|
695
|
+
# Location of json-formated version manifest, written at at the
|
696
|
+
# end of the build. If no path is specified
|
697
|
+
# +install_dir+/version-manifest.json is used.
|
698
|
+
#
|
699
|
+
# @example
|
700
|
+
# json_manifest_path
|
701
|
+
#
|
702
|
+
# @return [String]
|
703
|
+
#
|
704
|
+
def json_manifest_path(path = NULL)
|
705
|
+
if null?(path)
|
706
|
+
@json_manifest_path || File.join(install_dir, "version-manifest.json")
|
707
|
+
else
|
708
|
+
@json_manifest_path=path
|
709
|
+
end
|
710
|
+
end
|
711
|
+
expose :json_manifest_path
|
712
|
+
|
713
|
+
#
|
714
|
+
# Location of text-formatted manifest.
|
715
|
+
# (+install_dir+/version-manifest.txt if none is provided)
|
716
|
+
#
|
717
|
+
# This manifest uses the same format used by the
|
718
|
+
# 'version-manifest' software definition in omnibus-software.
|
719
|
+
#
|
720
|
+
# @example
|
721
|
+
# text_manifest_path
|
722
|
+
#
|
723
|
+
# @return [String]
|
724
|
+
#
|
725
|
+
def text_manifest_path(path = NULL)
|
726
|
+
if null?(path)
|
727
|
+
@test_manifest_path || File.join(install_dir, "version-manifest.txt")
|
728
|
+
else
|
729
|
+
@text_manifest_path = path
|
730
|
+
end
|
731
|
+
end
|
732
|
+
expose :text_manifest_path
|
733
|
+
|
670
734
|
#
|
671
735
|
# @!endgroup
|
672
736
|
# --------------------------------------------------
|
@@ -685,7 +749,7 @@ module Omnibus
|
|
685
749
|
#
|
686
750
|
def load_dependencies
|
687
751
|
dependencies.each do |dependency|
|
688
|
-
Software.load(self, dependency)
|
752
|
+
Software.load(self, dependency, manifest)
|
689
753
|
end
|
690
754
|
|
691
755
|
true
|
@@ -904,37 +968,80 @@ module Omnibus
|
|
904
968
|
end
|
905
969
|
|
906
970
|
#
|
971
|
+
# Cache the build order so we don't re-compute
|
907
972
|
#
|
973
|
+
# @return [Array<Omnibus::Software>]
|
908
974
|
#
|
909
|
-
def
|
910
|
-
|
911
|
-
|
975
|
+
def softwares
|
976
|
+
@softwares ||= library.build_order
|
977
|
+
end
|
912
978
|
|
913
|
-
|
914
|
-
|
979
|
+
#
|
980
|
+
# Generate a version manifest of the loaded software sources.
|
981
|
+
#
|
982
|
+
# @returns [Omnibus::Manifest]
|
983
|
+
#
|
984
|
+
def built_manifest
|
985
|
+
log.info(log_key) { "Building version manifest" }
|
986
|
+
m = Omnibus::Manifest.new(build_version, build_git_revision)
|
987
|
+
softwares.each do |software|
|
988
|
+
m.add(software.name, software.manifest_entry)
|
989
|
+
end
|
990
|
+
m
|
991
|
+
end
|
915
992
|
|
916
|
-
|
993
|
+
def download
|
917
994
|
ThreadPool.new(Config.workers) do |pool|
|
918
995
|
softwares.each do |software|
|
919
996
|
pool.schedule { software.fetch }
|
920
997
|
end
|
921
998
|
end
|
999
|
+
end
|
1000
|
+
|
1001
|
+
def build
|
1002
|
+
FileUtils.rm_rf(install_dir)
|
1003
|
+
FileUtils.mkdir_p(install_dir)
|
922
1004
|
|
923
|
-
# Now build each software
|
924
1005
|
softwares.each do |software|
|
925
1006
|
software.build_me
|
926
1007
|
end
|
927
1008
|
|
928
|
-
|
1009
|
+
write_json_manifest
|
1010
|
+
write_text_manifest
|
929
1011
|
HealthCheck.run!(self)
|
930
|
-
|
931
|
-
# Package
|
932
1012
|
package_me
|
933
|
-
|
934
|
-
# Compress
|
935
1013
|
compress_me
|
936
1014
|
end
|
937
1015
|
|
1016
|
+
def write_json_manifest
|
1017
|
+
File.open(json_manifest_path, 'w') do |f|
|
1018
|
+
f.write(JSON.pretty_generate(built_manifest.to_hash))
|
1019
|
+
end
|
1020
|
+
end
|
1021
|
+
|
1022
|
+
#
|
1023
|
+
# Writes a text manifest to the text_manifest_path. This uses the
|
1024
|
+
# same method as the "version-manifest" software definition in
|
1025
|
+
# omnibus-software.
|
1026
|
+
#
|
1027
|
+
def write_text_manifest
|
1028
|
+
File.open(text_manifest_path, 'w') do |f|
|
1029
|
+
f.puts "#{name} #{build_version}"
|
1030
|
+
f.puts ""
|
1031
|
+
f.puts Omnibus::Reports.pretty_version_map(self)
|
1032
|
+
end
|
1033
|
+
end
|
1034
|
+
|
1035
|
+
#
|
1036
|
+
# Download and build the project. Preserved for backwards
|
1037
|
+
# compatibility.
|
1038
|
+
#
|
1039
|
+
def build_me
|
1040
|
+
# Download all softwares in parallel
|
1041
|
+
download
|
1042
|
+
build
|
1043
|
+
end
|
1044
|
+
|
938
1045
|
#
|
939
1046
|
#
|
940
1047
|
#
|
@@ -1045,6 +1152,12 @@ module Omnibus
|
|
1045
1152
|
|
1046
1153
|
private
|
1047
1154
|
|
1155
|
+
def get_local_revision
|
1156
|
+
GitRepository.new("./").revision
|
1157
|
+
rescue StandardError
|
1158
|
+
"unknown"
|
1159
|
+
end
|
1160
|
+
|
1048
1161
|
#
|
1049
1162
|
# The log key for this project, overriden to include the name of the
|
1050
1163
|
# project for build output.
|
data/lib/omnibus/publisher.rb
CHANGED
@@ -35,22 +35,27 @@ module Omnibus
|
|
35
35
|
#
|
36
36
|
# @param [String] pattern
|
37
37
|
# the path/pattern of the release artifact(s)
|
38
|
+
#
|
38
39
|
# @param [Hash] options
|
39
40
|
# the list of options passed to the publisher
|
41
|
+
# @option options [Hash] :platform_mappings A simple
|
42
|
+
# mapping of build to publish platform(s)
|
43
|
+
# @example
|
44
|
+
# {
|
45
|
+
# 'ubuntu-10.04' => [
|
46
|
+
# 'ubuntu-10.04',
|
47
|
+
# 'ubuntu-12.04',
|
48
|
+
# 'ubuntu-14.04',
|
49
|
+
# ],
|
50
|
+
# }
|
40
51
|
#
|
41
52
|
def initialize(pattern, options = {})
|
42
53
|
@pattern = pattern
|
43
54
|
@options = options.dup
|
44
55
|
|
45
|
-
if @options[:
|
46
|
-
log.
|
47
|
-
"Publishing
|
48
|
-
end
|
49
|
-
end
|
50
|
-
|
51
|
-
if @options[:platform_version]
|
52
|
-
log.warn(log_key) do
|
53
|
-
"Publishing platform version has been overriden to '#{@options[:platform_version]}'"
|
56
|
+
if @options[:platform_mappings]
|
57
|
+
log.info(log_key) do
|
58
|
+
"Publishing will be performed using provided platform mappings."
|
54
59
|
end
|
55
60
|
end
|
56
61
|
end
|
@@ -61,7 +66,54 @@ module Omnibus
|
|
61
66
|
# @return [Array<String>]
|
62
67
|
#
|
63
68
|
def packages
|
64
|
-
@packages ||=
|
69
|
+
@packages ||= begin
|
70
|
+
publish_packages = Array.new
|
71
|
+
build_packages = FileSyncer.glob(@pattern).map { |path| Package.new(path) }
|
72
|
+
|
73
|
+
if @options[:platform_mappings]
|
74
|
+
# the platform map is a simple hash with publish to build platform mappings
|
75
|
+
@options[:platform_mappings].each_pair do |build_platform, publish_platforms|
|
76
|
+
# Splits `ubuntu-12.04` into `ubuntu` and `12.04`
|
77
|
+
build_platform, build_platform_version = build_platform.rpartition('-') - %w( - )
|
78
|
+
|
79
|
+
# locate the package for the build platform
|
80
|
+
packages = build_packages.select do |p|
|
81
|
+
p.metadata[:platform] == build_platform &&
|
82
|
+
p.metadata[:platform_version] == build_platform_version
|
83
|
+
end
|
84
|
+
|
85
|
+
if packages.empty?
|
86
|
+
log.warn(log_key) do
|
87
|
+
"Could not locate a package for build platform #{build_platform}-#{build_platform_version}. " \
|
88
|
+
"Publishing will be skipped for: #{publish_platforms.join(', ')}"
|
89
|
+
end
|
90
|
+
end
|
91
|
+
|
92
|
+
publish_platforms.each do |publish_platform|
|
93
|
+
publish_platform, publish_platform_version = publish_platform.rpartition('-') - %w( - )
|
94
|
+
|
95
|
+
packages.each do |p|
|
96
|
+
# create a copy of our package before mucking with its metadata
|
97
|
+
publish_package = p.dup
|
98
|
+
publish_metadata = p.metadata.dup.to_hash
|
99
|
+
|
100
|
+
# override the platform and platform version in the metadata
|
101
|
+
publish_metadata[:platform] = publish_platform
|
102
|
+
publish_metadata[:platform_version] = publish_platform_version
|
103
|
+
|
104
|
+
# Set the updated metadata on the package object
|
105
|
+
publish_package.metadata = Metadata.new(publish_package, publish_metadata)
|
106
|
+
|
107
|
+
publish_packages << publish_package
|
108
|
+
end
|
109
|
+
end
|
110
|
+
end
|
111
|
+
else
|
112
|
+
publish_packages.concat(build_packages)
|
113
|
+
end
|
114
|
+
|
115
|
+
publish_packages
|
116
|
+
end
|
65
117
|
end
|
66
118
|
|
67
119
|
#
|
@@ -79,45 +131,6 @@ module Omnibus
|
|
79
131
|
|
80
132
|
private
|
81
133
|
|
82
|
-
#
|
83
|
-
# The platform to publish a package for. A publisher can be optionally
|
84
|
-
# initialized with a platform which should be used in all publishing
|
85
|
-
# logic. This allows a package built on one platform to be published
|
86
|
-
# for another platform. For example, one might build on Ubuntu and
|
87
|
-
# test/publish on Ubuntu and Debian.
|
88
|
-
#
|
89
|
-
# @note Even if a glob pattern matches multiple packages (potentially
|
90
|
-
# across multiple platforms) all packages will be published for the
|
91
|
-
# same platform.
|
92
|
-
#
|
93
|
-
# @param [Package] package
|
94
|
-
#
|
95
|
-
# @return [String]
|
96
|
-
#
|
97
|
-
def publish_platform(package)
|
98
|
-
@options[:platform] || package.metadata[:platform]
|
99
|
-
end
|
100
|
-
|
101
|
-
#
|
102
|
-
# The platform version to publish a package for. A publisher can be
|
103
|
-
# optionally initialized with a platform version which should be used
|
104
|
-
# in all publishing logic. This allows a package built on one
|
105
|
-
# platform to be published for another platform version. For example,
|
106
|
-
# one might build on Ubuntu 10.04 and test/publish on Ubuntu 10.04
|
107
|
-
# and 12.04.
|
108
|
-
#
|
109
|
-
# @note Even if a glob pattern matches multiple packages (potentially
|
110
|
-
# across multiple platforms) all packages will be published for the
|
111
|
-
# same platform version.
|
112
|
-
#
|
113
|
-
# @param [Package] package
|
114
|
-
#
|
115
|
-
# @return [String]
|
116
|
-
#
|
117
|
-
def publish_platform_version(package)
|
118
|
-
@options[:platform_version] || package.metadata[:platform_version]
|
119
|
-
end
|
120
|
-
|
121
134
|
def safe_require(name)
|
122
135
|
require name
|
123
136
|
rescue LoadError
|
@@ -38,7 +38,10 @@ module Omnibus
|
|
38
38
|
artifact_for(package).upload(
|
39
39
|
repository,
|
40
40
|
remote_path_for(package),
|
41
|
-
metadata_for(package)
|
41
|
+
metadata_for(package).merge(
|
42
|
+
'build.name' => package.metadata[:name],
|
43
|
+
'build.number' => package.metadata[:version],
|
44
|
+
),
|
42
45
|
)
|
43
46
|
end
|
44
47
|
rescue Artifactory::Error::HTTPError => e
|
@@ -56,6 +59,14 @@ module Omnibus
|
|
56
59
|
# If a block was given, "yield" the package to the caller
|
57
60
|
block.call(package) if block
|
58
61
|
end
|
62
|
+
|
63
|
+
if build_record?
|
64
|
+
if packages.empty?
|
65
|
+
log.warn(log_key) { "No packages were uploaded, build record will not be created." }
|
66
|
+
else
|
67
|
+
build_for(packages).save
|
68
|
+
end
|
69
|
+
end
|
59
70
|
end
|
60
71
|
|
61
72
|
private
|
@@ -79,6 +90,77 @@ module Omnibus
|
|
79
90
|
)
|
80
91
|
end
|
81
92
|
|
93
|
+
#
|
94
|
+
# The build object that corresponds to this package.
|
95
|
+
#
|
96
|
+
# @param [Array<Package>] packages
|
97
|
+
# the packages to create the build from
|
98
|
+
#
|
99
|
+
# @return [Artifactory::Resource::Build]
|
100
|
+
#
|
101
|
+
def build_for(packages)
|
102
|
+
name = packages.first.metadata[:name]
|
103
|
+
# Attempt to load the version-manifest.json file which represents
|
104
|
+
# the build.
|
105
|
+
manifest = if File.exist?(version_manifest)
|
106
|
+
Manifest.from_file(version_manifest)
|
107
|
+
else
|
108
|
+
Manifest.new(packages.first.metadata[:version])
|
109
|
+
end
|
110
|
+
|
111
|
+
# Upload the actual package
|
112
|
+
log.info(log_key) { "Saving build info for #{name}, Build ##{manifest.build_version}" }
|
113
|
+
|
114
|
+
Artifactory::Resource::Build.new(
|
115
|
+
client: client,
|
116
|
+
name: name,
|
117
|
+
number: manifest.build_version,
|
118
|
+
vcs_revision: manifest.build_git_revision,
|
119
|
+
build_agent: {
|
120
|
+
name: 'omnibus',
|
121
|
+
version: Omnibus::VERSION,
|
122
|
+
},
|
123
|
+
properties: {
|
124
|
+
'omnibus.project' => name,
|
125
|
+
'omnibus.version' => manifest.build_version,
|
126
|
+
'omnibus.version_manifest' => manifest.to_json,
|
127
|
+
},
|
128
|
+
modules: [
|
129
|
+
{
|
130
|
+
# com.getchef:chef-server:12.0.0
|
131
|
+
id: [
|
132
|
+
Config.artifactory_base_path.gsub('/', '.'),
|
133
|
+
name,
|
134
|
+
manifest.build_version,
|
135
|
+
].join(':'),
|
136
|
+
artifacts: packages.map do |package|
|
137
|
+
{
|
138
|
+
type: File.extname(package.path).split('.').last,
|
139
|
+
sha1: package.metadata[:sha1],
|
140
|
+
md5: package.metadata[:md5],
|
141
|
+
name: package.metadata[:basename],
|
142
|
+
}
|
143
|
+
end
|
144
|
+
}
|
145
|
+
]
|
146
|
+
)
|
147
|
+
end
|
148
|
+
|
149
|
+
#
|
150
|
+
# Indicates if an Artifactory build record should be created for the
|
151
|
+
# published set of packages.
|
152
|
+
#
|
153
|
+
# @return [Boolean]
|
154
|
+
#
|
155
|
+
def build_record?
|
156
|
+
# We want to create a build record by default
|
157
|
+
if @options[:build_record].nil?
|
158
|
+
true
|
159
|
+
else
|
160
|
+
@options[:build_record]
|
161
|
+
end
|
162
|
+
end
|
163
|
+
|
82
164
|
#
|
83
165
|
# The Artifactory client object to communicate with the Artifactory API.
|
84
166
|
#
|
@@ -109,8 +191,8 @@ module Omnibus
|
|
109
191
|
def metadata_for(package)
|
110
192
|
{
|
111
193
|
'omnibus.project' => package.metadata[:name],
|
112
|
-
'omnibus.platform' =>
|
113
|
-
'omnibus.platform_version' =>
|
194
|
+
'omnibus.platform' => package.metadata[:platform],
|
195
|
+
'omnibus.platform_version' => package.metadata[:platform_version],
|
114
196
|
'omnibus.architecture' => package.metadata[:arch],
|
115
197
|
'omnibus.version' => package.metadata[:version],
|
116
198
|
'omnibus.iteration' => package.metadata[:iteration],
|
@@ -130,6 +212,15 @@ module Omnibus
|
|
130
212
|
@options[:repository]
|
131
213
|
end
|
132
214
|
|
215
|
+
#
|
216
|
+
# The path to the builds version-manfest.json file (as supplied as an option).
|
217
|
+
#
|
218
|
+
# @return [String]
|
219
|
+
#
|
220
|
+
def version_manifest
|
221
|
+
@options[:version_manifest] || ''
|
222
|
+
end
|
223
|
+
|
133
224
|
#
|
134
225
|
# The path where the package will live inside of the Artifactory repository.
|
135
226
|
# This is dynamically computed from the values in the project definition
|
@@ -148,8 +239,8 @@ module Omnibus
|
|
148
239
|
Config.artifactory_base_path,
|
149
240
|
package.metadata[:name],
|
150
241
|
package.metadata[:version],
|
151
|
-
|
152
|
-
|
242
|
+
package.metadata[:platform],
|
243
|
+
package.metadata[:platform_version],
|
153
244
|
package.metadata[:basename],
|
154
245
|
)
|
155
246
|
end
|