Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 24 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1 +1,25 @@
include dev-resources/Makefile.i18n

.PHONY: version dist jar clean

WORKDIR := target
VERSION := $(shell awk --field-separator '"' '/def ps-version/ { print $$2 }' project.clj)
JAR := $(shell awk --field-separator '"' '/:uberjar-name/ { print $$2 }' project.clj)

version:
@echo $(VERSION)

clean:
rm -rf $(WORKDIR)

jar: $(WORKDIR)/$(JAR)

dist: $(WORKDIR)/puppetserver-$(VERSION).tar.gz

%.tar.gz: $(WORKDIR)/$(JAR) $(wildcard to-ship/*)
mkdir -p $(WORKDIR)/$*
cp -r $^ $(WORKDIR)/$*/
tar cf $@ -C $(WORKDIR) $*

$(WORKDIR)/$(JAR):
lein uberjar
14 changes: 14 additions & 0 deletions to-ship/Gemfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
source ENV['GEM_SOURCE'] || 'https://artifactory.delivery.puppetlabs.net/artifactory/api/gems/rubygems/'

def location_for(place, fake_version = nil)
if place =~ /^(git[:@][^#]*)#(.*)/
[fake_version, { :git => $1, :branch => $2, :require => false }].compact
elsif place =~ /^file:\/\/(.*)/
['>= 0', { :path => File.expand_path($1), :require => false }]
else
[place, { :require => false }]
end
end

gem 'packaging', *location_for(ENV['PACKAGING_LOCATION'] || '~> 0.99')
gem 'fpm'
63 changes: 63 additions & 0 deletions to-ship/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
prefix = /usr/local
datadir = $(prefix)/share
confdir = /etc
rubylibdir = $(shell ruby -rrbconfig -e "puts RbConfig::CONFIG['sitelibdir']")
rundir = /var/run
bindir = /usr/bin

install-puppetserver:
install -d -m 0755 "$(DESTDIR)$(datadir)/puppetserver"
install -m 0644 puppet-server-release.jar "$(DESTDIR)$(datadir)/puppetserver"
install -m 0774 ext/ezbake-functions.sh "$(DESTDIR)$(datadir)/puppetserver"
install -m 0644 ext/ezbake.manifest "$(DESTDIR)$(datadir)/puppetserver"
install -d -m 0755 "$(DESTDIR)$(confdir)/puppetlabs/puppetserver/conf.d"
install -m 0644 ext/config/conf.d/puppetserver.conf "$(DESTDIR)$(confdir)/puppetlabs/puppetserver/conf.d/puppetserver.conf"
install -m 0644 ext/config/request-logging.xml "$(DESTDIR)$(confdir)/puppetlabs/puppetserver/request-logging.xml"
install -m 0644 ext/config/logback.xml "$(DESTDIR)$(confdir)/puppetlabs/puppetserver/logback.xml"
install -m 0644 ext/config/conf.d/global.conf "$(DESTDIR)$(confdir)/puppetlabs/puppetserver/conf.d/global.conf"
install -m 0644 ext/config/conf.d/web-routes.conf "$(DESTDIR)$(confdir)/puppetlabs/puppetserver/conf.d/web-routes.conf"
install -m 0644 ext/config/conf.d/auth.conf "$(DESTDIR)$(confdir)/puppetlabs/puppetserver/conf.d/auth.conf"
install -m 0644 ext/config/conf.d/metrics.conf "$(DESTDIR)$(confdir)/puppetlabs/puppetserver/conf.d/metrics.conf"
install -m 0644 ext/config/conf.d/ca.conf "$(DESTDIR)$(confdir)/puppetlabs/puppetserver/conf.d/ca.conf"
install -m 0644 ext/config/conf.d/webserver.conf "$(DESTDIR)$(confdir)/puppetlabs/puppetserver/conf.d/webserver.conf"
install -m 0644 ext/config/services.d/ca.cfg "$(DESTDIR)$(confdir)/puppetlabs/puppetserver/services.d/ca.cfg"
install -d -m 0755 "$(DESTDIR)$(datadir)/puppetserver/cli"
install -d -m 0755 "$(DESTDIR)$(datadir)/puppetserver/cli/apps"
install -d -m 0755 "$(DESTDIR)$(bindir)"
install -m 0755 "ext/bin/puppetserver" "$(DESTDIR)$(bindir)/puppetserver"
install -m 0755 ext/cli/foreground "$(DESTDIR)$(datadir)/puppetserver/cli/apps/foreground"
install -m 0755 ext/cli/irb "$(DESTDIR)$(datadir)/puppetserver/cli/apps/irb"
install -m 0755 ext/cli/ca "$(DESTDIR)$(datadir)/puppetserver/cli/apps/ca"
install -m 0755 ext/cli/gem "$(DESTDIR)$(datadir)/puppetserver/cli/apps/gem"
install -m 0755 ext/cli/stop "$(DESTDIR)$(datadir)/puppetserver/cli/apps/stop"
install -m 0755 ext/cli/start "$(DESTDIR)$(datadir)/puppetserver/cli/apps/start"
install -m 0755 ext/cli/ruby "$(DESTDIR)$(datadir)/puppetserver/cli/apps/ruby"
install -m 0755 ext/cli/reload "$(DESTDIR)$(datadir)/puppetserver/cli/apps/reload"
install -m 0755 ext/cli/prune "$(DESTDIR)$(datadir)/puppetserver/cli/apps/prune"
install -d -m 0755 "$(DESTDIR)$(rundir)"


install-rpm-sysv-init: install-rpm-preinst
install -d -m 0755 "$(DESTDIR)$(initdir)"
install -m 0755 ext/redhat/init "$(DESTDIR)$(initdir)/puppetserver"
install -d -m 0755 "$(DESTDIR)$(defaultsdir)"
install -m 0644 ext/default "$(DESTDIR)$(defaultsdir)/puppetserver"
install -d -m 0755 "$(DESTDIR)$(rundir)"

install-rpm-systemd: install-rpm-preinst
install -d -m 0755 "$(DESTDIR)$(defaultsdir)"
install -m 0644 ext/default "$(DESTDIR)$(defaultsdir)/puppetserver"
install -d -m 0755 "$(DESTDIR)$(unitdir)"
install -m 0755 ext/puppetserver.service "$(DESTDIR)$(unitdir)/puppetserver.service"

install-rpm-preinst:

install-deb-sysv-init: install-deb-preinst
install -d -m 0755 "$(DESTDIR)$(initdir)"
install -m 0755 ext/debian/puppetserver.init "$(DESTDIR)$(initdir)/puppetserver"
install -d -m 0755 "$(DESTDIR)$(defaultsdir)"
install -m 0644 ext/default "$(DESTDIR)$(defaultsdir)/puppetserver"
install -d -m 0755 "$(DESTDIR)$(rundir)"

install-deb-preinst:

75 changes: 75 additions & 0 deletions to-ship/Rakefile
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't know why this file is here, but it's in the tarball now.

Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
require 'rake'
require './ezbake.rb'

puts "EZBAKE PROJECT NAME: #{EZBake::Config[:project]}"


RAKE_ROOT = File.dirname(__FILE__)

# TODO: not sure what to do here. I have it this way so that you
# can toggle it on and off during dev, but in practice, we probably
# just want it on all the time? Otherwise we'd just be detecting
# to see if there were any snapshots involved, and if so, we'd
# dynamically turn it on; so it's not providing any safety...
LEIN_SNAPSHOTS_IN_RELEASE = true
if LEIN_SNAPSHOTS_IN_RELEASE
ENV['LEIN_SNAPSHOTS_IN_RELEASE'] = 'y'
end

# Load tasks and variables for packaging automation
require 'packaging'
Pkg::Util::RakeUtils.load_packaging_tasks

namespace :package do
task :bootstrap do
puts 'Bootstrap is no longer needed, using packaging-as-a-gem'
end
task :implode do
puts 'Implode is no longer needed, using packaging-as-a-gem'
end
end

# We want to use ezbake's package:tar and its dependencies, because it
# contains all the special java snowflake magicks, so we have to clear the
# packaging repo's. We also want to use ezbake's clean task, since it has so
# much more clean than the packaging repo knows about
['clean'].each do |task|
Rake::Task[task].clear if Rake::Task.task_defined?(task)
end

# All variables have been set, so we can load the ezbake tasks
Dir[ File.join(RAKE_ROOT, 'tasks','*.rake') ].sort.each { |t| load t }

task :'default.erb' => [ :package ]

task :allclean => [ :clobber ]

desc "Remove build artifacts (other than clojure (lein) builds)"
task :clean do
rm_rf FileList["ext/files", "pkg", "*.tar.gz"]
end

desc "Get rid of build artifacts including clojure (lein) builds"
task :clobber => [ :clean ] do
rm_rf FileList["target/EZBake::Config[:project]*jar"]
end

if defined?(Pkg) and defined?(Pkg::Config)
@version = Pkg::Config.version
else
begin
%x{which git >/dev/null 2>&1}
if $?.success?
@version = %x{git describe --always --dirty}
if $?.success?
@version.chomp!
end
end
rescue
@version = "0.0-dev-build"
end
end

task :version do
puts @version
end
149 changes: 149 additions & 0 deletions to-ship/controller.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,149 @@
#!/bin/bash

set -ex

################
# Usage: controller.sh <os> <version> <basepath>
# The controller script does all of the jar compilation
# and setup needed to build packages for <os>
# The os string should be one of el, redhatfips, sles, debian, ubuntu,
# or fedora
# The version should be the numerical OS version for el,
# redhatfips, sles, and fedora and the codename for debian/ubuntu.
# The resulting artifacts will be stored in <basepath>
################
build_os=$1
build_ver=$2
basepath=$3

if [ ! -d "$basepath" ]; then
mkdir -p $basepath
fi
if [ ! -d "$basepath/base" ]; then
DESTDIR="$basepath/base" bash install.sh install_redhat
fi
if [ ! -d "$basepath/systemd_el" ]; then
cp -r "$basepath/base" "$basepath/systemd_el"
DESTDIR="$basepath/systemd_el" bash install.sh systemd_redhat
fi
if [ ! -d "$basepath/old_el" ]; then
cp -r "$basepath/base" "$basepath/old_el"
DESTDIR="$basepath/old_el" bash install.sh sysv_init_redhat
fi
if [ ! -d "$basepath/old_sles" ]; then
cp -r "$basepath/base" "$basepath/old_sles"
DESTDIR="$basepath/old_sles" bash install.sh sysv_init_suse
fi


# things are only different if we have docs, deb docs get
# installed in an unversioned folder but rpm docs get installed
# in a versioned folder.
if [ -d ext/docs ]; then
if [ ! -d "$basepath/base_deb" ]; then
DESTDIR="$basepath/base_deb" bash install.sh install_deb
if [ ! -d "$basepath/systemd_deb" ]; then
cp -r "$basepath/base_deb" "$basepath/systemd_deb"
DESTDIR="$basepath/systemd_deb" bash install.sh systemd_deb
fi
if [ ! -d "$basepath/systemd_notasksmax_deb" ]; then
cp -r "$basepath/base_deb" "$basepath/systemd_notasksmax_deb"
DESTDIR="$basepath/systemd_notasksmax_deb" USE_TASKSMAX=false bash install.sh systemd_deb
fi
if [ ! -d "$basepath/sysvinit_deb" ]; then
cp -r "$basepath/base_deb" "$basepath/sysvinit_deb"
DESTDIR="$basepath/sysvinit_deb" bash install.sh sysv_init_deb
fi
fi
else
if [ ! -d "$basepath/systemd_deb" ]; then
cp -r "$basepath/base" "$basepath/systemd_deb"
DESTDIR="$basepath/systemd_deb" bash install.sh systemd_deb
fi
if [ ! -d "$basepath/systemd_notasksmax_deb" ]; then
cp -r "$basepath/base" "$basepath/systemd_notasksmax_deb"
DESTDIR="$basepath/systemd_notasksmax_deb" USE_TASKSMAX=false bash install.sh systemd_deb
fi
if [ ! -d "$basepath/sysvinit_deb" ]; then
cp -r "$basepath/base" "$basepath/sysvinit_deb"
DESTDIR="$basepath/sysvinit_deb" bash install.sh sysv_init_deb
fi
fi

os=$build_os
if [ "$os" = "debian" ]; then
os_dist=$build_ver
else
os_version=$build_ver
fi

case $os in
# there's no differences in packaging for deb vs ubuntu
# if that changes we'll need to fix this
debian|ubuntu)
if [ "$os_dist" = 'trusty' ]; then
dir="$basepath/sysvinit_deb"
elif [ "$os_dist" = 'jessie' ]; then
# the version of systemd that ships with jessie doesn't
# support TasksMax
dir="$basepath/systemd_notasksmax_deb"
else
dir="$basepath/systemd_deb"
fi
;;
el|redhatfips)
if [ "$os_version" -gt '6' ]; then
dir="$basepath/systemd_el"
else
dir="$basepath/old_el"
fi
;;
amazon)
dir="$basepath/systemd_el"
;;
sles)
if [ "$os_version" -gt '11' ]; then
dir="$basepath/systemd_el"
else
dir="$basepath/old_sles"
fi
;;
*)
echo "I have no idea what I'm doing with $os, teach me?" >&2
exit 1
;;
esac

# bash will eat your spaces, so let's array. see http://mywiki.wooledge.org/BashFAQ/050 for more fun.
params=("--user" "puppet" "--group" "puppet" "--chdir" "$dir" "--realname" "puppetserver" "--operating-system" "$os" "--name" "openvox-server" "--package-version" "8.11.0" "--release" "1" "--platform-version" "8")
if [ -n "$os_version" ]; then params+=("--os-version" "$os_version"); fi
if [ -n "$os_dist" ]; then params+=("--dist" "$os_dist"); fi

params+=('--description' "$(printf "Vox Pupuli puppetserver\nContains: OpenVox Server (puppetlabs/puppetserver 8.11.0,org.clojure/clojure 1.11.2,org.bouncycastle/bcpkix-jdk18on 1.78.1,puppetlabs/jruby-utils 5.2.0,puppetlabs/puppetserver 8.11.0,com.puppetlabs/trapperkeeper-webserver-jetty10 1.0.18,puppetlabs/trapperkeeper-metrics 2.0.4)")")
Comment on lines +117 to +122
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this part should be templated somehow




params+=('--replaces' "'puppetserver',''")


params+=('--create-dir' '/opt/puppetlabs/server/data/puppetserver/jars')
params+=('--create-dir' '/opt/puppetlabs/server/data/puppetserver/yaml')



if [[ "$os" = 'el' || "$os" = 'sles' || "$os" = 'fedora' || "$os" = 'redhatfips' || "$os" = 'amazon' ]]; then
# pull in rpm dependencies
params+=("--additional-dependency")
params+=("openvox-agent >= 8.21.1")
# get rpm install trigger scripts
# get rpm upgrade trigger scripts
: # Need something in case there are no additional dependencies
else
# if we aren't an rpm, pull in deb dependencies
params+=("--additional-dependency")
params+=("openvox-agent (>= 8.21.1)")
: # Need something in case there are no additional dependencies
fi
Comment on lines +126 to +146
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This part can probably be folded into fpm.rb.



ruby $PWD/ext/fpm.rb "${params[@]}"
Loading