Commit fd95fde3 authored by Marin Jankovski's avatar Marin Jankovski

Merge tag 'v5.0.0' of https://github.com/chef/omnibus into upgrade_omnibus_version

Version 5.0.0
parents dc6b89b2 c078b22c
rvm: rvm:
- 2.0.0 - 2.0.0
- 2.1 - 2.1
- 2.2
bundler_args: "--jobs 7 --without docs local" bundler_args: "--jobs 7 --without docs local"
branches: branches:
only: only:
......
Omnibus CHANGELOG Omnibus CHANGELOG
================= =================
v5.0.0 (November 10, 2015)
--------------------------
### New Features
- Wind River Linux 5 support for Cisco Nexus devices (#539)
- [artifactory publisher] Support custom properties in Artifactory publishing (#568)
- [msi packager] New "fast" mode for MSI packager (#565)
- Change the `appbundler` DSL method to not make an apps dir
- Unit and functional tests now run on Windows (and are tested by Appveyor) (#556, #557)
### Bug Fixes
- [msi packager] Fix missing package name in signature (#541)
- [rpm packager] Fix building RPMs on ARM platforms (#542)
- [bff packager] Fix regression with AIX package ownership in staging directory (#553)
- [solaris packager] Use the proper architecture value in Solaris packages (#554, #555)
- Add info message for publish cli corner case (#551)
- [net fetcher] missing checksum raises exception (#549)
### Potentially Breaking Changes
- Dropped Ruby 1.9.x support (#567)
v4.1.0 (September 1, 2015) v4.1.0 (September 1, 2015)
------------------------- -------------------------
### New Features ### New Features
......
...@@ -18,9 +18,10 @@ project lead. ...@@ -18,9 +18,10 @@ project lead.
## Maintainers ## Maintainers
* [Daniel DeLeo](https://github.com/danielsdeleo) * [Daniel DeLeo](https://github.com/danielsdeleo)
* [Jay Mundrawala](https://github.com/jdmundrawala) * [Jay Mundrawala](https://github.com/jaym)
* [Lamont Granquist](https://github.com/lamont-granquist) * [Lamont Granquist](https://github.com/lamont-granquist)
* [Scott Hain](https://github.com/scotthain) * [Scott Hain](https://github.com/scotthain)
* [Seth Vargo](http://github.com/sethvargo) * [Seth Vargo](http://github.com/sethvargo)
* [Steven Danna](https://github.com/stevendanna) * [Steven Danna](https://github.com/stevendanna)
* [Yvonne Lam](http://github.com/yzl) * [Yvonne Lam](http://github.com/yzl)
* [Thom May](https://github.com/thommay)
...@@ -204,7 +204,7 @@ Additionally, there are a number of DSL methods avaiable inside the `build` bloc ...@@ -204,7 +204,7 @@ Additionally, there are a number of DSL methods avaiable inside the `build` bloc
For more DSL methods, please consult the [`Builder` documentation](http://rubydoc.info/github/opscode/omnibus/Omnibus/Builder). For more DSL methods, please consult the [`Builder` documentation](http://rubydoc.info/github/opscode/omnibus/Omnibus/Builder).
You can support building multiple verisons of the same software in the same software definition file using the `version` method and giving a block: You can support building multiple versions of the same software in the same software definition file using the `version` method and giving a block:
```ruby ```ruby
name "ruby" name "ruby"
......
...@@ -276,27 +276,12 @@ module Omnibus ...@@ -276,27 +276,12 @@ module Omnibus
def appbundle(app_name, options = {}) def appbundle(app_name, options = {})
build_commands << BuildCommand.new("appbundle `#{app_name}'") do build_commands << BuildCommand.new("appbundle `#{app_name}'") do
bin_dir = "#{install_dir}/bin" bin_dir = "#{install_dir}/bin"
embedded_apps_root = "#{install_dir}/embedded/apps"
embedded_app_dir = "#{embedded_apps_root}/#{app_name}"
gemfile_lock = "#{embedded_app_dir}/Gemfile.lock"
appbundler_bin = windows_safe_path("#{install_dir}/embedded/bin/appbundler") appbundler_bin = windows_safe_path("#{install_dir}/embedded/bin/appbundler")
# Ensure the main bin dir exists # Ensure the main bin dir exists
FileUtils.mkdir_p(bin_dir) FileUtils.mkdir_p(bin_dir)
# Ensure the embedded app directory exists
FileUtils.mkdir_p(embedded_apps_root) shellout!("#{appbundler_bin} '#{Omnibus::Config.source_dir}/#{app_name}' '#{bin_dir}'", options)
# Copy the application code into place
FileUtils.cp_r("#{Omnibus::Config.source_dir}/#{app_name}", embedded_apps_root)
# Delete any top-level `.git` directory
FileUtils.rm_rf("#{embedded_app_dir}/.git")
# Prepare the environment
options[:env] ||= {}
env = with_embedded_path || {}
env["BUNDLE_GEMFILE"] = gemfile_lock
options[:env].merge!(env)
shellout!("#{appbundler_bin} '#{embedded_app_dir}' '#{bin_dir}'", options)
end end
end end
expose :appbundle expose :appbundle
......
...@@ -70,6 +70,10 @@ module Omnibus ...@@ -70,6 +70,10 @@ module Omnibus
type: :boolean, type: :boolean,
desc: 'Optionally create an Artifactory build record for the published artifacts', desc: 'Optionally create an Artifactory build record for the published artifacts',
default: true default: true
method_option :properties,
type: :hash,
desc: 'Properites to attach to published artifacts',
default: {}
desc 'artifactory REPOSITORY PATTERN', 'Publish to an Artifactory instance' desc 'artifactory REPOSITORY PATTERN', 'Publish to an Artifactory instance'
def artifactory(repository, pattern) def artifactory(repository, pattern)
options[:repository] = repository options[:repository] = repository
......
...@@ -214,6 +214,18 @@ EOH ...@@ -214,6 +214,18 @@ EOH
end end
end end
class ChecksumMissing < Error
def initialize(software)
super <<-EOH
Verification for #{software.name} failed due to a missing checksum.
This added security check is used to prevent MITM attacks when downloading the
remote file. You must specify a checksum for each version of software downloaded
from a remote location.
EOH
end
end
class ChecksumMismatch < Error class ChecksumMismatch < Error
def initialize(software, expected, actual) def initialize(software, expected, actual)
super <<-EOH super <<-EOH
......
...@@ -229,12 +229,16 @@ module Omnibus ...@@ -229,12 +229,16 @@ module Omnibus
# #
# The digest type defined in the software definition # The digest type defined in the software definition
# #
# @raise [ChecksumMissing]
# if the checksum does not exist
#
# @return [Symbol] # @return [Symbol]
# #
def digest_type def digest_type
DIGESTS.each do |digest| DIGESTS.each do |digest|
return digest if source.key? digest return digest if source.key? digest
end end
raise ChecksumMissing.new(self)
end end
# #
......
...@@ -96,7 +96,7 @@ module Omnibus ...@@ -96,7 +96,7 @@ module Omnibus
when 1 when 1
from_hash_v1(manifest_data) from_hash_v1(manifest_data)
else else
raise InvalidManifestFormat, "Unknown manifest fromat version: #{manifest_data['manifest_format']}" raise InvalidManifestFormat, "Unknown manifest format version: #{manifest_data['manifest_format']}"
end end
end end
......
...@@ -18,6 +18,9 @@ require 'json' ...@@ -18,6 +18,9 @@ require 'json'
module Omnibus module Omnibus
class Metadata class Metadata
extend Sugarable
include Sugarable
class << self class << self
# #
# Render the metadata for the package at the given path, generated by the # Render the metadata for the package at the given path, generated by the
...@@ -108,8 +111,14 @@ module Omnibus ...@@ -108,8 +111,14 @@ module Omnibus
# @return [String] # @return [String]
# #
def arch def arch
if (Ohai['platform'] == 'windows') && (Config.windows_arch.to_sym == :x86) if windows? && windows_arch_i386?
'i386' 'i386'
elsif solaris?
if intel?
'i386'
elsif sparc?
'sparc'
end
else else
Ohai['kernel']['machine'] Ohai['kernel']['machine']
end end
...@@ -132,9 +141,9 @@ module Omnibus ...@@ -132,9 +141,9 @@ module Omnibus
# the platform family short name # the platform family short name
# #
def platform_shortname def platform_shortname
if Ohai['platform_family'] == 'rhel' if rhel?
'el' 'el'
elsif Ohai['platform'] == 'suse' elsif suse?
'sles' 'sles'
else else
Ohai['platform'] Ohai['platform']
...@@ -157,7 +166,7 @@ module Omnibus ...@@ -157,7 +166,7 @@ module Omnibus
# #
def truncate_platform_version(platform_version, platform) def truncate_platform_version(platform_version, platform)
case platform case platform
when 'centos', 'debian', 'el', 'fedora', 'freebsd', 'omnios', 'pidora', 'raspbian', 'rhel', 'sles', 'suse', 'smartos' when 'centos', 'debian', 'el', 'fedora', 'freebsd', 'omnios', 'pidora', 'raspbian', 'rhel', 'sles', 'suse', 'smartos', 'nexus', 'ios_xr'
# Only want MAJOR (e.g. Debian 7, OmniOS r151006, SmartOS 20120809T221258Z) # Only want MAJOR (e.g. Debian 7, OmniOS r151006, SmartOS 20120809T221258Z)
platform_version.split('.').first platform_version.split('.').first
when 'aix', 'gentoo', 'mac_os_x', 'openbsd', 'slackware', 'solaris2', 'opensuse', 'ubuntu' when 'aix', 'gentoo', 'mac_os_x', 'openbsd', 'slackware', 'solaris2', 'opensuse', 'ubuntu'
......
...@@ -37,6 +37,7 @@ module Omnibus ...@@ -37,6 +37,7 @@ module Omnibus
'debian' => DEB, 'debian' => DEB,
'fedora' => RPM, 'fedora' => RPM,
'rhel' => RPM, 'rhel' => RPM,
'wrlinux' => RPM,
'aix' => BFF, 'aix' => BFF,
'solaris2' => Solaris, 'solaris2' => Solaris,
'windows' => MSI, 'windows' => MSI,
......
...@@ -22,6 +22,7 @@ module Omnibus ...@@ -22,6 +22,7 @@ module Omnibus
include Digestable include Digestable
include Logging include Logging
include NullArgumentable include NullArgumentable
include Sugarable
include Templating include Templating
include Util include Util
......
...@@ -173,7 +173,7 @@ module Omnibus ...@@ -173,7 +173,7 @@ module Omnibus
# This implies that if we are in /tmp/staging/project/dir/things, # This implies that if we are in /tmp/staging/project/dir/things,
# we will chown from 'project' on, rather than 'project/dir', which leaves # we will chown from 'project' on, rather than 'project/dir', which leaves
# project owned by the build user (which is incorrect) # project owned by the build user (which is incorrect)
shellout!("sudo chown -R 0:0 #{File.join(staging_dir, project.install_dir)}") shellout!("sudo chown -R 0:0 #{File.join(staging_dir, project.install_dir.match(/^\/?(\w+)/).to_s)}")
log.info(log_key) { "Creating .bff file" } log.info(log_key) { "Creating .bff file" }
# Since we want the owner to be root, we need to sudo the mkinstallp # Since we want the owner to be root, we need to sudo the mkinstallp
......
...@@ -421,6 +421,10 @@ module Omnibus ...@@ -421,6 +421,10 @@ module Omnibus
else else
'armv7l' 'armv7l'
end end
when 'aarch64'
# Debian prefers amd64 on ARMv8/AArch64 (64bit ARM) platforms
# see https://wiki.debian.org/Arm64Port
'arm64'
when 'ppc64le' when 'ppc64le'
# Debian prefers to use ppc64el for little endian architecture name # Debian prefers to use ppc64el for little endian architecture name
# where as others like gnutools/rhel use ppc64le( note the last 2 chars) # where as others like gnutools/rhel use ppc64le( note the last 2 chars)
......
This diff is collapsed.
...@@ -282,27 +282,27 @@ module Omnibus ...@@ -282,27 +282,27 @@ module Omnibus
render_template(resource_path('spec.erb'), render_template(resource_path('spec.erb'),
destination: spec_file, destination: spec_file,
variables: { variables: {
name: safe_base_package_name, name: safe_base_package_name,
version: safe_version, version: safe_version,
iteration: safe_build_iteration, iteration: safe_build_iteration,
vendor: vendor, vendor: vendor,
license: license, license: license,
dist_tag: dist_tag, dist_tag: dist_tag,
architecture: safe_architecture, maintainer: project.maintainer,
maintainer: project.maintainer, homepage: project.homepage,
homepage: project.homepage, description: project.description,
description: project.description, priority: priority,
priority: priority, category: category,
category: category, conflicts: project.conflicts,
conflicts: project.conflicts, replaces: project.replaces,
replaces: project.replaces, dependencies: project.runtime_dependencies,
dependencies: project.runtime_dependencies, user: project.package_user,
user: project.package_user, group: project.package_group,
group: project.package_group, scripts: scripts,
scripts: scripts, config_files: config_files,
config_files: config_files, files: files,
files: files, build_dir: build_dir,
build_dir: build_dir, platform_family: Ohai['platform_family']
} }
) )
end end
...@@ -316,6 +316,7 @@ module Omnibus ...@@ -316,6 +316,7 @@ module Omnibus
# #
def create_rpm_file def create_rpm_file
command = %|fakeroot rpmbuild| command = %|fakeroot rpmbuild|
command << %| --target #{safe_architecture}|
command << %| -bb| command << %| -bb|
command << %| --buildroot #{staging_dir}/BUILD| command << %| --buildroot #{staging_dir}/BUILD|
command << %| --define '_topdir #{staging_dir}'| command << %| --define '_topdir #{staging_dir}'|
...@@ -494,16 +495,27 @@ module Omnibus ...@@ -494,16 +495,27 @@ module Omnibus
# http://rpm.org/ticket/56 # http://rpm.org/ticket/56
# #
if version =~ /\-/ if version =~ /\-/
converted = version.gsub('-', '~') if Ohai['platform_family'] == 'wrlinux'
converted = version.gsub('-', '_') #WRL has an elderly RPM version
log.warn(log_key) do log.warn(log_key) do
"Tildes hold special significance in the RPM package versions. " \ "Omnibus replaces dashes (-) with tildes (~) so pre-release " \
"They mark a version as lower priority in RPM's version compare " \ "versions get sorted earlier than final versions. However, the " \
"logic. We'll replace all dashes (-) with tildes (~) so pre-release" \ "version of rpmbuild on Wind River Linux does not support this. " \
"versions get sorted earlier then final versions. Converting" \ "All dashes will be replaced with underscores (_). Converting " \
"`#{project.build_version}' to `#{converted}'." "`#{project.build_version}' to `#{converted}'."
end
else
converted = version.gsub('-', '~')
log.warn(log_key) do
"Tildes hold special significance in the RPM package versions. " \
"They mark a version as lower priority in RPM's version compare " \
"logic. We'll replace all dashes (-) with tildes (~) so pre-release" \
"versions get sorted earlier then final versions. Converting" \
"`#{project.build_version}' to `#{converted}'."
end
end end
version = converted version = converted
end end
......
...@@ -14,29 +14,32 @@ ...@@ -14,29 +14,32 @@
# limitations under the License. # limitations under the License.
# #
require 'socket'
module Omnibus module Omnibus
class Packager::Solaris < Packager::Base class Packager::Solaris < Packager::Base
# @return [Hash]
SCRIPT_MAP = {
# Default Omnibus naming
postinst: 'postinstall',
postrm: 'postremove',
# Default Solaris naming
postinstall: 'postinstall',
postremove: 'postremove',
}.freeze
id :solaris id :solaris
build do build do
shellout! "cd #{install_dirname} && find #{install_basename} -print > #{staging_dir_path('files')}" write_scripts
write_prototype_file
write_pkginfo_file
write_prototype_content create_solaris_file
write_pkginfo_content
copy_file("#{project.package_scripts_path}/postinst", staging_dir_path('postinstall'))
copy_file("#{project.package_scripts_path}/postrm", staging_dir_path('postremove'))
shellout! "pkgmk -o -r #{install_dirname} -d #{staging_dir} -f #{staging_dir_path('Prototype')}"
shellout! "pkgchk -vd #{staging_dir} #{project.package_name}"
shellout! "pkgtrans #{staging_dir} #{package_path} #{project.package_name}"
end end
# @see Base#package_name # @see Base#package_name
def package_name def package_name
"#{project.package_name}-#{pkgmk_version}.#{Ohai['kernel']['machine']}.solaris" "#{project.package_name}-#{pkgmk_version}.#{safe_architecture}.solaris"
end end
def pkgmk_version def pkgmk_version
...@@ -50,24 +53,42 @@ module Omnibus ...@@ -50,24 +53,42 @@ module Omnibus
def install_basename def install_basename
File.basename(project.install_dir) File.basename(project.install_dir)
end end
def staging_dir_path(file_name) def staging_dir_path(file_name)
File.join(staging_dir, file_name) File.join(staging_dir, file_name)
end end
#
# Copy all scripts in {Project#package_scripts_path} to the control
# directory of this repo.
#
# @return [void]
#
def write_scripts
SCRIPT_MAP.each do |source, destination|
source_path = File.join(project.package_scripts_path, source.to_s)
if File.file?(source_path)
destination_path = staging_dir_path(destination)
log.debug(log_key) { "Adding script `#{source}' to `#{destination_path}'" }
copy_file(source_path, destination_path)
end
end
end
# #
# Generate a Prototype file for solaris build # Generate a Prototype file for solaris build
# #
def write_prototype_content def write_prototype_file
prototype_content = <<-EOF.gsub(/^ {8}/, '') shellout! "cd #{install_dirname} && find #{install_basename} -print > #{staging_dir_path('files')}"
i pkginfo
i postinstall
i postremove
EOF
# generate list of control files # generate list of control files
File.open staging_dir_path('Prototype'), 'w+' do |f| File.open staging_dir_path('Prototype'), 'w+' do |f|
f.write prototype_content f.write <<-EOF.gsub(/^ {10}/, '')
i pkginfo
i postinstall
i postremove
EOF
end end
# generate the prototype's file list # generate the prototype's file list
...@@ -80,7 +101,10 @@ module Omnibus ...@@ -80,7 +101,10 @@ module Omnibus
# #
# Generate a pkginfo file for solaris build # Generate a pkginfo file for solaris build
# #
def write_pkginfo_content def write_pkginfo_file
hostname = Socket.gethostname
# http://docs.oracle.com/cd/E19683-01/816-0219/6m6njqbat/index.html
pkginfo_content = <<-EOF.gsub(/^ {8}/, '') pkginfo_content = <<-EOF.gsub(/^ {8}/, '')
CLASSES=none CLASSES=none
TZ=PST TZ=PST
...@@ -88,17 +112,44 @@ module Omnibus ...@@ -88,17 +112,44 @@ module Omnibus
BASEDIR=#{install_dirname} BASEDIR=#{install_dirname}
PKG=#{project.package_name} PKG=#{project.package_name}
NAME=#{project.package_name} NAME=#{project.package_name}
ARCH=#{`uname -p`.chomp} ARCH=#{safe_architecture}
VERSION=#{pkgmk_version} VERSION=#{pkgmk_version}
CATEGORY=application CATEGORY=application
DESC=#{project.description} DESC=#{project.description}
VENDOR=#{project.maintainer} VENDOR=#{project.maintainer}
EMAIL=#{project.maintainer} EMAIL=#{project.maintainer}
PSTAMP=#{`hostname`.chomp + Time.now.utc.iso8601} PSTAMP=#{hostname}#{Time.now.utc.iso8601}
EOF EOF
File.open staging_dir_path('pkginfo'), 'w+' do |f| File.open staging_dir_path('pkginfo'), 'w+' do |f|
f.write pkginfo_content f.write pkginfo_content
end end
end end
#
# Generate the Solaris file using +pkg*+.
#
# @return [void]
#
def create_solaris_file
shellout! "pkgmk -o -r #{install_dirname} -d #{staging_dir} -f #{staging_dir_path('Prototype')}"
shellout! "pkgchk -vd #{staging_dir} #{project.package_name}"
shellout! "pkgtrans #{staging_dir} #{package_path} #{project.package_name}"
end
#
# The architecture for this Solaris package.
#
# @return [String]
#
def safe_architecture
# The #i386? and #intel? helpers come from chef-sugar
if intel?
'i386'
elsif sparc?
'sparc'
else
Ohai['kernel']['machine']
end
end
end end
end end
...@@ -112,6 +112,10 @@ module Omnibus ...@@ -112,6 +112,10 @@ module Omnibus
publish_packages.concat(build_packages) publish_packages.concat(build_packages)
end end
if publish_packages.empty?
log.info(log_key) { 'No packages found, skipping publish' }
end
publish_packages publish_packages
end end
end end
......
...@@ -38,10 +38,7 @@ module Omnibus ...@@ -38,10 +38,7 @@ module Omnibus
artifact_for(package).upload( artifact_for(package).upload(
repository, repository,
remote_path_for(package), remote_path_for(package),
metadata_for(package).merge( default_properties.merge(metadata_properties_for(package)),
'build.name' => package.metadata[:name],
'build.number' => package.metadata[:version],
),
) )
end end
rescue Artifactory::Error::HTTPError => e rescue Artifactory::Error::HTTPError => e
...@@ -120,11 +117,11 @@ module Omnibus ...@@ -120,11 +117,11 @@ module Omnibus
name: 'omnibus', name: 'omnibus',
version: Omnibus::VERSION, version: Omnibus::VERSION,
}, },
properties: { properties: default_properties.merge(
'omnibus.project' => name, 'omnibus.project' => name,
'omnibus.version' => manifest.build_version, 'omnibus.version' => manifest.build_version,
'omnibus.version_manifest' => manifest.to_json, 'omnibus.version_manifest' => manifest.to_json,
}, ),
modules: [ modules: [
{ {
# com.getchef:chef-server:12.0.0 # com.getchef:chef-server:12.0.0
...@@ -188,8 +185,8 @@ module Omnibus ...@@ -188,8 +185,8 @@ module Omnibus
#