Updates to include new configuration files.
[integration.git] / packaging / rpm / opendaylight-controller.spec
1 # Spec file only supports RHEL and Fedora now
2 %if 0%{?rhel} || 0%{?fedora}
3
4 Name: opendaylight-controller
5 Version: 0.1.0
6 Release: 0.6.0%{?dist}
7 Summary: OpenDaylight SDN Controller
8 Group: Applications/Communications
9 License: EPL
10 URL: http://www.opendaylight.org
11
12 # todo: Temporary method for generating tarball
13 # git clone https://git.opendaylight.org/gerrit/p/controller.git
14 # cd controller
15 # git archive --prefix=opendaylight-controller-0.1.0/ HEAD | xz > opendaylight-controller-0.1.0.tar.xz
16 # git clone https://git.opendaylight.org/gerrit/p/integration.git
17 # cd integration
18 # git archive --prefix=opendaylight-integration-0.1.0/HEAD | xz > opendaylight-integration-0.1.0.tar.xz
19 Source0: %{name}-%{version}.tar.xz
20 Source1: opendaylight-integration-%{version}.tar.xz
21 Patch0: opendaylight-integration-fix-paths.patch
22
23 BuildArch: noarch
24
25 BuildRequires: java-devel
26 BuildRequires: maven
27 %if 0%{?fedora}
28 BuildRequires: systemd
29 %else
30 BuildRequires: sysvinit-tools
31 %endif
32
33 Requires: java >= 1:1.7.0
34
35 # todo: Need to create proper packages for all the dependencies.
36 # Here you should have at least dependencies for the packages containing .jar
37 # files that you want to create symlinks to. For now all the jars in a
38 # dependencies package.
39 #Requires: slf4j
40
41 Requires: %{name}-dependencies
42
43 %if 0%{?fedora}
44 Requires(post): systemd
45 Requires(preun): systemd
46 Requires(postun): systemd
47 %else
48 # use sysV for rhel
49 Requires(post): chkconfig
50 Requires(preun): chkconfig
51
52 # This is for /sbin/service
53 Requires(preun): initscripts
54 Requires(postun): initscripts
55 %endif
56
57
58 # This is the directory where all the application resources (scripts,
59 # libraries, etc) will be installed: /usr/share/opendaylight
60 %global resources_dir %{_datadir}/%{name}
61
62 # This is the directory where variable data used by the application should be
63 # created: /var/lib/opendaylight
64 %global data_dir %{_localstatedir}/lib/%{name}
65
66 # This is the directory where the application stores its configuration:
67 # /etc/opendaylight
68 %global configuration_dir %{_sysconfdir}/%{name}
69
70 # This is the directory that has all the JAVA dependencies.
71 %global deps_dir %{_javadir}/opendaylight-controller-dependencies
72
73 # This is the integration buildsubdir and packaging dirs:
74 #%global intbuildsubdir %{_builddir}/%{buildsubdir}/opendaylight-integration-%{version}
75 %global pkgdir opendaylight-integration-%{version}/packaging/rpm
76
77
78 %description
79 OpenDaylight SDN Controller
80
81
82 %prep
83
84 %setup -q
85 %setup -q -D -T -a 1
86 cd opendaylight-integration-%{version}
87 %patch0 -p1
88
89
90 # In more restrictive distributions we should also here remove from the source
91 # package any third party binaries, or replace them with those provided by the
92 # distribution, before performing the actual build.
93
94
95 %build
96
97 # This regular maven build will need to be replaced by the distribution
98 # specific maven build command, but this is ok for now:
99 # todo: eventually move to using mvn-build or mvn-rpmbuild so dependencies are
100 # not downloaded.
101 # Don't do the tests since those are already covered by the normal merge and
102 # verify process and this build does not need to verify them.
103 # maven.compile.fork is used to reduce the build time.
104 #export MAVEN_OPTS="-Xmx1024m -XX:MaxPermSize=256m" && \
105 #  mvn clean install -Dmaven.test.skip=true -DskipIT -Dmaven.compile.fork=true
106 export MAVEN_OPTS="-Xmx1024m -XX:MaxPermSize=256m" && mvn clean install -Dmaven.test.skip=true
107
108
109 %install
110
111 # Extract the contents of the distribution to a temporary directory so that we
112 # can take things from there and move them to the correct locations:
113 mkdir -p tmp
114 unzip -o -d tmp opendaylight/distribution/opendaylight/target/distribution.opendaylight-osgipackage.zip
115
116 # Create the directories:
117 mkdir -p %{buildroot}%{configuration_dir}
118 mkdir -p %{buildroot}%{resources_dir}/configuration
119 mkdir -p %{buildroot}%{data_dir}/configuration
120
121 mv tmp/opendaylight/configuration/config.ini %{buildroot}%{configuration_dir}
122 ln -s %{configuration_dir}/config.ini %{buildroot}%{data_dir}/configuration
123 mv tmp/opendaylight/configuration/* %{buildroot}%{resources_dir}/configuration
124 rmdir tmp/opendaylight/configuration
125 ln -s %{resources_dir}/configuration/initial %{buildroot}%{data_dir}/configuration
126 ln -s %{resources_dir}/configuration/context.xml %{buildroot}%{data_dir}/configuration
127 ln -s %{resources_dir}/configuration/logback.xml %{buildroot}%{data_dir}/configuration
128 ln -s %{resources_dir}/configuration/tomcat-server.xml %{buildroot}%{data_dir}/configuration
129 ln -s %{resources_dir}/configuration/tomcat-logging.properties %{buildroot}%{data_dir}/configuration
130 ln -s %{resources_dir}/configuration/RSA.pk %{buildroot}%{data_dir}/configuration
131
132 mv tmp/opendaylight/* %{buildroot}%{resources_dir}
133
134 ln -s %{resources_dir}/lib %{buildroot}%{data_dir}
135 ln -s %{resources_dir}/plugins %{buildroot}%{data_dir}
136
137 %if 0%{?fedora}
138 install -m 644 -D %{pkgdir}/%{name}.systemd %{buildroot}%{_unitdir}/%{name}.service
139 %else
140 install -m 644 -D %{pkgdir}/%{name}.sysv %{buildroot}%{_initddir}/%{name}
141 %endif
142 install -m 644 -D %{pkgdir}/%{name}.sysconfig %{buildroot}%{_sysconfdir}/sysconfig/%{name}
143
144 # Fix all the run.sh files to the right names.
145 install -m 755 -D %{buildroot}%{resources_dir}/run.sh %{buildroot}%{resources_dir}/run.internal.sh
146 install -m 755 -D opendaylight-integration-%{version}/distributions/base/src/assemble/resources/run.sh \
147     %{buildroot}%{resources_dir}/run.base.sh
148 rm %{buildroot}%{resources_dir}/run.sh
149 install -m 755 -D opendaylight-integration-%{version}/distributions/virtualization/src/assemble/resources/run.sh \
150     %{buildroot}%{resources_dir}/run.sh
151 install -m 755 -D opendaylight-integration-%{version}/packaging/rpm/run.dist.sh %{buildroot}%{resources_dir}/run.dist.sh
152
153 # Usually one wants to replace the .jar files of the dependencies by symlinks
154 # to the ones provided to the system. This assumes the dependencies have been
155 # installed as separate packages and listed in the Requires header.
156 cd %{buildroot}%{resources_dir}/lib
157 for src in $( ls -I "org.opendaylight.*" );
158 do
159     rm -f ${src}
160     #tgt=$(echo ${src} | sed -e "s/-[0-9].*/.jar/")
161     #ln -s %{deps_dir}/${tgt} ${src}
162     ln -s %{deps_dir}/${src} ${src}
163 done
164
165 cd %{buildroot}%{resources_dir}/plugins
166 for src in $( ls -I "org.opendaylight.*" );
167 do
168     rm -f ${src}
169     #tgt=$(echo ${src} | sed -e "s/-[0-9].*/.jar/")
170     #ln -s %{deps_dir}/${tgt} ${src}
171     ln -s %{deps_dir}/${src} ${src}
172 done
173
174
175 # Fix the permissions as they come with all the permissions (mode 777)
176 # from the .zip file:
177 find %{buildroot}%{resources_dir} -type d -exec chmod 755 {} \;
178 find %{buildroot}%{resources_dir} -type f -exec chmod 644 {} \;
179 find %{buildroot}%{data_dir} -type d -exec chmod 755 {} \;
180 find %{buildroot}%{data_dir} -type f -exec chmod 755 {} \;
181 chmod 755 %{buildroot}%{resources_dir}/run.sh
182 chmod 755 %{buildroot}%{resources_dir}/run.base.sh
183 chmod 755 %{buildroot}%{resources_dir}/run.internal.sh
184 chmod 755 %{buildroot}%{resources_dir}/run.dist.sh
185 %if 0%{?rhel}
186 chmod 755 %{buildroot}%{_initddir}/%{name}
187 %endif
188
189 # Remove the temporary directory:
190 rm -rf tmp
191
192
193 %pre
194
195 # todo: register the opendaylight group:user.
196 # Create the group and user that will run the service before installing the
197 # package, as some of the files and directories will be owned by this user:
198 getent group opendaylight > /dev/null
199 if [ "$?" != 0 ]; then
200     groupadd \
201         -f \
202         -r \
203         opendaylight
204 fi
205
206 getent passwd opendaylight > /dev/null
207 if [ "$?" != 0 ]; then
208     useradd \
209         -r \
210         -g opendaylight \
211         -c "OpenDaylight SDN" \
212         -s /sbin/nologin \
213         -d %{data_dir} \
214         opendaylight
215 fi
216
217 # Currently not enabling service on boot.
218 #%post
219 #%systemd_post %{name}.service
220
221 %preun
222 %if 0%{?fedora}
223 %systemd_preun %{name}.service
224 %else
225 if [ $1 -eq 0 ] ; then
226     /sbin/service %{name} stop >/dev/null 2>&1
227     /sbin/chkconfig --del %{name}
228 fi
229 %endif
230
231 %postun
232 %if 0%{?fedora}
233 %systemd_postun
234 %else
235 if [ "$1" -ge "1" ] ; then
236     /sbin/service %{name} condrestart >/dev/null 2>&1 || :
237 fi
238 %endif
239
240 %clean
241 # This check is used for mock build so the build files are not deleted.
242 %if "%{noclean}" == "1"
243     exit 0
244 %endif
245
246
247 %files
248
249 %{resources_dir}
250 %if 0%{?fedora}
251 %{_unitdir}/%{name}.service
252 %else
253 %{_initddir}/%{name}
254 %endif
255
256 # Configuration files should marked as such, so that they aren't overwritten
257 # when updating the package:
258 %dir %{configuration_dir}
259 %config(noreplace) %{configuration_dir}/config.ini
260 %config(noreplace) %{_sysconfdir}/sysconfig/%{name}
261
262 # The data directory needs to be owned by the user that will run the service,
263 # as it will need to write inside:
264 %attr(-, opendaylight, opendaylight) %{data_dir}
265
266 # Documentation:
267 %doc LICENSE
268 %doc NOTICE
269 %doc README.OPENDAYLIGHT
270
271 %endif
272
273 %changelog
274 * Fri Jan 10 2014 Sam Hague <shague@redhat.com> - 0.1.0-0.6.0
275 - Updates to include new configuration files.
276
277 * Thu Jan 09 2014 Sam Hague <shague@redhat.com> - 0.1.0-0.5.0
278 - Updates for OF1.3 support.
279
280 * Thu Jan 02 2014 Sam Hague <shague@redhat.com> - 0.1.0-0.4.0
281 - Updates to include building distributions.
282
283 * Mon Dec 23 2013 Hsin-Yi Shen <hshen@redhat.com> - 0.1.0-0.3.0
284 - Updates to support building rpm for both RHEL and fedora.
285
286 * Fri Nov 22 2013 Sam Hague <shague@redhat.com> - 0.1.0-0.2.0
287 - Updates to support building rpm with jenkins.
288
289 * Tue Nov 12 2013 Sam Hague <shague@redhat.com> - 0.1.0-0.1.20131007git20dcbd1
290 - Modify the source tarball instructions and name.
291
292 * Wed Nov 06 2013 Sam Hague <shague@redhat.com> - 0.1.0-0.1.20131007git2f02ee4
293 - Add systemd support to install the service.
294 - Simplify the file permission modification logic.
295 - Modify the mvn command to not build tests.
296
297 * Fri Nov 01 2013 Sam Hague <shague@redhat.com> - 0.1.0-0.1.20131007git31c8f18
298 - Modify to include opendaylight-controller-dependencies.
299 - Do not delete the files in var
300
301 * Mon Oct 07 2013 Sam Hague <shague@redhat.com> - 0.1.0-0.1.20131007gitd684dd4
302 - Initial Fedora package.