# ODL is a noarch package, so this isn't necessary. It's also very slow. %define __jar_repack 0 Name: opendaylight Version: 9.0.0 # The Fedora/CentOS packaging guidelines *require* the use of a disttag. ODL'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: 2.el7 BuildArch: noarch Summary: OpenDaylight SDN Controller Group: Applications/Communications License: EPL-1.0 URL: http://www.opendaylight.org Source0: %name-9.0.0-2.tar.gz Source1: %name-b8ecbbb9e1cfdbb7909d582d58d09601db37be98.service.tar.gz Buildroot: /tmp # This spec can be shared by Red Hat and SUSE based OS. The only difference is # the name of the dependent packages. Depending on the distro, we use one name # or another. For example, shadow-utils for RH and shadow for SUSE %if 0%{?rhel} # Required for ODL at run time Requires: java >= 1:1.8.0 # Required for creating odl group Requires(pre): shadow-utils %else %if 0%{?suse_version} # Required for ODL at run time Requires: java >= 1.8.0 # Required for creating odl group Requires(pre): shadow %else echo "Your OS is not supported" exit 1 %endif% %endif% # Required for configuring systemd BuildRequires: systemd %pre # Create `odl` 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 odl > /dev/null || useradd odl -M -d $RPM_BUILD_ROOT/opt/%name getent group odl > /dev/null || groupadd odl # Blacklist unwanted/false requirements INTPAK-10 %global __requires_exclude ^(mono|osgi).*$ %description OpenDaylight Software Defined Networking controller %prep # Extract Source0 (ODL archive) %autosetup -n opendaylight-0.9.0 # Extract Source1 (systemd config) %autosetup -T -D -b 1 -c -n %name-b8ecbbb9e1cfdbb7909d582d58d09601db37be98.service %install # Create directory in build root for ODL mkdir -p $RPM_BUILD_ROOT/opt/%name # Copy ODL from archive to its dir in build root cp -r ../opendaylight-0.9.0/* $RPM_BUILD_ROOT/opt/%name # Create directory in build root for systemd .service file mkdir -p $RPM_BUILD_ROOT/%{_unitdir} # Copy ODL's systemd .service file to correct dir in build root cp ../../BUILD/%name-b8ecbbb9e1cfdbb7909d582d58d09601db37be98.service/%name-b8ecbbb9e1cfdbb7909d582d58d09601db37be98.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 # ODL will run as odl:odl, set as user:group for ODL dir, don't override mode %attr(-,odl,odl) /opt/%name # Configure systemd unitfile user/group/mode %attr(0644,root,root) %{_unitdir}/%name.service %changelog * Mon Oct 08 2018 Daniel Farrell - 9.0.0-2 - Create 9.0.0-2 RPM