omnibus 5.3.0 → 5.4.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +14 -0
- data/features/commands/manifest.feature +1 -0
- data/features/commands/publish.feature +7 -0
- data/lib/omnibus.rb +0 -1
- data/lib/omnibus/cli.rb +3 -2
- data/lib/omnibus/cli/changelog.rb +2 -1
- data/lib/omnibus/cli/publish.rb +6 -1
- data/lib/omnibus/manifest.rb +30 -16
- data/lib/omnibus/manifest_entry.rb +5 -5
- data/lib/omnibus/metadata.rb +7 -4
- data/lib/omnibus/package.rb +2 -2
- data/lib/omnibus/packager.rb +10 -2
- data/lib/omnibus/packagers/ips.rb +301 -0
- data/lib/omnibus/project.rb +3 -3
- data/lib/omnibus/publisher.rb +2 -0
- data/lib/omnibus/publishers/artifactory_publisher.rb +66 -42
- data/lib/omnibus/publishers/s3_publisher.rb +1 -1
- data/lib/omnibus/software.rb +1 -1
- data/lib/omnibus/version.rb +1 -1
- data/omnibus.gemspec +2 -0
- data/resources/ips/doc-transform.erb +2 -0
- data/resources/ips/gen.manifestfile.erb +7 -0
- data/spec/spec_helper.rb +1 -0
- data/spec/unit/manifest_spec.rb +59 -27
- data/spec/unit/metadata_spec.rb +107 -2
- data/spec/unit/packager_spec.rb +64 -0
- data/spec/unit/packagers/ips_spec.rb +222 -0
- data/spec/unit/publisher_spec.rb +62 -0
- data/spec/unit/publishers/artifactory_publisher_spec.rb +82 -5
- data/spec/unit/publishers/s3_publisher_spec.rb +3 -3
- data/spec/unit/software_spec.rb +1 -1
- metadata +38 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 407d08f9b06a939ef258ff8c14f27b12afb74234
|
4
|
+
data.tar.gz: 84d25b4c5c73eede7828af010d99273771f2d547
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: fecc2417ce2c9137d12a2675e52105e9f2b263e8953a1f264582c15204614fd8de7cb62792c9e6d9b46a18b69ce707973f275ce46490703eabbea4ee7c0e5b0f
|
7
|
+
data.tar.gz: b7d07fb926de84af9f2bb56b526bca9594a634c0b20a92e4b88d5daf206f595035ddf06bbe138c61b5a361f44b071bfb867f0ac2ce57dfee1336585cbf6b11fb
|
data/CHANGELOG.md
CHANGED
@@ -1,6 +1,20 @@
|
|
1
1
|
Omnibus CHANGELOG
|
2
2
|
=================
|
3
3
|
|
4
|
+
v5.4.0 (April 18, 2016)
|
5
|
+
-----------------------
|
6
|
+
### New Features
|
7
|
+
- Include license and version manifest in generated `*.metadata.json` (#656)
|
8
|
+
- Deprecate the `--version-manifest` on `omnibus publish` (#656)
|
9
|
+
- Create Solaris IPS package (#654)
|
10
|
+
- Use symbolized keys for all Manifest hashes (#657)
|
11
|
+
- Publish a package’s `*.metadata.json` to Artifactory (#664)
|
12
|
+
- Add the build’s `LICENSE` content to `*.metadata.json` (#664)
|
13
|
+
|
14
|
+
### Bug Fixes
|
15
|
+
- Add proper support for loading v2 manifests (#657)
|
16
|
+
- Replacing the use of JSON gem with FFI_yajl (#661)
|
17
|
+
|
4
18
|
v5.3.0 (March 25, 2016)
|
5
19
|
-----------------------
|
6
20
|
### New Features
|
@@ -6,3 +6,10 @@ Feature: omnibus publish
|
|
6
6
|
"""
|
7
7
|
Publishing will be performed using provided platform mappings.
|
8
8
|
"""
|
9
|
+
|
10
|
+
Scenario: When a user provides the deprecated `--version-manifest` flag
|
11
|
+
* I run `omnibus publish artifactory fake * --version-manifest /fake/path/version-manifest.json`
|
12
|
+
* the output should contain:
|
13
|
+
"""
|
14
|
+
The `--version-manifest' option has been deprecated. Version manifest data is now part of the `*.metadata.json' file
|
15
|
+
"""
|
data/lib/omnibus.rb
CHANGED
data/lib/omnibus/cli.rb
CHANGED
@@ -16,6 +16,7 @@
|
|
16
16
|
|
17
17
|
require 'thor'
|
18
18
|
require 'omnibus'
|
19
|
+
require "ffi_yajl"
|
19
20
|
|
20
21
|
module Omnibus
|
21
22
|
class CLI < Command::Base
|
@@ -85,7 +86,7 @@ module Omnibus
|
|
85
86
|
if @options[:output_manifest]
|
86
87
|
FileUtils.mkdir_p('pkg')
|
87
88
|
File.open(::File.join('pkg', 'version-manifest.json'), 'w') do |f|
|
88
|
-
f.write(project.built_manifest.
|
89
|
+
f.write(FFI_Yajl::Encoder.encode(project.built_manifest.to_hash))
|
89
90
|
end
|
90
91
|
end
|
91
92
|
end
|
@@ -121,7 +122,7 @@ module Omnibus
|
|
121
122
|
Ohai['platform'] = @options[:platform] if @options[:platform]
|
122
123
|
Ohai['platform_version'] = @options[:platform_version] if @options[:platform_version]
|
123
124
|
Ohai['kernel']['machine'] = @options[:architecture] if @options[:architecture]
|
124
|
-
puts
|
125
|
+
puts FFI_Yajl::Encoder.encode(Project.load(name).built_manifest.to_hash, pretty: true)
|
125
126
|
end
|
126
127
|
|
127
128
|
#
|
@@ -18,6 +18,7 @@ require 'omnibus/changelog'
|
|
18
18
|
require 'omnibus/changelog_printer'
|
19
19
|
require 'omnibus/manifest_diff'
|
20
20
|
require 'omnibus/semantic_version'
|
21
|
+
require 'ffi_yajl'
|
21
22
|
|
22
23
|
module Omnibus
|
23
24
|
class Command::ChangeLog < Command::Base
|
@@ -104,7 +105,7 @@ module Omnibus
|
|
104
105
|
end
|
105
106
|
|
106
107
|
def manifest_for_revision(rev)
|
107
|
-
Omnibus::Manifest.from_hash(
|
108
|
+
Omnibus::Manifest.from_hash(FFI_Yajl::Parser.parse(local_git_repo.file_at_revision("version-manifest.json", rev)))
|
108
109
|
end
|
109
110
|
|
110
111
|
|
data/lib/omnibus/cli/publish.rb
CHANGED
@@ -76,6 +76,11 @@ module Omnibus
|
|
76
76
|
default: {}
|
77
77
|
desc 'artifactory REPOSITORY PATTERN', 'Publish to an Artifactory instance'
|
78
78
|
def artifactory(repository, pattern)
|
79
|
+
|
80
|
+
Omnibus.logger.deprecated('ArtifactoryPublisher') do
|
81
|
+
"The `--version-manifest' option has been deprecated. Version manifest data is now part of the `*.metadata.json' file"
|
82
|
+
end if options[:version_manifest]
|
83
|
+
|
79
84
|
options[:repository] = repository
|
80
85
|
publish(ArtifactoryPublisher, pattern, options)
|
81
86
|
end
|
@@ -89,7 +94,7 @@ module Omnibus
|
|
89
94
|
#
|
90
95
|
def publish(klass, pattern, options)
|
91
96
|
if options[:platform_mappings]
|
92
|
-
options[:platform_mappings] =
|
97
|
+
options[:platform_mappings] = FFI_Yajl::Parser.parse(File.read(File.expand_path(options[:platform_mappings])))
|
93
98
|
end
|
94
99
|
|
95
100
|
klass.publish(pattern, options) do |package|
|
data/lib/omnibus/manifest.rb
CHANGED
@@ -14,7 +14,7 @@
|
|
14
14
|
# limitations under the License.
|
15
15
|
#
|
16
16
|
|
17
|
-
require '
|
17
|
+
require 'ffi_yajl'
|
18
18
|
|
19
19
|
module Omnibus
|
20
20
|
class Manifest
|
@@ -35,8 +35,9 @@ module Omnibus
|
|
35
35
|
end
|
36
36
|
|
37
37
|
def entry_for(name)
|
38
|
-
|
39
|
-
|
38
|
+
name_sym = name.to_sym
|
39
|
+
if @data.key?(name_sym)
|
40
|
+
@data[name_sym]
|
40
41
|
else
|
41
42
|
raise MissingManifestEntry, "No manifest entry found for #{name}"
|
42
43
|
end
|
@@ -47,11 +48,12 @@ module Omnibus
|
|
47
48
|
raise NotAManifestEntry, "#{entry} is not an Omnibus:ManifestEntry"
|
48
49
|
end
|
49
50
|
|
50
|
-
|
51
|
+
name_sym = name.to_sym
|
52
|
+
if @data.key?(name_sym)
|
51
53
|
log.warn(log_key) { "Overritting existing manifest entry for #{name}" }
|
52
54
|
end
|
53
55
|
|
54
|
-
@data[
|
56
|
+
@data[name_sym] = entry
|
55
57
|
self
|
56
58
|
end
|
57
59
|
|
@@ -71,12 +73,12 @@ module Omnibus
|
|
71
73
|
memo
|
72
74
|
end
|
73
75
|
ret = {
|
74
|
-
|
75
|
-
|
76
|
+
manifest_format: LATEST_MANIFEST_FORMAT,
|
77
|
+
software: software_hash
|
76
78
|
}
|
77
|
-
ret[
|
78
|
-
ret[
|
79
|
-
ret[
|
79
|
+
ret[:build_version] = build_version if build_version
|
80
|
+
ret[:build_git_revision] = build_git_revision if build_git_revision
|
81
|
+
ret[:license] = license
|
80
82
|
ret
|
81
83
|
end
|
82
84
|
|
@@ -86,7 +88,7 @@ module Omnibus
|
|
86
88
|
# @return [String]
|
87
89
|
#
|
88
90
|
def to_json
|
89
|
-
|
91
|
+
FFI_Yajl::Encoder.encode(to_hash, pretty: true)
|
90
92
|
end
|
91
93
|
|
92
94
|
#
|
@@ -94,24 +96,36 @@ module Omnibus
|
|
94
96
|
#
|
95
97
|
|
96
98
|
def self.from_hash(manifest_data)
|
97
|
-
case manifest_data[
|
99
|
+
case manifest_data[:manifest_format].to_i
|
98
100
|
when 1
|
99
101
|
from_hash_v1(manifest_data)
|
102
|
+
when 2
|
103
|
+
from_hash_v2(manifest_data)
|
100
104
|
else
|
101
|
-
raise InvalidManifestFormat, "Unknown manifest format version: #{manifest_data[
|
105
|
+
raise InvalidManifestFormat, "Unknown manifest format version: #{manifest_data[:manifest_format]}"
|
102
106
|
end
|
103
107
|
end
|
104
108
|
|
105
109
|
def self.from_hash_v1(manifest_data)
|
106
|
-
m = Omnibus::Manifest.new(manifest_data[
|
107
|
-
manifest_data[
|
110
|
+
m = Omnibus::Manifest.new(manifest_data[:build_version], manifest_data[:build_git_revision])
|
111
|
+
manifest_data[:software].each do |name, entry_data|
|
112
|
+
m.add(name, Omnibus::ManifestEntry.new(name, keys_to_syms(entry_data)))
|
113
|
+
end
|
114
|
+
m
|
115
|
+
end
|
116
|
+
|
117
|
+
def self.from_hash_v2(manifest_data)
|
118
|
+
m = Omnibus::Manifest.new(manifest_data[:build_version], manifest_data[:build_git_revision], manifest_data[:license])
|
119
|
+
manifest_data[:software].each do |name, entry_data|
|
108
120
|
m.add(name, Omnibus::ManifestEntry.new(name, keys_to_syms(entry_data)))
|
109
121
|
end
|
110
122
|
m
|
111
123
|
end
|
112
124
|
|
113
125
|
def self.from_file(filename)
|
114
|
-
|
126
|
+
data = File.read(File.expand_path(filename))
|
127
|
+
hash = FFI_Yajl::Parser.parse(data, symbolize_names: true)
|
128
|
+
from_hash(hash)
|
115
129
|
end
|
116
130
|
|
117
131
|
private
|
@@ -28,11 +28,11 @@ module Omnibus
|
|
28
28
|
|
29
29
|
def to_hash
|
30
30
|
{
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
31
|
+
locked_version: @locked_version,
|
32
|
+
locked_source: @locked_source,
|
33
|
+
source_type: @source_type,
|
34
|
+
described_version: @described_version,
|
35
|
+
license: @license
|
36
36
|
}
|
37
37
|
end
|
38
38
|
|
data/lib/omnibus/metadata.rb
CHANGED
@@ -14,7 +14,7 @@
|
|
14
14
|
# limitations under the License.
|
15
15
|
#
|
16
16
|
|
17
|
-
require '
|
17
|
+
require 'ffi_yajl'
|
18
18
|
|
19
19
|
module Omnibus
|
20
20
|
class Metadata
|
@@ -61,6 +61,9 @@ module Omnibus
|
|
61
61
|
homepage: project.homepage,
|
62
62
|
version: project.build_version,
|
63
63
|
iteration: project.build_iteration,
|
64
|
+
license: project.license,
|
65
|
+
version_manifest: project.built_manifest.to_hash,
|
66
|
+
license_content: File.exist?(project.license_file_path) ? File.read(project.license_file_path) : ''
|
64
67
|
}
|
65
68
|
|
66
69
|
instance = new(package, data)
|
@@ -78,7 +81,7 @@ module Omnibus
|
|
78
81
|
#
|
79
82
|
def for_package(package)
|
80
83
|
data = File.read(path_for(package))
|
81
|
-
hash =
|
84
|
+
hash = FFI_Yajl::Parser.parse(data, symbolize_names: true)
|
82
85
|
|
83
86
|
# Ensure Platform version has been truncated
|
84
87
|
if hash[:platform_version] && hash[:platform]
|
@@ -265,7 +268,7 @@ module Omnibus
|
|
265
268
|
#
|
266
269
|
def save
|
267
270
|
File.open(path, 'w+') do |f|
|
268
|
-
f.write(
|
271
|
+
f.write(FFI_Yajl::Encoder.encode(to_hash, pretty: true))
|
269
272
|
end
|
270
273
|
|
271
274
|
true
|
@@ -286,7 +289,7 @@ module Omnibus
|
|
286
289
|
# @return [String]
|
287
290
|
#
|
288
291
|
def to_json
|
289
|
-
|
292
|
+
FFI_Yajl::Encoder.encode(@data, pretty: true)
|
290
293
|
end
|
291
294
|
end
|
292
295
|
end
|
data/lib/omnibus/package.rb
CHANGED
@@ -14,7 +14,7 @@
|
|
14
14
|
# limitations under the License.
|
15
15
|
#
|
16
16
|
|
17
|
-
require '
|
17
|
+
require 'ffi_yajl'
|
18
18
|
|
19
19
|
module Omnibus
|
20
20
|
class Package
|
@@ -95,7 +95,7 @@ module Omnibus
|
|
95
95
|
# The parsed contents of the metadata.
|
96
96
|
#
|
97
97
|
# @raise [NoPackageMetadataFile] if the {#metadata} does not exist
|
98
|
-
# @raise [
|
98
|
+
# @raise [FFI_Yajl::ParseError] if the JSON is not valid
|
99
99
|
#
|
100
100
|
# @return [Hash<Symbol, String>]
|
101
101
|
#
|
data/lib/omnibus/packager.rb
CHANGED
@@ -17,6 +17,7 @@
|
|
17
17
|
module Omnibus
|
18
18
|
module Packager
|
19
19
|
include Logging
|
20
|
+
include Sugarable
|
20
21
|
|
21
22
|
autoload :Base, 'omnibus/packagers/base'
|
22
23
|
autoload :BFF, 'omnibus/packagers/bff'
|
@@ -25,6 +26,7 @@ module Omnibus
|
|
25
26
|
autoload :MSI, 'omnibus/packagers/msi'
|
26
27
|
autoload :PKG, 'omnibus/packagers/pkg'
|
27
28
|
autoload :Solaris, 'omnibus/packagers/solaris'
|
29
|
+
autoload :IPS, 'omnibus/packagers/ips'
|
28
30
|
autoload :RPM, 'omnibus/packagers/rpm'
|
29
31
|
|
30
32
|
#
|
@@ -40,7 +42,8 @@ module Omnibus
|
|
40
42
|
'rhel' => RPM,
|
41
43
|
'wrlinux' => RPM,
|
42
44
|
'aix' => BFF,
|
43
|
-
'
|
45
|
+
'solaris' => Solaris,
|
46
|
+
'ips' => IPS,
|
44
47
|
'windows' => MSI,
|
45
48
|
'mac_os_x' => PKG,
|
46
49
|
}.freeze
|
@@ -56,7 +59,13 @@ module Omnibus
|
|
56
59
|
#
|
57
60
|
def for_current_system
|
58
61
|
family = Ohai['platform_family']
|
62
|
+
version = Ohai['platform_version']
|
59
63
|
|
64
|
+
if family == 'solaris2' && Chef::Sugar::Constraints::Version.new(version).satisfies?('>= 5.11')
|
65
|
+
family = "ips"
|
66
|
+
elsif family == 'solaris2' && Chef::Sugar::Constraints::Version.new(version).satisfies?('>= 5.10')
|
67
|
+
family = "solaris"
|
68
|
+
end
|
60
69
|
if klass = PLATFORM_PACKAGER_MAP[family]
|
61
70
|
klass
|
62
71
|
else
|
@@ -64,7 +73,6 @@ module Omnibus
|
|
64
73
|
"Could not determine packager for `#{family}', defaulting " \
|
65
74
|
"to `makeself'!"
|
66
75
|
end
|
67
|
-
|
68
76
|
Makeself
|
69
77
|
end
|
70
78
|
end
|
@@ -0,0 +1,301 @@
|
|
1
|
+
#
|
2
|
+
# Copyright 2016 Chef Software, Inc.
|
3
|
+
#
|
4
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
5
|
+
# you may not use this file except in compliance with the License.
|
6
|
+
# You may obtain a copy of the License at
|
7
|
+
#
|
8
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
9
|
+
#
|
10
|
+
# Unless required by applicable law or agreed to in writing, software
|
11
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
12
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
13
|
+
# See the License for the specific language governing permissions and
|
14
|
+
# limitations under the License.
|
15
|
+
#
|
16
|
+
|
17
|
+
module Omnibus
|
18
|
+
class Packager::IPS < Packager::Base
|
19
|
+
id :ips
|
20
|
+
|
21
|
+
setup do
|
22
|
+
create_directory(source_dir)
|
23
|
+
# Copy the full-stack installer into our scratch directory, accounting for
|
24
|
+
# any excluded files.
|
25
|
+
#
|
26
|
+
# /opt/hamlet => /tmp/daj29013/proto_install/opt/hamlet
|
27
|
+
# Create the proto_install directory inside staging_dir
|
28
|
+
destination = File.join(source_dir, project.install_dir)
|
29
|
+
FileSyncer.sync(project.install_dir, destination, exclude: exclusions)
|
30
|
+
write_transform_file
|
31
|
+
end
|
32
|
+
|
33
|
+
build do
|
34
|
+
#
|
35
|
+
# Package manifest generation is divided into the following stages:
|
36
|
+
#
|
37
|
+
write_pkg_metadata
|
38
|
+
generate_pkg_contents
|
39
|
+
generate_pkg_deps
|
40
|
+
validate_pkg_manifest
|
41
|
+
|
42
|
+
#
|
43
|
+
# To create an IPS package we need to generate a repo, publish our
|
44
|
+
# package into said repo. Finally, we export a portable `*.p5p`
|
45
|
+
# file from this repo.
|
46
|
+
#
|
47
|
+
create_ips_repo
|
48
|
+
publish_ips_pkg
|
49
|
+
export_pkg_archive_file
|
50
|
+
end
|
51
|
+
|
52
|
+
#
|
53
|
+
# @!group DSL methods
|
54
|
+
# --------------------------------------------------
|
55
|
+
|
56
|
+
#
|
57
|
+
# The publisher prefix for the IPS package.
|
58
|
+
#
|
59
|
+
# @example
|
60
|
+
# identifier 'Chef'
|
61
|
+
#
|
62
|
+
# @param [String] val
|
63
|
+
# the package identifier
|
64
|
+
#
|
65
|
+
# @return [String]
|
66
|
+
#
|
67
|
+
def publisher_prefix(val = NULL)
|
68
|
+
if null?(val)
|
69
|
+
@publisher_prefix || 'Omnibus'
|
70
|
+
else
|
71
|
+
@publisher_prefix = val
|
72
|
+
end
|
73
|
+
end
|
74
|
+
expose :publisher_prefix
|
75
|
+
|
76
|
+
#
|
77
|
+
# @!endgroup
|
78
|
+
# --------------------------------------------------
|
79
|
+
|
80
|
+
#
|
81
|
+
# @see Base#package_name
|
82
|
+
#
|
83
|
+
def package_name
|
84
|
+
"#{safe_base_package_name}.p5p"
|
85
|
+
end
|
86
|
+
|
87
|
+
#
|
88
|
+
# For more info about fmri see:
|
89
|
+
#
|
90
|
+
# http://docs.oracle.com/cd/E23824_01/html/E21796/pkg-5.html
|
91
|
+
#
|
92
|
+
def fmri_package_name
|
93
|
+
version = project.build_version.split(/[^\d]/)[0..2].join('.')
|
94
|
+
platform = Ohai['platform_version']
|
95
|
+
"#{safe_base_package_name}@#{version},#{platform}-#{project.build_iteration}"
|
96
|
+
end
|
97
|
+
|
98
|
+
#
|
99
|
+
# The full path to the transform file on disk.
|
100
|
+
#
|
101
|
+
# @return [String]
|
102
|
+
#
|
103
|
+
def transform_file
|
104
|
+
@transform_file ||= File.join(staging_dir, 'doc-transform')
|
105
|
+
end
|
106
|
+
|
107
|
+
#
|
108
|
+
# The full path to the pkg metadata file on disk.
|
109
|
+
#
|
110
|
+
# @return [String]
|
111
|
+
#
|
112
|
+
def pkg_metadata_file
|
113
|
+
@pkg_metadata_file ||= File.join(staging_dir, 'gen.manifestfile')
|
114
|
+
end
|
115
|
+
|
116
|
+
#
|
117
|
+
# The full path to the pkg manifest file on disk.
|
118
|
+
#
|
119
|
+
# @return [String]
|
120
|
+
#
|
121
|
+
def pkg_manifest_file
|
122
|
+
@pkg_manifest_file ||= File.join(staging_dir, "#{safe_base_package_name}.p5m")
|
123
|
+
end
|
124
|
+
|
125
|
+
#
|
126
|
+
# The path to the +publish/repo+ directory inside the staging directory.
|
127
|
+
#
|
128
|
+
# @return [String]
|
129
|
+
#
|
130
|
+
def repo_dir
|
131
|
+
@repo_dir ||= File.join(staging_dir, 'publish', 'repo')
|
132
|
+
end
|
133
|
+
|
134
|
+
#
|
135
|
+
# The path to the +proto-install+ directory inside the staging directory.
|
136
|
+
#
|
137
|
+
# @return [String]
|
138
|
+
#
|
139
|
+
def source_dir
|
140
|
+
@source_dir ||= File.join(staging_dir, 'proto_install')
|
141
|
+
end
|
142
|
+
|
143
|
+
#
|
144
|
+
# Return the IPS-ready base package name, converting any invalid characters to
|
145
|
+
# dashes (+-+).
|
146
|
+
#
|
147
|
+
# @return [String]
|
148
|
+
#
|
149
|
+
def safe_base_package_name
|
150
|
+
if project.package_name =~ /\A[a-z0-9\.\+\-]+\z/
|
151
|
+
project.package_name.dup
|
152
|
+
else
|
153
|
+
converted = project.package_name.downcase.gsub(/[^a-z0-9\.\+\-]+/, '-')
|
154
|
+
|
155
|
+
log.warn(log_key) do
|
156
|
+
"The `name' component of IPS package names can only include " \
|
157
|
+
"lowercase alphabetical characters (a-z), numbers (0-9), dots (.), " \
|
158
|
+
"plus signs (+), and dashes (-). Converting `#{project.package_name}' to " \
|
159
|
+
"`#{converted}'."
|
160
|
+
end
|
161
|
+
converted
|
162
|
+
end
|
163
|
+
end
|
164
|
+
|
165
|
+
#
|
166
|
+
# The architecture for this IPS package.
|
167
|
+
#
|
168
|
+
# @return [String]
|
169
|
+
#
|
170
|
+
def safe_architecture
|
171
|
+
if intel?
|
172
|
+
'i386'
|
173
|
+
elsif sparc?
|
174
|
+
'sparc'
|
175
|
+
else
|
176
|
+
Ohai['kernel']['machine']
|
177
|
+
end
|
178
|
+
end
|
179
|
+
|
180
|
+
#
|
181
|
+
# A set of transform rules that `pkgmogrify' will apply to the package
|
182
|
+
# manifest.
|
183
|
+
#
|
184
|
+
# @return [void]
|
185
|
+
#
|
186
|
+
def write_transform_file
|
187
|
+
render_template(resource_path('doc-transform.erb'),
|
188
|
+
destination: transform_file,
|
189
|
+
variables: {
|
190
|
+
pathdir: project.install_dir.split('/')[1],
|
191
|
+
}
|
192
|
+
)
|
193
|
+
end
|
194
|
+
|
195
|
+
#
|
196
|
+
# Generate package metadata
|
197
|
+
#
|
198
|
+
# Create the gen template for `pkgmogrify`
|
199
|
+
#
|
200
|
+
# @return [void]
|
201
|
+
#
|
202
|
+
def write_pkg_metadata
|
203
|
+
render_template(resource_path('gen.manifestfile.erb'),
|
204
|
+
destination: pkg_metadata_file,
|
205
|
+
variables: {
|
206
|
+
name: safe_base_package_name,
|
207
|
+
fmri_package_name: fmri_package_name,
|
208
|
+
description: project.description,
|
209
|
+
summary: project.friendly_name,
|
210
|
+
arch: safe_architecture,
|
211
|
+
}
|
212
|
+
)
|
213
|
+
|
214
|
+
# Print the full contents of the rendered template file to generate package contents
|
215
|
+
log.debug(log_key) { "Rendered Template:\n" + File.read(pkg_metadata_file) }
|
216
|
+
end
|
217
|
+
|
218
|
+
#
|
219
|
+
# Create the package contents using `pkgsend` and `pkgfmt`
|
220
|
+
#
|
221
|
+
# @return [void]
|
222
|
+
#
|
223
|
+
def generate_pkg_contents
|
224
|
+
shellout!("pkgsend generate #{source_dir} | pkgfmt > #{pkg_manifest_file}.1")
|
225
|
+
shellout!("pkgmogrify -DARCH=`uname -p` #{pkg_manifest_file}.1 #{pkg_metadata_file} #{transform_file} | pkgfmt > #{pkg_manifest_file}.2")
|
226
|
+
end
|
227
|
+
|
228
|
+
#
|
229
|
+
# Generate the package deps
|
230
|
+
#
|
231
|
+
# @return [void]
|
232
|
+
#
|
233
|
+
def generate_pkg_deps
|
234
|
+
shellout!("pkgdepend generate -md #{source_dir} #{pkg_manifest_file}.2 | pkgfmt > #{pkg_manifest_file}.3")
|
235
|
+
shellout!("pkgmogrify -DARCH=`uname -p` #{pkg_manifest_file}.3 #{transform_file} | pkgfmt > #{pkg_manifest_file}.4")
|
236
|
+
shellout!("pkgdepend resolve -m #{pkg_manifest_file}.4")
|
237
|
+
end
|
238
|
+
|
239
|
+
#
|
240
|
+
# Validate the generated package manifest using `pkglint`
|
241
|
+
#
|
242
|
+
# @return [void]
|
243
|
+
#
|
244
|
+
def validate_pkg_manifest
|
245
|
+
log.info(log_key) { "Validating package manifest" }
|
246
|
+
shellout!("pkglint -c /tmp/lint-cache -r http://pkg.oracle.com/solaris/release #{pkg_manifest_file}.4.res")
|
247
|
+
end
|
248
|
+
|
249
|
+
#
|
250
|
+
# Create a local IPS repo for publishing
|
251
|
+
#
|
252
|
+
# @return [void]
|
253
|
+
#
|
254
|
+
def create_ips_repo
|
255
|
+
shellout!("pkgrepo create #{repo_dir}")
|
256
|
+
log.info(log_key) { "Created IPS repo: #{repo_dir}" }
|
257
|
+
end
|
258
|
+
|
259
|
+
#
|
260
|
+
# Publish the IPS pkg into the local IPS repo
|
261
|
+
#
|
262
|
+
# @return [void]
|
263
|
+
#
|
264
|
+
def publish_ips_pkg
|
265
|
+
shellout!("pkgrepo -s #{repo_dir} set publisher/prefix=#{publisher_prefix}")
|
266
|
+
shellout!("pkgsend publish -s #{repo_dir} -d #{source_dir} #{pkg_manifest_file}.4.res")
|
267
|
+
log.info(log_key) { "Published IPS package to repo: #{repo_dir}"}
|
268
|
+
|
269
|
+
repo_info = shellout("pkg list -afv -g #{repo_dir}").stdout
|
270
|
+
log.debug(log_key) do
|
271
|
+
<<-EOH.strip
|
272
|
+
Published IPS package:
|
273
|
+
|
274
|
+
#{repo_info}
|
275
|
+
EOH
|
276
|
+
end
|
277
|
+
end
|
278
|
+
|
279
|
+
#
|
280
|
+
# Convert a the published IPS pkg from the local repo into the more
|
281
|
+
# easily distributable `*.p5p` archive.
|
282
|
+
#
|
283
|
+
# @return [void]
|
284
|
+
#
|
285
|
+
def export_pkg_archive_file
|
286
|
+
# The destination file cannot already exist
|
287
|
+
File.delete(package_path) if File.exist?(package_path)
|
288
|
+
shellout!("pkgrecv -s #{repo_dir} -a -d #{package_path} #{safe_base_package_name}")
|
289
|
+
log.info(log_key) { "Exported IPS package archive: #{package_path}"}
|
290
|
+
|
291
|
+
list_pkgarchive = shellout("pkgrepo list -s #{package_path} '*@latest'").stdout
|
292
|
+
log.debug(log_key) do
|
293
|
+
<<-EOH.strip
|
294
|
+
IPS package archive contents:
|
295
|
+
|
296
|
+
#{list_pkgarchive}
|
297
|
+
EOH
|
298
|
+
end
|
299
|
+
end
|
300
|
+
end
|
301
|
+
end
|