#!/usr/bin/env sh
-# Build the ODL SRPM and noarch RPM described in opendaylight.spec
-# This is designed to be run in the included Vagrant environment.
+# Reads build info from build_vars files to build ODL RPMs and SRPMs
+# This is designed to be run in the included Vagrant environment
# Echo commands as they are run
set -x
build()
{
# Common names used in this script
- odl_version="0.$version_major.$version_minor"
- rpm_version="$version_major.$version_minor.$version_patch"
odl_srpm="opendaylight-$rpm_version-$rpm_release.$rpm_disttag.src.rpm"
odl_rpm="opendaylight-$rpm_version-$rpm_release.$rpm_disttag.noarch.rpm"
odl_tarball="distribution-karaf-$odl_version-$codename.tar.gz"
cp $specfile_path $rpmbuild_spec_dir
# Build ODL SRPM and noarch RPM
- # Override disttag from .el7.centos to .el7 per best-practices/expected norms
- # See: https://bugs.centos.org/view.php?id=9098
+ # Override specfile macros with values that define the build
cd $rpmbuild_spec_dir
- rpmbuild -ba --define "dist .$rpm_disttag" opendaylight.spec
+ rpmbuild -ba --define "dist .$rpm_disttag" \
+ --define "codename $codename" \
+ --define "version_major $version_major" \
+ --define "version_minor $version_minor" \
+ --define "version_patch $version_patch" \
+ --define "rpm_release $rpm_release" \
+ --define "odl_version $odl_version" \
+ --define "rpm_version $rpm_version" \
+ --define "java_version $java_version" \
+ --define "sysd_commit $sysd_commit" \
+ opendaylight.spec
# Confirm SRPM found in expected location
if [ -f $srpm_out_path ]; then
# Accept path to build vars file as a param, build all if absent
if [[ $# -eq 0 ]]; then
# If no build vars file passed, do all builds described in build_vars dir
- for vars_file in /vagrant/build_vars/*; do
+ for vars_file in /vagrant/build_vars/vars_*; do
source $vars_file
build
done
--- /dev/null
+#!/usr/bin/env sh
+# Variables to define an OpenDaylight RPM build
+# `build.sh` reads these and passes them to opendaylight.spec
+# To define a new ODL RPM build, copy one of these and adjust as-needed
+
+# Version fields for the ODL release
+version_patch=0
+
+# Override disttag from .el7.centos to .el7 per best-practices/expected norms
+# See: https://bugs.centos.org/view.php?id=9098
+rpm_disttag="el7"
+
+# Java versions supported by this ODL release
+java_version=">= 1:1.7.0"
+
+# Version of ODL systemd unitfile to download and package in ODL RPM
+# Update this commit if systemd unit file is updated
+sysd_commit="4a872270893f0daeebcbbcc0ff0014978e3c5f68"
+
+# Directory used for caching build artifacts
+# Being able to customize this is useful for some offline builds
+cache_dir="/vagrant"
+
+# ODL version translation
+# Note that the RPM is shifting ODL's version to the left by one value
+# to be consistent with the major.minor.patch scheme used universally
+# by RPMs. ODL's version is currently prefixed with a static, useless
+# leading 0, which is widely ignored in practice. For now the version
+# translation happens here. This will likely be fixed as ODL moves to
+# a continuous release model.
+odl_version="0.$version_major.$version_minor"
+rpm_version="$version_major.$version_minor.$version_patch"
-codename="Lithium"
+#!/usr/bin/env sh
+# Variables to define an OpenDaylight RPM build
+# `build.sh` reads these and passes them to `opendaylight.spec`
+# To define a new ODL RPM build, copy one of these and adjust as-needed
+
+# Directory used for caching build artifacts
+# Customizing this is useful for some offline builds
+cache_dir="/vagrant"
+
+# Version fields for the ODL release
version_major=3
version_minor=0
-version_patch=0
+
+# Include variable defaults that are common to many builds
+# NB: To use vars in default_vars.sh, define them before this source cmd
+# Example: version_[major,minor,patch] is used for [odl,rpm]_version
+# NB: To override vars things defined in default_vars, define them after
+source $cache_dir/build_vars/default_vars.sh
+
+# Elemental codename for the ODL release, including SR if applicable
+codename="Lithium"
+
+# RPM version for the given ODL major.minor.patch
rpm_release=2
-rpm_disttag="el7"
-java_version=">= 1:1.7.0"
-sysd_commit="4a87227"
-cache_dir="/vagrant"
# ODL is a noarch package, so this isn't necessary. It's also very slow.
%define __jar_repack 0
-# Override the %define macros below build multiple versions of ODL's RPM
-# Default values are for the latest supported ODL release
-
-# Version of ODL systemd unitfile to download and package in ODL RPM
-# Update this commit if systemd unit file is updated
-%define commit 4a872270893f0daeebcbbcc0ff0014978e3c5f68
-%define shortcommit %(c=%{commit}; echo ${c:0:7})
-
-# ODL version variables
-# Note that the RPM is shifting ODL's version to the left by one value
-# to be consistent with the major.minor.patch scheme used universally
-# by RPMs. ODL's version is currently prefixed with a static, useless
-# leading 0, which is widely ignored in practice. For now the version
-# translation happens here. This will likely be fixed as ODL moves to
-# a continuous release model.
-%define odl_codename Lithium
-%define odl_version_major 3
-%define odl_version_minor 0
-%define odl_version_patch 0
-%define odl_version 0.%{odl_version_major}.%{odl_version_minor}
-%define odl_rpm_version %{odl_version_major}.%{odl_version_minor}.%{odl_version_patch}
-%define odl_rpm_release 2
-%define java_version >= 1:1.7.0
-
Name: opendaylight
-Version: %{odl_rpm_version}
+Version: %{rpm_version}
# 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: %{odl_rpm_release}%{dist}
+Release: %{rpm_release}%{dist}
BuildArch: noarch
Summary: OpenDaylight SDN Controller
Group: Applications/Communications
License: EPL-1.0
URL: http://www.opendaylight.org
-Source0: https://nexus.opendaylight.org/content/groups/public/org/opendaylight/integration/distribution-karaf/%{odl_version}-%{odl_codename}/distribution-karaf-%{odl_version}-%{odl_codename}.tar.gz
-Source1: https://github.com/dfarrell07/opendaylight-systemd/archive/%{shortcommit}/opendaylight-systemd-%{shortcommit}.tar.gz
+Source0: https://nexus.opendaylight.org/content/groups/public/org/opendaylight/integration/distribution-karaf/%{odl_version}-%{codename}/distribution-karaf-%{odl_version}-%{codename}.tar.gz
+Source1: https://github.com/dfarrell07/opendaylight-systemd/archive/%{sysd_commit}/opendaylight-systemd-%{sysd_commit}.tar.gz
Buildroot: /tmp
# Required for ODL at run time
Requires: java %{java_version}
getent group odl > /dev/null || groupadd odl
%description
-OpenDaylight %{odl_codename}
+OpenDaylight %{codename}
%prep
# Extract Source0 (ODL archive)
-%autosetup -n distribution-karaf-%{odl_version}-%{odl_codename}
+%autosetup -n distribution-karaf-%{odl_version}-%{codename}
# Extract Source1 (systemd config)
-%autosetup -T -D -b 1 -n opendaylight-systemd-%{commit}
+%autosetup -T -D -b 1 -n opendaylight-systemd-%{sysd_commit}
%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 ../distribution-karaf-%{odl_version}-%{odl_codename}/* $RPM_BUILD_ROOT/opt/%name
+cp -r ../distribution-karaf-%{odl_version}-%{codename}/* $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/opendaylight-systemd-%{commit}/opendaylight.service $RPM_BUILD_ROOT/%{_unitdir}
+cp ../../BUILD/opendaylight-systemd-%{sysd_commit}/opendaylight.service $RPM_BUILD_ROOT/%{_unitdir}
%postun
# When the RPM is removed, the subdirs containing new files wouldn't normally