1 # ODL is a noarch package, so this isn't necessary. It's also very slow.
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
13 Summary: OpenDaylight SDN Controller
14 Group: Applications/Communications
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
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
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
35 OpenDaylight {{ codename }}
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
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
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
58 rm -rf $RPM_BUILD_ROOT/opt/%name
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
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