diff options
author | Mauro Sardara <msardara+fdio@cisco.com> | 2017-09-05 20:11:45 +0200 |
---|---|---|
committer | Mauro Sardara <msardara+fdio@cisco.com> | 2017-09-05 18:21:57 +0000 |
commit | 4868cfef785f83fef983971e3ae2adba581a335a (patch) | |
tree | 43cad282f4e2f9d3d91098efda0b864098b78bc7 /scripts | |
parent | 009e5b9b4c15f28bdb4a5a2fbd4e013e9ab15765 (diff) |
Adding support for packaging
Change-Id: Ifce8355ee5f85513d368df8b3a92b69e2abdef20
Signed-off-by: Mauro Sardara <msardara+fdio@cisco.com>
Diffstat (limited to 'scripts')
-rw-r--r-- | scripts/build_package.sh | 81 | ||||
-rw-r--r-- | scripts/version | 57 |
2 files changed, 138 insertions, 0 deletions
diff --git a/scripts/build_package.sh b/scripts/build_package.sh new file mode 100644 index 00000000..8189efdc --- /dev/null +++ b/scripts/build_package.sh @@ -0,0 +1,81 @@ +#!/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 <mauro.sardara@cisco.com> 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 new file mode 100644 index 00000000..dcf93d83 --- /dev/null +++ b/scripts/version @@ -0,0 +1,57 @@ +#!/bin/bash + +path=$( cd "$(dirname "${BASH_SOURCE}")" ; pwd -P ) +version_prefix="Vicn-v" + +cd "$path" + +git rev-parse 2> /dev/null +if [ $? == 0 ]; then + vstring=$(git describe --dirty --match "$version_prefix*" | sed "s/$version_prefix//") +elif [ -f .version ]; then + vstring=$(cat .version) +else + if [ -f ../rpm/*.gz ]; then + vstring=$(ls ../rpm/*.gz) + else + exit 1 + fi +fi + +TAG=$(echo ${vstring} | cut -d- -f1 | sed -e "s/$version_prefix//") +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) +else + CMT=$(echo ${vstring} | cut -s -d- -f3,4) +fi +CMTR=$(echo $CMT | sed 's/-/_/') + +if [ -n "${BUILD_NUMBER}" ]; then + BLD="~b${BUILD_NUMBER}" +else + BLD="~b1" +fi + +if [ "$1" = "rpm-version" ]; then + echo ${TAG} + exit +fi + +if [ "$1" = "rpm-release" ]; then + [ -z "${ADD}" ] && echo release && exit + echo ${ADD}${CMTR:+~${CMTR}}${BLD} + exit +fi + + if [ -n "${ADD}" ]; then + if [ "$1" = "rpm-string" ]; then + echo ${TAG}-${ADD}${CMTR:+~${CMTR}}${BLD} + else + echo ${TAG}-${ADD}${CMT:+~${CMT}}${BLD} + fi + else + echo ${TAG}-release +fi
\ No newline at end of file |