Skip to content

Commit

Permalink
First cut at better build and install #106
Browse files Browse the repository at this point in the history
  • Loading branch information
mfeit-internet2 committed Jul 24, 2020
1 parent 3f39c3a commit bf4551e
Show file tree
Hide file tree
Showing 7 changed files with 111 additions and 171 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -42,3 +42,6 @@ staticfiles

# Build by-products
/esmond-*.rpm

# Editor droppings
*~
33 changes: 33 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
#
# Makefile for esmond
#
# (Doesn't really build anything, it's just here for the clean.)
#

default:
@echo "Nothing to do here."


TO_CLEAN += \
bin \
configure_esmond \
esmond.egg-info \
include \
lib \
lib64 \
pip-selfcheck.json \
staticfiles \
tsdb-data \
vagrant-data \
*.rpm

FILE_MODE=644
TO_CHMOD += \
util/gen_django_secret_key.py \
util/migrate_tastypie_keys.py \
util/ps_remove_data.conf \
util/ps_remove_data.py

clean:
chmod $(FILE_MODE) $(TO_CHMOD)
rm -rf $(TO_CLEAN) *~
29 changes: 1 addition & 28 deletions Vagrantfile
Original file line number Diff line number Diff line change
Expand Up @@ -206,34 +206,7 @@ EOF
echo
set -e
# TODO: See if there's a way to get this location from Vagrant
cd /vagrant
RPMBUILD="${HOME}/rpmbuild"
yum -y install git rpm-build
BRANCH=$(git rev-parse --abbrev-ref HEAD)
RPMVERSION=$(rpmspec -q --qf "%{Version}\n" rpm/esmond.spec | head -1)
for DIR in SOURCES SRPMS
do
mkdir -p "${RPMBUILD}/${DIR}"
done
git archive --format=tar --prefix="esmond-${RPMVERSION}/" "remotes/origin/${BRANCH}" \
| gzip > "${RPMBUILD}/SOURCES/esmond-${RPMVERSION}.tar.gz"
rpmbuild -bs rpm/esmond.spec
yum-builddep -y ${RPMBUILD}/SRPMS/*.src.rpm
rpmbuild -ba rpm/esmond.spec
cp ${RPMBUILD}/RPMS/$(uname -m)/* .
/vagrant/build-esmond
SHELL

Expand Down
54 changes: 54 additions & 0 deletions build-esmond
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
#!/bin/sh


echo
echo Building Esmond
echo

set -e

yum -y install git rpm-build

# TODO: See if there's a way to get this location from Vagrant
WORK_DIR=/tmp/esmond-build
rm -rf "${WORK_DIR}"
mkdir -p "${WORK_DIR}"
rsync --archive --delete ./ "${WORK_DIR}"

RPMBUILD="${HOME}/rpmbuild"
rm -rf "${RPMBUILD}"
for DIR in SOURCES SRPMS
do
mkdir -p "${RPMBUILD}/${DIR}"
done

OLD_DIR="${PWD}"
cd "${WORK_DIR}"

BRANCH=$(git rev-parse --abbrev-ref HEAD)

RPMVERSION=$(rpmspec -q --qf "%{Version}\n" rpm/esmond.spec | head -1)


TARBALL="${RPMBUILD}/SOURCES/esmond-${RPMVERSION}.tar.gz"
rm -rf "${TARBALL}"

TAR_BUILD=/tmp/esmond-tar-build
TAR_ESMOND="${TAR_BUILD}/esmond-${RPMVERSION}"
rm -rf "${TAR_BUILD}"
mkdir -p "${TAR_ESMOND}"
rsync \
--exclude "*~" \
--exclude "*.rpm" \
--archive --delete ./ "${TAR_ESMOND}"
(cd "${TAR_BUILD}" && tar czf "${TARBALL}" .)
rm -rf "${TAR_BUILD}"

rpmbuild -bs rpm/esmond.spec

yum-builddep -y ${RPMBUILD}/SRPMS/*.src.rpm

rpmbuild -ba rpm/esmond.spec

cp ${RPMBUILD}/RPMS/$(uname -m)/* "${OLD_DIR}"

61 changes: 19 additions & 42 deletions rpm/esmond.spec
Original file line number Diff line number Diff line change
Expand Up @@ -68,13 +68,19 @@ Requires: policycoreutils-python
Requires: cassandra20
Requires: httpd
Requires: mod_ssl
Requires: esmond-database
Requires(post): esmond-database
Requires: sqlite
Requires: sqlite-devel
Requires: memcached
#java 1.7 needed for cassandra. dependency wrong in cassandra rpm.
Requires: java-1.7.0-openjdk
Requires(post): drop-in


# Packages from older versions
Obsoletes: esmond-compat
Obsoletes: esmond-database




%description
Expand All @@ -83,48 +89,19 @@ uses a hybrid model for storing data using TSDB for time series data and an SQL
database for everything else. All data is available via a REST style interface
(as JSON) allowing for easy integration with other tools.

%package database-%{postgresql}
Summary: Esmond PostgreSQL %{postgresql_version} Database Plugin
Group: Development/Tools
Requires: %{postgresql} >= %{postgresql_version}
Requires: %{postgresql}-server >= %{postgresql_version}
Requires: %{postgresql}-devel >= %{postgresql_version}
Requires(post): %{postgresql} >= %{postgresql_version}
Requires(post): %{postgresql}-server >= %{postgresql_version}
Requires(post): %{postgresql}-devel >= %{postgresql_version}
Requires(post): drop-in
Provides: esmond-database

%description database-%{postgresql}
Installs Postgresql 9.5 using one of the vendor RPMs. It will also try to migrate an
older version of the database to Postgresql 9.5 if it finds one present and there is not
already data .

%package compat
Summary: Esmond Backward Compatibility
Group: Development/Tools
Requires: esmond >= 2.1
Requires: esmond-database-%{postgresql}
Obsoletes: esmond < 2.1

%description compat
Transitions esmond instances prior to the split of database modules to new version

%pre
# Create the 'esmond' user
/usr/sbin/groupadd -r esmond 2> /dev/null || :
/usr/sbin/useradd -g esmond -r -s /sbin/nologin -c "Esmond User" -d /tmp esmond 2> /dev/null || :

%pre database-%{postgresql}
# Create the 'esmond' user
/usr/sbin/groupadd -r esmond 2> /dev/null || :
/usr/sbin/useradd -g esmond -r -s /sbin/nologin -c "Esmond User" -d /tmp esmond 2> /dev/null || :

%prep
%setup -q -n %{name}-%{version}

%build


%install
# Copy and build in place so that we know what the path in the various files
# will be
Expand Down Expand Up @@ -181,14 +158,22 @@ rm -rf rpms
rm -f mkdevenv
rm -f pylint.rc
rm -f Vagrantfile
rm -rf vagrant
rm -rf .vagrant
rm -f build-esmond
rm -f Makefile
rm -rf debian
rm -rf .travis.yml



# Install python libs so don't rely on pip connectivity during RPM install
# NOTE: This part is why its not noarch
# We don't want to use a PIP > 19.0.2 to avoid build errors in dependencies
virtualenv-3.6 --prompt="(esmond)" . --system-site-packages --no-pip
. bin/activate
curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py
python get-pip.py pip==18.1
python3 get-pip.py pip==18.1
#Invoking pip using 'python -m pip' to avoid 128 char shebang line limit that pip can hit in build envs like Jenkins
python3 -m pip install --install-option="--prefix=%{buildroot}%{install_base}" -r requirements.txt
#not pretty but below is the best way I could find to remove references to buildroot
Expand Down Expand Up @@ -253,11 +238,6 @@ if [ "$1" = "1" ]; then
systemctl restart httpd
fi

%post database-%{postgresql}
#try to update the database if this is a clean install
if [ "$1" = "1" ]; then
%{dbscript_base}/upgrade-pgsql95.sh
fi

%postun
if [ "$1" != "0" ]; then
Expand All @@ -266,6 +246,7 @@ if [ "$1" != "0" ]; then
fi

%files
%defattr(-,esmond,esmond)
%config(noreplace) %{config_base}/esmond.conf
%attr(0755,esmond,esmond) %{install_base}/bin/*
%attr(0755,esmond,esmond) %{install_base}/util/*
Expand Down Expand Up @@ -302,12 +283,8 @@ fi
/etc/httpd/conf.d/apache-esmond.conf
%{_tmpfilesdir}/esmond.conf

%files database-%{postgresql}
%defattr(0644,esmond,esmond,0755)
%attr(0755,esmond,esmond) %{dbscript_base}/upgrade-pgsql95.sh
%attr(0755,esmond,esmond) %{dbscript_base}/configure-pgsql95.sh

%files compat

%changelog
* Wed Mar 5 2014 Monte Goode <mmgoode@lbl.gov> .99-1
Expand Down
2 changes: 1 addition & 1 deletion rpm/scripts/db/configure-pgsql95.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#!/bin/bash
PG_VERSION=9.5
PG_VERSION=10
PG_BINDIR=/usr/pgsql-${PG_VERSION}/bin
PG_DATADIR=/var/lib/pgsql/${PG_VERSION}/data
PG_SERVICE_NAME="postgresql-${PG_VERSION}"
Expand Down
100 changes: 0 additions & 100 deletions rpm/scripts/db/upgrade-pgsql95.sh

This file was deleted.

0 comments on commit bf4551e

Please sign in to comment.