Packaging update to support building ODL distributions.
authorSam Hague <shague@redhat.com>
Mon, 6 Jan 2014 15:12:23 +0000 (10:12 -0500)
committerSam Hague <shague@redhat.com>
Mon, 6 Jan 2014 15:12:23 +0000 (10:12 -0500)
This commit adds support for building the ODL OVSDB virtualization distribution.
- Added spec for building the ovsdb package
- Added distribution support to the controller spec. Mainly consists of adding
the integration run.sh wrapper script for run.sh.
- Updated dependencies.spec to also package ovsdb dependencies.
- Added spec for building the distribution. The spec simply Requires the
specific packages for the distribution. For example, it Requires the
controller, ovsdb and dependencies packages to support the OVSDB
virtualization package.

Change-Id: Iad931c46fc41bd107926dd9a41b5013638c55084
Signed-off-by: Sam Hague <shague@redhat.com>
packaging/rpm/README
packaging/rpm/opendaylight-controller-dependencies.spec
packaging/rpm/opendaylight-controller.spec
packaging/rpm/opendaylight-controller.sysconfig
packaging/rpm/opendaylight-controller.systemd
packaging/rpm/opendaylight-controller.sysv
packaging/rpm/opendaylight-distribution.spec [new file with mode: 0644]
packaging/rpm/opendaylight-ovsdb.spec [new file with mode: 0644]
packaging/rpm/run.dist.sh [new file with mode: 0755]

index 75ce2c6d652751df7924578f546fc8ee4e43239b..e86ac15ca2ff9b756726f90549a37513fe609bd0 100644 (file)
@@ -3,6 +3,31 @@ RPM package for Fedora that still relies on Maven to include the JAVA
 artifacts. The plan is to create a dependencies RPM to package up all the
 artifacts.
 
+Release 0.1.0-0.4.0
+1. Build
+Build all the required packages:
+rpmbuild opendaylight-controller.spec
+rpmbuild opendaylight-ovsdb.spec
+rpmbuild opendaylight-dependencies.spec
+rpmbuild opendaylight-distribution.spec
+
+2. Install
+rpm -Uvh opendaylight-distribution
+* This will install all required packages.
+
+3. Start/Stop
+sudo systemctl start opendaylight-controller.service
+sudo systemctl stop opendaylight-controller.service
+* to get the osgi console: telnet 127.0.0.1 2400
+
+4. Distribution
+Edit the sysconfig file to change the type of distribution:
+sudo vi /etc/sysconfig/opendaylight-controller
+Set ODL_DIST to the desired distribution, i.e.
+ODL_DEST="-virt ovsdb" or ODL_DEST="-virt opendove"
+
+Release <0.1.0-0.4.0
+
 1. Get a source tarball:
 $git clone https://git.opendaylight.org/gerrit/p/controller.git
 $cd controller
index 85184873356b8bf659173aa51cf2ae28c50b9122..565c602932df434b3fccb6f4ef90db43749222de 100644 (file)
@@ -1,11 +1,16 @@
 Name: opendaylight-controller-dependencies
 Version: 0.1.0
-Release: 0.2.0%{?dist}
+Release: 0.3.0%{?dist}
 Summary: OpenDaylight SDN Controller Dependencies
 Group: Applications/Communications
 License: EPL
 URL: http://www.opendaylight.org
-Source: opendaylight-controller-%{version}.zip
+
+# The sources are built by the other projects so just copy them:
+# cp ~/rpmbuild/BUILD/opendaylight-controller-0.1.0/opendaylight/distribution/opendaylight/target/distribution.opendaylight-osgipackage.zip ~/rpmbuild/SOURCES/opendaylight-controller-%{version}.zip
+# cp ~/rpmbuild/BUILD/opendaylight-ovsdb-0.1.0/distribution/opendaylight/target/distribution.ovsdb-1.0.0-SNAPSHOT-osgipackage.zip ~/rpmbuild/SOURCES/opendaylight-ovsdb-%{version}.zip
+Source0: opendaylight-controller-%{version}.zip
+Source1: opendaylight-ovsdb-%{version}.zip
 BuildArch: noarch
 Requires: java >= 1:1.7.0
 
@@ -23,30 +28,35 @@ OpenDaylight SDN Controller Dependencies
 
 
 %prep
-%setup -q -c opendaylight-controller-dependencies-%{version}
 
+%setup -q -c -c -n opendaylight-controller-dependencies-%{version}
+%setup -q -T -a 1 -c -n opendaylight-ovsdb-dependencies-%{version}
 
-%build
 
-# Nothing to build, just repackage the jars
+%build
 exit 0
 
 
 %install
 
+mv -f ../opendaylight-controller-dependencies-%{version}/opendaylight/lib/* opendaylight/lib/
+mv -f ../opendaylight-controller-dependencies-%{version}/opendaylight/plugins/* opendaylight/plugins/
+
 # Create the directory for the dependencies:
 mkdir -p %{buildroot}%{deps_dir}
 
 for src in $( ls -I "org.opendaylight.*" opendaylight/lib );
 do
-    tgt=$(echo ${src} | sed -e "s/-[0-9].*/.jar/")
-    mv opendaylight/lib/${src} %{buildroot}%{deps_dir}/${tgt}
+    #tgt=$(echo ${src} | sed -e "s/-[0-9].*/.jar/")
+    #mv opendaylight/lib/${src} %{buildroot}%{deps_dir}/${tgt}
+    mv opendaylight/lib/${src} %{buildroot}%{deps_dir}/${src}
 done
 
 for src in $( ls -I "org.opendaylight.*" opendaylight/plugins );
 do
-    tgt=$(echo ${src} | sed -e "s/-[0-9].*/.jar/")
-    mv opendaylight/plugins/${src} %{buildroot}%{deps_dir}/${tgt}
+    #tgt=$(echo ${src} | sed -e "s/-[0-9].*/.jar/")
+    #mv opendaylight/plugins/${src} %{buildroot}%{deps_dir}/${tgt}
+    mv opendaylight/plugins/${src} %{buildroot}%{deps_dir}/${src}
 done
 
 
@@ -57,6 +67,9 @@ done
 
 
 %changelog
+* Thu Jan 02 2014 Sam Hague <shague@redhat.com> - 0.1.0-0.3.0
+- Updates to include building distributions.
+
 * Fri Nov 22 2013 Sam Hague <shague@redhat.com> - 0.1.0-0.2.0
 - Updates to support building rpm with jenkins.
 
index 197cafe0497537988c35bfa74c7aa2cd0d8c3df0..7db2a7fab0a142454a50426f140d37273bb61213 100644 (file)
@@ -3,7 +3,7 @@
 
 Name: opendaylight-controller
 Version: 0.1.0
-Release: 0.3.0%{?dist}
+Release: 0.4.0%{?dist}
 Summary: OpenDaylight SDN Controller
 Group: Applications/Communications
 License: EPL
@@ -12,10 +12,11 @@ URL: http://www.opendaylight.org
 # todo: Temporary method for generating tarball
 # git clone https://git.opendaylight.org/gerrit/p/controller.git
 # cd controller
-# git archive --prefix=opendaylight-controller-0.1.0/ 20dcbd1 | xz > opendaylight-controller-0.1.0.tar.xz
+# git archive --prefix=opendaylight-controller-0.1.0/ HEAD | xz > opendaylight-controller-0.1.0.tar.xz
 # git clone https://git.opendaylight.org/gerrit/p/integration.git
-# cd packaging/rpm/fedora
-# git archive 20dcbd1 opendaylight-controller.sysconfig opendaylight-controller.systemd | xz > opendaylight-controller-integration-0.1.0.tar.xz
+# cd packaging/rpm
+# git archive HEAD opendaylight-controller.sysconfig opendaylight-controller.systemd \
+#   opendaylight-controller.sysv run.dist.sh | xz > opendaylight-controller-integration-0.1.0.tar.xz
 Source0: %{name}-%{version}.tar.xz
 Source1: %{name}-integration-%{version}.tar.xz
 
@@ -97,6 +98,7 @@ OpenDaylight SDN Controller
 #  mvn clean install -Dmaven.test.skip=true -DskipIT -Dmaven.compile.fork=true
 export MAVEN_OPTS="-Xmx1024m -XX:MaxPermSize=256m" && mvn clean install -Dmaven.test.skip=true
 
+
 %install
 
 # Extract the contents of the distribution to a temporary directory so that we
@@ -128,6 +130,7 @@ install -m 644 -D %{name}.systemd %{buildroot}%{_unitdir}/%{name}.service
 install -m 644 -D %{name}.sysv %{buildroot}%{_initddir}/%{name}
 %endif
 install -m 644 -D %{name}.sysconfig %{buildroot}%{_sysconfdir}/sysconfig/%{name}
+install -m 755 -D run.dist.sh %{buildroot}%{resources_dir}/run.dist.sh
 
 # Usually one wants to replace the .jar files of the dependencies by symlinks
 # to the ones provided to the system. This assumes the dependencies have been
@@ -136,16 +139,18 @@ cd %{buildroot}%{resources_dir}/lib
 for src in $( ls -I "org.opendaylight.*" );
 do
     rm -f ${src}
-    tgt=$(echo ${src} | sed -e "s/-[0-9].*/.jar/")
-    ln -s %{deps_dir}/${tgt} ${src}
+    #tgt=$(echo ${src} | sed -e "s/-[0-9].*/.jar/")
+    #ln -s %{deps_dir}/${tgt} ${src}
+    ln -s %{deps_dir}/${src} ${src}
 done
 
 cd %{buildroot}%{resources_dir}/plugins
 for src in $( ls -I "org.opendaylight.*" );
 do
     rm -f ${src}
-    tgt=$(echo ${src} | sed -e "s/-[0-9].*/.jar/")
-    ln -s %{deps_dir}/${tgt} ${src}
+    #tgt=$(echo ${src} | sed -e "s/-[0-9].*/.jar/")
+    #ln -s %{deps_dir}/${tgt} ${src}
+    ln -s %{deps_dir}/${src} ${src}
 done
 
 
@@ -156,6 +161,7 @@ find %{buildroot}%{resources_dir} -type f -exec chmod 644 {} \;
 find %{buildroot}%{data_dir} -type d -exec chmod 755 {} \;
 find %{buildroot}%{data_dir} -type f -exec chmod 755 {} \;
 chmod 755 %{buildroot}%{resources_dir}/run.sh
+chmod 755 %{buildroot}%{resources_dir}/run.dist.sh
 %if 0%{?rhel}
 chmod 755 %{buildroot}%{_initddir}/%{name}
 %endif
@@ -212,6 +218,7 @@ fi
 %endif
 
 %clean
+# This check is used for mock build so the build files are not deleted.
 %if "%{noclean}" == "1"
     exit 0
 %endif
@@ -244,6 +251,9 @@ fi
 %endif
 
 %changelog
+* Thu Jan 02 2014 Sam Hague <shague@redhat.com> - 0.1.0-0.4.0
+- Updates to include building distributions.
+
 * Mon Dec 23 2013 Hsin-Yi Shen <hshen@redhat.com> - 0.1.0-0.3.0
 - Updates to support building rpm for both RHEL and fedora.
 
index e92d40419a885f087bd71e999a4af4fc0e584958..e5dd2ef18c86ef892864832e73955c64d884fd62 100644 (file)
@@ -4,3 +4,6 @@ ODL_DATADIR=/var/lib/opendaylight-controller
 
 # The path to the java jre or jdk:
 #JAVA_HOME=/usr
+
+# The requested distribution:
+ODL_DIST="-virt ovsdb"
\ No newline at end of file
index a98b0f6c0b80e35096e5bb05c12f2f5358f72e1c..53bd7d3c7993f10e16440e9c7b9810599878e423 100644 (file)
@@ -9,7 +9,7 @@ User=opendaylight
 Group=opendaylight
 EnvironmentFile=-/etc/sysconfig/opendaylight-controller
 WorkingDirectory=/var/lib/opendaylight-controller
-ExecStart=-/usr/share/opendaylight-controller/run.sh -start
+ExecStart=-/usr/share/opendaylight-controller/run.dist.sh $ODL_DIST -start
 ExecStop=-/usr/share/opendaylight-controller/run.sh -stop
 
 [Install]
index 28110f290820d15f8fe2c04c2462291003be4552..6a4ac7c028749f4588c758b1ec8b798d6d370855 100644 (file)
@@ -20,7 +20,7 @@
 # Source function library.
 . /etc/rc.d/init.d/functions
 
-exec="/usr/share/opendaylight-controller/run.sh"
+exec="/usr/share/opendaylight-controller/run.dist.sh"
 prog="opendaylight-controller"
 config="/etc/opendaylight-controller/config.ini"
 
@@ -33,7 +33,7 @@ start() {
     [ -f $config ] || exit 6
     echo -n $"Starting $prog: "
     # if not running, start it up here, usually something like "daemon $exec"
-    $exec -start
+    $exec $ODL_DIST -start
     retval=$?
     echo
     # [ $retval -eq 0 ] && touch $lockfile
@@ -43,7 +43,7 @@ start() {
 stop() {
     echo -n $"Stopping $prog: "
     # stop it here, often "killproc $prog"
-    $exec -stop
+    /usr/share/opendaylight-controller/run.sh" -stop
     retval=$?
     echo
     # [ $retval -eq 0 ] && rm -f $lockfile
diff --git a/packaging/rpm/opendaylight-distribution.spec b/packaging/rpm/opendaylight-distribution.spec
new file mode 100644 (file)
index 0000000..1807dac
--- /dev/null
@@ -0,0 +1,27 @@
+# Spec file only supports RHEL and Fedora now
+%if 0%{?rhel} || 0%{?fedora}
+
+Name: opendaylight-distribution
+Version: 0.1.0
+Release: 0.1.0%{?dist}
+Summary: OpenDaylight SDN Controller Distributions
+Group: Applications/Communications
+License: EPL
+URL: http://www.opendaylight.org
+BuildArch: noarch
+
+Requires: java >= 1:1.7.0
+Requires: opendaylight-controller
+Requires: opendaylight-ovsdb
+Requires: opendaylight-controller-dependencies
+
+%description
+OpenDaylight SDN Controller Distributions
+
+%files
+
+%endif
+
+%changelog
+* Thu Jan 02 2014 Sam Hague <shague@redhat.com> - 0.1.0-0.1.0
+- Initial package.
diff --git a/packaging/rpm/opendaylight-ovsdb.spec b/packaging/rpm/opendaylight-ovsdb.spec
new file mode 100644 (file)
index 0000000..3c4b14e
--- /dev/null
@@ -0,0 +1,107 @@
+# Spec file only supports RHEL and Fedora now
+%if 0%{?rhel} || 0%{?fedora}
+
+Name: opendaylight-ovsdb
+Version: 0.1.0
+Release: 0.1.0%{?dist}
+Summary: OpenDaylight OVSDB
+Group: Applications/Communications
+License: EPL
+URL: http://www.opendaylight.org
+
+# todo: Temporary method for generating tarball
+# git clone https://git.opendaylight.org/gerrit/p/ovsdb.git
+# cd ovsdb
+# git archive --prefix=opendaylight-ovsdb-0.1.0/ HEAD | xz > opendaylight-ovsdb-0.1.0.tar.xz
+Source0: %{name}-%{version}.tar.xz
+
+BuildArch: noarch
+
+BuildRequires: java-devel
+BuildRequires: maven
+Requires: java >= 1:1.7.0
+
+# This is the directory where all the application resources (scripts,
+# libraries, etc) will be installed: /usr/share/opendaylight
+%global resources_dir %{_datadir}/opendaylight-controller
+
+# This is the directory that has all the JAVA dependencies.
+%global deps_dir %{_javadir}/opendaylight-controller-dependencies
+
+
+%description
+OpenDaylight OVSDB
+
+
+%prep
+
+%setup -q
+
+
+%build
+
+# This regular maven build will need to be replaced by the distribution
+# specific maven build command, but this is ok for now:
+# todo: eventually move to using mvn-build or mvn-rpmbuild so dependencies are
+# not downloaded.
+# Don't do the tests since those are already covered by the normal merge and
+# verify process and this build does not need to verify them.
+# maven.compile.fork is used to reduce the build time.
+#export MAVEN_OPTS="-Xmx1024m -XX:MaxPermSize=256m" && \
+#  mvn clean install -Dmaven.test.skip=true -DskipIT -Dmaven.compile.fork=true
+export MAVEN_OPTS="-Xmx1024m -XX:MaxPermSize=256m" && mvn clean install -Dmaven.test.skip=true
+
+
+%install
+
+# Extract the contents of the distribution to a temporary directory so that we
+# can take things from there and move them to the correct locations:
+# todo: Need spec and pom file versions to be consistent so we don't have to
+# hardcode the version here.
+mkdir -p tmp
+unzip -o -d tmp distribution/opendaylight/target/distribution.ovsdb-1.0.0-SNAPSHOT-osgipackage.zip
+
+# Create the directories:
+mkdir -p %{buildroot}%{resources_dir}/plugins
+
+# Only install the extra jars needed by ovsdb.
+# opendaylight jars will be moved to the plugins dir and external jars will be
+# symlinked to the opendaylight dependencies directory.
+for src in $( ls tmp/opendaylight/plugins/*.jar);
+do
+    tgt=$(basename ${src})
+    if [ ! -f %{_builddir}/%{buildsubdir}/distribution/opendaylight/target/generated-resources/opendaylight/plugins/${tgt} ]; then
+        if [ "${tgt}" != "${tgt/org.opendaylight/}" ]; then
+            mv ${src} %{buildroot}%{resources_dir}/plugins
+        else
+            ln -s %{deps_dir}/${tgt} %{buildroot}%{resources_dir}/plugins/${tgt}
+        fi
+    fi
+done
+
+
+# Fix the permissions as they come with all the permissions (mode 777)
+# from the .zip file:
+find %{buildroot}%{resources_dir} -type d -exec chmod 755 {} \;
+find %{buildroot}%{resources_dir} -type f -exec chmod 644 {} \;
+
+# Remove the temporary directory:
+rm -rf tmp
+
+
+%clean
+%if "%{noclean}" == "1"
+    exit 0
+%endif
+
+
+%files
+
+%{resources_dir}
+
+
+%endif
+
+%changelog
+* Thu Jan 02 2014 Sam Hague <shague@redhat.com> - 0.1.0-0.1.0
+- Initial package.
diff --git a/packaging/rpm/run.dist.sh b/packaging/rpm/run.dist.sh
new file mode 100755 (executable)
index 0000000..f8c92c9
--- /dev/null
@@ -0,0 +1,37 @@
+#!/bin/bash
+
+function usage {
+    echo "Please select one of the 3 supported Virtualization technology : \"$0 -virt [ovsdb | opendove | vtn]\""
+    exit 1
+}
+
+virtIndex=0
+while true ; do
+    (( i += 1 ))
+    case "${@:$i:1}" in
+        -virt) virtIndex=$i ;;
+        "") break ;;
+    esac
+done
+
+# Virtualization edition select
+if [ ${virtIndex} -eq 0 ]; then
+    usage
+fi
+
+virt=${@:$virtIndex+1:1}
+if [ "${virt}" == "" ]; then
+    usage
+else
+    if [ "${virt}" == "ovsdb" ]; then
+        ODL_VIRT_FILTER="opendove|vtn"
+    elif [ "${virt}" == "opendove" ]; then
+        ODL_VIRT_FILTER="ovsdb|vtn"
+    elif [ "${virt}" == "vtn" ]; then
+        ODL_VIRT_FILTER="affinity|opendove|ovsdb|controller.(arphandler|samples)"
+    else
+        usage
+    fi
+fi
+
+/usr/share/opendaylight-controller/run.sh -Dfelix.fileinstall.filter="^(?!org.opendaylight.(${ODL_VIRT_FILTER})).*" "${@:1:$virtIndex-1}" "${@:virtIndex+2}"