Require Java >=1.8 for RPMs, vs current >=1.7
[integration/packaging.git] / rpm / specs / opendaylight.spec
1 # ODL is a noarch package, so this isn't necessary. It's also very slow.
2 %define __jar_repack 0
3
4 Name:       opendaylight
5 Version:    {{ version_major }}.{{ version_minor }}.{{ version_patch }}
6 # The Fedora/CentOS packaging guidelines *require* the use of a disttag. ODL's
7 #   RPM build doesn't do anything Fedora/CentOS specific, so the disttag is
8 #   unnecessary and unused in our case, but both the docs and the pros (apevec)
9 #   agree that we should include it.
10 # See: https://fedoraproject.org/wiki/Packaging:DistTag
11 Release:    {{ rpm_release }}.el7
12 BuildArch:  noarch
13 Summary:    OpenDaylight SDN Controller
14 Group:      Applications/Communications
15 License:    EPL-1.0
16 URL:        http://www.opendaylight.org
17 Source0:    %name-{{ version_major }}.{{ version_minor }}.{{ version_patch }}-{{ rpm_release }}.tar.gz
18 Source1:    %name-{{ sysd_commit }}.service.tar.gz
19 Buildroot:  /tmp
20 # Required for ODL at run time
21 Requires:   java >= 1:1.8.0
22 # Required for creating odl group
23 Requires(pre): shadow-utils
24 # Required for configuring systemd
25 BuildRequires: systemd
26
27 %pre
28 # Create `odl` 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 odl > /dev/null || useradd odl -M -d $RPM_BUILD_ROOT/opt/%name
32 getent group odl > /dev/null || groupadd odl
33
34 %description
35 OpenDaylight {{ codename }}
36
37 %prep
38 # Extract Source0 (ODL archive)
39 %autosetup -n distribution-karaf-0.{{ version_major }}.{{ version_minor }}-{{ codename }}
40 # Extract Source1 (systemd config)
41 %autosetup -T -D -b 1 -c -n %name-{{ sysd_commit }}.service
42
43 %install
44 # Create directory in build root for ODL
45 mkdir -p $RPM_BUILD_ROOT/opt/%name
46 # Copy ODL from archive to its dir in build root
47 cp -r ../distribution-karaf-0.{{ version_major }}.{{ version_minor }}-{{ codename }}/* $RPM_BUILD_ROOT/opt/%name
48 # Create directory in build root for systemd .service file
49 mkdir -p $RPM_BUILD_ROOT/%{_unitdir}
50 # Copy ODL's systemd .service file to correct dir in build root
51 cp ../../BUILD/%name-{{ sysd_commit }}.service/%name-{{ sysd_commit }}.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 # ODL will run as odl:odl, set as user:group for ODL dir, don't override mode
63 %attr(-,odl,odl) /opt/%name
64 # Configure systemd unitfile user/group/mode
65 %attr(0644,root,root) %{_unitdir}/%name.service
66
67 %changelog
68 * {{ changelog_date }} {{ changelog_name }} <{{ changelog_email }}> - {{ version_major }}.{{ version_minor }}.{{ version_patch }}-{{ rpm_release }}
69 - Create {{ version_major }}.{{ version_minor }}.{{ version_patch }}-{{ rpm_release }} RPM