Skip to content

Commit

Permalink
Merge pull request #56 from Comcast/migrate-to-centos7
Browse files Browse the repository at this point in the history
Work on updating support Centos 7 and Systemd.
  • Loading branch information
schmidtw authored Nov 13, 2017
2 parents 36b6a90 + fd68452 commit 6e11d76
Show file tree
Hide file tree
Showing 10 changed files with 162 additions and 281 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ src/vendor
src/caduceus/caduceus
src/caduceus/debug
src/caduceus/output
caduceus.spec

# config
src/caduceus/caduceus.json
Expand Down
4 changes: 2 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ branches:
- master

before_install:
- docker pull schmidtw/webpa.builder.centos6:latest
- docker run -it -e BUILD_NUMBER=$TRAVIS_BUILD_NUMBER -d --name build schmidtw/webpa.builder.centos6 bash
- docker pull schmidtw/xmidt.builder.centos7:latest
- docker run -it -e BUILD_NUMBER=$TRAVIS_BUILD_NUMBER -d --name build schmidtw/xmidt.builder.centos7 bash
- env
- docker exec build rpm -q golang
- docker exec build go version
Expand Down
2 changes: 2 additions & 0 deletions ChangeLog
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
* Sun Nov 12 2017 Weston Schmidt - 0.1.1
- update to support centos 7 / systemd
* Tue Mar 28 2017 Weston Schmidt - 0.1.1
- initial creation
61 changes: 52 additions & 9 deletions build_rpm.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,41 @@

NAME=caduceus

RPM_BUILD_ROOT=/root
SIGN=1


usage()
{
echo "usage: build_rpm.sh [--rpm-build-root path] [--no-sign]"
echo " --rpm-build-root - the path where /rpmbuild exists for your user"
echo " --no-sign - don't try to sign the build"
}

while [ "$1" != "" ]; do
case $1 in
--rpm-build-root ) shift
RPM_BUILD_ROOT=$1
;;

--no-sign ) SIGN=0
;;

--build-number ) shift
BUILD_NUMBER=$1
;;

-h | --help ) usage
exit
;;

* ) usage
exit 1

esac
shift
done

echo "Adjusting build number..."

taglist=`git tag -l`
Expand All @@ -26,22 +61,30 @@ echo "Building the ${NAME} rpm..."
pushd ..
cp -r ${NAME} ${NAME}-$release
tar -czvf ${NAME}-$new_release.tar.gz ${NAME}-$release
mv ${NAME}-$new_release.tar.gz /root/rpmbuild/SOURCES
mv ${NAME}-$new_release.tar.gz ${RPM_BUILD_ROOT}/rpmbuild/SOURCES
rm -rf ${NAME}-$release
popd

# Merge the changelog into the spec file so we're consistent
cat ${NAME}.spec.in > ${NAME}.spec
cat ChangeLog >> ${NAME}.spec

yes "" | rpmbuild -ba --sign \
--define "_signature gpg" \
--define "_gpg_name Comcast Xmidt Team <[email protected]>" \
--define "_ver $release" \
--define "_releaseno ${BUILD_NUMBER}" \
--define "_fullver $new_release" \
${NAME}.spec
if [ 0 eq $SIGN ]; then
yes "" | rpmbuild -ba \
--define "_ver $release" \
--define "_releaseno ${BUILD_NUMBER}" \
--define "_fullver $new_release" \
${NAME}.spec
else
yes "" | rpmbuild -ba --sign \
--define "_signature gpg" \
--define "_gpg_name Comcast Xmidt Team <[email protected]>" \
--define "_ver $release" \
--define "_releaseno ${BUILD_NUMBER}" \
--define "_fullver $new_release" \
${NAME}.spec
fi

pushd ..
echo "$new_release" > versionno.txt
popd

110 changes: 0 additions & 110 deletions caduceus.spec

This file was deleted.

93 changes: 93 additions & 0 deletions caduceus.spec.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
%define debug_package %{nil}

Name: caduceus
Version: %{_ver}
Release: %{_releaseno}%{?dist}
Summary: The Xmidt event delivery server.

Group: System Environment/Daemons
License: ASL 2.0
URL: https://github.com/Comcast/%{name}
Source0: %{name}-%{_fullver}.tar.gz

BuildRequires: golang >= 1.8
BuildRequires: systemd
Requires: systemd

Provides: %{name}

%description
The Xmidt server for delivering events.

%prep
%setup -q


%build
export GOPATH=$(pwd)
pushd src
glide install --strip-vendor
cd %{name}
go build %{name}
popd

%install

# Install Binary
mkdir -p %{buildroot}%{_bindir}
%{__install} -p src/%{name}/%{name} %{buildroot}%{_bindir}

# Install Service
mkdir -p %{buildroot}%{_unitdir}/
%{__install} -m644 etc/systemd/%{name}.service %{buildroot}%{_unitdir}

# Install Configuration
%{__install} -d %{buildroot}%{_sysconfdir}/%{name}
%{__install} -p etc/%{name}/%{name}.json %{buildroot}%{_sysconfdir}/%{name}/%{name}.json

# Create Logging Location
%{__install} -d %{buildroot}%{_localstatedir}/log/%{name}

%files
%defattr(644, %{name}, %{name}, 755)

# Binary
%attr(755, %{name}, %{name}) %{_bindir}/%{name}

# Systemd
%attr(755, %{name}, %{name}) %{_unitdir}/%{name}.service

# Configuration
%dir %{_sysconfdir}/%{name}
%config %attr(644, %{name}, %{name}) %{_sysconfdir}/%{name}/%{name}.json

# Logging Location
%dir %{_localstatedir}/log/%{name}

%pre
# If app user does not exist, create
id %{name} >/dev/null 2>&1
if [ $? != 0 ]; then
/usr/sbin/groupadd -r %{name} >/dev/null 2>&1
/usr/sbin/useradd -r -g %{name} %{name} >/dev/null 2>&1
fi


%post
%systemd_post %{name}.service

%preun
%systemd_preun %{name}.service

%postun
%systemd_postun_with_restart %{name}.service

# Do not remove anything if this is not an uninstall
if [ $1 = 0 ]; then
/usr/sbin/userdel -r %{name} >/dev/null 2>&1
/usr/sbin/groupdel %{name} >/dev/null 2>&1
# Ignore errors from above
true
fi

%changelog
5 changes: 0 additions & 5 deletions etc/caduceus/caduceus.env.example

This file was deleted.

61 changes: 0 additions & 61 deletions etc/caduceus/supervisord.conf

This file was deleted.

Loading

0 comments on commit 6e11d76

Please sign in to comment.