Add jar dependencies package.
authorSam Hague <shague@redhat.com>
Fri, 1 Nov 2013 18:38:39 +0000 (14:38 -0400)
committerSam Hague <shague@redhat.com>
Fri, 1 Nov 2013 18:38:39 +0000 (14:38 -0400)
The current opendaylight-controller rpm uses the JAVA artifacts that
are already included in the distribution. This is not allowed in a
proper Fedora distribution. This commit creates a "dependencies"
package to remove the use of the pre-built artifacts from the
controller rpm. In the future this dependencies package will go
away as the artifacts are added in their own packages.

Change-Id: I7cc3891e6f18428b13133d8a0ff999ef1d79158c
Signed-off-by: Sam Hague <shague@redhat.com>
packaging/rpm/fedora/README
packaging/rpm/fedora/opendaylight-controller-dependencies.spec [new file with mode: 0644]
packaging/rpm/fedora/opendaylight-controller.spec

index 8ac8dca1d3271c1cd82e9101660184117912d300..75ce2c6d652751df7924578f546fc8ee4e43239b 100644 (file)
@@ -23,3 +23,52 @@ $rpmbuild -ba opendaylight-controller.spec
 
 4. uninstall rpm:
 #rpm -e opendaylight-controller-0.1.0-0.1.20131007gitd684dd4.fc19.noarch
+
+
+Using yum for testing.
+
+1. Create a local repo:
+yum install createrepo
+yum install vsftpd
+systemctl start vsftpd.service
+
+Add /etc/yum.repos.d/localftp.repo
+[localftp]
+name=Local FTP repo
+baseurl=file://127.0.0.1/pub
+enabled=0
+gpgcheck=0
+metadata_expire=1m
+
+2. Add packages to local repo:
+cp opendaylight-controller.spec /var/ftp/pub
+cp opendaylight-controller-dependencies.spec /var/ftp/pub
+
+3. Update local repo with new packages:
+Change the enabled=0 to enabled=1 in the localftp.repo file.
+createrepo /var/ftp/pub
+yum clean expire-cache
+
+4. Verify the repo is there:
+yum repolist
+
+Yum away...
+
+You could also use a fiel based repo and change the baseurl to:
+file:////var/ftp/pub.
+This failed with a network error for me so I switched to ftp.
+
+
+The file system after install should look like
+
+/etc/opendaylight-controller/config.ini
+/usr/share/java/opendaylight-dependencies/{all the non-opendaylight jars from
+the lib and plugin directories
+/usr/share/opendaylight-controller/run.bat, run.sh, ..
+/usr/share/opendaylight-controller/configuration/...
+/usr/share/opendaylight-controller/lib/*.jar ln's to /usr/share/java/opendaylight-dependencies/*.jar
+/usr/share/opendaylight-controller/plugins/*.jar ln's to /usr/share/java/opendaylight-dependencies/*.jar
+/var/lib/opendaylight-controller
+/var/lib/opendaylight-controller/configuration/ ln's back to /usr/share/opendaylight-controller/configuration
+/var/lib/opendaylight-controller/lib
+/var/lib/opendaylight-controller/plugins
\ No newline at end of file
diff --git a/packaging/rpm/fedora/opendaylight-controller-dependencies.spec b/packaging/rpm/fedora/opendaylight-controller-dependencies.spec
new file mode 100644 (file)
index 0000000..c13ebd0
--- /dev/null
@@ -0,0 +1,61 @@
+Name: opendaylight-controller-dependencies
+Version: 0.1.0
+Release: 0.1.20131101git31c8f18%{?dist}
+Summary: OpenDaylight SDN Controller Dependencies
+Group: Applications/Communications
+License: EPL
+URL: http://www.opendaylight.org
+Source: opendaylight-controller-%%{version}.zip
+BuildArch: noarch
+Requires: java >= 1:1.7.0
+
+# Here you should have at least dependencies for the packages containing .jar
+# files that you want to create symlinks to:
+# First pass just use everything from the distribution zip.
+#Requires: slf4j
+
+# This is the directory where all dependencies will go:
+# /usr/share/java/opendaylight-controller-dependencies
+%global deps_dir %{_javadir}/%{name}
+
+%description
+OpenDaylight SDN Controller Dependencies
+
+
+%prep
+%setup -q -c opendaylight-controller-dependencies-%{version}
+
+
+%build
+
+# Nothing to build, just repackage the jars
+exit 0
+
+
+%install
+
+# 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}
+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}
+done
+
+
+%files
+
+# Own the directory containing the dependencies and its contents:
+%{deps_dir}
+
+
+%changelog
+* Fri Nov 01 2013 Sam Hague <shague@redhat.com> - 0.1.0-0.1.20131007git31c8f18
+- Initial Fedora package.
index d599154176c89751ee50e3dbccb8509a84153049..34ad43267b20dacb86e6a7bd30556b478ac227ff 100644 (file)
@@ -2,7 +2,7 @@ Name: opendaylight-controller
 # todo: Use the ODL snapshot version? Could also be used for the
 # Source property in a proper URL.
 Version: 0.1.0
-Release: 0.1.20131007gitd684dd4%{?dist}
+Release: 0.1.20131101git31c8f18%{?dist}
 Summary: OpenDaylight SDN Controller
 Group: Applications/Communications
 License: EPL
@@ -11,7 +11,7 @@ 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/ d684dd4 | xz > opendaylight-controller-0.1.0.tar.xz
+# git archive --prefix=opendaylight-controller-0.1.0/ 31c8f18 | xz > opendaylight-controller-0.1.0.tar.xz
 Source: opendaylight-controller-%{version}.tar.xz
 
 BuildArch: noarch
@@ -23,9 +23,10 @@ Requires: java >= 1:1.7.0
 
 # todo: Need to create proper packages for all the dependencies.
 # Here you should have at least dependencies for the packages containing .jar
-# files that you want to create symlinks to.
-Requires: slf4j
-
+# files that you want to create symlinks to. For now all the jars in a
+# dependencies package.
+#Requires: slf4j
+Requires: opendaylight-controller-dependencies
 
 # This is the directory where all the application resources (scripts,
 # libraries, etc) will be installed: /usr/share/opendaylight
@@ -39,6 +40,8 @@ Requires: slf4j
 # /etc/opendaylight
 %global configuration_dir %{_sysconfdir}/%{name}
 
+%global deps_dir %{_javadir}/opendaylight-controller-dependencies
+
 
 %description
 OpenDaylight SDN Controller
@@ -60,7 +63,8 @@ OpenDaylight SDN Controller
 # 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.
-MAVEN_OPTS="-Xmx1024m -XX:MaxPermSize=256m"; mvn clean install -DskipTests
+MAVEN_OPTS="-Xmx1024m -XX:MaxPermSize=256m" && mvn clean install -DskipTests
+#MAVEN_OPTS="-XX:PermSize=256m -Xmx1024m  -XX:MaxPermSize=512m" && mvn -DskipTests clean install
 # below is just for testing
 # MAVEN_OPTS="-Xmx1024m -XX:MaxPermSize=256m"; mvn package
 
@@ -87,25 +91,42 @@ ln -s %{resources_dir}/configuration/logback.xml %{buildroot}%{data_dir}/configu
 ln -s %{resources_dir}/configuration/tomcat-server.xml %{buildroot}%{data_dir}/configuration
 
 mv tmp/opendaylight/* %{buildroot}%{resources_dir}
+
 ln -s %{resources_dir}/lib %{buildroot}%{data_dir}
 ln -s %{resources_dir}/plugins %{buildroot}%{data_dir}
 
+
 # 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
 # installed as separate packages and listed in the Requires header.
-while read resource_path system_path
+#while read resource_path system_path
+#do
+#    rm -f %%{buildroot}%%{resources_dir}/${resource_path}
+##    ln -s %%{_javadir}/${system_path} %%{buildroot}%%{resources_dir}/${resource_path}
+#    ln -s %%{deps_dir}/%%{system_path} %%{buildroot}%%{resources_dir}/${resource_path}
+#done <<.
+#lib/jersey-core.jar jersey-core.jar
+#.
+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}
+done
+
+cd %{buildroot}%{resources_dir}/plugins
+for src in $( ls -I "org.opendaylight.*" );
 do
-    rm -f %{buildroot}%{resources_dir}/${resource_path}
-    ln -s %{_javadir}/${system_path} %{buildroot}%{resources_dir}/${resource_path}
-done <<.
-lib/slf4j-api-1.7.2.jar slf4j/slf4j-api.jar
-.
+    rm -f ${src}
+    tgt=$(echo ${src} | sed -e "s/-[0-9].*/.jar/")
+    ln -s %{deps_dir}/${tgt} ${src}
+done
+
 
 # Fix the permissions as they come with all the permissions (mode 777)
 # from the .zip file:
 chmod -R 755 %{buildroot}%{resources_dir}
-#chmod 755 %%{buildroot}%%{resources_dir}/lib
-#chmod 755 %%{buildroot}%%{resources_dir}/plugins
 
 # Remove the temporary directory:
 rm -rf tmp
@@ -163,13 +184,11 @@ fi
 # todo: add checks to ensure controller is stopped
 #%%preun
 
-%postun
-
-if [ $1 = 0 ]; then
-    rm -rf %{data_dir}
-fi
-
 
 %changelog
+* Fri Nov 01 2013 Sam Hague <shague@redhat.com> - 0.1.0-0.1.20131007git31c8f18
+- Modify to include opendaylight-controller-dependencies.
+- Do not delete the files in var
+
 * Mon Oct 07 2013 Sam Hague <shague@redhat.com> - 0.1.0-0.1.20131007gitd684dd4
 - Initial Fedora package.