summaryrefslogtreecommitdiffstats
path: root/packaging/rpm/honeycomb.spec
blob: cac0ecfa168e1e15d76ca2ffbadcf3cc992056d6 (plain)
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
# Honyecomb is a noarch package, so this isn't necessary. It's also very slow.
%define __jar_repack 0
%define _version %(./version)
%define _release %(./release)

Name:       honeycomb
Version:    %{_version}
# The Fedora/CentOS packaging guidelines *require* the use of a disttag. Honeycomb's
#   RPM build doesn't do anything Fedora/CentOS specific, so the disttag is
#   unnecessary and unused in our case, but both the docs and the pros (apevec)
#   agree that we should include it.
# See: https://fedoraproject.org/wiki/Packaging:DistTag
Release:    %{_release}
BuildArch:  noarch
Summary:    fd.io Honeycomb
Group:      Applications/Communications
License:    Apache-1.0
URL:        http://www.fd.io
Source0:     vpp-integration-karaf-%{_version}-SNAPSHOT.zip
Source1:     honeycomb.service
Requires:    vpp, java >= 1:1.8.0
# Required for creating honeycomb group
Requires(pre): shadow-utils
# Required for configuring systemd
BuildRequires: systemd

%pre
# Create `honeycomb` user/group
# Short circuits if the user/group already exists
# Home dir must be a valid path for various files to be created in it
getent passwd honeycomb > /dev/null || useradd honeycomb -M -d $RPM_BUILD_ROOT/opt/%name
getent group honeycomb > /dev/null || groupadd honeycomb
getent group vpp > /dev/null && usermod -a -G vpp honeycomb

%description
fd.io Honeycomb

%prep
# Extract Source0 (Honeycomb archive)
%autosetup -n vpp-integration-karaf-%{_version}-SNAPSHOT

%install
# Create directory in build root for Honeycomb
mkdir -p $RPM_BUILD_ROOT/opt/%name
# Copy Honeycomb from archive to its dir in build root
cp -r ../vpp-integration-karaf-%{_version}-SNAPSHOT/* $RPM_BUILD_ROOT/opt/%name
# Create directory in build root for systemd .service file
mkdir -p $RPM_BUILD_ROOT/%{_unitdir}
# Copy Honeycomb's systemd .service file to correct dir in build root
echo "PWD:$PWD"
cp ${RPM_BUILD_ROOT}/../../%{name}.service $RPM_BUILD_ROOT/%{_unitdir}/%name.service

%postun
#   When the RPM is removed, the subdirs containing new files wouldn't normally
#   be deleted. Manually clean them up.
#   Warning: This does assume there's no data there that should be preserved
if [ $1 -eq 0 ]; then
    rm -rf $RPM_BUILD_ROOT/opt/%name
fi

%files
# Honeycomb will run as honeycomb:honeycomb, set as user:group for honeycomb dir, don't override mode
%attr(-,honeycomb,honeycomb) /opt/%name
# Configure systemd unitfile user/group/mode
%attr(0644,root,root) %{_unitdir}/%name.service