Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Debian/Ubuntu packaging #542

Open
wants to merge 6 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 23 additions & 0 deletions README.Debian
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
How to create Ubuntu (or Debian) packages, to be buildable locally or
in a Ubuntu Launchpad PPA:

1. Check packaging.conf, set maintainer and GnuPG key ID.
To turn off signatures for local pbuilder build: SKIP_PACKAGE_SIGNING=1
Note: Launchpad PPA uploads only works with signed packages!

2. Call ./renew-debian-changelog to automatically update the package
version, according to Git commit and current date. This will update
debian/changelog and configure.ac.

3. Build Ubuntu/Debian packages:
- Create package: ./build-deb <distribution>
distribution: focal, groovy, hirsute, unstable, etc.
- Create source package and build using pbuilder:
./build-deb <distribution>
The result will be in /var/cache/pbuilder/result
- Create packages for focal, groovy and hirsute + upload to PPA:
./make-ppa
Note: dput has to be configured properly (in ~/.dput.cf)!


24.03.2020 Thomas Dreibholz <dreibh@simula.no>
122 changes: 122 additions & 0 deletions build-deb
Original file line number Diff line number Diff line change
@@ -0,0 +1,122 @@
#!/usr/bin/env bash
#
# Debian/Ubuntu Packaging Scripts
# Copyright (C) 2002-2021 by Thomas Dreibholz
#
# 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.
#
# Contact: dreibh@iem.uni-due.de

# Bash options:
set -e


# ====== Obtain package and version information =============================
OVERRIDE_PACKAGE_DISTRIBUTION="$1"

CHANGELOG_HEADER="`head -n1 debian/changelog`"

# The package name, e.g. MyApplication
PACKAGE=`echo ${CHANGELOG_HEADER} | sed -e "s/(.*//" -e "s/ //g"`
# The package distribution, e.g. precise, raring, ...
PACKAGE_DISTRIBUTION=`echo ${CHANGELOG_HEADER} | sed -e "s/[^)]*)//" -e "s/;.*//g" -e "s/ //g"`
# The package's version, e.g. 1.2.3-1ubuntu1
PACKAGE_VERSION=`echo ${CHANGELOG_HEADER} | sed -e "s/.*(//" -e "s/).*//" -e "s/ //g" -e "s/ //g" -e "s/^[0-9]://g"`
# The package's output version, e.g. 1.2.3-1ubuntu
OUTPUT_VERSION=`echo ${PACKAGE_VERSION} | sed -e "s/\(ubuntu\|ppa\)[0-9]*$/\1/"`
# The package's Debian version, e.g. 1.2.3-1
DEBIAN_VERSION=`echo ${OUTPUT_VERSION} | sed -e "s/\(ubuntu\|ppa\)$//1"`
# The package's upstream version, e.g. 1.2.3
UPSTREAM_VERSION=`echo ${DEBIAN_VERSION} | sed -e "s/-[0-9]*$//"`
# The package's plain upstream version, e.g. 1.2.3 (without e.g. ~svn<xxxx>)
PLAIN_VERSION=`echo ${UPSTREAM_VERSION} | sed -e "s/\([0-9\.]*\)[-+~].*$/\1/"`


echo -e "\x1b[34m######################################################################\x1b[0m"
echo -e "\x1b[34mCHANGELOG_HEADER: ${CHANGELOG_HEADER}\x1b[0m"
echo -e "\x1b[34mPACKAGE: ${PACKAGE}\x1b[0m"
echo -e "\x1b[34mPACKAGE_DISTRIBUTION: ${PACKAGE_DISTRIBUTION}\x1b[0m"
echo -e "\x1b[34mPACKAGE_VERSION ${PACKAGE_VERSION}\x1b[0m"
echo -e "\x1b[34mOUTPUT_VERSION: ${OUTPUT_VERSION}\x1b[0m"
echo -e "\x1b[34mDEBIAN_VERSION: ${DEBIAN_VERSION}\x1b[0m"
echo -e "\x1b[34mUPSTREAM_VERSION: ${UPSTREAM_VERSION}\x1b[0m"
echo -e "\x1b[34mPLAIN_VERSION: ${PLAIN_VERSION}\x1b[0m"
echo -e "\x1b[34m######################################################################\x1b[0m"

if [ ! -e ./packaging.conf ] ; then
echo >&2 "ERROR: packaging.conf does not exist -> no configuration for the new package!"
exit 1
fi
. ./packaging.conf

if [ "${OVERRIDE_PACKAGE_DISTRIBUTION}" != "" ] ; then
PACKAGE_DISTRIBUTION="${OVERRIDE_PACKAGE_DISTRIBUTION}"
echo ""
echo -e "\x1b[34m**** Overriding PACKAGE_DISTRIBUTION: PACKAGE_DISTRIBUTION=${PACKAGE_DISTRIBUTION}! ****\x1b[0m"
echo ""
fi


# ====== Create source package ==============================================
sudo echo ""
./clean-deb
./make-deb ${PACKAGE_DISTRIBUTION}

if [ "${PACKAGE_DISTRIBUTION}" == "unstable" -o \
"${PACKAGE_DISTRIBUTION}" == "testing" -o \
"${PACKAGE_DISTRIBUTION}" == "stable" -o \
"${PACKAGE_DISTRIBUTION}" == "default" ] ; then
if [ "${PACKAGE_DISTRIBUTION}" == "default" ] ; then
version=${PACKAGE_VERSION}
else
version=${DEBIAN_VERSION}
fi
changesFilesPattern="${PACKAGE}_${version}_*.changes"
dscFile=`ls ${PACKAGE}_${version}.dsc | tail -n1`
else
changesFilesPattern="${PACKAGE}_${OUTPUT_VERSION}~${PACKAGE_DISTRIBUTION}[0-9]_*.changes"
dscFile=`ls ${PACKAGE}_${OUTPUT_VERSION}~${PACKAGE_DISTRIBUTION}[0-9].dsc | tail -n1`
fi


# ====== Build binary package ===============================================
echo -e ""
echo -e "\x1b[34m`date +%FT%H:%M:%S`: ====== Building binary package ========================================\x1b[0m"
echo -e ""

if [ ! -e "${dscFile}" ] ; then
echo >&2 "ERROR: Unable to find description file ${dscFile}!"
exit 1
fi
sudo pbuilder build ${dscFile}


# ====== Run lintian ========================================================
echo -e ""
echo -e "\x1b[34m`date +%FT%H:%M:%S`: ====== Running lintian ================================================\x1b[0m"
echo -e ""

changesFile=`find /var/cache/pbuilder/result/ -name "${changesFilesPattern}"`
if [ ! -e "${changesFile}" ] ; then
echo >&2 "ERROR: Unable to find changes file ${changesFile}!"
exit 1
fi

profile="ubuntu"
if [ "${PACKAGE_DISTRIBUTION}" == "unstable" -o \
"${PACKAGE_DISTRIBUTION}" == "testing" -o \
"${PACKAGE_DISTRIBUTION}" == "stable" ] ; then
profile="debian"
fi
echo "Calling: lintian -iIEv --pedantic --suppress-tags file-references-package-build-path --profile ${profile} ${changesFile}"
lintian -iIEv --pedantic --suppress-tags file-references-package-build-path --profile ${profile} ${changesFile} || true
36 changes: 36 additions & 0 deletions clean-deb
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
#!/usr/bin/env bash
#
# Debian/Ubuntu Packaging Scripts
# Copyright (C) 2002-2021 by Thomas Dreibholz
#
# 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.
#
# Contact: dreibh@iem.uni-due.de


# ====== Obtain package information =========================================
CHANGELOG_HEADER="`head -n1 debian/changelog`"
PACKAGE=`echo ${CHANGELOG_HEADER} | sed -e "s/(.*//" -e "s/ //g"`


# ====== Clean up ===========================================================
rm -f *.deb *.dsc *.asc *.changes *.build *.upload *.tar.gz stamp-h* svn-commit* *~

for type in gz bz2 xz ; do
find . -maxdepth 1 -name "${PACKAGE}-*.${type}" | xargs -r rm
find . -maxdepth 1 -name "${PACKAGE}_*.${type}" | xargs -r rm
done
find . -maxdepth 1 -name "*.buildinfo" | xargs -r rm

shopt -s extglob
rm -rf ${PACKAGE}-+([0-9]).+([0-9]).+([0-9])*
5 changes: 5 additions & 0 deletions debian/changelog
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
p4lang-pi (0.1.0+g202103250946~827907-1ppa1) unstable; urgency=medium

* Self-made package

-- Thomas Dreibholz <dreibh@iem.uni-due.de> Thu, 25 Mar 2021 10:46:15 +0100
1 change: 1 addition & 0 deletions debian/compat
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
12
119 changes: 119 additions & 0 deletions debian/control
Original file line number Diff line number Diff line change
@@ -0,0 +1,119 @@
Source: p4lang-pi
Section: net
Priority: optional
Maintainer: Thomas Dreibholz <dreibh@simula.no>
Build-Depends: autoconf,
automake,
debhelper (>= 12),
dh-python,
libboost-dev,
libboost-system-dev,
libboost-thread-dev,
libgrpc++-dev,
libgrpc-dev,
libjudy-dev,
libnanomsg-dev,
libprotobuf-dev,
libprotoc-dev,
libreadline-dev,
libtool,
libtool-bin,
p4lang-bmv2-dev,
pkg-config,
protobuf-compiler,
protobuf-compiler-grpc,
python2,
python3-all,
valgrind
Standards-Version: 4.5.1.0
Rules-Requires-Root: no
Homepage: https://github.com/p4lang/PI
Vcs-Git: https://github.com/p4lang/PI
Vcs-Browser: https://github.com/p4lang/PI

Package: p4lang-pi-bin
Architecture: amd64 arm64
Depends: libboost-dev,
p4lang-bmv2-bin,
p4lang-pi-libs (= ${binary:Version}),
${misc:Depends},
${python:Depends},
${shlibs:Depends}
Recommends: hipercontracer,
netperfmeter,
rsplib-tools,
subnetcalc,
tcpdump,
tsctp,
tshark
Description: Implementation framework of a P4Runtime server (binaries)
Protocol Independent API (PI or P4 Runtime) defines a set of APIs that allow
interacting with entities defined in a P4 program.
.
This package contains the binary programs.

Package: p4lang-pi-libs
Section: libs
Architecture: amd64 arm64
Depends: p4lang-bmv2-libs,
${misc:Depends},
${shlibs:Depends}
Description: Implementation framework of a P4Runtime server (libraries)
Protocol Independent API (PI or P4 Runtime) defines a set of APIs that allow
interacting with entities defined in a P4 program.
.
This package contains the libraries.

Package: python-p4lang-pi
Section: python
Architecture: amd64 arm64
Depends: p4lang-bmv2,
p4lang-pi-libs (= ${binary:Version}),
python2,
${misc:Depends},
${python:Depends},
${shlibs:Depends}
Description: Implementation framework of a P4Runtime server (Python libraries)
Protocol Independent API (PI or P4 Runtime) defines a set of APIs that allow
interacting with entities defined in a P4 program.
.
This package contains the Python libraries.

Package: p4lang-pi-dev
Section: libdevel
Architecture: amd64 arm64
Depends: libboost-dev,
libboost-system-dev,
libboost-thread-dev,
libgrpc++-dev,
libgrpc-dev,
libjudy-dev,
libprotobuf-dev,
libprotoc-dev,
p4lang-bmv2,
p4lang-bmv2-dev,
p4lang-pi-libs (= ${binary:Version}),
protobuf-compiler,
protobuf-compiler-grpc,
${misc:Depends},
${shlibs:Depends}
Description: Implementation framework of a P4Runtime server (development files)
Protocol Independent API (PI or P4 Runtime) defines a set of APIs that allow
interacting with entities defined in a P4 program.
.
This package contains the development files.

Package: p4lang-pi
Architecture: amd64 arm64
Depends: p4lang-pi-bin (= ${binary:Version}),
p4lang-pi-dev (= ${binary:Version}),
p4lang-pi-libs (= ${binary:Version}),
python-p4lang-pi (= ${binary:Version}),
${misc:Depends},
${shlibs:Depends}
Description: Implementation framework of a P4Runtime server (metapackage)
Protocol Independent API (PI or P4 Runtime) defines a set of APIs that allow
interacting with entities defined in a P4 program.
.
This metapackage depends on the binaries, libraries and development
packages.
20 changes: 20 additions & 0 deletions debian/copyright
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
Format: https://www.debian.org/doc/packaging-manuals/copyright-format/1.0/
Upstream-Name: p4lang-pi
Upstream-Contact: Antonin Bas <antonin@barefootnetworks.com>
Source: https://github.com/p4lang/PI

Files: *
Copyright: Antonin Bas <antonin@barefootnetworks.com>
License: Apache-2.0
A permissive license whose main conditions require preservation of copyright
and license notices. Contributors provide an express grant of patent rights.
Licensed works, modifications, and larger works may be distributed under
different terms and without source code.

Files: debian/*
Copyright: Thomas Dreibholz <dreibh@simula.no>
License: Apache-2.0
A permissive license whose main conditions require preservation of copyright
and license notices. Contributors provide an express grant of patent rights.
Licensed works, modifications, and larger works may be distributed under
different terms and without source code.
3 changes: 3 additions & 0 deletions debian/p4lang-pi-bin.install
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
usr/bin/pi_convert_p4info
usr/bin/pi_gen_fe_defines
usr/bin/pi_gen_native_json
Loading