e95b5455a4713d99b997742da1266ae9fc3cef7a
[honeycomb.git] / packaging / rpm / honeycomb.spec
1 # Honyecomb is a noarch package, so this isn't necessary. It's also very slow.
2 %define __jar_repack 0
3 %define _version %(./version)
4 %define _release %(./release)
5
6 Name:       honeycomb
7 Version:    %{_version}
8 # The Fedora/CentOS packaging guidelines *require* the use of a disttag. Honeycomb's
9 #   RPM build doesn't do anything Fedora/CentOS specific, so the disttag is
10 #   unnecessary and unused in our case, but both the docs and the pros (apevec)
11 #   agree that we should include it.
12 # See: https://fedoraproject.org/wiki/Packaging:DistTag
13 Release:    %{_release}
14 BuildArch:  noarch
15 Summary:    fd.io Honeycomb
16 Group:      Applications/Communications
17 License:    Apache-1.0
18 URL:        http://www.fd.io
19 Source0:     vpp-integration-distribution-%{_version}-SNAPSHOT-hc.zip
20 Source1:     honeycomb.service
21 Requires:    vpp, vpp-plugins, java >= 1:1.8.0
22 # Required for creating honeycomb group
23 Requires(pre): shadow-utils
24 # Required for configuring systemd
25 BuildRequires: systemd
26
27 %pre
28 # Create `honeycomb` user/group
29 # Short circuits if the user/group already exists
30 # Home dir must be a valid path for various files to be created in it
31 getent passwd honeycomb > /dev/null || useradd honeycomb -M -d $RPM_BUILD_ROOT/opt/%name
32 getent group honeycomb > /dev/null || groupadd honeycomb
33 getent group vpp > /dev/null && usermod -a -G vpp honeycomb
34
35 %description
36 fd.io Honeycomb
37
38 %prep
39 # Extract Source0 (Honeycomb archive)
40 %autosetup -n vpp-integration-distribution-%{_version}-SNAPSHOT
41
42 %install
43 # Create directory in build root for Honeycomb
44 mkdir -p $RPM_BUILD_ROOT/opt/%name
45 # Copy Honeycomb from archive to its dir in build root
46 cp -r ../vpp-integration-distribution-%{_version}-SNAPSHOT/* $RPM_BUILD_ROOT/opt/%name
47 # Create directory in build root for systemd .service file
48 mkdir -p $RPM_BUILD_ROOT/%{_unitdir}
49 # Copy Honeycomb's systemd .service file to correct dir in build root
50 echo "PWD:$PWD"
51 cp ${RPM_BUILD_ROOT}/../../%{name}.service $RPM_BUILD_ROOT/%{_unitdir}/%name.service
52
53 %postun
54 #   When the RPM is removed, the subdirs containing new files wouldn't normally
55 #   be deleted. Manually clean them up.
56 #   Warning: This does assume there's no data there that should be preserved
57 if [ $1 -eq 0 ]; then
58     rm -rf $RPM_BUILD_ROOT/opt/%name
59 fi
60
61 %files
62 # Honeycomb will run as honeycomb:honeycomb, set as user:group for honeycomb dir, don't override mode
63 %attr(-,honeycomb,honeycomb) /opt/%name
64 # Configure systemd unitfile user/group/mode
65 %attr(0644,root,root) %{_unitdir}/%name.service
66