omnibus 3.2.2 → 4.0.0.beta.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +140 -10
- data/CHANGELOG.md +181 -8
- data/README.md +63 -35
- data/Rakefile +1 -1
- data/docs/omnibus-build-cache.md b/data/docs/Build → Cache.md +0 -0
- data/docs/Building on Debian.md +59 -0
- data/docs/Building on OSX.md +61 -35
- data/docs/Building on RHEL.md +74 -0
- data/docs/Building on Windows.md +40 -81
- data/features/commands/build.feature +1 -2
- data/features/commands/clean.feature +1 -1
- data/lib/omnibus.rb +111 -204
- data/lib/omnibus/build_version.rb +3 -20
- data/lib/omnibus/build_version_dsl.rb +2 -3
- data/lib/omnibus/builder.rb +103 -211
- data/lib/omnibus/cleaner.rb +5 -7
- data/lib/omnibus/cli.rb +1 -4
- data/lib/omnibus/cli/base.rb +9 -16
- data/lib/omnibus/compressor.rb +60 -0
- data/{spec/data/complicated/config/software/version-manifest.rb → lib/omnibus/compressors/base.rb} +17 -12
- data/lib/omnibus/compressors/dmg.rb +312 -0
- data/lib/omnibus/{null_builder.rb → compressors/null.rb} +10 -4
- data/lib/omnibus/compressors/tgz.rb +141 -0
- data/lib/omnibus/config.rb +89 -83
- data/lib/omnibus/core_extensions.rb +1 -0
- data/lib/omnibus/core_extensions/open_uri.rb +58 -0
- data/lib/omnibus/digestable.rb +9 -3
- data/lib/omnibus/exceptions.rb +116 -175
- data/lib/omnibus/fetcher.rb +97 -138
- data/lib/omnibus/fetchers/git_fetcher.rb +130 -165
- data/lib/omnibus/fetchers/net_fetcher.rb +205 -164
- data/lib/omnibus/fetchers/{s3_cache_fetcher.rb → null_fetcher.rb} +27 -17
- data/lib/omnibus/fetchers/path_fetcher.rb +74 -32
- data/lib/omnibus/file_syncer.rb +149 -0
- data/lib/omnibus/generator.rb +103 -32
- data/lib/omnibus/generator_files/.kitchen.yml.erb +5 -1
- data/lib/omnibus/generator_files/Gemfile.erb +13 -7
- data/lib/omnibus/generator_files/config/projects/project.rb.erb +28 -0
- data/lib/omnibus/generator_files/config/software/zlib.rb.erb +55 -0
- data/lib/omnibus/generator_files/omnibus.rb.erb +5 -7
- data/lib/omnibus/git_cache.rb +11 -13
- data/lib/omnibus/logger.rb +76 -22
- data/lib/omnibus/logging.rb +1 -1
- data/lib/omnibus/metadata.rb +264 -0
- data/lib/omnibus/ohai.rb +0 -51
- data/lib/omnibus/package.rb +4 -228
- data/lib/omnibus/packager.rb +71 -0
- data/lib/omnibus/packagers/base.rb +118 -176
- data/lib/omnibus/packagers/bff.rb +136 -0
- data/lib/omnibus/packagers/deb.rb +389 -0
- data/lib/omnibus/packagers/makeself.rb +114 -0
- data/lib/omnibus/packagers/msi.rb +346 -0
- data/lib/omnibus/packagers/pkg.rb +278 -0
- data/lib/omnibus/packagers/rpm.rb +438 -0
- data/lib/omnibus/packagers/solaris.rb +110 -0
- data/lib/omnibus/project.rb +263 -666
- data/lib/omnibus/publisher.rb +3 -3
- data/lib/omnibus/s3_cache.rb +21 -30
- data/lib/omnibus/software.rb +132 -271
- data/lib/omnibus/templating.rb +66 -0
- data/lib/omnibus/thread_pool.rb +109 -0
- data/lib/omnibus/util.rb +137 -15
- data/lib/omnibus/version.rb +1 -1
- data/omnibus.gemspec +2 -2
- data/resources/bff/gen.template.erb +22 -0
- data/resources/bff/postinstall.sh +0 -0
- data/resources/bff/unpostinstall.sh +0 -0
- data/resources/deb/conffiles.erb +3 -0
- data/resources/deb/control.erb +25 -0
- data/resources/deb/md5sums.erb +3 -0
- data/{lib/omnibus/generator_files/mac_dmg → resources/dmg}/background.png +0 -0
- data/resources/dmg/create_dmg.osascript.erb +17 -0
- data/{lib/omnibus/generator_files/mac_dmg → resources/dmg}/icon.png +0 -0
- data/{bin → resources/makeself}/makeself-header.sh +0 -0
- data/{bin → resources/makeself}/makeself.sh +0 -0
- data/{lib/omnibus/generator_files/package_scripts/makeselfinst.erb → resources/makeself/post_extract.sh.erb} +4 -4
- data/{lib/omnibus/generator_files/windows_msi → resources/msi}/assets/LICENSE.rtf +0 -0
- data/{lib/omnibus/generator_files/windows_msi → resources/msi}/assets/banner_background.bmp +0 -0
- data/{lib/omnibus/generator_files/windows_msi → resources/msi}/assets/dialog_background.bmp +0 -0
- data/{lib/omnibus/generator_files/windows_msi → resources/msi}/assets/project.ico +0 -0
- data/{lib/omnibus/generator_files/windows_msi → resources/msi}/assets/project_16x16.ico +0 -0
- data/{lib/omnibus/generator_files/windows_msi → resources/msi}/assets/project_32x32.ico +0 -0
- data/{spec/fixtures/sample/files/windows_msi/Resources/localization-en-us.wxl → resources/msi/localization-en-us.wxl.erb} +3 -4
- data/resources/msi/parameters.wxi.erb +9 -0
- data/{lib/omnibus/generator_files/windows_msi → resources/msi}/source.wxs.erb +14 -15
- data/{lib/omnibus/generator_files/mac_pkg → resources/pkg}/background.png +0 -0
- data/resources/pkg/distribution.xml.erb +21 -0
- data/resources/pkg/license.html.erb +3 -0
- data/resources/pkg/welcome.html.erb +7 -0
- data/resources/rpm/rpmmacros.erb +3 -0
- data/resources/rpm/signing.erb +40 -0
- data/resources/rpm/spec.erb +70 -0
- data/spec/functional/builder_spec.rb +90 -111
- data/spec/functional/fetchers/git_fetcher_spec.rb +130 -0
- data/spec/functional/fetchers/net_fetcher_spec.rb +110 -0
- data/spec/functional/fetchers/path_fetcher_spec.rb +97 -0
- data/spec/functional/file_syncer_spec.rb +206 -0
- data/spec/functional/templating_spec.rb +73 -0
- data/spec/spec_helper.rb +31 -94
- data/spec/support/env_helpers.rb +20 -0
- data/spec/support/examples.rb +56 -0
- data/spec/support/file_helpers.rb +46 -0
- data/spec/support/git_helpers.rb +107 -0
- data/spec/support/logging_helpers.rb +33 -0
- data/spec/support/matchers.rb +36 -0
- data/spec/support/ohai_helpers.rb +22 -0
- data/spec/support/path_helpers.rb +19 -0
- data/spec/support/shell_helpers.rb +14 -0
- data/spec/unit/build_version_dsl_spec.rb +0 -17
- data/spec/unit/build_version_spec.rb +1 -19
- data/spec/unit/builder_spec.rb +158 -46
- data/spec/unit/compressor_spec.rb +45 -0
- data/spec/unit/compressors/base_spec.rb +26 -0
- data/spec/unit/compressors/dmg_spec.rb +291 -0
- data/spec/unit/compressors/null_spec.rb +23 -0
- data/spec/unit/compressors/tgz_spec.rb +67 -0
- data/spec/unit/config_spec.rb +27 -34
- data/spec/unit/digestable_spec.rb +4 -4
- data/spec/unit/fetchers/git_fetcher_spec.rb +110 -39
- data/spec/unit/fetchers/net_fetcher_spec.rb +182 -72
- data/spec/unit/fetchers/path_fetcher_spec.rb +111 -0
- data/spec/unit/generator_spec.rb +137 -0
- data/spec/unit/git_cache_spec.rb +24 -34
- data/spec/unit/library_spec.rb +21 -82
- data/spec/unit/metadata_spec.rb +207 -0
- data/spec/unit/ohai_spec.rb +0 -7
- data/spec/unit/omnibus_spec.rb +41 -36
- data/spec/unit/package_spec.rb +1 -216
- data/spec/unit/packagers/base_spec.rb +76 -190
- data/spec/unit/packagers/bff_spec.rb +160 -0
- data/spec/unit/packagers/deb_spec.rb +324 -0
- data/spec/unit/packagers/makeself_spec.rb +80 -0
- data/spec/unit/packagers/msi_spec.rb +267 -0
- data/spec/unit/packagers/pkg_spec.rb +219 -0
- data/spec/unit/packagers/rpm_spec.rb +328 -0
- data/spec/unit/project_spec.rb +217 -80
- data/spec/unit/publisher_spec.rb +6 -2
- data/spec/unit/publishers/artifactory_publisher_spec.rb +1 -1
- data/spec/unit/publishers/s3_publisher_spec.rb +1 -1
- data/spec/unit/s3_cacher_spec.rb +22 -5
- data/spec/unit/software_spec.rb +89 -232
- data/spec/unit/util_spec.rb +188 -0
- metadata +159 -402
- data/features/commands/_deprecated.feature +0 -84
- data/lib/omnibus/cleanroom.rb +0 -141
- data/lib/omnibus/cli/deprecated.rb +0 -132
- data/lib/omnibus/generator_files/mac_pkg/license.html.erb +0 -1
- data/lib/omnibus/generator_files/mac_pkg/welcome.html.erb +0 -9
- data/lib/omnibus/generator_files/project.rb.erb +0 -20
- data/lib/omnibus/generator_files/software/c-example.rb.erb +0 -42
- data/lib/omnibus/generator_files/software/erlang-example.rb.erb +0 -38
- data/lib/omnibus/generator_files/software/ruby-example.rb.erb +0 -24
- data/lib/omnibus/generator_files/windows_msi/localization-en-us.wxl.erb +0 -20
- data/lib/omnibus/generator_files/windows_msi/parameters.wxi.erb +0 -9
- data/lib/omnibus/packagers/mac_dmg.rb +0 -235
- data/lib/omnibus/packagers/mac_pkg.rb +0 -176
- data/lib/omnibus/packagers/windows_msi.rb +0 -109
- data/spec/data/complicated/config/patches/bzip2/makefile_take_env_vars.patch +0 -15
- data/spec/data/complicated/config/patches/couchdb/patch_for_couchjs_stack.patch +0 -19
- data/spec/data/complicated/config/patches/gd/gd-2.0.33-configure-libpng.patch +0 -100
- data/spec/data/complicated/config/patches/keepalived/keepalived-1.2.9_opscode_centos_5.patch +0 -15
- data/spec/data/complicated/config/patches/libedit/freebsd-vi-fix.patch +0 -24
- data/spec/data/complicated/config/patches/libiconv/libiconv-1.14_srclib_stdio.in.h-remove-gets-declarations.patch +0 -29
- data/spec/data/complicated/config/patches/libwrap/tcp_wrappers-7.6-makefile-dest-fix.patch +0 -35
- data/spec/data/complicated/config/patches/libwrap/tcp_wrappers-7.6-malloc-fix.patch +0 -13
- data/spec/data/complicated/config/patches/libwrap/tcp_wrappers-7.6-shared_lib_plus_plus-1.patch +0 -1035
- data/spec/data/complicated/config/patches/logrotate/logrotate_basedir_override.patch +0 -12
- data/spec/data/complicated/config/patches/ncurses/ncurses-5.9-solaris-xopen_source_extended-detection.patch +0 -11
- data/spec/data/complicated/config/patches/ncurses/ncurses-clang.patch +0 -42
- data/spec/data/complicated/config/patches/ncurses/patch-aa +0 -23
- data/spec/data/complicated/config/patches/ncurses/patch-ab +0 -44
- data/spec/data/complicated/config/patches/ncurses/patch-ac +0 -40
- data/spec/data/complicated/config/patches/ncurses/patch-ad +0 -12
- data/spec/data/complicated/config/patches/ncurses/patch-aix-configure +0 -23
- data/spec/data/complicated/config/patches/ncurses/patch-cxx_cursesf.h +0 -22
- data/spec/data/complicated/config/patches/ncurses/patch-cxx_cursesm.h +0 -22
- data/spec/data/complicated/config/patches/nrpe/fix_for_runit.patch +0 -64
- data/spec/data/complicated/config/patches/openssl/openssl-1.0.1f-do-not-build-docs.patch +0 -101
- data/spec/data/complicated/config/patches/postgresql/postgresql-9.1.2-configure-ncurses-fix.patch +0 -12
- data/spec/data/complicated/config/patches/ruby/patch-configure +0 -103
- data/spec/data/complicated/config/patches/ruby/ruby-aix-configure.patch +0 -10
- data/spec/data/complicated/config/patches/ruby/ruby-openssl-1.0.1c.patch +0 -42
- data/spec/data/complicated/config/patches/ruby/ruby_aix_1_9_3_448_ssl_EAGAIN.patch +0 -57
- data/spec/data/complicated/config/patches/ruby/rvm-cflags.patch +0 -27
- data/spec/data/complicated/config/projects/angrychef.rb +0 -32
- data/spec/data/complicated/config/projects/chef-windows.rb +0 -32
- data/spec/data/complicated/config/projects/chef.rb +0 -32
- data/spec/data/complicated/config/projects/chefdk-windows.rb +0 -41
- data/spec/data/complicated/config/projects/chefdk.rb +0 -44
- data/spec/data/complicated/config/software/appbundler.rb +0 -25
- data/spec/data/complicated/config/software/autoconf.rb +0 -35
- data/spec/data/complicated/config/software/automake.rb +0 -39
- data/spec/data/complicated/config/software/berkshelf.rb +0 -44
- data/spec/data/complicated/config/software/bundler.rb +0 -25
- data/spec/data/complicated/config/software/bzip2.rb +0 -46
- data/spec/data/complicated/config/software/cacerts.rb +0 -44
- data/spec/data/complicated/config/software/chef-client-msi.rb +0 -87
- data/spec/data/complicated/config/software/chef-gem.rb +0 -26
- data/spec/data/complicated/config/software/chef-vault.rb +0 -43
- data/spec/data/complicated/config/software/chef-windows.rb +0 -158
- data/spec/data/complicated/config/software/chef.rb +0 -170
- data/spec/data/complicated/config/software/chefdk.rb +0 -103
- data/spec/data/complicated/config/software/couchdb.rb +0 -53
- data/spec/data/complicated/config/software/curl.rb +0 -48
- data/spec/data/complicated/config/software/erlang.rb +0 -65
- data/spec/data/complicated/config/software/expat.rb +0 -21
- data/spec/data/complicated/config/software/fcgi.rb +0 -56
- data/spec/data/complicated/config/software/fcgiwrap.rb +0 -41
- data/spec/data/complicated/config/software/gd.rb +0 -56
- data/spec/data/complicated/config/software/gdbm.rb +0 -40
- data/spec/data/complicated/config/software/gecode.rb +0 -48
- data/spec/data/complicated/config/software/git.rb +0 -40
- data/spec/data/complicated/config/software/help2man.rb +0 -30
- data/spec/data/complicated/config/software/icu.rb +0 -40
- data/spec/data/complicated/config/software/jre.rb +0 -48
- data/spec/data/complicated/config/software/keepalived.rb +0 -43
- data/spec/data/complicated/config/software/libarchive.rb +0 -50
- data/spec/data/complicated/config/software/libedit.rb +0 -69
- data/spec/data/complicated/config/software/libffi.rb +0 -71
- data/spec/data/complicated/config/software/libgcc.rb +0 -39
- data/spec/data/complicated/config/software/libiconv.rb +0 -55
- data/spec/data/complicated/config/software/libjpeg.rb +0 -39
- data/spec/data/complicated/config/software/libpng.rb +0 -38
- data/spec/data/complicated/config/software/libtool.rb +0 -52
- data/spec/data/complicated/config/software/libwrap.rb +0 -50
- data/spec/data/complicated/config/software/libxml2.rb +0 -51
- data/spec/data/complicated/config/software/libxslt.rb +0 -52
- data/spec/data/complicated/config/software/libyaml-windows.rb +0 -43
- data/spec/data/complicated/config/software/libyaml.rb +0 -62
- data/spec/data/complicated/config/software/logrotate.rb +0 -41
- data/spec/data/complicated/config/software/makedepend.rb +0 -73
- data/spec/data/complicated/config/software/mysql2.rb +0 -42
- data/spec/data/complicated/config/software/nagios-plugins.rb +0 -53
- data/spec/data/complicated/config/software/nagios.rb +0 -66
- data/spec/data/complicated/config/software/ncurses.rb +0 -149
- data/spec/data/complicated/config/software/nginx.rb +0 -40
- data/spec/data/complicated/config/software/nodejs.rb +0 -44
- data/spec/data/complicated/config/software/nokogiri.rb +0 -55
- data/spec/data/complicated/config/software/nrpe.rb +0 -61
- data/spec/data/complicated/config/software/ohai.rb +0 -64
- data/spec/data/complicated/config/software/omnibus-ctl.rb +0 -34
- data/spec/data/complicated/config/software/openresty.rb +0 -67
- data/spec/data/complicated/config/software/openssl.rb +0 -158
- data/spec/data/complicated/config/software/pcre.rb +0 -42
- data/spec/data/complicated/config/software/perl-extutils-embed.rb +0 -15
- data/spec/data/complicated/config/software/perl-extutils-makemaker.rb +0 -15
- data/spec/data/complicated/config/software/perl.rb +0 -48
- data/spec/data/complicated/config/software/perl_pg_driver.rb +0 -12
- data/spec/data/complicated/config/software/php.rb +0 -41
- data/spec/data/complicated/config/software/pip.rb +0 -30
- data/spec/data/complicated/config/software/pkg-config.rb +0 -66
- data/spec/data/complicated/config/software/popt.rb +0 -47
- data/spec/data/complicated/config/software/postgresql.rb +0 -51
- data/spec/data/complicated/config/software/preparation.rb +0 -30
- data/spec/data/complicated/config/software/pygments.rb +0 -25
- data/spec/data/complicated/config/software/python.rb +0 -49
- data/spec/data/complicated/config/software/rabbitmq.rb +0 -36
- data/spec/data/complicated/config/software/rebar.rb +0 -36
- data/spec/data/complicated/config/software/redis.rb +0 -33
- data/spec/data/complicated/config/software/rsync.rb +0 -48
- data/spec/data/complicated/config/software/ruby-windows-devkit.rb +0 -30
- data/spec/data/complicated/config/software/ruby-windows.rb +0 -30
- data/spec/data/complicated/config/software/ruby.rb +0 -162
- data/spec/data/complicated/config/software/rubygems-customization.rb +0 -57
- data/spec/data/complicated/config/software/rubygems.rb +0 -37
- data/spec/data/complicated/config/software/runit.rb +0 -118
- data/spec/data/complicated/config/software/server-jre.rb +0 -46
- data/spec/data/complicated/config/software/setuptools.rb +0 -30
- data/spec/data/complicated/config/software/spawn-fcgi.rb +0 -40
- data/spec/data/complicated/config/software/sphinx.rb +0 -26
- data/spec/data/complicated/config/software/spidermonkey.rb +0 -60
- data/spec/data/complicated/config/software/sqitch.rb +0 -24
- data/spec/data/complicated/config/software/test-kitchen.rb +0 -39
- data/spec/data/complicated/config/software/unicorn.rb +0 -27
- data/spec/data/complicated/config/software/util-macros.rb +0 -46
- data/spec/data/complicated/config/software/xproto.rb +0 -46
- data/spec/data/complicated/config/software/yajl.rb +0 -30
- data/spec/data/complicated/config/software/zlib.rb +0 -67
- data/spec/data/overrides/bad_line.overrides +0 -3
- data/spec/data/overrides/good.overrides +0 -5
- data/spec/data/overrides/with_dupes.overrides +0 -4
- data/spec/data/projects/chefdk.rb +0 -41
- data/spec/data/projects/sample.rb +0 -13
- data/spec/data/software/erchef.rb +0 -42
- data/spec/data/software/zlib.rb +0 -67
- data/spec/fixtures/sample/files/mac_dmg/Resources/background.png +0 -0
- data/spec/fixtures/sample/files/mac_dmg/Resources/icon.png +0 -0
- data/spec/fixtures/sample/files/mac_pkg/Resources/background.png +0 -0
- data/spec/fixtures/sample/files/mac_pkg/Resources/license.html +0 -1
- data/spec/fixtures/sample/files/mac_pkg/Resources/welcome.html +0 -9
- data/spec/fixtures/sample/files/windows_msi/Resources/assets/LICENSE.rtf +0 -8
- data/spec/fixtures/sample/files/windows_msi/Resources/assets/banner_background.bmp +0 -0
- data/spec/fixtures/sample/files/windows_msi/Resources/assets/dialog_background.bmp +0 -0
- data/spec/fixtures/sample/files/windows_msi/Resources/assets/project.ico +0 -0
- data/spec/fixtures/sample/files/windows_msi/Resources/assets/project_16x16.ico +0 -0
- data/spec/fixtures/sample/files/windows_msi/Resources/assets/project_32x32.ico +0 -0
- data/spec/fixtures/sample/files/windows_msi/Resources/parameters.wxi.erb +0 -9
- data/spec/fixtures/sample/files/windows_msi/Resources/source.wxs +0 -74
- data/spec/integration/packagers/mac_spec.rb +0 -58
- data/spec/integration/packagers/windows_spec.rb +0 -70
- data/spec/unit/packagers/mac_pkg_spec.rb +0 -151
@@ -0,0 +1,278 @@
|
|
1
|
+
#
|
2
|
+
# Copyright 2014 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::PKG < Packager::Base
|
19
|
+
id :pkg
|
20
|
+
|
21
|
+
setup do
|
22
|
+
# Create the resources directory
|
23
|
+
create_directory(resources_dir)
|
24
|
+
|
25
|
+
# Render the license
|
26
|
+
render_template(resource_path('license.html.erb'),
|
27
|
+
destination: "#{resources_dir}/license.html",
|
28
|
+
variables: {
|
29
|
+
name: project.name,
|
30
|
+
friendly_name: project.friendly_name,
|
31
|
+
maintainer: project.maintainer,
|
32
|
+
}
|
33
|
+
)
|
34
|
+
|
35
|
+
# Render the welcome template
|
36
|
+
render_template(resource_path('welcome.html.erb'),
|
37
|
+
destination: "#{resources_dir}/welcome.html",
|
38
|
+
variables: {
|
39
|
+
name: project.name,
|
40
|
+
friendly_name: project.friendly_name,
|
41
|
+
maintainer: project.maintainer,
|
42
|
+
}
|
43
|
+
)
|
44
|
+
|
45
|
+
# "Render" the assets
|
46
|
+
copy_file(resource_path('background.png'), "#{resources_dir}/background.png")
|
47
|
+
end
|
48
|
+
|
49
|
+
build do
|
50
|
+
build_component_pkg
|
51
|
+
|
52
|
+
write_distribution_file
|
53
|
+
|
54
|
+
build_product_pkg
|
55
|
+
end
|
56
|
+
|
57
|
+
#
|
58
|
+
# @!group DSL methods
|
59
|
+
# --------------------------------------------------
|
60
|
+
|
61
|
+
#
|
62
|
+
# The identifer for the PKG package.
|
63
|
+
#
|
64
|
+
# @example
|
65
|
+
# identifier 'com.getchef.chefdk'
|
66
|
+
#
|
67
|
+
# @param [String] val
|
68
|
+
# the package identifier
|
69
|
+
#
|
70
|
+
# @return [String]
|
71
|
+
#
|
72
|
+
def identifier(val = NULL)
|
73
|
+
if null?(val)
|
74
|
+
@identifier
|
75
|
+
else
|
76
|
+
@identifier = val
|
77
|
+
end
|
78
|
+
end
|
79
|
+
expose :identifier
|
80
|
+
|
81
|
+
#
|
82
|
+
# Set or return the signing identity. If this value is provided, Omnibus
|
83
|
+
# will attempt to sign the PKG.
|
84
|
+
#
|
85
|
+
# @example
|
86
|
+
# signing_identity "foo"
|
87
|
+
#
|
88
|
+
# @param [String] val
|
89
|
+
# the identity to use when signing the PKG
|
90
|
+
#
|
91
|
+
# @return [String]
|
92
|
+
# the PKG-signing identity
|
93
|
+
#
|
94
|
+
def signing_identity(val = NULL)
|
95
|
+
if null?(val)
|
96
|
+
@signing_identity
|
97
|
+
else
|
98
|
+
@signing_identity = val
|
99
|
+
end
|
100
|
+
end
|
101
|
+
expose :signing_identity
|
102
|
+
|
103
|
+
#
|
104
|
+
# @!endgroup
|
105
|
+
# --------------------------------------------------
|
106
|
+
|
107
|
+
# @see Base#package_name
|
108
|
+
def package_name
|
109
|
+
"#{safe_project_name}-#{safe_version}-#{safe_build_iteration}.pkg"
|
110
|
+
end
|
111
|
+
|
112
|
+
#
|
113
|
+
# The full path where the product package was/will be written.
|
114
|
+
#
|
115
|
+
# @return [String]
|
116
|
+
#
|
117
|
+
def final_pkg
|
118
|
+
File.expand_path("#{Config.package_dir}/#{package_name}")
|
119
|
+
end
|
120
|
+
|
121
|
+
#
|
122
|
+
# The path where the product package resources will live. We cannot store
|
123
|
+
# resources in the top-level staging dir, because +productbuild+'s
|
124
|
+
# +--resources+ flag expects a directory that does not contain the parent
|
125
|
+
# package.
|
126
|
+
#
|
127
|
+
# @return [String]
|
128
|
+
#
|
129
|
+
def resources_dir
|
130
|
+
File.expand_path("#{staging_dir}/Resources")
|
131
|
+
end
|
132
|
+
|
133
|
+
#
|
134
|
+
# Construct the intermediate build product. It can be installed with the
|
135
|
+
# Installer.app, but doesn't contain the data needed to customize the
|
136
|
+
# installer UI.
|
137
|
+
#
|
138
|
+
# @return [void]
|
139
|
+
#
|
140
|
+
def build_component_pkg
|
141
|
+
command = <<-EOH.gsub(/^ {8}/, '')
|
142
|
+
pkgbuild \\
|
143
|
+
--identifier "#{safe_identifier}" \\
|
144
|
+
--version "#{safe_version}" \\
|
145
|
+
--scripts "#{project.package_scripts_path}" \\
|
146
|
+
--root "#{project.install_dir}" \\
|
147
|
+
--install-location "#{project.install_dir}" \\
|
148
|
+
"#{component_pkg}"
|
149
|
+
EOH
|
150
|
+
|
151
|
+
Dir.chdir(staging_dir) do
|
152
|
+
shellout!(command)
|
153
|
+
end
|
154
|
+
end
|
155
|
+
|
156
|
+
#
|
157
|
+
# Write the Distribution file to the staging area. This method generates the
|
158
|
+
# content of the Distribution file, which is used by +productbuild+ to
|
159
|
+
# select the component packages to include in the product package.
|
160
|
+
#
|
161
|
+
# It also includes information used to customize the UI of the Mac OS X
|
162
|
+
# installer.
|
163
|
+
#
|
164
|
+
# @return [void]
|
165
|
+
#
|
166
|
+
def write_distribution_file
|
167
|
+
render_template(resource_path('distribution.xml.erb'),
|
168
|
+
destination: "#{staging_dir}/Distribution",
|
169
|
+
mode: 0600,
|
170
|
+
variables: {
|
171
|
+
friendly_name: project.friendly_name,
|
172
|
+
identifier: safe_identifier,
|
173
|
+
version: safe_version,
|
174
|
+
component_pkg: component_pkg,
|
175
|
+
}
|
176
|
+
)
|
177
|
+
end
|
178
|
+
|
179
|
+
#
|
180
|
+
# Construct the product package. The generated package is the final build
|
181
|
+
# product that is shipped to end users.
|
182
|
+
#
|
183
|
+
# @return [void]
|
184
|
+
#
|
185
|
+
def build_product_pkg
|
186
|
+
command = <<-EOH.gsub(/^ {8}/, '')
|
187
|
+
productbuild \\
|
188
|
+
--distribution "#{staging_dir}/Distribution" \\
|
189
|
+
--resources "#{resources_dir}" \\
|
190
|
+
EOH
|
191
|
+
|
192
|
+
command << %Q( --sign "#{signing_identity}" \\\n) if signing_identity
|
193
|
+
command << %Q( "#{final_pkg}")
|
194
|
+
command << %Q(\n)
|
195
|
+
|
196
|
+
Dir.chdir(staging_dir) do
|
197
|
+
shellout!(command)
|
198
|
+
end
|
199
|
+
end
|
200
|
+
|
201
|
+
#
|
202
|
+
# The name of the (only) component package.
|
203
|
+
#
|
204
|
+
# @return [String] the filename of the component .pkg file to create.
|
205
|
+
#
|
206
|
+
def component_pkg
|
207
|
+
"#{safe_project_name}-core.pkg"
|
208
|
+
end
|
209
|
+
|
210
|
+
#
|
211
|
+
# Return the PKG-ready project name, removing any invalid characters.
|
212
|
+
#
|
213
|
+
# @return [String]
|
214
|
+
#
|
215
|
+
def safe_project_name
|
216
|
+
if project.name =~ /\A[[:alnum:]]+\z/
|
217
|
+
project.name.dup
|
218
|
+
else
|
219
|
+
converted = project.name.downcase.gsub(/[^[:alnum:]+]/, '')
|
220
|
+
|
221
|
+
log.warn(log_key) do
|
222
|
+
"The `name' compontent of Mac package names can only include " \
|
223
|
+
"alphabetical characters (a-z, A-Z), and numbers (0-9). Converting " \
|
224
|
+
"`#{project.name}' to `#{converted}'."
|
225
|
+
end
|
226
|
+
|
227
|
+
converted
|
228
|
+
end
|
229
|
+
end
|
230
|
+
|
231
|
+
#
|
232
|
+
# The identifier for this mac package (the com.whatever.thing.whatever).
|
233
|
+
# This is a configurable project value, but a default value is calculated if
|
234
|
+
# one is not given.
|
235
|
+
#
|
236
|
+
# @return [String]
|
237
|
+
#
|
238
|
+
def safe_identifier
|
239
|
+
return identifier if identifier
|
240
|
+
|
241
|
+
maintainer = project.maintainer.gsub(/[^[:alnum:]+]/, '').downcase
|
242
|
+
"test.#{maintainer}.pkg.#{safe_project_name}"
|
243
|
+
end
|
244
|
+
|
245
|
+
#
|
246
|
+
# This is actually just the regular build_iternation, but it felt lonely
|
247
|
+
# among all the other +safe_*+ methods.
|
248
|
+
#
|
249
|
+
# @return [String]
|
250
|
+
#
|
251
|
+
def safe_build_iteration
|
252
|
+
project.build_iteration
|
253
|
+
end
|
254
|
+
|
255
|
+
#
|
256
|
+
# Return the PKG-ready version, converting any invalid characters to
|
257
|
+
# dashes (+-+).
|
258
|
+
#
|
259
|
+
# @return [String]
|
260
|
+
#
|
261
|
+
def safe_version
|
262
|
+
if project.build_version =~ /\A[a-zA-Z0-9\.\+\-]+\z/
|
263
|
+
project.build_version.dup
|
264
|
+
else
|
265
|
+
converted = project.build_version.gsub(/[^a-zA-Z0-9\.\+\-]+/, '-')
|
266
|
+
|
267
|
+
log.warn(log_key) do
|
268
|
+
"The `version' compontent of Mac package names can only include " \
|
269
|
+
"alphabetical characters (a-z, A-Z), numbers (0-9), dots (.), " \
|
270
|
+
"plus signs (+), and dashes (-). Converting " \
|
271
|
+
"`#{project.build_version}' to `#{converted}'."
|
272
|
+
end
|
273
|
+
|
274
|
+
converted
|
275
|
+
end
|
276
|
+
end
|
277
|
+
end
|
278
|
+
end
|
@@ -0,0 +1,438 @@
|
|
1
|
+
#
|
2
|
+
# Copyright 2014 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
|
+
# need to make sure rpmbuild is installed
|
18
|
+
|
19
|
+
module Omnibus
|
20
|
+
class Packager::RPM < Packager::Base
|
21
|
+
# @return [Array]
|
22
|
+
SCRIPTS = %w(pre post preun postun verifyscript pretans posttrans).freeze
|
23
|
+
|
24
|
+
id :rpm
|
25
|
+
|
26
|
+
setup do
|
27
|
+
# Create our magic directories
|
28
|
+
create_directory("#{staging_dir}/BUILD")
|
29
|
+
create_directory("#{staging_dir}/RPMS")
|
30
|
+
create_directory("#{staging_dir}/SRPMS")
|
31
|
+
create_directory("#{staging_dir}/SOURCES")
|
32
|
+
create_directory("#{staging_dir}/SPECS")
|
33
|
+
|
34
|
+
# Copy the full-stack installer into the SOURCE directory, accounting for
|
35
|
+
# any excluded files.
|
36
|
+
#
|
37
|
+
# /opt/hamlet => /tmp/daj29013/BUILD/opt/hamlet
|
38
|
+
destination = File.join(build_dir, project.install_dir)
|
39
|
+
FileSyncer.sync(project.install_dir, destination, exclude: exclusions)
|
40
|
+
|
41
|
+
# Copy over any user-specified extra package files.
|
42
|
+
#
|
43
|
+
# Files retain their relative paths inside the scratch directory, so
|
44
|
+
# we need to grab the dirname of the file, create that directory, and
|
45
|
+
# then copy the file into that directory.
|
46
|
+
#
|
47
|
+
# extra_package_file '/path/to/foo.txt' #=> /tmp/BUILD/path/to/foo.txt
|
48
|
+
project.extra_package_files.each do |file|
|
49
|
+
parent = File.dirname(file)
|
50
|
+
destination = File.join("#{staging_dir}/BUILD", parent)
|
51
|
+
|
52
|
+
create_directory(destination)
|
53
|
+
copy_file(file, destination)
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
57
|
+
build do
|
58
|
+
# Generate the spec
|
59
|
+
write_rpm_spec
|
60
|
+
|
61
|
+
# Generate the rpm
|
62
|
+
create_rpm_file
|
63
|
+
end
|
64
|
+
|
65
|
+
#
|
66
|
+
# @!group DSL methods
|
67
|
+
# --------------------------------------------------
|
68
|
+
|
69
|
+
#
|
70
|
+
# Set or return the signing passphrase. If this value is provided,
|
71
|
+
# Omnibus will attempt to sign the RPM.
|
72
|
+
#
|
73
|
+
# @example
|
74
|
+
# signing_passphrase "foo"
|
75
|
+
#
|
76
|
+
# @param [String] val
|
77
|
+
# the passphrase to use when signing the RPM
|
78
|
+
#
|
79
|
+
# @return [String]
|
80
|
+
# the RPM-signing passphrase
|
81
|
+
#
|
82
|
+
def signing_passphrase(val = NULL)
|
83
|
+
if null?(val)
|
84
|
+
@signing_passphrase
|
85
|
+
else
|
86
|
+
@signing_passphrase = val
|
87
|
+
end
|
88
|
+
end
|
89
|
+
expose :signing_passphrase
|
90
|
+
|
91
|
+
#
|
92
|
+
# Set or return the vendor who made this package.
|
93
|
+
#
|
94
|
+
# @example
|
95
|
+
# vendor "Seth Vargo <sethvargo@gmail.com>"
|
96
|
+
#
|
97
|
+
# @param [String] val
|
98
|
+
# the vendor who make this package
|
99
|
+
#
|
100
|
+
# @return [String]
|
101
|
+
# the vendor who make this package
|
102
|
+
#
|
103
|
+
def vendor(val = NULL)
|
104
|
+
if null?(val)
|
105
|
+
@vendor || 'Omnibus <omnibus@getchef.com>'
|
106
|
+
else
|
107
|
+
unless val.is_a?(String)
|
108
|
+
raise InvalidValue.new(:vendor, 'be a String')
|
109
|
+
end
|
110
|
+
|
111
|
+
@vendor = val
|
112
|
+
end
|
113
|
+
end
|
114
|
+
expose :vendor
|
115
|
+
|
116
|
+
#
|
117
|
+
# Set or return the license for this package.
|
118
|
+
#
|
119
|
+
# @example
|
120
|
+
# license "Apache 2.0"
|
121
|
+
#
|
122
|
+
# @param [String] val
|
123
|
+
# the license for this package
|
124
|
+
#
|
125
|
+
# @return [String]
|
126
|
+
# the license for this package
|
127
|
+
#
|
128
|
+
def license(val = NULL)
|
129
|
+
if null?(val)
|
130
|
+
@license || 'unknown'
|
131
|
+
else
|
132
|
+
unless val.is_a?(String)
|
133
|
+
raise InvalidValue.new(:license, 'be a String')
|
134
|
+
end
|
135
|
+
|
136
|
+
@license = val
|
137
|
+
end
|
138
|
+
end
|
139
|
+
expose :license
|
140
|
+
|
141
|
+
#
|
142
|
+
# Set or return the priority for this package.
|
143
|
+
#
|
144
|
+
# @example
|
145
|
+
# priority "extra"
|
146
|
+
#
|
147
|
+
# @param [String] val
|
148
|
+
# the priority for this package
|
149
|
+
#
|
150
|
+
# @return [String]
|
151
|
+
# the priority for this package
|
152
|
+
#
|
153
|
+
def priority(val = NULL)
|
154
|
+
if null?(val)
|
155
|
+
@priority || 'extra'
|
156
|
+
else
|
157
|
+
unless val.is_a?(String)
|
158
|
+
raise InvalidValue.new(:priority, 'be a String')
|
159
|
+
end
|
160
|
+
|
161
|
+
@priority = val
|
162
|
+
end
|
163
|
+
end
|
164
|
+
expose :priority
|
165
|
+
|
166
|
+
#
|
167
|
+
# Set or return the category for this package.
|
168
|
+
#
|
169
|
+
# @example
|
170
|
+
# category "databases"
|
171
|
+
#
|
172
|
+
# @param [String] val
|
173
|
+
# the category for this package
|
174
|
+
#
|
175
|
+
# @return [String]
|
176
|
+
# the category for this package
|
177
|
+
#
|
178
|
+
def category(val = NULL)
|
179
|
+
if null?(val)
|
180
|
+
@category || 'default'
|
181
|
+
else
|
182
|
+
unless val.is_a?(String)
|
183
|
+
raise InvalidValue.new(:category, 'be a String')
|
184
|
+
end
|
185
|
+
|
186
|
+
@category = val
|
187
|
+
end
|
188
|
+
end
|
189
|
+
expose :category
|
190
|
+
|
191
|
+
#
|
192
|
+
# @!endgroup
|
193
|
+
# --------------------------------------------------
|
194
|
+
|
195
|
+
#
|
196
|
+
# @return [String]
|
197
|
+
#
|
198
|
+
def package_name
|
199
|
+
"#{safe_project_name}-#{safe_version}-#{safe_build_iteration}.#{safe_architecture}.rpm"
|
200
|
+
end
|
201
|
+
|
202
|
+
#
|
203
|
+
# The path to the +BUILD+ directory inside the staging directory.
|
204
|
+
#
|
205
|
+
# @return [String]
|
206
|
+
#
|
207
|
+
def build_dir
|
208
|
+
@build_dir ||= File.join(staging_dir, 'BUILD')
|
209
|
+
end
|
210
|
+
|
211
|
+
#
|
212
|
+
# Render an rpm spec file in +SPECS/#{name}.spec+ using the supplied ERB
|
213
|
+
# template.
|
214
|
+
#
|
215
|
+
# @return [void]
|
216
|
+
#
|
217
|
+
def write_rpm_spec
|
218
|
+
# Create a map of scripts that exist and their contents
|
219
|
+
scripts = SCRIPTS.inject({}) do |hash, name|
|
220
|
+
path = File.join(project.package_scripts_path, name)
|
221
|
+
|
222
|
+
if File.file?(path)
|
223
|
+
hash[name] = File.read(path)
|
224
|
+
end
|
225
|
+
|
226
|
+
hash
|
227
|
+
end
|
228
|
+
|
229
|
+
# Get a list of user-declared config files
|
230
|
+
config_files = project.config_files.map { |file| rpm_safe(file) }
|
231
|
+
|
232
|
+
# Get a list of all files
|
233
|
+
files = FileSyncer.glob("#{build_dir}/**/*")
|
234
|
+
.map { |path| path.gsub("#{build_dir}/", '') }
|
235
|
+
.map { |path| "/#{path}" }
|
236
|
+
.map { |path| rpm_safe(path) }
|
237
|
+
.reject { |path| config_files.include?(path) }
|
238
|
+
|
239
|
+
render_template(resource_path('spec.erb'),
|
240
|
+
destination: spec_file,
|
241
|
+
variables: {
|
242
|
+
name: safe_project_name,
|
243
|
+
version: safe_version,
|
244
|
+
iteration: safe_build_iteration,
|
245
|
+
vendor: vendor,
|
246
|
+
license: license,
|
247
|
+
architecture: safe_architecture,
|
248
|
+
maintainer: project.maintainer,
|
249
|
+
homepage: project.homepage,
|
250
|
+
description: project.description,
|
251
|
+
priority: priority,
|
252
|
+
category: category,
|
253
|
+
conflicts: project.conflicts,
|
254
|
+
replaces: project.replaces,
|
255
|
+
dependencies: project.runtime_dependencies,
|
256
|
+
user: project.package_user,
|
257
|
+
group: project.package_group,
|
258
|
+
scripts: scripts,
|
259
|
+
config_files: config_files,
|
260
|
+
files: files,
|
261
|
+
}
|
262
|
+
)
|
263
|
+
end
|
264
|
+
|
265
|
+
#
|
266
|
+
# Generate the RPM file using +rpmbuild+. The use of the +fakeroot+ command
|
267
|
+
# is required so that the package is owned by +root:root+, but the build
|
268
|
+
# user does not need to have sudo permissions.
|
269
|
+
#
|
270
|
+
# @return [void]
|
271
|
+
#
|
272
|
+
def create_rpm_file
|
273
|
+
log.info(log_key) { "Creating .rpm file" }
|
274
|
+
|
275
|
+
command = %|fakeroot rpmbuild|
|
276
|
+
command << %| -bb|
|
277
|
+
command << %| --buildroot #{staging_dir}/BUILD|
|
278
|
+
command << %| --define "_topdir #{staging_dir}"|
|
279
|
+
|
280
|
+
if signing_passphrase
|
281
|
+
if File.exist?("#{ENV['HOME']}/.rpmmacros")
|
282
|
+
log.info(log_key) { "Detected .rpmmacros file at `#{ENV['HOME']}'" }
|
283
|
+
else
|
284
|
+
log.info(log_key) { "Using default .rpmmacros file from Omnibus" }
|
285
|
+
|
286
|
+
# Generate a temporary home directory
|
287
|
+
home = Dir.mktmpdir
|
288
|
+
|
289
|
+
render_template(resource_path('rpmmacros.erb'),
|
290
|
+
destination: "#{home}/.rpmmacros",
|
291
|
+
variables: {
|
292
|
+
gpg_name: project.maintainer,
|
293
|
+
gpg_path: "#{ENV['HOME']}/.gnupg", # TODO: Make this configurable
|
294
|
+
}
|
295
|
+
)
|
296
|
+
|
297
|
+
command << " --sign"
|
298
|
+
command << " #{spec_file}"
|
299
|
+
|
300
|
+
with_rpm_signing do |signing_script|
|
301
|
+
shellout!("#{signing_script} \"#{command}\"", environment: { 'HOME' => home })
|
302
|
+
end
|
303
|
+
end
|
304
|
+
else
|
305
|
+
command << " #{spec_file}"
|
306
|
+
shellout!("#{command}")
|
307
|
+
end
|
308
|
+
|
309
|
+
FileSyncer.glob("#{staging_dir}/RPMS/**/*.rpm").each do |rpm|
|
310
|
+
copy_file(rpm, Config.package_dir)
|
311
|
+
end
|
312
|
+
end
|
313
|
+
|
314
|
+
#
|
315
|
+
# The full path to this spec file on disk.
|
316
|
+
#
|
317
|
+
# @return [String]
|
318
|
+
#
|
319
|
+
def spec_file
|
320
|
+
"#{staging_dir}/SPECS/#{package_name}.spec"
|
321
|
+
end
|
322
|
+
|
323
|
+
#
|
324
|
+
# Render the rpm signing script with secure permissions, call the given
|
325
|
+
# block with the path to the script, and ensure deletion of the script from
|
326
|
+
# disk since it contains sensitive information.
|
327
|
+
#
|
328
|
+
# @param [Proc] block
|
329
|
+
# the block to call
|
330
|
+
#
|
331
|
+
# @return [String]
|
332
|
+
#
|
333
|
+
def with_rpm_signing(&block)
|
334
|
+
directory = Dir.mktmpdir
|
335
|
+
destination = "#{directory}/sign-rpm"
|
336
|
+
|
337
|
+
render_template(resource_path('signing.erb'),
|
338
|
+
destination: destination,
|
339
|
+
mode: 0700,
|
340
|
+
variables: {
|
341
|
+
passphrase: signing_passphrase,
|
342
|
+
}
|
343
|
+
)
|
344
|
+
|
345
|
+
# Yield the destination to the block
|
346
|
+
block.call(destination)
|
347
|
+
ensure
|
348
|
+
remove_file(destination)
|
349
|
+
remove_directory(directory)
|
350
|
+
end
|
351
|
+
|
352
|
+
#
|
353
|
+
# Generate an RPM-safe name from the given string, doing the following:
|
354
|
+
#
|
355
|
+
# - Replace [ with [\[] to make rpm not use globs
|
356
|
+
# - Replace * with [*] to make rpm not use globs
|
357
|
+
# - Replace ? with [?] to make rpm not use globs
|
358
|
+
# - Replace % with [%] to make rpm not expand macros
|
359
|
+
#
|
360
|
+
# @param [String] string
|
361
|
+
# the string to sanitize
|
362
|
+
#
|
363
|
+
def rpm_safe(string)
|
364
|
+
string = "\"#{string}\"" if string[/\s/]
|
365
|
+
|
366
|
+
string.dup
|
367
|
+
.gsub("[", "[\\[]")
|
368
|
+
.gsub("*", "[*]")
|
369
|
+
.gsub("?", "[?]")
|
370
|
+
.gsub("%", "[%]")
|
371
|
+
end
|
372
|
+
|
373
|
+
#
|
374
|
+
# Return the RPM-ready project name, converting any invalid characters to
|
375
|
+
# dashes (+-+).
|
376
|
+
#
|
377
|
+
# @return [String]
|
378
|
+
#
|
379
|
+
def safe_project_name
|
380
|
+
if project.name =~ /\A[a-z0-9\.\+\-]+\z/
|
381
|
+
project.name.dup
|
382
|
+
else
|
383
|
+
converted = project.name.downcase.gsub(/[^a-z0-9\.\+\-]+/, '-')
|
384
|
+
|
385
|
+
log.warn(log_key) do
|
386
|
+
"The `name' compontent of RPM package names can only include " \
|
387
|
+
"lowercase alphabetical characters (a-z), numbers (0-9), dots (.), " \
|
388
|
+
"plus signs (+), and dashes (-). Converting `#{project.name}' to " \
|
389
|
+
"`#{converted}'."
|
390
|
+
end
|
391
|
+
|
392
|
+
converted
|
393
|
+
end
|
394
|
+
end
|
395
|
+
|
396
|
+
#
|
397
|
+
# This is actually just the regular build_iternation, but it felt lonely
|
398
|
+
# among all the other +safe_*+ methods.
|
399
|
+
#
|
400
|
+
# @return [String]
|
401
|
+
#
|
402
|
+
def safe_build_iteration
|
403
|
+
project.build_iteration
|
404
|
+
end
|
405
|
+
|
406
|
+
#
|
407
|
+
# RPM package versions cannot contain dashes, so we will convert them to
|
408
|
+
# underscores.
|
409
|
+
#
|
410
|
+
# @return [String]
|
411
|
+
#
|
412
|
+
def safe_version
|
413
|
+
if project.build_version =~ /\A[a-zA-Z0-9\.\+\-]+\z/
|
414
|
+
project.build_version.dup
|
415
|
+
else
|
416
|
+
converted = project.build_version.gsub(/[^a-zA-Z0-9\.\+\-]+/, '-')
|
417
|
+
|
418
|
+
log.warn(log_key) do
|
419
|
+
"The `version' compontent of RPM package names can only include " \
|
420
|
+
"alphabetical characters (a-z, A-Z), numbers (0-9), dots (.), " \
|
421
|
+
"plus signs (+), and dashes (-). Converting " \
|
422
|
+
"`#{project.build_version}' to `#{converted}'."
|
423
|
+
end
|
424
|
+
|
425
|
+
converted
|
426
|
+
end
|
427
|
+
end
|
428
|
+
|
429
|
+
#
|
430
|
+
# The architecture for this RPM package.
|
431
|
+
#
|
432
|
+
# @return [String]
|
433
|
+
#
|
434
|
+
def safe_architecture
|
435
|
+
Ohai['kernel']['machine']
|
436
|
+
end
|
437
|
+
end
|
438
|
+
end
|