From 07f748542334e9b12d8b8c6e3fcf381310638e5e Mon Sep 17 00:00:00 2001 From: Steven Danna Date: Mon, 8 Aug 2016 10:23:12 +0100 Subject: [PATCH] [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 --- omnibus/.kitchen.yml | 4 +- omnibus/Berksfile | 1 + omnibus/Gemfile | 1 + omnibus/README.md | 10 ++-- omnibus/config/projects/inspec.rb | 39 +++++++----- omnibus/config/software/inspec.rb | 39 ++++++++---- omnibus/config/software/train.rb | 28 --------- omnibus/omnibus.rb | 9 ++- omnibus/resources/inspec/deb/conffiles.erb | 3 - omnibus/resources/inspec/deb/control.erb | 25 -------- omnibus/resources/inspec/deb/md5sums.erb | 3 - omnibus/resources/inspec/rpm/rpmmacros.erb | 3 - omnibus/resources/inspec/rpm/signing.erb | 40 ------------- omnibus/resources/inspec/rpm/spec.erb | 69 ---------------------- 14 files changed, 68 insertions(+), 206 deletions(-) delete mode 100644 omnibus/config/software/train.rb delete mode 100644 omnibus/resources/inspec/deb/conffiles.erb delete mode 100644 omnibus/resources/inspec/deb/control.erb delete mode 100644 omnibus/resources/inspec/deb/md5sums.erb delete mode 100644 omnibus/resources/inspec/rpm/rpmmacros.erb delete mode 100644 omnibus/resources/inspec/rpm/signing.erb delete mode 100644 omnibus/resources/inspec/rpm/spec.erb diff --git a/omnibus/.kitchen.yml b/omnibus/.kitchen.yml index c4d0285db..9fbebd140 100644 --- a/omnibus/.kitchen.yml +++ b/omnibus/.kitchen.yml @@ -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 diff --git a/omnibus/Berksfile b/omnibus/Berksfile index 30f63849a..c8a472db3 100644 --- a/omnibus/Berksfile +++ b/omnibus/Berksfile @@ -1,3 +1,4 @@ +# encoding: utf-8 source 'https://supermarket.chef.io' cookbook 'omnibus' diff --git a/omnibus/Gemfile b/omnibus/Gemfile index 48e0ab92f..7bd5b1a0e 100644 --- a/omnibus/Gemfile +++ b/omnibus/Gemfile @@ -1,3 +1,4 @@ +# encoding: utf-8 source 'https://rubygems.org' # Install omnibus diff --git a/omnibus/README.md b/omnibus/README.md index 58f91eb61..722ee7eb8 100644 --- a/omnibus/README.md +++ b/omnibus/README.md @@ -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 diff --git a/omnibus/config/projects/inspec.rb b/omnibus/config/projects/inspec.rb index 62a2f93d9..ecbb8efc3 100644 --- a/omnibus/config/projects/inspec.rb +++ b/omnibus/config/projects/inspec.rb @@ -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 ' +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' diff --git a/omnibus/config/software/inspec.rb b/omnibus/config/software/inspec.rb index 69c175e00..546f7b78f 100644 --- a/omnibus/config/software/inspec.rb +++ b/omnibus/config/software/inspec.rb @@ -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 diff --git a/omnibus/config/software/train.rb b/omnibus/config/software/train.rb deleted file mode 100644 index c5c55ed75..000000000 --- a/omnibus/config/software/train.rb +++ /dev/null @@ -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 diff --git a/omnibus/omnibus.rb b/omnibus/omnibus.rb index 983fe9d45..e6da68dea 100644 --- a/omnibus/omnibus.rb +++ b/omnibus/omnibus.rb @@ -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 diff --git a/omnibus/resources/inspec/deb/conffiles.erb b/omnibus/resources/inspec/deb/conffiles.erb deleted file mode 100644 index 64282d6ee..000000000 --- a/omnibus/resources/inspec/deb/conffiles.erb +++ /dev/null @@ -1,3 +0,0 @@ -<% config_files.each do |file| -%> -<%= file %> -<% end -%> diff --git a/omnibus/resources/inspec/deb/control.erb b/omnibus/resources/inspec/deb/control.erb deleted file mode 100644 index df91e3463..000000000 --- a/omnibus/resources/inspec/deb/control.erb +++ /dev/null @@ -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 -%> diff --git a/omnibus/resources/inspec/deb/md5sums.erb b/omnibus/resources/inspec/deb/md5sums.erb deleted file mode 100644 index c8120efa7..000000000 --- a/omnibus/resources/inspec/deb/md5sums.erb +++ /dev/null @@ -1,3 +0,0 @@ -<% md5sums.each do |path, checksum| -%> -<%= checksum %> <%= path %> -<% end -%> diff --git a/omnibus/resources/inspec/rpm/rpmmacros.erb b/omnibus/resources/inspec/rpm/rpmmacros.erb deleted file mode 100644 index ea0382347..000000000 --- a/omnibus/resources/inspec/rpm/rpmmacros.erb +++ /dev/null @@ -1,3 +0,0 @@ -%_signature gpg -%_gpg_path <%= gpg_path %> -%_gpg_name <%= gpg_name %> diff --git a/omnibus/resources/inspec/rpm/signing.erb b/omnibus/resources/inspec/rpm/signing.erb deleted file mode 100644 index 59a984852..000000000 --- a/omnibus/resources/inspec/rpm/signing.erb +++ /dev/null @@ -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 diff --git a/omnibus/resources/inspec/rpm/spec.erb b/omnibus/resources/inspec/rpm/spec.erb deleted file mode 100644 index a072167b0..000000000 --- a/omnibus/resources/inspec/rpm/spec.erb +++ /dev/null @@ -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 -%>