Add systemd unit file for kojid

Signed-off-by: Dennis Gilmore <dennis@ausil.us>
This commit is contained in:
Zbigniew Jędrzejewski-Szmek 2013-08-10 15:17:27 -04:00 committed by Dennis Gilmore
parent 3260dbebdb
commit 10a75fc22f
4 changed files with 66 additions and 9 deletions

View file

@ -105,6 +105,7 @@ force-tag::
# @$(MAKE) tag TAG_OPTS="-F $(TAG_OPTS)"
DESTDIR ?= /
TYPE = systemd
install:
@if [ "$(DESTDIR)" = "" ]; then \
echo " "; \
@ -115,4 +116,4 @@ install:
mkdir -p $(DESTDIR)
for d in $(SUBDIRS); do make DESTDIR=`cd $(DESTDIR); pwd` \
-C $$d install; [ $$? = 0 ] || exit 1; done
-C $$d install TYPE=$(TYPE); [ $$? = 0 ] || exit 1; done

View file

@ -1,6 +1,7 @@
BINFILES = kojid
LIBEXECFILES = mergerepos
SYSTEMDSYSTEMUNITDIR = $(shell pkg-config systemd --variable=systemdsystemunitdir)
TYPE = systemd
_default:
@echo "nothing to make. try make install"
@ -9,7 +10,7 @@ clean:
rm -f *.o *.so *.pyc *~
install:
_install:
@if [ "$(DESTDIR)" = "" ]; then \
echo " "; \
echo "ERROR: A destdir is required"; \
@ -23,13 +24,19 @@ install:
install -p -m 755 $(LIBEXECFILES) $(DESTDIR)/usr/libexec/kojid
mkdir -p $(DESTDIR)/etc/mock/koji
mkdir -p $(DESTDIR)/etc/kojid
install -p -m 644 kojid.conf $(DESTDIR)/etc/kojid/kojid.conf
install-systemd: _install
mkdir -p $(DESTDIR)$(SYSTEMDSYSTEMUNITDIR)
install -p -m 644 kojid.service $(DESTDIR)$(SYSTEMDSYSTEMUNITDIR)
install-sysv: _install
mkdir -p $(DESTDIR)/etc/rc.d/init.d
install -p -m 755 kojid.init $(DESTDIR)/etc/rc.d/init.d/kojid
mkdir -p $(DESTDIR)/etc/sysconfig
install -p -m 644 kojid.sysconfig $(DESTDIR)/etc/sysconfig/kojid
mkdir -p $(DESTDIR)/etc/kojid
install -p -m 644 kojid.conf $(DESTDIR)/etc/kojid/kojid.conf
install: install-$(TYPE)

14
builder/kojid.service Normal file
View file

@ -0,0 +1,14 @@
[Unit]
Description=Koji build server
Documentation=https://fedoraproject.org/wiki/Koji/ServerHowTo
After=network.target
[Service]
ExecStart=/usr/sbin/kojid \
--fg \
--force-lock \
--verbose
[Install]
WantedBy=multi-user.target

View file

@ -1,5 +1,12 @@
%{!?python_sitelib: %define python_sitelib %(%{__python} -c "from distutils.sysconfig import get_python_lib; print get_python_lib()")}
%if 0%{?fedora} >= 21 || 0%{?redhat} >= 7
%global use_systemd 1
%else
%global use_systemd 0
%global install_opt TYPE=sysv
%endif
%define baserelease 1
#build with --define 'testbuild 1' to have a timestamp appended to release
%if "x%{?testbuild}" == "x1"
@ -23,6 +30,10 @@ Requires: rpm-python
Requires: pyOpenSSL
Requires: python-urlgrabber
BuildRequires: python
%if %{use_systemd}
BuildRequires: systemd
BuildRequires: pkgconfig
%endif
%description
Koji is a system for building and tracking RPMS. The base package
@ -63,11 +74,17 @@ License: LGPLv2 and GPLv2+
#mergerepos (from createrepo) is GPLv2+
Requires: %{name} = %{version}-%{release}
Requires: mock >= 0.9.14
Requires(pre): /usr/sbin/useradd
%if %{use_systemd}
Requires(post): systemd
Requires(preun): systemd
Requires(postun): systemd
%else
Requires(post): /sbin/chkconfig
Requires(post): /sbin/service
Requires(preun): /sbin/chkconfig
Requires(preun): /sbin/service
Requires(pre): /usr/sbin/useradd
%endif
Requires: /usr/bin/cvs
Requires: /usr/bin/svn
Requires: /usr/bin/git
@ -135,7 +152,7 @@ koji-web is a web UI to the Koji system.
%install
rm -rf $RPM_BUILD_ROOT
make DESTDIR=$RPM_BUILD_ROOT install
make DESTDIR=$RPM_BUILD_ROOT %{?install_opt} install
%clean
rm -rf $RPM_BUILD_ROOT
@ -192,8 +209,12 @@ rm -rf $RPM_BUILD_ROOT
%{_sbindir}/kojid
%dir %{_libexecdir}/kojid
%{_libexecdir}/kojid/mergerepos
%if %{use_systemd}
%{_unitdir}/kojid.service
%else
%{_initrddir}/kojid
%config(noreplace) %{_sysconfdir}/sysconfig/kojid
%endif
%dir %{_sysconfdir}/kojid
%config(noreplace) %{_sysconfdir}/kojid/kojid.conf
%attr(-,kojibuilder,kojibuilder) %{_sysconfdir}/mock/koji
@ -201,6 +222,19 @@ rm -rf $RPM_BUILD_ROOT
%pre builder
/usr/sbin/useradd -r -s /bin/bash -G mock -d /builddir -M kojibuilder 2>/dev/null ||:
%if %{use_systemd}
%post builder
%systemd_post kojid.service
%preun builder
%systemd_preun kojid.service
%postun builder
%systemd_postun kojid.service
%else
%post builder
/sbin/chkconfig --add kojid
@ -209,6 +243,7 @@ if [ $1 = 0 ]; then
/sbin/service kojid stop &> /dev/null
/sbin/chkconfig --del kojid
fi
%endif
%files vm
%defattr(-,root,root)