omnibus 4.0.0.beta.1 → 4.0.0.rc.1
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.
- checksums.yaml +4 -4
- data/CHANGELOG.md +29 -0
- data/docs/Building on RHEL.md +1 -0
- data/lib/omnibus/builder.rb +48 -1
- data/lib/omnibus/config.rb +13 -0
- data/lib/omnibus/digestable.rb +2 -2
- data/lib/omnibus/exceptions.rb +21 -0
- data/lib/omnibus/fetchers/git_fetcher.rb +75 -9
- data/lib/omnibus/fetchers/net_fetcher.rb +5 -3
- data/lib/omnibus/generator.rb +0 -13
- data/{resources/bff/postinstall.sh → lib/omnibus/generator_files/package_scripts/makeselfinst.erb} +0 -0
- data/lib/omnibus/packagers/base.rb +25 -1
- data/lib/omnibus/packagers/bff.rb +99 -12
- data/lib/omnibus/packagers/deb.rb +10 -8
- data/lib/omnibus/packagers/makeself.rb +24 -16
- data/lib/omnibus/packagers/msi.rb +6 -5
- data/lib/omnibus/packagers/pkg.rb +59 -10
- data/lib/omnibus/packagers/rpm.rb +42 -25
- data/lib/omnibus/packagers/solaris.rb +5 -5
- data/lib/omnibus/project.rb +54 -5
- data/lib/omnibus/software.rb +37 -39
- data/lib/omnibus/version.rb +1 -1
- data/omnibus.gemspec +1 -0
- data/resources/bff/gen.template.erb +3 -2
- data/resources/rpm/signing.erb +1 -1
- data/spec/functional/builder_spec.rb +75 -3
- data/spec/functional/fetchers/git_fetcher_spec.rb +31 -2
- data/spec/support/examples.rb +8 -2
- data/spec/support/git_helpers.rb +8 -0
- data/spec/unit/builder_spec.rb +6 -0
- data/spec/unit/config_spec.rb +1 -0
- data/spec/unit/generator_spec.rb +0 -12
- data/spec/unit/packagers/base_spec.rb +16 -0
- data/spec/unit/packagers/bff_spec.rb +58 -5
- data/spec/unit/packagers/deb_spec.rb +15 -3
- data/spec/unit/packagers/makeself_spec.rb +56 -9
- data/spec/unit/packagers/pkg_spec.rb +57 -4
- data/spec/unit/packagers/rpm_spec.rb +38 -23
- data/spec/unit/project_spec.rb +16 -5
- data/spec/unit/software_spec.rb +0 -1
- metadata +18 -6
- data/resources/bff/unpostinstall.sh +0 -0
- data/resources/makeself/post_extract.sh.erb +0 -27
@@ -37,14 +37,14 @@ module Omnibus
|
|
37
37
|
|
38
38
|
Dir.chdir(staging_dir) do
|
39
39
|
shellout! "pkgmk -o -r #{install_dirname} -d /tmp/pkgmk -f /tmp/pkgmk/Prototype"
|
40
|
-
shellout! "pkgchk -vd /tmp/pkgmk #{project.
|
41
|
-
shellout! "pkgtrans /tmp/pkgmk /var/cache/omnibus/pkg/#{package_name} #{project.
|
40
|
+
shellout! "pkgchk -vd /tmp/pkgmk #{project.package_name}"
|
41
|
+
shellout! "pkgtrans /tmp/pkgmk /var/cache/omnibus/pkg/#{package_name} #{project.package_name}"
|
42
42
|
end
|
43
43
|
end
|
44
44
|
|
45
45
|
# @see Base#package_name
|
46
46
|
def package_name
|
47
|
-
"#{project.
|
47
|
+
"#{project.package_name}-#{pkgmk_version}.#{Ohai['kernel']['machine']}.solaris"
|
48
48
|
end
|
49
49
|
|
50
50
|
def pkgmk_version
|
@@ -92,8 +92,8 @@ module Omnibus
|
|
92
92
|
TZ=PST
|
93
93
|
PATH=/sbin:/usr/sbin:/usr/bin:/usr/sadm/install/bin
|
94
94
|
BASEDIR=#{install_dirname}
|
95
|
-
PKG=#{project.
|
96
|
-
NAME=#{project.
|
95
|
+
PKG=#{project.package_name}
|
96
|
+
NAME=#{project.package_name}
|
97
97
|
ARCH=#{`uname -p`.chomp}
|
98
98
|
VERSION=#{pkgmk_version}
|
99
99
|
CATEGORY=application
|
data/lib/omnibus/project.rb
CHANGED
@@ -120,6 +120,27 @@ module Omnibus
|
|
120
120
|
end
|
121
121
|
expose :friendly_name
|
122
122
|
|
123
|
+
#
|
124
|
+
# Set or retrieve the package name of the project. Defaults to the package
|
125
|
+
# name defaults to the project name.
|
126
|
+
#
|
127
|
+
# @example
|
128
|
+
# package_name 'com.chef.project'
|
129
|
+
#
|
130
|
+
# @param [String] val
|
131
|
+
# the package name to set
|
132
|
+
#
|
133
|
+
# @return [String]
|
134
|
+
#
|
135
|
+
def package_name(val = NULL)
|
136
|
+
if null?(val)
|
137
|
+
@package_name || name
|
138
|
+
else
|
139
|
+
@package_name = val
|
140
|
+
end
|
141
|
+
end
|
142
|
+
expose :package_name
|
143
|
+
|
123
144
|
#
|
124
145
|
# **[Required]** Set or retrieve the path at which the project should be
|
125
146
|
# installed by the generated package.
|
@@ -170,6 +191,21 @@ module Omnibus
|
|
170
191
|
end
|
171
192
|
expose :default_root
|
172
193
|
|
194
|
+
#
|
195
|
+
# Path to the +/files+ directory in the omnibus project. This directory can
|
196
|
+
# contain arbritary files used by the project.
|
197
|
+
#
|
198
|
+
# @example
|
199
|
+
# patch = File.join(files_path, 'rubygems', 'patch.rb')
|
200
|
+
#
|
201
|
+
# @return [String]
|
202
|
+
# path to the files directory
|
203
|
+
#
|
204
|
+
def files_path
|
205
|
+
File.expand_path("#{Config.project_root}/files")
|
206
|
+
end
|
207
|
+
expose :files_path
|
208
|
+
|
173
209
|
#
|
174
210
|
# **[Required]** Set or retrieve the the package maintainer.
|
175
211
|
#
|
@@ -830,10 +866,23 @@ module Omnibus
|
|
830
866
|
# install path cache, or software definitions to invalidate the cache for
|
831
867
|
# this project.
|
832
868
|
#
|
869
|
+
# @param [Software] software
|
870
|
+
# the software that dirtied the cache
|
871
|
+
#
|
833
872
|
# @return [true, false]
|
834
873
|
#
|
835
|
-
def dirty!
|
836
|
-
|
874
|
+
def dirty!(software)
|
875
|
+
raise ProjectAlreadyDirty.new(self) if culprit
|
876
|
+
@culprit = software
|
877
|
+
end
|
878
|
+
|
879
|
+
#
|
880
|
+
# The software definition which dirtied this project.
|
881
|
+
#
|
882
|
+
# @return [Software, nil]
|
883
|
+
#
|
884
|
+
def culprit
|
885
|
+
@culprit
|
837
886
|
end
|
838
887
|
|
839
888
|
#
|
@@ -842,7 +891,7 @@ module Omnibus
|
|
842
891
|
# @return [true, false]
|
843
892
|
#
|
844
893
|
def dirty?
|
845
|
-
|
894
|
+
!!culprit
|
846
895
|
end
|
847
896
|
|
848
897
|
#
|
@@ -907,8 +956,8 @@ module Omnibus
|
|
907
956
|
|
908
957
|
# Copy the generated package and metadata back into the workspace
|
909
958
|
package_path = File.join(Config.package_dir, packager.package_name)
|
910
|
-
FileUtils.cp(package_path, destination)
|
911
|
-
FileUtils.cp("#{package_path}.metadata.json", destination)
|
959
|
+
FileUtils.cp(package_path, destination, preserve: true)
|
960
|
+
FileUtils.cp("#{package_path}.metadata.json", destination, preserve: true)
|
912
961
|
end
|
913
962
|
|
914
963
|
#
|
data/lib/omnibus/software.rb
CHANGED
@@ -160,19 +160,6 @@ module Omnibus
|
|
160
160
|
end
|
161
161
|
expose :description
|
162
162
|
|
163
|
-
#
|
164
|
-
# Always build the given software definition.
|
165
|
-
#
|
166
|
-
# @param [true, false] val
|
167
|
-
#
|
168
|
-
# @return [true, false]
|
169
|
-
#
|
170
|
-
def always_build(val)
|
171
|
-
@always_build = val
|
172
|
-
@always_build
|
173
|
-
end
|
174
|
-
expose :always_build
|
175
|
-
|
176
163
|
#
|
177
164
|
# Add a software dependency to this software.
|
178
165
|
#
|
@@ -717,20 +704,32 @@ module Omnibus
|
|
717
704
|
end
|
718
705
|
end
|
719
706
|
|
720
|
-
#
|
707
|
+
#
|
708
|
+
# Build the software package. If git caching is turned on (see
|
709
|
+
# {Config#use_git_caching}), the build is restored according to the
|
710
|
+
# documented restoration procedure in the git cache. If the build cannot
|
711
|
+
# be restored (if the tag does not exist), the actual build steps are
|
712
|
+
# executed.
|
713
|
+
#
|
714
|
+
# @return [true]
|
715
|
+
#
|
721
716
|
def build_me
|
722
|
-
|
723
|
-
|
724
|
-
|
725
|
-
|
726
|
-
|
727
|
-
|
717
|
+
if Config.use_git_caching
|
718
|
+
if project.dirty?
|
719
|
+
log.info(log_key) do
|
720
|
+
"Building because `#{project.culprit.name}' dirtied the cache"
|
721
|
+
end
|
722
|
+
execute_build
|
723
|
+
elsif git_cache.restore
|
728
724
|
log.info(log_key) { "Restored from cache" }
|
729
|
-
true
|
730
725
|
else
|
731
|
-
log.info(log_key) { "Could not restore from cache
|
726
|
+
log.info(log_key) { "Could not restore from cache" }
|
732
727
|
execute_build
|
728
|
+
project.dirty!(self)
|
733
729
|
end
|
730
|
+
else
|
731
|
+
log.debug(log_key) { "Forcing build because git caching is off" }
|
732
|
+
execute_build
|
734
733
|
end
|
735
734
|
|
736
735
|
project.build_version_dsl.resolve(self)
|
@@ -792,22 +791,12 @@ module Omnibus
|
|
792
791
|
private
|
793
792
|
|
794
793
|
#
|
795
|
-
#
|
796
|
-
# always be built if git caching is disabled ({Config#use_git_caching}) or
|
797
|
-
# if the parent project has dirtied the cache.
|
794
|
+
# The git caching implementation for this software.
|
798
795
|
#
|
799
|
-
# @return [
|
796
|
+
# @return [GitCache]
|
800
797
|
#
|
801
|
-
def
|
802
|
-
|
803
|
-
return true
|
804
|
-
end
|
805
|
-
|
806
|
-
if project.dirty?
|
807
|
-
return true
|
808
|
-
end
|
809
|
-
|
810
|
-
!!@always_build
|
798
|
+
def git_cache
|
799
|
+
@git_cache ||= GitCache.new(self)
|
811
800
|
end
|
812
801
|
|
813
802
|
#
|
@@ -838,18 +827,27 @@ module Omnibus
|
|
838
827
|
end
|
839
828
|
end
|
840
829
|
|
830
|
+
#
|
831
|
+
# Actually build this software, executing the steps provided in the
|
832
|
+
# {#build} block and dirtying the cache.
|
833
|
+
#
|
834
|
+
# @return [void]
|
835
|
+
#
|
841
836
|
def execute_build
|
842
837
|
fetcher.clean
|
843
838
|
builder.build
|
844
839
|
|
845
840
|
if Config.use_git_caching
|
846
|
-
|
841
|
+
git_cache.incremental
|
847
842
|
log.info(log_key) { 'Dirtied the cache' }
|
848
843
|
end
|
849
|
-
|
850
|
-
project.dirty!
|
851
844
|
end
|
852
845
|
|
846
|
+
#
|
847
|
+
# The log key for this software, including its name.
|
848
|
+
#
|
849
|
+
# @return [String]
|
850
|
+
#
|
853
851
|
def log_key
|
854
852
|
@log_key ||= "#{super}: #{name}"
|
855
853
|
end
|
data/lib/omnibus/version.rb
CHANGED
data/omnibus.gemspec
CHANGED
@@ -6,8 +6,9 @@ Fileset
|
|
6
6
|
Fileset VRMF: <%= version %>
|
7
7
|
Fileset Description: <%= description %>
|
8
8
|
USRLIBLPPFiles
|
9
|
-
|
10
|
-
|
9
|
+
<% scripts.each do |name, install_path| -%>
|
10
|
+
<%= name %>: <%= install_path %>
|
11
|
+
<% end -%>
|
11
12
|
EOUSRLIBLPPFiles
|
12
13
|
Bosboot required: N
|
13
14
|
License agreement acceptance required: N
|
data/resources/rpm/signing.erb
CHANGED
@@ -10,8 +10,8 @@ module Omnibus
|
|
10
10
|
# a real Ruby just for functional tests.
|
11
11
|
#
|
12
12
|
def fake_embedded_bin(name)
|
13
|
-
create_directory(
|
14
|
-
create_link(Bundler.which(name), File.join(
|
13
|
+
create_directory(embedded_bin_dir)
|
14
|
+
create_link(Bundler.which(name), File.join(embedded_bin_dir, name))
|
15
15
|
end
|
16
16
|
|
17
17
|
subject { described_class.new(software) }
|
@@ -131,13 +131,85 @@ module Omnibus
|
|
131
131
|
|
132
132
|
fake_embedded_bin('bundle')
|
133
133
|
|
134
|
-
|
134
|
+
# Pass GEM_HOME and GEM_PATH to subprocess so our fake bin works
|
135
|
+
options = {}
|
136
|
+
options[:env] = {
|
137
|
+
'GEM_HOME' => ENV['GEM_HOME'],
|
138
|
+
'GEM_PATH' => ENV['GEM_PATH'],
|
139
|
+
}
|
140
|
+
|
141
|
+
subject.bundle('install', options)
|
135
142
|
output = capture_logging { subject.build }
|
136
143
|
|
137
144
|
expect(output).to include('bundle install')
|
138
145
|
end
|
139
146
|
end
|
140
147
|
|
148
|
+
describe '#appbundle' do
|
149
|
+
it 'executes the command as the embedded appbundler' do
|
150
|
+
|
151
|
+
source_dir = "#{Omnibus::Config.source_dir}/example"
|
152
|
+
embedded_app_dir = "#{software.install_dir}/embedded/apps/example"
|
153
|
+
bin_dir = "#{software.install_dir}/bin"
|
154
|
+
|
155
|
+
FileUtils.mkdir(source_dir)
|
156
|
+
|
157
|
+
gemspec = File.join(source_dir, 'example.gemspec')
|
158
|
+
File.open(gemspec, 'w') do |f|
|
159
|
+
f.write <<-EOH.gsub(/^ {12}/, '')
|
160
|
+
Gem::Specification.new do |gem|
|
161
|
+
gem.name = 'example'
|
162
|
+
gem.version = '1.0.0'
|
163
|
+
gem.author = 'Chef Software, Inc.'
|
164
|
+
gem.email = 'info@getchef.com'
|
165
|
+
gem.description = 'Installs a thing'
|
166
|
+
gem.summary = gem.description
|
167
|
+
end
|
168
|
+
EOH
|
169
|
+
end
|
170
|
+
|
171
|
+
gemfile = File.join(source_dir, 'Gemfile')
|
172
|
+
File.open(gemfile, 'w') do |f|
|
173
|
+
f.write <<-EOH.gsub(/^ {12}/, '')
|
174
|
+
gemspec
|
175
|
+
EOH
|
176
|
+
end
|
177
|
+
|
178
|
+
gemfile_lock = File.join(source_dir, 'Gemfile.lock')
|
179
|
+
File.open(gemfile_lock, 'w') do |f|
|
180
|
+
f.write <<-EOH.gsub(/^ {12}/, '')
|
181
|
+
PATH
|
182
|
+
remote: .
|
183
|
+
specs:
|
184
|
+
example (1.0.0)
|
185
|
+
|
186
|
+
GEM
|
187
|
+
specs:
|
188
|
+
|
189
|
+
PLATFORMS
|
190
|
+
ruby
|
191
|
+
|
192
|
+
DEPENDENCIES
|
193
|
+
example!
|
194
|
+
EOH
|
195
|
+
end
|
196
|
+
|
197
|
+
fake_embedded_bin('appbundler')
|
198
|
+
|
199
|
+
# Pass GEM_HOME and GEM_PATH to subprocess so our fake bin works
|
200
|
+
options = {}
|
201
|
+
options[:env] = {
|
202
|
+
'GEM_HOME' => ENV['GEM_HOME'],
|
203
|
+
'GEM_PATH' => ENV['GEM_PATH'],
|
204
|
+
}
|
205
|
+
|
206
|
+
subject.appbundle('example', options)
|
207
|
+
output = capture_logging { subject.build }
|
208
|
+
|
209
|
+
expect(output).to include("/opt/chefdk/embedded/bin/appbundler '#{embedded_app_dir}' '#{bin_dir}'")
|
210
|
+
end
|
211
|
+
end
|
212
|
+
|
141
213
|
describe '#rake' do
|
142
214
|
it 'executes the command as the embedded rake' do
|
143
215
|
rakefile = File.join(tmp_path, 'Rakefile')
|
@@ -98,6 +98,16 @@ module Omnibus
|
|
98
98
|
end
|
99
99
|
end
|
100
100
|
|
101
|
+
context 'when the version is an annnotated tag' do
|
102
|
+
let(:version) { 'v1.2.4' }
|
103
|
+
let(:remote) { remote_git_repo('zlib', annotated_tags: [version]) }
|
104
|
+
|
105
|
+
it 'it defererences and parses the annotated tag' do
|
106
|
+
subject.fetch
|
107
|
+
expect(revision).to eq('efde208366abd0f91419d8a54b45e3f6e0540105')
|
108
|
+
end
|
109
|
+
end
|
110
|
+
|
101
111
|
context 'when the version is a branch' do
|
102
112
|
let(:version) { 'sethvargo/magic_ponies' }
|
103
113
|
let(:remote) { remote_git_repo('zlib', branches: [version]) }
|
@@ -108,15 +118,34 @@ module Omnibus
|
|
108
118
|
end
|
109
119
|
end
|
110
120
|
|
111
|
-
context 'when the version is a
|
121
|
+
context 'when the version is a full SHA-1' do
|
122
|
+
let(:version) { '45ded6d3b1a35d66ed866b2c3eb418426e6382b0' }
|
123
|
+
let(:remote) { remote_git_repo('zlib') }
|
124
|
+
|
125
|
+
it 'parses the full SHA-1' do
|
126
|
+
subject.fetch
|
127
|
+
expect(revision).to eq('45ded6d3b1a35d66ed866b2c3eb418426e6382b0')
|
128
|
+
end
|
129
|
+
end
|
130
|
+
|
131
|
+
context 'when the version is a abbreviated SHA-1' do
|
112
132
|
let(:version) { '45ded6d' }
|
113
133
|
let(:remote) { remote_git_repo('zlib') }
|
114
134
|
|
115
|
-
it 'parses the
|
135
|
+
it 'parses the abbreviated SHA-1' do
|
116
136
|
subject.fetch
|
117
137
|
expect(revision).to eq('45ded6d3b1a35d66ed866b2c3eb418426e6382b0')
|
118
138
|
end
|
119
139
|
end
|
140
|
+
|
141
|
+
context 'when the version is a non-existent ref' do
|
142
|
+
let(:version) { 'fufufufufu' }
|
143
|
+
let(:remote) { remote_git_repo('zlib') }
|
144
|
+
|
145
|
+
it 'raise an exception' do
|
146
|
+
expect { subject.fetch }.to raise_error(UnresolvableGitReference)
|
147
|
+
end
|
148
|
+
end
|
120
149
|
end
|
121
150
|
|
122
151
|
describe '#version_for_cache' do
|
data/spec/support/examples.rb
CHANGED
@@ -15,8 +15,9 @@ RSpec.shared_examples 'a software' do |name = 'chefdk'|
|
|
15
15
|
let(:softwares_dir) { File.join(project_root, 'config', 'software', name) }
|
16
16
|
let(:templates_dir) { File.join(project_root, 'config', 'templates', name) }
|
17
17
|
|
18
|
-
let(:install_dir)
|
19
|
-
let(:bin_dir)
|
18
|
+
let(:install_dir) { File.join(project_root, 'opt', name) }
|
19
|
+
let(:bin_dir) { File.join(install_dir, 'bin') }
|
20
|
+
let(:embedded_bin_dir) { File.join(install_dir, 'embedded', 'bin') }
|
20
21
|
|
21
22
|
let(:software) do
|
22
23
|
double(Omnibus::Software,
|
@@ -52,5 +53,10 @@ RSpec.shared_examples 'a software' do |name = 'chefdk'|
|
|
52
53
|
|
53
54
|
FileUtils.mkdir_p(install_dir)
|
54
55
|
FileUtils.mkdir_p(bin_dir)
|
56
|
+
FileUtils.mkdir_p(embedded_bin_dir)
|
57
|
+
|
58
|
+
allow(software).to receive(:with_embedded_path).and_return(
|
59
|
+
"PATH" => "#{bin_dir}:#{embedded_bin_dir}:#{ENV['PATH']}"
|
60
|
+
)
|
55
61
|
end
|
56
62
|
end
|