Skip to content

Commit

Permalink
Merge pull request #123 from PagerDuty/release_v1_5
Browse files Browse the repository at this point in the history
Release v1.5
  • Loading branch information
mlewis033 authored Aug 13, 2018
2 parents 5adfa79 + 6053b63 commit bc25305
Show file tree
Hide file tree
Showing 23 changed files with 354 additions and 105 deletions.
47 changes: 26 additions & 21 deletions Vagrantfile
Original file line number Diff line number Diff line change
@@ -1,45 +1,50 @@
# -*- mode: ruby -*-
# vi: set ft=ruby :


_bento_centos65 = {
"box" => "bento_centos65",
"box_url" => "http://opscode-vm-bento.s3.amazonaws.com/vagrant/virtualbox/opscode_centos-6.5_chef-provisionerless.box",
"box" => "bento_centos65",
"box_url" => "http://opscode-vm-bento.s3.amazonaws.com/vagrant/virtualbox/opscode_centos-6.5_chef-provisionerless.box",
}
_bento_centos72 = {
"box" => "bento_centos72",
"box_url" => "http://opscode-vm-bento.s3.amazonaws.com/vagrant/virtualbox/opscode_centos-7.2_chef-provisionerless.box",
}
_bento_ubuntu1204 = {
"box" => "bento_ubuntu1204",
"box_url" => "http://opscode-vm-bento.s3.amazonaws.com/vagrant/virtualbox/opscode_ubuntu-12.04_chef-provisionerless.box",
"box" => "bento_ubuntu1204",
"box_url" => "http://opscode-vm-bento.s3.amazonaws.com/vagrant/virtualbox/opscode_ubuntu-12.04_chef-provisionerless.box",
}
_bento_ubuntu1404 = {
"box" => "bento_ubuntu1404",
"box_url" => "http://opscode-vm-bento.s3.amazonaws.com/vagrant/virtualbox/opscode_ubuntu-14.04_chef-provisionerless.box",
"box" => "bento_ubuntu1404",
"box_url" => "http://opscode-vm-bento.s3.amazonaws.com/vagrant/virtualbox/opscode_ubuntu-14.04_chef-provisionerless.box",
}
_bento_ubuntu1604 = {
"box" => "bento_ubuntu1604",
"box_url" => "http://opscode-vm-bento.s3.amazonaws.com/vagrant/virtualbox/opscode_ubuntu-16.04_chef-provisionerless.box",
"box" => "bento_ubuntu1604",
"box_url" => "http://opscode-vm-bento.s3.amazonaws.com/vagrant/virtualbox/opscode_ubuntu-16.04_chef-provisionerless.box",
}

vms = {
"agent-minimal-centos65" => _bento_centos65,
"agent-minimal-ubuntu1204" => _bento_ubuntu1204,
"agent-minimal-ubuntu1404" => _bento_ubuntu1404,
"agent-minimal-ubuntu1604" => _bento_ubuntu1604
"agent-minimal-centos65" => _bento_centos65,
"agent-minimal-centos72" => _bento_centos72,
"agent-minimal-ubuntu1204" => _bento_ubuntu1204,
"agent-minimal-ubuntu1404" => _bento_ubuntu1404,
"agent-minimal-ubuntu1604" => _bento_ubuntu1604
}

Vagrant.configure("2") do |conf_outer|

vms.each do |name, conf|
vms.each do |name, conf|

conf_outer.vm.define name do |config|
conf_outer.vm.define name do |config|

config.vm.box = conf["box"]
config.vm.box_url = conf["box_url"]
config.vm.box = conf["box"]
config.vm.box_url = conf["box_url"]

# Public/bridged network so VM can install packages from the internet
config.vm.network :public_network, :bridge => "en0: Wi-Fi (AirPort)"
## no longer necessary with Vagrant 2.1.2?
# Public/bridged network so VM can install packages from the internet
# config.vm.network :public_network, :bridge => "en0: Wi-Fi (AirPort)"

end # conf_outer.vm.define
end # conf_outer.vm.define

end # vms.each
end # vms.each

end # Vagrant.configure
39 changes: 39 additions & 0 deletions build-linux/deb/postrm
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
#!/bin/sh
#
# Copyright (c) 2013-2014, PagerDuty, Inc. <info@pagerduty.com>
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met:
#
# * Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer.
# * Redistributions in binary form must reproduce the above copyright
# notice, this list of conditions and the following disclaimer in the
# documentation and/or other materials provided with the distribution.
# * Neither the name of the copyright holder nor the
# names of its contributors may be used to endorse or promote products
# derived from this software without specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
# POSSIBILITY OF SUCH DAMAGE.
#

set -e

if [ $# -gt 1 ]; then # this is an upgrade
: # no-op
else # this is a remove
: # no-op
fi

exit 0
6 changes: 5 additions & 1 deletion build-linux/howto.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

# Linux Build Instructions

These instructions assume you're running this on a Mac with Vagrant installed,
Expand All @@ -9,6 +8,11 @@ should happen automatically)

To build Linux packages, you will need GPG keys to sign the packages.

NOTE: you'll need to generate your dev keys with gpg1 not gpg2. The command
sequence below should generate files: pubring.gpg, secring.gpg and trustdb.gpg.
If you see a file called pubring.kbx and a bunch of socket files then you're using
gpg2.

For development, you can generate new keys as follows:

```
Expand Down
2 changes: 1 addition & 1 deletion build-linux/make_common.env
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
## common variables for make_* scripts

FPM_VERSION=1.7.0
FPM_VERSION=1.4.0
32 changes: 13 additions & 19 deletions build-linux/make_package.sh
Original file line number Diff line number Diff line change
Expand Up @@ -87,22 +87,14 @@ mkdir -p \
data/var/lib/pdagent/outqueue/err \
data/var/lib/pdagent/outqueue/suc
mkdir -p data/var/lib/pdagent/scripts
# stage sysV & systemd service files for deb postinst
# stage sysV & systemd service files for pkg postinst
cp pdagent.init data/var/lib/pdagent/scripts/pdagent.init
cp pdagent.service data/var/lib/pdagent/scripts/pdagent.service

echo = /etc/...
mkdir -p data/etc/
cp ../conf/pdagent.conf data/etc/

if [ "$pkg_type" = "rpm" ]; then
# marks /etc/init.d/pdagent as co-owned by old_rpm && new_rpm and saves it from removal
# during yum update cleanu of old_rpm (yum cleanup internals regardless of prerm script)
mkdir -p data/etc/init.d
cp pdagent.init data/etc/init.d/pdagent
chmod 755 data/etc/init.d/pdagent
fi

if [ "$pkg_type" = "deb" ]; then
_PY_SITE_PACKAGES=data/usr/lib/python2.7/dist-packages
else
Expand All @@ -118,7 +110,6 @@ find pdagent -type f \( -name "*.py" -o -name "ca_certs.pem" \) \
-exec cp {} build-linux/$_PY_SITE_PACKAGES/{} \;
cd -


# copy the libraries for python2.7 rpm users
if [ "$pkg_type" = "rpm" ]; then
mkdir -p "$_PY27_SITE_PACKAGES"
Expand All @@ -133,6 +124,11 @@ if [ "$pkg_type" = "rpm" ]; then
_SIGN_OPTS="--rpm-sign"
fi

_POST_TRANS_OPT=""
if [ "$pkg_type" = "rpm" ]; then
_POST_TRANS_OPT="--rpm-posttrans ../rpm/posttrans"
fi

cd target

_DESC="The PagerDuty Agent package
Expand All @@ -145,18 +141,12 @@ else
fi
_PKG_MAINTAINER="$_PKG_MAINTAINER (PagerDuty, Inc.) <packages@pagerduty.com>"
if [ "$pkg_type" = "rpm" ]; then
source /opt/rh/ruby193/enable
FPM=/opt/rh/ruby193/root/usr/local/share/gems/gems/fpm-$FPM_VERSION/bin/fpm
source /opt/rh/rh-ruby23/enable
FPM=/opt/rh/rh-ruby23/root/usr/local/share/gems/gems/fpm-$FPM_VERSION/bin/fpm
else
FPM=fpm
fi

if [ "$pkg_type" = "deb" ]; then
_BEFORE_AND_AFTER_OPTS="--before-install ../$pkg_type/preinst --after-install ../$pkg_type/postinst --before-remove ../$pkg_type/prerm"
else
_BEFORE_AND_AFTER_OPTS="--after-install ../$pkg_type/postinst --before-remove ../$pkg_type/prerm"
fi

$FPM -s dir \
-t $pkg_type \
--name "pdagent" \
Expand All @@ -172,7 +162,11 @@ $FPM -s dir \
--${pkg_type}-user root \
--${pkg_type}-group root \
--config-files /etc/pdagent.conf \
$_BEFORE_AND_AFTER_OPTS \
--before-install ../$pkg_type/preinst \
--after-install ../$pkg_type/postinst \
--before-remove ../$pkg_type/prerm \
--after-remove ../$pkg_type/postrm \
$_POST_TRANS_OPT \
-C ../data \
etc usr var

Expand Down
25 changes: 9 additions & 16 deletions build-linux/make_rpm.sh
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
# POSSIBILITY OF SUCH DAMAGE.
#

set -e
set -x

# do stuff in the script's directory.
basedir=$(dirname $0)
Expand All @@ -48,27 +48,20 @@ rpm_install_root=$install_root/rpm
[ -d "$rpm_install_root" ] || mkdir -p $rpm_install_root

# install required packages.
[ $(sudo rpm -q rpm-build ruby193 createrepo \
[ $(sudo rpm -q rpm-build rh-ruby23 createrepo \
gcc gcc-c++ kernel-devel | \
grep -vc 'not installed') -eq 7 ] || {
echo "Installing required packages. This may take a few minutes..."
sudo yum install -y -q rpm-build createrepo gcc gcc-c++ kernel-devel
sudo yum install -y -q centos-release-SCL
sudo yum install -y -q ruby193 ruby193-ruby-devel
source /opt/rh/ruby193/enable
CUR_PWD=`pwd`
echo "Installing rubygems ..."
cd /tmp
sudo wget --no-check-certificate https://rubygems.org/rubygems/rubygems-2.6.8.tgz
sudo tar xzf rubygems-2.6.8.tgz
cd rubygems-2.6.8
sudo "LD_LIBRARY_PATH=$LD_LIBRARY_PATH" /opt/rh/ruby193/root/usr/bin/ruby setup.rb
cd $CUR_PWD
echo "Done installing."
sudo yum install -y -q centos-release-scl
sudo yum install -y -q rh-ruby23 rh-ruby23-ruby-devel
}
{ gem list fpm | grep fpm >/dev/null ; } || {

source /opt/rh/rh-ruby23/enable

{ sudo /opt/rh/rh-ruby23/root/usr/bin/gem list fpm | grep fpm >/dev/null ; } || {
echo "Installing fpm gem..."
sudo "LD_LIBRARY_PATH=$LD_LIBRARY_PATH" /opt/rh/ruby193/root/usr/bin/gem install -q -v $FPM_VERSION fpm
sudo "LD_LIBRARY_PATH=$LD_LIBRARY_PATH" /opt/rh/rh-ruby23/root/usr/bin/gem install -q -v $FPM_VERSION fpm
echo "Done installing."
}

Expand Down
23 changes: 19 additions & 4 deletions build-linux/rpm/postinst
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,19 @@

set -e

install_init () {
cp /var/lib/pdagent/scripts/pdagent.init /etc/init.d/pdagent
chmod +x /etc/init.d/pdagent
chkconfig --add pdagent
service pdagent restart
}

install_systemd () {
cp /var/lib/pdagent/scripts/pdagent.service /lib/systemd/system
systemctl enable pdagent
systemctl restart pdagent
}

# Create pdagent user & group
/usr/bin/getent passwd pdagent >/dev/null || \
/usr/sbin/adduser --system --shell /bin/false --no-create-home pdagent
Expand All @@ -52,8 +65,10 @@ fi
# Compile module .py to .pyc
python -m compileall -q -f "$INSTALL_PATH/"

# Register daemon
chkconfig --add pdagent
if which systemctl >/dev/null; then
install_systemd
else
install_init
fi

# Restart daemon
service pdagent restart
exit 0
39 changes: 39 additions & 0 deletions build-linux/rpm/postrm
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
#!/bin/sh
#
# Copyright (c) 2013-2014, PagerDuty, Inc. <info@pagerduty.com>
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met:
#
# * Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer.
# * Redistributions in binary form must reproduce the above copyright
# notice, this list of conditions and the following disclaimer in the
# documentation and/or other materials provided with the distribution.
# * Neither the name of the copyright holder nor the
# names of its contributors may be used to endorse or promote products
# derived from this software without specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
# POSSIBILITY OF SUCH DAMAGE.
#

set -e

if [ $1 -gt 0 ]; then # this is an upgrade
: # no-op
else # this is a remove
: # no-op
fi

exit 0
51 changes: 51 additions & 0 deletions build-linux/rpm/posttrans
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
#!/bin/sh
#
# Copyright (c) 2013-2014, PagerDuty, Inc. <info@pagerduty.com>
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met:
#
# * Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer.
# * Redistributions in binary form must reproduce the above copyright
# notice, this list of conditions and the following disclaimer in the
# documentation and/or other materials provided with the distribution.
# * Neither the name of the copyright holder nor the
# names of its contributors may be used to endorse or promote products
# derived from this software without specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
# POSSIBILITY OF SUCH DAMAGE.
#

set -e

reinstate_init () {
cp /var/lib/pdagent/scripts/pdagent.init /etc/init.d/pdagent
chmod +x /etc/init.d/pdagent
}

if [ -e "/tmp/pdagent_upgrade.txt" ]; then
if which systemctl >/dev/null; then
:
else
# reinstate /etc/init.d/pdagent that was deleted by v1.4 pkg removal
# this is a one-time fix and can be removed on the next version rev (v1.6)
reinstate_init
fi

# cleanup tmp file
rm /tmp/pdagent_upgrade.txt
fi

exit 0
Loading

0 comments on commit bc25305

Please sign in to comment.