[omnibus] Appbundle inspec and cleanup style issues

- Removes resource files which matched the default implementations
  contained in omnibus.

- Removes software definition for train which will be installed via the
  gem dependecies in the inspec defintion.

- Appbundle inspec to match our other ruby-based projects

- Update rubocop style violations

- Update copyright notices

Signed-off-by: Steven Danna <steve@chef.io>
This commit is contained in:
Steven Danna 2016-08-08 10:23:12 +01:00 committed by Christoph Hartmann
parent 5a8ee8c896
commit 07f7485423
14 changed files with 68 additions and 206 deletions

View file

@ -5,11 +5,11 @@ driver:
cpus: 2
memory: 2048
synced_folders:
- ['.', '/home/vagrant/inspec']
- ['..', '/home/vagrant/inspec']
provisioner:
name: chef_zero
require_chef_omnibus: 12.4.1
require_chef_omnibus: true
platforms:
- name: centos-7.1

View file

@ -1,3 +1,4 @@
# encoding: utf-8
source 'https://supermarket.chef.io'
cookbook 'omnibus'

View file

@ -1,3 +1,4 @@
# encoding: utf-8
source 'https://rubygems.org'
# Install omnibus

View file

@ -110,10 +110,12 @@ section:
```shell
$ bundle exec kitchen login ubuntu-1204
[vagrant@ubuntu...] $ cd inspec
[vagrant@ubuntu...] $ bundle install
[vagrant@ubuntu...] $ ...
[vagrant@ubuntu...] $ bin/omnibus build inspec
# Now inside the kitchen vm
$ sudo -i
$ export PATH=/opt/omnibus-toolchain/bin:/opt/omnibus-toolchain/embedded/bin:$PATH
$ cd /home/vagrant/inspec/omnibus
$ bundle install
$ bundle exec omnibus build inspec
```
For a complete list of all commands and platforms, run `kitchen list` or

View file

@ -1,12 +1,27 @@
# encoding: utf-8
#
# Copyright 2016 Chef Software, Inc
# Copyright:: Copyright 2016, Chef Software Inc.
# License:: Apache License, Version 2.0
#
# All Rights Reserved.
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
name "inspec"
maintainer "Christoph Hartmann"
homepage "https://github.com/chef/inspec"
name 'inspec'
maintainer 'Chef Software, Inc <maintainers@chef.io>'
homepage 'https://github.com/chef/inspec'
license 'Apache-2.0'
license_file '../LICENSE'
# Defaults to C:/inspec on Windows
# and /opt/inspec on all other platforms
@ -15,14 +30,8 @@ install_dir "#{default_root}/#{name}"
build_version Omnibus::BuildVersion.semver
build_iteration 1
# Creates required build directories
dependency "preparation"
dependency 'preparation'
dependency 'inspec'
# inspec dependencies/components
dependency "inspec"
# Version manifest file
dependency "version-manifest"
exclude "**/.git"
exclude "**/bundler/git"
exclude '**/.git'
exclude '**/bundler/git'

View file

@ -1,21 +1,33 @@
# encoding: utf-8
#
# Copyright 2015 Chef Software, Inc.
# Copyright:: Copyright 2016, Chef Software Inc.
# License:: Apache License, Version 2.0
#
# All Rights Reserved.
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
require_relative '../../../lib/inspec/version.rb'
name 'inspec'
dependency 'ruby'
dependency 'train'
dependency 'bundler'
dependency 'appbundler'
license "Apache-2.0"
license_file "LICENSE"
license :project_license
default_version "v0.18.0"
default_version "v#{Inspec::VERSION}"
source git: "https://github.com/chef/#{name}.git"
source path: "#{Omnibus::Config.project_root}/../"
build do
env = with_standard_compiler_flags(with_embedded_path)
@ -23,12 +35,15 @@ build do
# Remove existing built gems in case they exist in the current dir
delete "#{name}-*.gem"
# We bundle install to ensure the versions of gems we are going to
# appbundle-lock to are definitely installed
bundle 'install --without test integration tools maintenance', env: env
gem "build #{name}.gemspec", env: env
gem "install #{name}-*.gem --no-document", env: env
# Dependecy added to avoid this pry error:
# "Sorry, you can't use Pry without Readline or a compatible library."
gem "install rb-readline --no-document", env: env
touch "#{install_dir}/embedded/service/#{name}/.gitkeep"
# Dependecy added to avoid this pry error: "Sorry, you can't use Pry
# without Readline or a compatible library."
gem 'install rb-readline --no-document', env: env
appbundle 'inspec'
end

View file

@ -1,28 +0,0 @@
# encoding: utf-8
#
# Copyright 2015 Chef Software, Inc.
#
# All Rights Reserved.
#
# This should go away once this is all public
name 'train'
license "Apache-2.0"
license_file "LICENSE"
dependency 'ruby'
default_version "v0.10.4"
source git: "https://github.com/chef/#{name}.git"
build do
env = with_standard_compiler_flags(with_embedded_path)
# Remove existing built gems in case they exist in the current dir
delete "r-#{name}-*.gem"
gem "build #{name}.gemspec", env: env
gem "install r-#{name}-*.gem --no-document", env: env
end

View file

@ -1,3 +1,4 @@
# encoding: utf-8
#
# This file is used to configure the inspec project. It contains
# some minimal configuration examples for working with Omnibus. For a full list
@ -50,5 +51,9 @@ software_gems ['omnibus-software']
# Windows architecture defaults
# ------------------------------
windows_arch %w{x86 x64}.include?((ENV['OMNIBUS_WINDOWS_ARCH'] || '').downcase) ?
ENV['OMNIBUS_WINDOWS_ARCH'].downcase.to_sym : :x86
arch = if %w{x86 x64}.include?((ENV['OMNIBUS_WINDOWS_ARCH'] || '').downcase)
ENV['OMNIBUS_WINDOWS_ARCH'].downcase.to_sym
else
:x86
end
windows_arch arch

View file

@ -1,3 +0,0 @@
<% config_files.each do |file| -%>
<%= file %>
<% end -%>

View file

@ -1,25 +0,0 @@
Package: <%= name %>
Version: <%= version %>-<%= iteration %>
License: <%= license %>
Vendor: <%= vendor %>
Architecture: <%= architecture %>
Maintainer: <%= maintainer %>
Installed-Size: <%= installed_size %>
<% unless dependencies.empty? -%>
Depends: <%= dependencies.join(', ') %>
<% end -%>
<% unless conflicts.empty? -%>
Conflicts: <%= conflicts.join(', ') %>
<% end -%>
<% unless replaces.empty? -%>
Replaces: <%= replaces.join(', ') %>
<% end -%>
Section: <%= section %>
Priority: <%= priority %>
Homepage: <%= homepage %>
<% lines = description.split("\n") -%>
<% firstline, *remainder = lines -%>
Description: <%= firstline %>
<% if remainder.any? -%>
<%= remainder.collect { |l| l =~ /^ *$/ ? " ." : " #{l}" }.join("\n") %>
<% end -%>

View file

@ -1,3 +0,0 @@
<% md5sums.each do |path, checksum| -%>
<%= checksum %> <%= path %>
<% end -%>

View file

@ -1,3 +0,0 @@
%_signature gpg
%_gpg_path <%= gpg_path %>
%_gpg_name <%= gpg_name %>

View file

@ -1,40 +0,0 @@
#!/usr/bin/env ruby
unless (rpm_cmd = ARGV[0])
STDERR.puts 'Usage: sign-rpm RPM_COMMAND'
exit 1
end
password = '<%= passphrase %>'
require 'pty'
puts rpm_cmd
PTY.spawn(rpm_cmd) do |r, w, pid|
prompt = r.read(19)
# match the expected prompt exactly, since that's the only way we know if
# something went wrong.
unless prompt == 'Enter pass phrase: '
STDERR.puts "unexpected output from `#{rpm_cmd}`: '#{prompt}'"
Process.kill(:KILL, pid)
exit 1
end
STDOUT.puts prompt
w.write("#{password}\n")
# Keep printing output unti the command exits
loop do
begin
line = r.gets
puts line
if (line =~ /failed/) && !(line =~ /warning:/)
STDERR.puts 'RPM signing failure'
exit 1
end
rescue Errno::EIO
break
end
end
end

View file

@ -1,69 +0,0 @@
# Disable any shell actions, replace them with simply 'true'
%define __spec_prep_post true
%define __spec_prep_pre true
%define __spec_build_post true
%define __spec_build_pre true
%define __spec_install_post true
%define __spec_install_pre true
%define __spec_clean_post true
%define __spec_clean_pre true
# Use md5
%define _binary_filedigest_algorithm 1
# Use gzip payload compression
%define _binary_payload w9.gzdio
# Metadata
Name: <%= name %>
Version: <%= version %>
Release: <%= iteration %><%= dist_tag ? dist_tag : '' %>
Summary: <%= description.split("\n").first.empty? ? "_" : description.split("\n").first %>
AutoReqProv: no
BuildRoot: %buildroot
Prefix: /
Group: <%= category %>
License: <%= license %>
Vendor: <%= vendor %>
URL: <%= homepage %>
Packager: <%= maintainer %>
<% dependencies.each do |name| -%>
Requires: <%= name %>
<% end -%>
<% conflicts.each do |name| -%>
Conflicts: <%= name %>
<% end -%>
<% replaces.each do |name| -%>
Obsoletes: <%= name %>
<%- end -%>
<% # RPM rejects descriptions with blank lines (even between content) -%>
%description
<%= description.gsub(/^\s*$/, " .") %>
%prep
# noop
%build
# noop
%install
# noop
%clean
# noop
<% scripts.each do |name, contents| -%>
%<%= name %>
<%= contents %>
<% end -%>
%files
%defattr(-,<%= user %>,<%= group %>,-)
<% # Output config files and then regular files -%>
<% config_files.each do |file| -%>
%config(noreplace) <%= file %>
<% end -%>
<% # List all files -%>
<% files.each do |file| -%>
<%= file %>
<% end -%>