-
Notifications
You must be signed in to change notification settings - Fork 21
/
caduceus.spec
86 lines (68 loc) · 2.45 KB
/
caduceus.spec
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
%define AutoReqProv: no
%define __os_install_post %{nil}
Name: caduceus
Version: %{_version}
Release: %{_release}%{?dist}
Summary: The Xmidt API interface server.
Vendor: Comcast
Packager: Comcast
Group: System Environment/Daemons
License: ASL 2.0
URL: https://github.com/xmidt-org/caduceus
Source0: %{name}-%{_version}-%{_release}.tar.gz
Prefix: /opt
BuildRoot: %{_tmppath}/%{name}
BuildRequires: systemd
BuildRequires: golang >= 1.12
%description
The XMiDT server for delivering events
%build
GO111MODULE=on go build -ldflags "-X 'main.BuildTime=`date -u '+%Y-%m-%d %H:%M:%S'`' -X main.GitCommit=`git rev-parse --short HEAD` -X main.Version=%{_version}" -o $RPM_SOURCE_DIR/%{name} %{_topdir}/..
%install
echo rm -rf %{buildroot}
%{__install} -d %{buildroot}%{_bindir}
%{__install} -d %{buildroot}%{_initddir}
%{__install} -d %{buildroot}%{_sysconfdir}/%{name}
%{__install} -d %{buildroot}%{_localstatedir}/log/%{name}
%{__install} -d %{buildroot}%{_localstatedir}/run/%{name}
%{__install} -d %{buildroot}%{_unitdir}
%{__install} -p $RPM_SOURCE_DIR/%{name} %{buildroot}%{_bindir}
%{__install} -p $RPM_SOURCE_DIR/%{name}.service %{buildroot}%{_unitdir}/%{name}.service
%{__install} -p $RPM_SOURCE_DIR/%{name}.yaml %{buildroot}%{_sysconfdir}/%{name}/%{name}.yaml
%files
%defattr(644, root, root, 755)
%doc $RPM_SOURCE_DIR/LICENSE $RPM_SOURCE_DIR/CHANGELOG.md $RPM_SOURCE_DIR/NOTICE
%attr(755, root, root) %{_bindir}/%{name}
%{_unitdir}/%{name}.service
%dir %{_sysconfdir}/%{name}
%config %{_sysconfdir}/%{name}/%{name}.yaml
%dir %attr(755, %{name}, %{name}) %{_localstatedir}/log/%{name}
%dir %attr(755, %{name}, %{name}) %{_localstatedir}/run/%{name}
%pre
id %{name} >/dev/null 2>&1
if [ $? != 0 ]; then
/usr/sbin/groupadd -r %{name} >/dev/null 2>&1
/usr/sbin/useradd -d /var/run/%{name} -r -g %{name} %{name} >/dev/null 2>&1
fi
%post
if [ $1 = 1 ]; then
systemctl preset %{name}.service >/dev/null 2>&1 || :
fi
%preun
if [ -e /etc/init.d/%{name} ]; then
systemctl --no-reload disable %{name}.service > /dev/null 2>&1 || :
systemctl stop %{name}.service > /dev/null 2>&1 || :
fi
# If not an upgrade, then delete
if [ $1 = 0 ]; then
systemctl disable %{name}.service >/dev/null 2>&1 || :
fi
%postun
# 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