3 ##############################################################################
4 # Copyright (c) 2015 Ericsson AB and others.
5 # stefan.k.berg@ericsson.com
6 # jonas.bjurel@ericsson.com
7 # All rights reserved. This program and the accompanying materials
8 # are made available under the terms of the Apache License, Version 2.0
9 # which accompanies this distribution, and is available at
10 # http://www.apache.org/licenses/LICENSE-2.0
11 ##############################################################################
13 ##############################################################################
14 # Default variable declarations
24 BUILD_HISTORY=".odl-build-history"
26 ##############################################################################
28 # Description: Prints out usage of this script
35 $0 creates a ${PACKAGE_NAME} Debian package
42 -p Target build path, the path where the built tar ball is to be fetched
44 -d Package dependencies
45 -h Prints this message
48 E.g.: $0 -n my/deb/src/dest/path -N my-package -v 1.0-1 -t myTag -p path/to/the/source -m "Main Tainer <main.tainer.exampe.org> -d myJavaDependence
52 ##############################################################################
54 # Description: Cleans up all artifacts from earlier builds
58 if [ -e $BUILD_HISTORY ]; then
68 ##############################################################################
70 # Description: constructs the Debian pack control file
72 make-DEBIAN_control ()
75 Package: $PACKAGE_SHORT_NAME
76 Version: $PACKAGE_VERSION
80 Depends: $DEPENDENCIES
81 Maintainer: $MAINTAINER
82 Description: OpenDaylight deamon
83 This is a daemon for the opendaylight/odl controller service.
87 ##############################################################################
88 # subroutine: make-DEBIAN_conffiles
89 # Description: Constructs the Debian package config files assignment
91 make-DEBIAN_conffiles ()
94 /etc/odl/etc/all.policy
95 /etc/odl/etc/config.properties
96 /etc/odl/etc/custom.properties
97 /etc/odl/etc/distribution.info
98 /etc/odl/etc/equinox-debug.properties
99 /etc/odl/etc/java.util.logging.properties
100 /etc/odl/etc/jmx.acl.cfg
101 /etc/odl/etc/jmx.acl.java.lang.Memory.cfg
102 /etc/odl/etc/jmx.acl.org.apache.karaf.bundle.cfg
103 /etc/odl/etc/jmx.acl.org.apache.karaf.config.cfg
104 /etc/odl/etc/jmx.acl.org.apache.karaf.security.jmx.cfg
105 /etc/odl/etc/jmx.acl.osgi.compendium.cm.cfg
106 /etc/odl/etc/jre.properties
107 /etc/odl/etc/keys.properties
108 /etc/odl/etc/org.apache.felix.fileinstall-deploy.cfg
109 /etc/odl/etc/org.apache.karaf.command.acl.bundle.cfg
110 /etc/odl/etc/org.apache.karaf.command.acl.config.cfg
111 /etc/odl/etc/org.apache.karaf.command.acl.feature.cfg
112 /etc/odl/etc/org.apache.karaf.command.acl.jaas.cfg
113 /etc/odl/etc/org.apache.karaf.command.acl.kar.cfg
114 /etc/odl/etc/org.apache.karaf.command.acl.shell.cfg
115 /etc/odl/etc/org.apache.karaf.command.acl.system.cfg
116 /etc/odl/etc/org.apache.karaf.features.cfg
117 /etc/odl/etc/org.apache.karaf.features.obr.cfg
118 /etc/odl/etc/org.apache.karaf.features.repos.cfg
119 /etc/odl/etc/org.apache.karaf.jaas.cfg
120 /etc/odl/etc/org.apache.karaf.kar.cfg
121 /etc/odl/etc/org.apache.karaf.log.cfg
122 /etc/odl/etc/org.apache.karaf.management.cfg
123 /etc/odl/etc/org.apache.karaf.shell.cfg
124 /etc/odl/etc/org.ops4j.pax.logging.cfg
125 /etc/odl/etc/org.ops4j.pax.url.mvn.cfg
126 /etc/odl/etc/regions-config.xml
127 /etc/odl/etc/shell.init.script
128 /etc/odl/etc/startup.properties
129 /etc/odl/etc/system.properties
130 /etc/odl/etc/users.properties
131 /etc/odl/configuration/context.xml
132 /etc/odl/configuration/logback.xml
133 /etc/odl/configuration/tomcat-logging.properties
134 /etc/odl/configuration/tomcat-server.xml
138 ##############################################################################
139 # subroutine: make-DEBIAN_postinst
140 # Description: Constructs the Debian package post installation script
142 make-DEBIAN_postinst ()
146 ln -s /etc/${PACKAGE_SHORT_NAME}/* ${TARGET_INSTALL_PATH}
147 echo "OpenDaylight $TAG version $PACKAGE_VERSION has been installed"
151 ##############################################################################
152 # subroutine: make-DEBIAN_bin
153 # Description: Constructs the bin script (normally under /usr/bin)
159 ${TARGET_INSTALL_PATH}bin/karaf $@
163 ##############################################################################
164 # subroutine: make-DEBIAN_copyright
165 # Description: Constructs the copyright text (normally under /usr/share/doc...)
167 make-DEBIAN_copyright ()
170 OpenDaylight - an open source SDN controller
171 Licensed to the Apache Software Foundation (ASF) under one or more
172 contributor license agreements. See the NOTICE file distributed with
173 this work for additional information regarding copyright ownership.
174 The ASF licenses this file to You under the Apache License, Version 2.0
175 (the "License"); you may not use this file except in compliance with
176 the License. You may obtain a copy of the License at
178 http://www.apache.org/licenses/LICENSE-2.0
180 Unless required by applicable law or agreed to in writing, software
181 distributed under the License is distributed on an "AS IS" BASIS,
182 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
183 See the License for the specific language governing permissions and
184 limitations under the License.
188 ##############################################################################
189 # subroutine: make-DEBIAN_changelog
190 # Description: Constructs the changelog text (normally under /usr/share/doc...)
192 make-DEBIAN_changelog ()
195 $PACKAGE_SHORT_NAME ($PACKAGE_VERSION) precise-proposed; urgency=low
197 * Derived from $PACKAGE_NAME $PACHAGE_VERSION
199 -- $MAINTAINER $(date)
203 ##############################################################################
206 while getopts "N:n:v:d:Chm:t:p:" OPTION
216 COMMAND+="-N ${PACKAGE_NAME} "
220 PACKAGE_SHORT_NAME=$OPTARG
221 COMMAND+="-n ${PACKAGE_SHORT_NAME} "
225 PACKAGE_VERSION=$OPTARG
226 COMMAND+="-v ${PACKAGE_VERSION} "
230 TARGET_BUILD_PATH=$OPTARG
231 COMMAND+="-p ${TARGET_BUILD_PATH} "
236 COMMAND+="-t ${TAG} "
241 COMMAND+="-m ${MAINTAINER} "
246 COMMAND+="-d ${DEPENDENCIES} "
251 COMMAND+="-A ${ARCH} "
262 # Constructing script variables
263 DEB_PACK_BASE_PATH="f_${PACKAGE_SHORT_NAME}/${PACKAGE_NAME}_${PACKAGE_VERSION}/"
264 echo ${DEB_PACK_BASE_PATH} >> "$BUILD_HISTORY"
265 TARGET_INSTALL_PATH="/usr/share/java/${PACKAGE_SHORT_NAME}/"
266 DEB_PACK_CONTENT_PATH="${DEB_PACK_BASE_PATH}usr/share/java/${PACKAGE_SHORT_NAME}/"
267 DEB_PACK_CONFIG_PATH="${DEB_PACK_BASE_PATH}etc/${PACKAGE_SHORT_NAME}"
268 TARGET_TAR=$(ls ${TARGET_BUILD_PATH}*.tar.gz)
269 TARGET_TAR="${TARGET_TAR##*/}"
270 TAR_PATH="${TARGET_TAR%.*}"
271 TAR_PATH="${TAR_PATH%.*}"
272 if [ -e $DEB_PACK_BASE_PATH ]; then
273 rm -R $DEB_PACK_BASE_PATH
276 # Create Deb pack content and configuration
277 mkdir -p ${DEB_PACK_CONTENT_PATH}
278 cp ${TARGET_BUILD_PATH}${TARGET_TAR} ${DEB_PACK_CONTENT_PATH}
279 tar -xzf ${DEB_PACK_CONTENT_PATH}${TARGET_TAR} -C ${DEB_PACK_CONTENT_PATH}
280 rm ${DEB_PACK_CONTENT_PATH}${TARGET_TAR}
281 mv ${DEB_PACK_CONTENT_PATH}${TAR_PATH}/* ${DEB_PACK_CONTENT_PATH}.
282 rm -R ${DEB_PACK_CONTENT_PATH}${TAR_PATH}
284 # Crate and populate Deb pack config target
285 mkdir -p ${DEB_PACK_CONFIG_PATH}/etc
286 mv ${DEB_PACK_CONTENT_PATH}etc/* ${DEB_PACK_CONFIG_PATH}/etc/
287 rm -R ${DEB_PACK_CONTENT_PATH}etc
288 mkdir -p ${DEB_PACK_CONFIG_PATH}/configuration
289 mv ${DEB_PACK_CONTENT_PATH}configuration/* ${DEB_PACK_CONFIG_PATH}/configuration/
290 rm -R ${DEB_PACK_CONTENT_PATH}configuration
292 # Set package permisions
293 find ${DEB_PACK_CONTENT_PATH} -type d -print -exec chmod 755 {} \;
294 find ${DEB_PACK_CONFIG_PATH}/etc/ -type f -print -exec chmod 644 {} \;
295 find ${DEB_PACK_CONFIG_PATH}/etc/ -type d -print -exec chmod 755 {} \;
297 # Create package usr/bin odl script
298 mkdir "${DEB_PACK_BASE_PATH}usr/bin"
299 chmod 755 "${DEB_PACK_BASE_PATH}usr/bin"
300 make-DEBIAN_bin > "${DEB_PACK_BASE_PATH}usr/bin/odl"
301 chmod 755 "${DEB_PACK_BASE_PATH}usr/bin/odl"
303 # Create Deb pack install meta-data
304 mkdir "${DEB_PACK_BASE_PATH}DEBIAN"
305 make-DEBIAN_control > "${DEB_PACK_BASE_PATH}DEBIAN/control"
306 make-DEBIAN_conffiles > "${DEB_PACK_BASE_PATH}DEBIAN/conffiles"
307 mkdir -p "${DEB_PACK_BASE_PATH}usr/share/doc/${PACKAGE_SHORT_NAME}"
308 make-DEBIAN_copyright > "${DEB_PACK_BASE_PATH}usr/share/doc/${PACKAGE_SHORT_NAME}/copyright"
309 make-DEBIAN_changelog > "${DEB_PACK_BASE_PATH}usr/share/doc/${PACKAGE_SHORT_NAME}/changelog.Debian"
311 # Create Deb pack post install symlinks and usr/bin scripts
312 make-DEBIAN_postinst > "${DEB_PACK_BASE_PATH}DEBIAN/postinst"
313 chmod 755 "${DEB_PACK_BASE_PATH}DEBIAN/postinst"
314 mkdir -p "${DEB_PACK_BASE_PATH}usr/bin"