Brian O'Connor

Updating onos-package for debian packaging

Change-Id: Icc3899b3a35ba0a02a97f5eddebfbe51ff6c1638
...@@ -93,22 +93,16 @@ function build_compressed_package() { ...@@ -93,22 +93,16 @@ function build_compressed_package() {
93 93
94 # Build a DEB package 94 # Build a DEB package
95 function build_deb() { 95 function build_deb() {
96 - echo "You need to be root in order to generate a proper DEB package." 96 + echo "This command may ask for your password to run commands as sudo,"
97 + echo " because you need to be root in order to generate a proper DEB package."
97 98
98 sudo rm -fr $ONOS_DEB_ROOT 99 sudo rm -fr $ONOS_DEB_ROOT
99 100
100 mkdir -p $ONOS_DEB_ROOT/{DEBIAN,opt,etc/init} 101 mkdir -p $ONOS_DEB_ROOT/{DEBIAN,opt,etc/init}
101 102
102 - { 103 + # Copy the debian directory and fill in version
103 - echo "Package: ONOS" 104 + cp -r $ONOS_ROOT/tools/package/deb/* $ONOS_DEB_ROOT/DEBIAN/
104 - echo "Architecture: all" 105 + sed -i'' -E "s/@ONOS_POM_VERSION/$ONOS_POM_VERSION/" $ONOS_DEB_ROOT/DEBIAN/control
105 - echo "Maintainer: ONOS Project"
106 - echo "Depends: debconf (>= 0.5.00), default-jre-headless (>= 1.8) | openjdk-8-jre | oracle-java8-installer"
107 - echo "Priority: optional"
108 - echo "Version: $ONOS_POM_VERSION"
109 - echo "Description: Open Network Operating System (ONOS) is an"
110 - echo " opensource SDN controller."
111 - } > $ONOS_DEB_ROOT/DEBIAN/control
112 106
113 cp -r $ONOS_STAGE $ONOS_DEB_ROOT/opt/onos 107 cp -r $ONOS_STAGE $ONOS_DEB_ROOT/opt/onos
114 cp $ONOS_ROOT/tools/package/init/onos.conf $ONOS_DEB_ROOT/etc/init/ 108 cp $ONOS_ROOT/tools/package/init/onos.conf $ONOS_DEB_ROOT/etc/init/
...@@ -119,6 +113,8 @@ function build_deb() { ...@@ -119,6 +113,8 @@ function build_deb() {
119 113
120 sudo dpkg-deb --build $ONOS_DEB_ROOT > /dev/null && 114 sudo dpkg-deb --build $ONOS_DEB_ROOT > /dev/null &&
121 sudo mv $ONOS_STAGE_ROOT/deb.deb $ONOS_DEB && ls -l $ONOS_DEB 115 sudo mv $ONOS_STAGE_ROOT/deb.deb $ONOS_DEB && ls -l $ONOS_DEB
116 +
117 + #TODO run lintian on .deb
122 } 118 }
123 119
124 # Build an RPM package 120 # Build an RPM package
......
1 +Package: onos
2 +Architecture: all
3 +Maintainer: ONOS Project
4 +Depends: debconf (>= 0.5.00), default-jre-headless (>= 1.8) | openjdk-8-jre | oracle-java8-installer
5 +Priority: optional
6 +Version: @ONOS_POM_VERSION
7 +Description: Open Network Operating System (ONOS)
8 + Open Network Operating System (ONOS) is an opensource SDN controller.
1 +Upstream-Name: onos
2 +Source: http://github.com/opennetworkinglab/onos
3 +
4 +Files: *
5 +Copyright: 2014-2015 Open Networking Laboratory
6 +License: Apache 2.0
7 + Licensed under the Apache License, Version 2.0 (the "License");
8 + you may not use this file except in compliance with the License.
9 + You may obtain a copy of the License at
10 + .
11 + http://www.apache.org/licenses/LICENSE-2.0
12 + .
13 + Unless required by applicable law or agreed to in writing, software
14 + distributed under the License is distributed on an "AS IS" BASIS,
15 + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 + See the License for the specific language governing permissions and
17 + limitations under the License.
18 + .
19 + On Debian systems, the complete text of the Apache License 2.0 can
20 + be found in "/usr/share/common-licenses/Apache-2.0"
1 +#!/bin/bash
2 +
3 +ONOS_USER=sdn
4 +
5 +# Check to see if user exists, and if not, create a service account
6 +getent passwd $ONOS_USER >/dev/null 2&>1 || ( useradd -M $ONOS_USER && usermod -L $ONOS_USER )
7 +
8 +# Create ONOS options file
9 +[ ! -f /opt/onos/options ] && cat << EOF > /opt/onos/options
10 +export ONOS_OPTS=server
11 +export ONOS_USER="$ONOS_USER"
12 +EOF
13 +
14 +# Change permissions for onos directory
15 +[ -d /opt/onos ] && chown -R $ONOS_USER.$ONOS_USER /opt/onos
16 +
1 +#!/bin/bash
2 +
3 +# Check if onos is running; if it is, stop onos
4 +[ -z "$(status onos 2>/dev/null | grep start)" ] && echo "onos is not running." || (
5 + stop onos
6 +
7 + # Wait for onos to stop up to 5 seconds
8 + for i in $(seq 1 5); do
9 + [ -z "$(ps -ef | grep karaf.jar | grep -v grep)" ] && break
10 + sleep 1
11 + done
12 + [ -z "$(ps -ef | grep karaf.jar | grep -v grep)" ] && echo 'Stopped onos service' || echo 'Failed to stop onos'
13 + ps -ef | grep karaf.jar | grep -v grep
14 +)
15 +
16 +# Clean up onos runtime directories
17 +# TODO don't hardcode karaf version
18 +rm -rf /opt/onos/apache-karaf-3.0.3/
19 +rm -rf /opt/onos/var/*
20 +rm -rf /opt/onos/config
21 +rm -rf /opt/onos/options
22 +rm -rf /opt/onos/log
23 +
24 +#TODO consider removing the sdn user if we created it
...@@ -13,9 +13,12 @@ respawn ...@@ -13,9 +13,12 @@ respawn
13 env LANG=en_US.UTF-8 13 env LANG=en_US.UTF-8
14 14
15 pre-start script 15 pre-start script
16 + [ -f /opt/onos/options ] && . /opt/onos/options
17 + ONOS_USER=${ONOS_USER:-root}
18 +
16 # Ensure that the environment is initialized 19 # Ensure that the environment is initialized
17 - [ -d /opt/onos ] && mkdir -p /opt/onos/var 20 + [ -d /opt/onos ] && mkdir /opt/onos/var 2>/dev/null && chown $ONOS_USER.$ONOS_USER /opt/onos/var
18 - [ -d /opt/onos ] && mkdir -p /opt/onos/config 21 + [ -d /opt/onos ] && mkdir /opt/onos/config 2>/dev/null && chown $ONOS_USER.$ONOS_USER /opt/onos/config
19 # TODO make karaf version configurable 22 # TODO make karaf version configurable
20 [ -d /opt/onos ] && [ ! -h /opt/onos/log ] \ 23 [ -d /opt/onos ] && [ ! -h /opt/onos/log ] \
21 && ln -s /opt/onos/apache-karaf-3.0.3/data/log /opt/onos/log || : 24 && ln -s /opt/onos/apache-karaf-3.0.3/data/log /opt/onos/log || :
......