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:
- 2.0.0
- 2.1
- 2.2
bundler_args: "--jobs 7 --without docs local"
branches:
only:
......
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)
-------------------------
### New Features
......
......@@ -18,9 +18,10 @@ project lead.
## Maintainers
* [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)
* [Scott Hain](https://github.com/scotthain)
* [Seth Vargo](http://github.com/sethvargo)
* [Steven Danna](https://github.com/stevendanna)
* [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
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
name "ruby"
......
......@@ -276,27 +276,12 @@ module Omnibus
def appbundle(app_name, options = {})
build_commands << BuildCommand.new("appbundle `#{app_name}'") do
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")
# Ensure the main bin dir exists
FileUtils.mkdir_p(bin_dir)
# Ensure the embedded app directory exists
FileUtils.mkdir_p(embedded_apps_root)
# 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)
shellout!("#{appbundler_bin} '#{Omnibus::Config.source_dir}/#{app_name}' '#{bin_dir}'", options)
end
end
expose :appbundle
......
......@@ -70,6 +70,10 @@ module Omnibus
type: :boolean,
desc: 'Optionally create an Artifactory build record for the published artifacts',
default: true
method_option :properties,
type: :hash,
desc: 'Properites to attach to published artifacts',
default: {}
desc 'artifactory REPOSITORY PATTERN', 'Publish to an Artifactory instance'
def artifactory(repository, pattern)
options[:repository] = repository
......
......@@ -214,6 +214,18 @@ EOH
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
def initialize(software, expected, actual)
super <<-EOH
......
......@@ -229,12 +229,16 @@ module Omnibus
#
# The digest type defined in the software definition
#
# @raise [ChecksumMissing]
# if the checksum does not exist
#
# @return [Symbol]
#
def digest_type
DIGESTS.each do |digest|
return digest if source.key? digest
end
raise ChecksumMissing.new(self)
end
#
......
......@@ -96,7 +96,7 @@ module Omnibus
when 1
from_hash_v1(manifest_data)
else
raise InvalidManifestFormat, "Unknown manifest fromat version: #{manifest_data['manifest_format']}"
raise InvalidManifestFormat, "Unknown manifest format version: #{manifest_data['manifest_format']}"
end
end
......
......@@ -18,6 +18,9 @@ require 'json'
module Omnibus
class Metadata
extend Sugarable
include Sugarable
class << self
#
# Render the metadata for the package at the given path, generated by the
......@@ -108,8 +111,14 @@ module Omnibus
# @return [String]
#
def arch
if (Ohai['platform'] == 'windows') && (Config.windows_arch.to_sym == :x86)
if windows? && windows_arch_i386?
'i386'
elsif solaris?
if intel?
'i386'
elsif sparc?
'sparc'
end
else
Ohai['kernel']['machine']
end
......@@ -132,9 +141,9 @@ module Omnibus
# the platform family short name
#
def platform_shortname
if Ohai['platform_family'] == 'rhel'
if rhel?
'el'
elsif Ohai['platform'] == 'suse'
elsif suse?
'sles'
else
Ohai['platform']
......@@ -157,7 +166,7 @@ module Omnibus
#
def truncate_platform_version(platform_version, 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)
platform_version.split('.').first
when 'aix', 'gentoo', 'mac_os_x', 'openbsd', 'slackware', 'solaris2', 'opensuse', 'ubuntu'
......
......@@ -37,6 +37,7 @@ module Omnibus
'debian' => DEB,
'fedora' => RPM,
'rhel' => RPM,
'wrlinux' => RPM,
'aix' => BFF,
'solaris2' => Solaris,
'windows' => MSI,
......
......@@ -22,6 +22,7 @@ module Omnibus
include Digestable
include Logging
include NullArgumentable
include Sugarable
include Templating
include Util
......
......@@ -173,7 +173,7 @@ module Omnibus
# This implies that if we are in /tmp/staging/project/dir/things,
# we will chown from 'project' on, rather than 'project/dir', which leaves
# 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" }
# Since we want the owner to be root, we need to sudo the mkinstallp
......
......@@ -421,6 +421,10 @@ module Omnibus
else
'armv7l'
end
when 'aarch64'
# Debian prefers amd64 on ARMv8/AArch64 (64bit ARM) platforms
# see https://wiki.debian.org/Arm64Port
'arm64'
when 'ppc64le'
# Debian prefers to use ppc64el for little endian architecture name
# where as others like gnutools/rhel use ppc64le( note the last 2 chars)
......
This diff is collapsed.
......@@ -282,27 +282,27 @@ module Omnibus
render_template(resource_path('spec.erb'),
destination: spec_file,
variables: {
name: safe_base_package_name,
version: safe_version,
iteration: safe_build_iteration,
vendor: vendor,
license: license,
dist_tag: dist_tag,
architecture: safe_architecture,
maintainer: project.maintainer,
homepage: project.homepage,
description: project.description,
priority: priority,
category: category,
conflicts: project.conflicts,
replaces: project.replaces,
dependencies: project.runtime_dependencies,
user: project.package_user,
group: project.package_group,
scripts: scripts,
config_files: config_files,
files: files,
build_dir: build_dir,
name: safe_base_package_name,
version: safe_version,
iteration: safe_build_iteration,
vendor: vendor,
license: license,
dist_tag: dist_tag,
maintainer: project.maintainer,
homepage: project.homepage,
description: project.description,
priority: priority,
category: category,
conflicts: project.conflicts,
replaces: project.replaces,
dependencies: project.runtime_dependencies,
user: project.package_user,
group: project.package_group,
scripts: scripts,
config_files: config_files,
files: files,
build_dir: build_dir,
platform_family: Ohai['platform_family']
}
)
end
......@@ -316,6 +316,7 @@ module Omnibus
#
def create_rpm_file
command = %|fakeroot rpmbuild|
command << %| --target #{safe_architecture}|
command << %| -bb|
command << %| --buildroot #{staging_dir}/BUILD|
command << %| --define '_topdir #{staging_dir}'|
......@@ -494,16 +495,27 @@ module Omnibus
# http://rpm.org/ticket/56
#
if version =~ /\-/
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}'."
if Ohai['platform_family'] == 'wrlinux'
converted = version.gsub('-', '_') #WRL has an elderly RPM version
log.warn(log_key) do
"Omnibus replaces dashes (-) with tildes (~) so pre-release " \
"versions get sorted earlier than final versions. However, the " \
"version of rpmbuild on Wind River Linux does not support this. " \
"All dashes will be replaced with underscores (_). Converting " \
"`#{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
version = converted
end
......
......@@ -14,29 +14,32 @@
# limitations under the License.
#
require 'socket'
module Omnibus
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
build do
shellout! "cd #{install_dirname} && find #{install_basename} -print > #{staging_dir_path('files')}"
write_prototype_content
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}"
write_scripts
write_prototype_file
write_pkginfo_file
create_solaris_file
end
# @see Base#package_name
def package_name
"#{project.package_name}-#{pkgmk_version}.#{Ohai['kernel']['machine']}.solaris"
"#{project.package_name}-#{pkgmk_version}.#{safe_architecture}.solaris"
end
def pkgmk_version
......@@ -50,24 +53,42 @@ module Omnibus
def install_basename
File.basename(project.install_dir)
end
def staging_dir_path(file_name)
File.join(staging_dir, file_name)
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
#
def write_prototype_content
prototype_content = <<-EOF.gsub(/^ {8}/, '')
i pkginfo
i postinstall
i postremove
EOF
def write_prototype_file
shellout! "cd #{install_dirname} && find #{install_basename} -print > #{staging_dir_path('files')}"
# generate list of control files
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
# generate the prototype's file list
......@@ -80,7 +101,10 @@ module Omnibus
#
# 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}/, '')
CLASSES=none
TZ=PST
......@@ -88,17 +112,44 @@ module Omnibus
BASEDIR=#{install_dirname}
PKG=#{project.package_name}
NAME=#{project.package_name}
ARCH=#{`uname -p`.chomp}
ARCH=#{safe_architecture}
VERSION=#{pkgmk_version}
CATEGORY=application
DESC=#{project.description}
VENDOR=#{project.maintainer}
EMAIL=#{project.maintainer}
PSTAMP=#{`hostname`.chomp + Time.now.utc.iso8601}
PSTAMP=#{hostname}#{Time.now.utc.iso8601}
EOF
File.open staging_dir_path('pkginfo'), 'w+' do |f|
f.write pkginfo_content
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
......@@ -112,6 +112,10 @@ module Omnibus
publish_packages.concat(build_packages)
end
if publish_packages.empty?
log.info(log_key) { 'No packages found, skipping publish' }
end
publish_packages
end
end
......
......@@ -38,10 +38,7 @@ module Omnibus
artifact_for(package).upload(
repository,
remote_path_for(package),
metadata_for(package).merge(
'build.name' => package.metadata[:name],
'build.number' => package.metadata[:version],
),
default_properties.merge(metadata_properties_for(package)),
)
end
rescue Artifactory::Error::HTTPError => e
......@@ -120,11 +117,11 @@ module Omnibus
name: 'omnibus',
version: Omnibus::VERSION,
},
properties: {
properties: default_properties.merge(
'omnibus.project' => name,
'omnibus.version' => manifest.build_version,
'omnibus.version_manifest' => manifest.to_json,
},
),
modules: [
{
# com.getchef:chef-server:12.0.0
......@@ -188,8 +185,8 @@ module Omnibus
#
# @return [Hash<String, String>]
#
def metadata_for(package)
{
def metadata_properties_for(package)
metadata = {
'omnibus.project' => package.metadata[:name],
'omnibus.platform' => package.metadata[:platform],
'omnibus.platform_version' => package.metadata[:platform_version],
......@@ -201,6 +198,20 @@ module Omnibus
'omnibus.sha256' => package.metadata[:sha256],
'omnibus.sha512' => package.metadata[:sha512],
}
metadata.merge!(
'build.name' => package.metadata[:name],
'build.number' => package.metadata[:version],
) if build_record?
metadata
end
#
# Properties to attach to published artifacts (and build record).
#
# @return [Hash<String, String>]
#
def default_properties
@properties ||= @options[:properties] || {}
end
#
......
......@@ -30,6 +30,11 @@ require 'chef/sugar/vagrant'
module Omnibus
module Sugarable
def self.extended(base)
base.send(:extend, Chef::Sugar::DSL)
base.send(:extend, Omnibus::Sugar)
end
def self.included(base)
base.send(:include, Chef::Sugar::DSL)
base.send(:include, Omnibus::Sugar)
......
......@@ -15,5 +15,5 @@
#
module Omnibus
VERSION = '4.1.0'
VERSION = '5.0.0'
end
......@@ -13,7 +13,7 @@ Gem::Specification.new do |gem|
gem.description = gem.summary
gem.homepage = 'https://github.com/opscode/omnibus'
gem.required_ruby_version = '>= 1.9.1'
gem.required_ruby_version = '>= 2'
gem.files = `git ls-files`.split($/)
gem.bindir = 'bin'
......
......@@ -16,4 +16,8 @@
<String Id="VerifyReadyDlgInstallTitle">{\WixUI_Font_Title_White}Ready to install [ProductName]</String>
<String Id="FeatureMainName"><%= friendly_name %></String>
<String Id="MinimumOSVersionMessage">This package requires minimum OS version: Windows 7/Windows Server 2008 R2 or greater.</String>
<String Id="DowngradeErrorMessage">A newer version of [ProductName] is already installed.</String>
<String Id="FileExtractionProgress">Extracting files, please wait...</String>
</WixLocalization>
......@@ -12,23 +12,60 @@
Version="$(var.VersionNumber)" Manufacturer="!(loc.ManufacturerName)" UpgradeCode="$(var.UpgradeCode)">
<!--
Define the minimum supported installer version (2.0).
The install should be done for the whole machine not just the current user
Minimum installer version (2.0) - Window XP and above.
The install scope is per machine, not the current user
-->
<Package InstallerVersion="200" InstallPrivileges="elevated" Compressed="yes" InstallScope="perMachine" />
<Package InstallerVersion="200" InstallPrivileges="elevated"
Compressed="yes" InstallScope="perMachine" />
<Media Id="1" Cabinet="Project.cab" EmbedCab="yes" CompressionLevel="high" />
<!-- Major upgrade -->
<Upgrade Id="$(var.UpgradeCode)">
<UpgradeVersion OnlyDetect="yes" Minimum="$(var.VersionNumber)" IncludeMinimum="no" Property="NEWERVERSIONDETECTED" />
<UpgradeVersion Minimum="0.0.0.0" IncludeMinimum="yes" Maximum="$(var.VersionNumber)" IncludeMaximum="yes" Property="OLDERVERSIONBEINGUPGRADED" />
</Upgrade>
<!--
Uncomment launch condition below to check for minimum OS
601 = Windows 7/Server 2008R2.
-->
<!-- Condition Message="!(loc.MinimumOSVersionMessage)">
<![CDATA[Installed OR VersionNT >= 601]]>
</Condition -->
<!-- We always do Major upgrades -->
<MajorUpgrade DowngradeErrorMessage="!(loc.DowngradeErrorMessage)" />
<!--
If fastmsi is set, custom actions will be invoked during install to unzip
project files, and during uninstall to remove the project folder
-->
<% if fastmsi %>
<SetProperty Id="FastUnzip"
Value="FASTZIPDIR=[INSTALLLOCATION];FASTZIPAPPNAME=chefdk"
Sequence="execute"
Before="FastUnzip" />
<CustomAction Id="FastUnzip"
BinaryKey="CustomActionFastMsiDLL"
DllEntry="FastUnzip"
Execute="deferred"
Return="check" />
<Binary Id="CustomActionFastMsiDLL"
SourceFile="CustomActionFastMsi.CA.dll" />
<CustomAction Id="Cleanup"
Directory="INSTALLLOCATION"
ExeCommand="cmd /C &quot;rd /S /Q chefdk&quot;"
Execute="deferred"
Return="ignore" />
<InstallExecuteSequence>
<RemoveExistingProducts After="InstallValidate" />
<Custom Action="FastUnzip" After="InstallFiles">NOT Installed</Custom>
<Custom Action="Cleanup" After="RemoveFiles">REMOVE~="ALL"</Custom>
</InstallExecuteSequence>
<UI>
<ProgressText Action="FastUnzip">!(loc.FileExtractionProgress)</ProgressText>
</UI>
<% end %>
<Directory Id="TARGETDIR" Name="SourceDir">
<Directory Id="WINDOWSVOLUME">
<% hierarchy.each.with_index do |(name, id), index| -%>
......
......@@ -19,7 +19,6 @@ Name: <%= name %>
Version: <%= version %>
Release: <%= iteration %><%= dist_tag %>
Summary: <%= description.split("\n").first.empty? ? "_" : description.split("\n").first %>
BuildArch: <%= architecture %>
AutoReqProv: no
BuildRoot: %buildroot
Prefix: /
......
......@@ -15,18 +15,94 @@ module Omnibus
# manner similar to one that omnibus provides, we would need to emulate
# the fixup steps here as well, which is a pain the ass.
#
# So just don't run those tests on windows.
# Instead we write batch files that redirect to the batch files