Merge pull request #2 from richardc/MCOP-245_add_packaging
MCOP-245 Add pl:packaging
This commit is contained in:
2
.gitignore
vendored
Normal file
2
.gitignore
vendored
Normal file
@@ -0,0 +1,2 @@
|
||||
ext/packaging
|
||||
/pkg/
|
||||
86
Rakefile
86
Rakefile
@@ -1,20 +1,92 @@
|
||||
RAKE_ROOT = File.expand_path(File.dirname(__FILE__))
|
||||
specdir = File.join([File.dirname(__FILE__), "spec"])
|
||||
|
||||
require 'rake'
|
||||
begin
|
||||
require 'rspec/core/rake_task'
|
||||
require 'mcollective'
|
||||
rescue LoadError
|
||||
end
|
||||
|
||||
if defined?(RSpec::Core::RakeTask)
|
||||
desc "Run plugin tests"
|
||||
RSpec::Core::RakeTask.new(:test) do |t|
|
||||
require "#{specdir}/spec_helper.rb"
|
||||
t.pattern = 'spec/**/*_spec.rb'
|
||||
begin
|
||||
load File.join(RAKE_ROOT, 'ext', 'packaging.rake')
|
||||
rescue LoadError
|
||||
end
|
||||
|
||||
tmp_load_path = $LOAD_PATH.map { |f| f.shellescape }.join(" -I ")
|
||||
t.rspec_opts = tmp_load_path + " " + File.read("#{specdir}/spec.opts").chomp
|
||||
def safe_system *args
|
||||
raise RuntimeError, "Failed: #{args.join(' ')}" unless system *args
|
||||
end
|
||||
|
||||
def check_build_env
|
||||
raise "Not all environment variables have been set. Missing #{{"'DESTDIR'" => ENV["DESTDIR"], "'MCLIBDIR'" => ENV["MCLIBDIR"], "'MCBINDIR'" => ENV["MCBINDIR"], "'TARGETDIR'" => ENV["TARGETDIR"]}.reject{|k,v| v != nil}.keys.join(", ")}" unless ENV["DESTDIR"] && ENV["MCLIBDIR"] && ENV["MCBINDIR"] && ENV["TARGETDIR"]
|
||||
raise "DESTDIR - '#{ENV["DESTDIR"]}' is not a directory" unless File.directory?(ENV["DESTDIR"])
|
||||
raise "MCLIBDIR - '#{ENV["MCLIBDIR"]}' is not a directory" unless File.directory?(ENV["MCLIBDIR"])
|
||||
raise "MCBINDIR - '#{ENV["MCBINDIR"]}' is not a directory" unless File.directory?(ENV["MCBINDIR"])
|
||||
raise "TARGETDIR - '#{ENV["TARGETDIR"]}' is not a directory" unless File.directory?(ENV["TARGETDIR"])
|
||||
end
|
||||
|
||||
def build_package(path)
|
||||
require 'yaml'
|
||||
options = []
|
||||
|
||||
if File.directory?(path)
|
||||
buildops = File.join(path, "buildops.yaml")
|
||||
buildops = YAML.load_file(buildops) if File.exists?(buildops)
|
||||
|
||||
return unless buildops["build"]
|
||||
|
||||
libdir = ENV["LIBDIR"] || buildops["mclibdir"]
|
||||
mcname = ENV["MCNAME"] || buildops["mcname"]
|
||||
sign = ENV["SIGN"] || buildops["sign"]
|
||||
|
||||
options << "--pluginpath=#{libdir}" if libdir
|
||||
options << "--mcname=#{mcname}" if mcname
|
||||
options << "--sign" if sign
|
||||
|
||||
options << "--dependency=\"#{buildops["dependencies"].join(" ")}\"" if buildops["dependencies"]
|
||||
|
||||
safe_system("ruby -I #{File.join(ENV["MCLIBDIR"], "lib").shellescape} #{File.join(ENV["MCBINDIR"], "mco").shellescape} plugin package -v #{path.shellescape} #{options.join(" ")}")
|
||||
move_artifacts
|
||||
end
|
||||
end
|
||||
|
||||
def move_artifacts
|
||||
rpms = FileList["*.rpm"]
|
||||
debs = FileList["*.deb","*.orig.tar.gz","*.debian.tar.gz","*.diff.gz","*.dsc","*.changes"]
|
||||
[debs,rpms].each do |pkgs|
|
||||
unless pkgs.empty?
|
||||
safe_system("mv #{pkgs} #{ENV["DESTDIR"]}") unless File.expand_path(ENV["DESTDIR"]) == Dir.pwd
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
desc "Build packages for specified plugin in target directory"
|
||||
task :buildplugin do
|
||||
check_build_env
|
||||
build_package(ENV["TARGETDIR"])
|
||||
end
|
||||
|
||||
desc "Build packages for all plugins in target directory"
|
||||
task :build do
|
||||
check_build_env
|
||||
packages = Dir.glob(File.join(ENV["TARGETDIR"], "*"))
|
||||
|
||||
packages.each do |package|
|
||||
if File.directory?(File.expand_path(package))
|
||||
build_package(File.expand_path(package))
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
desc "Run agent and application tests"
|
||||
task :test do
|
||||
require "#{specdir}/spec_helper.rb"
|
||||
if ENV["TARGETDIR"]
|
||||
test_pattern = "#{File.expand_path(ENV["TARGETDIR"])}/spec/**/*_spec.rb"
|
||||
else
|
||||
test_pattern = 'spec/**/*_spec.rb'
|
||||
end
|
||||
sh "rspec #{Dir.glob(test_pattern).sort.join(' ')}"
|
||||
end
|
||||
|
||||
task :default => :test
|
||||
|
||||
21
ext/build_defaults.yaml
Normal file
21
ext/build_defaults.yaml
Normal file
@@ -0,0 +1,21 @@
|
||||
---
|
||||
packaging_url: 'git://github.com/puppetlabs/packaging.git --branch=master'
|
||||
packaging_repo: 'packaging'
|
||||
pbuild_conf: '/etc/pbuilderrc'
|
||||
default_cow: 'base-squeeze-i386.cow'
|
||||
cows: 'base-lucid-i386.cow base-precise-i386.cow base-squeeze-i386.cow base-stable-i386.cow base-testing-i386.cow base-trusty-i386.cow base-wheezy-i386.cow base-saucy-i386.cow'
|
||||
packager: 'puppetlabs'
|
||||
gpg_name: 'info@puppetlabs.com'
|
||||
gpg_key: '4BD6EC30'
|
||||
sign_tar: FALSE
|
||||
# a space separated list of mock configs
|
||||
final_mocks: 'pl-el-5-i386 pl-el-6-i386 pl-el-7-x86_64 pl-fedora-19-i386 pl-fedora-20-i386'
|
||||
yum_host: 'yum.puppetlabs.com'
|
||||
yum_repo_path: '/opt/repository/yum/'
|
||||
build_gem: FALSE
|
||||
build_dmg: FALSE
|
||||
build_doc: FALSE
|
||||
build_ips: FALSE
|
||||
apt_host: 'apt.puppetlabs.com'
|
||||
apt_repo_url: 'http://apt.puppetlabs.com'
|
||||
apt_repo_path: '/opt/repository/incoming'
|
||||
5
ext/debian/changelog.erb
Normal file
5
ext/debian/changelog.erb
Normal file
@@ -0,0 +1,5 @@
|
||||
mcollective-actionpolicy-auth (<%= @debversion %>) lucid unstable sid squeeze wheezy precise; urgency=low
|
||||
|
||||
* Update to version <%= @debversion %>
|
||||
|
||||
-- Puppet Labs Release <info@puppetlabs.com> <%= Time.now.strftime("%a, %d %b %Y %H:%M:%S %z")%>
|
||||
1
ext/debian/compat
Normal file
1
ext/debian/compat
Normal file
@@ -0,0 +1 @@
|
||||
7
|
||||
13
ext/debian/control
Normal file
13
ext/debian/control
Normal file
@@ -0,0 +1,13 @@
|
||||
Source: mcollective-actionpolicy-auth
|
||||
Homepage: https://github.com/puppetlabs/mcollective-actionpolicy-auth
|
||||
Section: utils
|
||||
Priority: extra
|
||||
Maintainer: Puppet Labs
|
||||
Build-Depends: cdbs, debhelper
|
||||
Standards-Version: 3.8.0
|
||||
|
||||
Package: mcollective-actionpolicy-auth
|
||||
Architecture: all
|
||||
Description: Action Policy simplerpc authorization plugin
|
||||
Depends: mcollective-common(>= 2.2.1)
|
||||
|
||||
5
ext/debian/copyright
Normal file
5
ext/debian/copyright
Normal file
@@ -0,0 +1,5 @@
|
||||
Upstream Author:
|
||||
Puppet Labs https://github.com/puppetlabs/mcollective-actionpolicy-auth
|
||||
|
||||
License:
|
||||
ASL 2.0
|
||||
1
ext/debian/install
Normal file
1
ext/debian/install
Normal file
@@ -0,0 +1 @@
|
||||
util/* usr/share/mcollective/plugins/mcollective/util/
|
||||
4
ext/debian/rules
Normal file
4
ext/debian/rules
Normal file
@@ -0,0 +1,4 @@
|
||||
#!/usr/bin/make -f
|
||||
|
||||
%:
|
||||
dh $@
|
||||
36
ext/packaging.rake
Normal file
36
ext/packaging.rake
Normal file
@@ -0,0 +1,36 @@
|
||||
build_defs_file = File.join(RAKE_ROOT, 'ext', 'build_defaults.yaml')
|
||||
if File.exist?(build_defs_file)
|
||||
begin
|
||||
require 'yaml'
|
||||
@build_defaults ||= YAML.load_file(build_defs_file)
|
||||
rescue Exception => e
|
||||
STDERR.puts "Unable to load yaml from #{build_defs_file}:"
|
||||
raise e
|
||||
end
|
||||
@packaging_url = @build_defaults['packaging_url']
|
||||
@packaging_repo = @build_defaults['packaging_repo']
|
||||
raise "Could not find packaging url in #{build_defs_file}" if @packaging_url.nil?
|
||||
raise "Could not find packaging repo in #{build_defs_file}" if @packaging_repo.nil?
|
||||
|
||||
namespace :package do
|
||||
desc "Bootstrap packaging automation, e.g. clone into packaging repo"
|
||||
task :bootstrap do
|
||||
if File.exist?(File.join(RAKE_ROOT, "ext", @packaging_repo))
|
||||
puts "It looks like you already have ext/#{@packaging_repo}. If you don't like it, blow it away with package:implode."
|
||||
else
|
||||
cd File.join(RAKE_ROOT, 'ext') do
|
||||
%x{git clone #{@packaging_url}}
|
||||
end
|
||||
end
|
||||
end
|
||||
desc "Remove all cloned packaging automation"
|
||||
task :implode do
|
||||
rm_rf File.join(RAKE_ROOT, "ext", @packaging_repo)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
begin
|
||||
load File.join(RAKE_ROOT, 'ext', 'packaging', 'packaging.rake')
|
||||
rescue LoadError
|
||||
end
|
||||
14
ext/project_data.yaml
Normal file
14
ext/project_data.yaml
Normal file
@@ -0,0 +1,14 @@
|
||||
---
|
||||
project: 'mcollective-actionpolicy-auth'
|
||||
author: 'Puppet Labs'
|
||||
email: 'info@puppetlabs.com'
|
||||
homepage: 'https://github.com/puppetlabs/mcollective-actionpolicy-auth'
|
||||
summary: 'Action Policy simplerpc authorization plugin'
|
||||
description: 'Action Policy simplerpc authorization plugin'
|
||||
# files and gem_files are space separated lists
|
||||
files:
|
||||
- util
|
||||
# List of packaging related templates to evaluate before the tarball is packed
|
||||
templates:
|
||||
- "ext/redhat/mcollective-actionpolicy-auth.spec.erb"
|
||||
- "ext/debian/changelog.erb"
|
||||
39
ext/redhat/mcollective-actionpolicy-auth.spec.erb
Normal file
39
ext/redhat/mcollective-actionpolicy-auth.spec.erb
Normal file
@@ -0,0 +1,39 @@
|
||||
# VERSION is subbed out during rake srpm process
|
||||
%global realversion <%= @version %>
|
||||
%global rpmversion <%= @rpmversion %>
|
||||
|
||||
Summary: Action Policy simplerpc authorization plugin
|
||||
Name: mcollective-actionpolicy-auth
|
||||
Version: %{rpmversion}
|
||||
Release: <%= @rpmrelease -%>%{?dist}
|
||||
Vendor: %{?_host_vendor}
|
||||
License: ASL 2.0
|
||||
URL: https://github.com/puppetlabs/mcollective-actionpolicy-auth
|
||||
BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)
|
||||
BuildArch: noarch
|
||||
Group: System Tools
|
||||
Source0: mcollective-actionpolicy-auth-%{realversion}.tar.gz
|
||||
Requires: mcollective-common >= 2.2.1
|
||||
|
||||
%description
|
||||
Action Policy simplerpc authorization plugin
|
||||
|
||||
%prep
|
||||
%setup -q -n %{name}-%{realversion}
|
||||
|
||||
%build
|
||||
|
||||
%install
|
||||
rm -rf %{buildroot}
|
||||
%{__install} -d -m0755 %{buildroot}%{_libexecdir}/mcollective/mcollective
|
||||
cp -a util %{buildroot}%{_libexecdir}/mcollective/mcollective
|
||||
|
||||
%clean
|
||||
rm -rf %{buildroot}
|
||||
|
||||
%files
|
||||
%{_libexecdir}/mcollective/mcollective/util/*
|
||||
|
||||
%changelog
|
||||
* <%= Time.now.strftime("%a %b %d %Y") %> Puppet Labs Release <info@puppetlabs.com> - <%= @rpmversion %>-<%= @rpmrelease %>
|
||||
- Build for <%= @version %>
|
||||
Reference in New Issue
Block a user