From 5221d15ea04d68fcd6492cc13cfe5ef3db92573a Mon Sep 17 00:00:00 2001 From: Mauro Sardara Date: Fri, 22 Sep 2017 21:53:55 +0200 Subject: Fixing packaging support Change-Id: I322e678a8fe455afc3325204062fb47fa45f5245 Signed-off-by: Mauro Sardara --- debian/changelog | 6 +-- debian/control | 12 +----- debian/netmon.postinst | 2 +- debian/python3-netmodel.postinst | 3 ++ debian/rules | 2 - debian/vicn.postinst | 3 ++ scripts/build-package.sh | 88 ++++++++++++++++++++++++++++++++++++++++ scripts/build_package.sh | 81 ------------------------------------ scripts/version | 6 +-- vicn/core/collection.py | 23 +++++++++++ 10 files changed, 125 insertions(+), 101 deletions(-) create mode 100644 debian/python3-netmodel.postinst create mode 100644 debian/vicn.postinst create mode 100644 scripts/build-package.sh delete mode 100644 scripts/build_package.sh create mode 100644 vicn/core/collection.py diff --git a/debian/changelog b/debian/changelog index 90590ffb..cc91eb40 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,5 +1,5 @@ -vicn (1.0-25~g009e5b9~b1) UNRELEASED; urgency=medium +vicn (0.1-1) UNRELEASED; urgency=medium - * Initial release (Closes: #nnnn) + * Initial release. (Closes: #XXXXXX) - -- Mauro Sardara Tue, 18 Oct 2016 12:10:07 +0200 + -- Mon, 10 Jul 2017 11:07:54 +0200 diff --git a/debian/control b/debian/control index 1dad2688..99e51ee9 100644 --- a/debian/control +++ b/debian/control @@ -1,5 +1,4 @@ Source: vicn -Version: 3.23 Section: python Priority: optional Maintainer: Jordan Augé @@ -11,7 +10,6 @@ Vcs-Browser: https://gerrit.fd.io/r/gitweb?p=cicn.git X-Python3-Version: >= 3.5 Package: python3-netmodel -Version: 3.23 Architecture: all Depends: ${python3:Depends}, ${misc:Depends}, python3-daemon, python3-lockfile, python3-setuptools, python3-pip Suggests: python-netmodel-doc @@ -19,15 +17,13 @@ Description: Netmodel Netmodel Package: netmon -Version: 3.23 Architecture: all -Depends: ${python3:Depends}, ${misc:Depends}, python3-netmodel +Depends: ${python3:Depends}, ${misc:Depends}, python3-netmodel, bwm-ng Suggests: netmon-doc Description: Monitoring Monitoring daemon Package: vicn -Version: 3.23 Architecture: all Depends: ${python3:Depends}, ${misc:Depends}, python3-netmodel Suggests: vicn-doc @@ -51,9 +47,3 @@ Description: vICN experiment controller The master, vICN, controls the whole cluster of servers, by means of HTTPS REST APIs and remote SSH. -#Package: vicn-resource-hicn -#Architecture: all -#Depends: vicn -#Description: TODO -# TODO - diff --git a/debian/netmon.postinst b/debian/netmon.postinst index fdbfb95e..41df34c0 100644 --- a/debian/netmon.postinst +++ b/debian/netmon.postinst @@ -1,3 +1,3 @@ #!/bin/bash -pip3 install --upgrade autobahn +pip3 install --upgrade pylxd diff --git a/debian/python3-netmodel.postinst b/debian/python3-netmodel.postinst new file mode 100644 index 00000000..587f14b0 --- /dev/null +++ b/debian/python3-netmodel.postinst @@ -0,0 +1,3 @@ +#!/bin/bash + +pip3 install --upgrade autobahn pyopenssl pylxd diff --git a/debian/rules b/debian/rules index 86a95b03..14bba467 100755 --- a/debian/rules +++ b/debian/rules @@ -8,8 +8,6 @@ %: dh $@ --with python3,sphinxdoc --buildsystem=pybuild -override_dh_auto_test: - #override_dh_auto_build: export http_proxy=127.0.0.1:9 #override_dh_auto_build: export https_proxy=127.0.0.1:9 #override_dh_auto_build: dh_auto_build diff --git a/debian/vicn.postinst b/debian/vicn.postinst new file mode 100644 index 00000000..41df34c0 --- /dev/null +++ b/debian/vicn.postinst @@ -0,0 +1,3 @@ +#!/bin/bash + +pip3 install --upgrade pylxd diff --git a/scripts/build-package.sh b/scripts/build-package.sh new file mode 100644 index 00000000..264b6ab6 --- /dev/null +++ b/scripts/build-package.sh @@ -0,0 +1,88 @@ +k#!/bin/bash +set -euxo pipefail +IFS=$'\n\t' + +SCRIPT_PATH=$( cd "$(dirname "${BASH_SOURCE}")" ; pwd -P ) +APT_PATH=`which apt-get` || true +apt_get=${APT_PATH:-"/usr/local/bin/apt-get"} + +BUILD_TOOLS_UBUNTU="build-essential doxygen" +DEPS_UBUNTU="devscripts debhelper python3-all python3-setuptools python3-docutils python3-sphinx python3-networkx python3-pyparsing python3-pip" +DEPS_PYTHON="autobahn pyopenssl" + +setup() { + + DISTRIB_ID=$1 + + if [ "$DISTRIB_ID" == "Ubuntu" ]; then + sudo ${apt_get} update || true + fi +} + +# Parameters: +# $1 = Package name +# +build_package() { + + PACKAGE_NAME=$1 + + ARCHITECTURE="all" + + # Figure out what system we are running on + if [ -f /etc/lsb-release ];then + . /etc/lsb-release + DEB=ON + RPM=OFF + else + echo "ERROR: System configuration not recognized. Build failed" + exit -1 + fi + + echo ARCHITECTURE: $ARCHITECTURE + echo DISTRIB_ID: $DISTRIB_ID + echo DISTRIB_RELEASE: $DISTRIB_RELEASE + echo DISTRIB_CODENAME: $DISTRIB_CODENAME + echo DISTRIB_DESCRIPTION: $DISTRIB_DESCRIPTION + + setup $DISTRIB_ID + # Install package dependencies + if [ $DISTRIB_ID == "Ubuntu" ]; then + echo $BUILD_TOOLS_UBUNTU $DEPS_UBUNTU | xargs sudo ${apt_get} install -y --allow-unauthenticated + echo $DEPS_PYTHON | xargs sudo pip3 install --upgrade + fi + + # do nothing but print the current slave hostname + hostname + + # Make the package + VERSION=$(bash $SCRIPT_PATH/version) + + cat << EOF > $SCRIPT_PATH/../debian/changelog +vicn ($VERSION) UNRELEASED; urgency=medium + + * Initial release (Closes: #nnnn) + + -- Mauro Sardara Tue, 18 Oct 2016 12:10:07 +0200 +EOF + + mkdir -p $SCRIPT_PATH/../vicn_build_root + ls -1 | while read line; do if [ "$line" != "$(basename $SCRIPT_PATH)" ]; then mv $line $SCRIPT_PATH/../vicn_build_root; fi done || true + cd $SCRIPT_PATH/../vicn_build_root + + debuild --no-lintian --no-tgz-check -i -us -uc -b + + cd $SCRIPT_PATH/.. + mkdir build + mv *.deb build + + echo "*******************************************************************" + echo "* $PACKAGE_NAME BUILD SUCCESSFULLY COMPLETED" + echo "*******************************************************************" + + exit 0 +} + +PACKAGE_NAME="VICN" +pushd $SCRIPT_PATH/.. +build_package $PACKAGE_NAME +popd diff --git a/scripts/build_package.sh b/scripts/build_package.sh deleted file mode 100644 index 8189efdc..00000000 --- a/scripts/build_package.sh +++ /dev/null @@ -1,81 +0,0 @@ -#!/bin/bash -set -euxo pipefail -IFS=$'\n\t' - -SCRIPT_PATH=$( cd "$(dirname "${BASH_SOURCE}")" ; pwd -P ) -APT_PATH=`which apt-get` || true -apt_get=${APT_PATH:-"/usr/local/bin/apt-get"} - -BUILD_TOOLS_UBUNTU="build-essential doxygen" -DEPS_UBUNTU="devscripts debhelper python3-all python3-setuptools python3-docutils python3-sphinx python3-networkx python3-openssl python3-pyparsing python3-pip" - -setup() { - - DISTRIB_ID=$1 - - if [ "$DISTRIB_ID" == "Ubuntu" ]; then - sudo ${apt_get} update || true - fi -} - -# Parameters: -# $1 = Package name -# -build_package() { - - PACKAGE_NAME=$1 - - ARCHITECTURE="all" - - # Figure out what system we are running on - if [ -f /etc/lsb-release ];then - . /etc/lsb-release - DEB=ON - RPM=OFF - else - echo "ERROR: System configuration not recognized. Build failed" - exit -1 - fi - - echo ARCHITECTURE: $ARCHITECTURE - echo DISTRIB_ID: $DISTRIB_ID - echo DISTRIB_RELEASE: $DISTRIB_RELEASE - echo DISTRIB_CODENAME: $DISTRIB_CODENAME - echo DISTRIB_DESCRIPTION: $DISTRIB_DESCRIPTION - - setup $DISTRIB_ID - # Install package dependencies - if [ $DISTRIB_ID == "Ubuntu" ]; then - echo $BUILD_TOOLS_UBUNTU $DEPS_UBUNTU | xargs sudo ${apt_get} install -y --allow-unauthenticated - fi - - # do nothing but print the current slave hostname - hostname - - # Make the package - VERSION=$(bash $SCRIPT_PATH/version) - - cat << EOF > $SCRIPT_PATH/../debian/changelog -vicn ($VERSION) UNRELEASED; urgency=medium - - * Initial release (Closes: #nnnn) - - -- Mauro Sardara Tue, 18 Oct 2016 12:10:07 +0200 -EOF - - pushd $SCRIPT_PATH/.. - debuild --no-lintian --no-tgz-check -i -us -uc -b - popd - - echo "*******************************************************************" - echo "* $PACKAGE_NAME BUILD SUCCESSFULLY COMPLETED" - echo "*******************************************************************" - - exit 0 -} - -PACKAGE_NAME="VICN" -pushd $SCRIPT_PATH/.. -build_package $PACKAGE_NAME -popd - diff --git a/scripts/version b/scripts/version index dcf93d83..2f4c1d4a 100644 --- a/scripts/version +++ b/scripts/version @@ -7,7 +7,7 @@ cd "$path" git rev-parse 2> /dev/null if [ $? == 0 ]; then - vstring=$(git describe --dirty --match "$version_prefix*" | sed "s/$version_prefix//") + vstring=$(git describe --match "$version_prefix*" | sed "s/$version_prefix//") elif [ -f .version ]; then vstring=$(cat .version) else @@ -23,7 +23,7 @@ ADD=$(echo ${vstring} | cut -s -d- -f2) git rev-parse 2> /dev/null if [ $? == 0 ]; then - CMT=$(git describe --dirty --match "$version_prefix*" | sed "s/$version_prefix//" | cut -s -d- -f3,4) + CMT=$(git describe --match "$version_prefix*" | sed "s/$version_prefix//" | cut -s -d- -f3,4) else CMT=$(echo ${vstring} | cut -s -d- -f3,4) fi @@ -54,4 +54,4 @@ fi fi else echo ${TAG}-release -fi \ No newline at end of file +fi diff --git a/vicn/core/collection.py b/vicn/core/collection.py new file mode 100644 index 00000000..fb222891 --- /dev/null +++ b/vicn/core/collection.py @@ -0,0 +1,23 @@ +#!/usr/bin/env python3 +# -*- coding: utf-8 -*- +# +# Copyright (c) 2017 Cisco and/or its affiliates. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at: +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +from vicn.core.sa_collections import InstrumentedList +from netmodel.model.collection import Collection + +class Collection(InstrumentedList, Collection): + pass -- cgit 1.2.3-korg