From 7da822ae93b1bb73ed6da45af53b737e78bf762c Mon Sep 17 00:00:00 2001 From: Thomas Dreibholz Date: Fri, 26 Mar 2021 11:54:57 +0100 Subject: [PATCH 1/4] Added Debian/Ubuntu packaging files. --- debian/changelog | 5 + debian/compat | 1 + debian/control | 119 ++++++++++++++++++++++ debian/copyright | 20 ++++ debian/p4lang-pi-bin.install | 3 + debian/p4lang-pi-dev.install | 89 ++++++++++++++++ debian/p4lang-pi-libs.install | 11 ++ debian/p4lang-pi-libs.lintian-overrides | 1 + debian/python-p4lang-pi.install | 39 +++++++ debian/python-p4lang-pi.lintian-overrides | 1 + debian/rules | 19 ++++ debian/source/format | 1 + 12 files changed, 309 insertions(+) create mode 100644 debian/changelog create mode 100644 debian/compat create mode 100644 debian/control create mode 100644 debian/copyright create mode 100644 debian/p4lang-pi-bin.install create mode 100644 debian/p4lang-pi-dev.install create mode 100644 debian/p4lang-pi-libs.install create mode 100644 debian/p4lang-pi-libs.lintian-overrides create mode 100644 debian/python-p4lang-pi.install create mode 100644 debian/python-p4lang-pi.lintian-overrides create mode 100755 debian/rules create mode 100644 debian/source/format diff --git a/debian/changelog b/debian/changelog new file mode 100644 index 00000000..034d3260 --- /dev/null +++ b/debian/changelog @@ -0,0 +1,5 @@ +p4lang-pi (0.1.0+g202103250946~827907-1ppa1) unstable; urgency=medium + + * Self-made package + + -- Thomas Dreibholz Thu, 25 Mar 2021 10:46:15 +0100 diff --git a/debian/compat b/debian/compat new file mode 100644 index 00000000..48082f72 --- /dev/null +++ b/debian/compat @@ -0,0 +1 @@ +12 diff --git a/debian/control b/debian/control new file mode 100644 index 00000000..71fcefaf --- /dev/null +++ b/debian/control @@ -0,0 +1,119 @@ +Source: p4lang-pi +Section: net +Priority: optional +Maintainer: Thomas Dreibholz +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/osinstom/PI +Vcs-Git: https://github.com/simula/PI +Vcs-Browser: https://github.com/simula/PI/tree/p4-packaging + +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. diff --git a/debian/copyright b/debian/copyright new file mode 100644 index 00000000..d674cad1 --- /dev/null +++ b/debian/copyright @@ -0,0 +1,20 @@ +Format: https://www.debian.org/doc/packaging-manuals/copyright-format/1.0/ +Upstream-Name: p4lang-pi +Upstream-Contact: Antonin Bas +Source: https://github.com/p4lang/PI + +Files: * +Copyright: Antonin Bas +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 +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. diff --git a/debian/p4lang-pi-bin.install b/debian/p4lang-pi-bin.install new file mode 100644 index 00000000..ef2cc0f3 --- /dev/null +++ b/debian/p4lang-pi-bin.install @@ -0,0 +1,3 @@ +usr/bin/pi_convert_p4info +usr/bin/pi_gen_fe_defines +usr/bin/pi_gen_native_json diff --git a/debian/p4lang-pi-dev.install b/debian/p4lang-pi-dev.install new file mode 100644 index 00000000..7e9b4c1e --- /dev/null +++ b/debian/p4lang-pi-dev.install @@ -0,0 +1,89 @@ +usr/include/PI/frontends/cpp/ +usr/include/PI/frontends/cpp/tables.h +usr/include/PI/frontends/generic/ +usr/include/PI/frontends/generic/pi.h +usr/include/PI/frontends/proto/ +usr/include/PI/frontends/proto/device_mgr.h +usr/include/PI/frontends/proto/logging.h +usr/include/PI/int/pi_int.h +usr/include/PI/int/rpc_common.h +usr/include/PI/int/serialize.h +usr/include/PI/p4info.h +usr/include/PI/p4info/act_profs.h +usr/include/PI/p4info/actions.h +usr/include/PI/p4info/counters.h +usr/include/PI/p4info/digests.h +usr/include/PI/p4info/meters.h +usr/include/PI/p4info/tables.h +usr/include/PI/pi.h +usr/include/PI/pi_act_prof.h +usr/include/PI/pi_base.h +usr/include/PI/pi_clone.h +usr/include/PI/pi_counter.h +usr/include/PI/pi_learn.h +usr/include/PI/pi_mc.h +usr/include/PI/pi_meter.h +usr/include/PI/pi_tables.h +usr/include/PI/pi_value.h +usr/include/PI/proto/p4info_to_and_from_proto.h +usr/include/PI/proto/pi_server.h +usr/include/PI/proto/util.h +usr/include/PI/target/pi_act_prof_imp.h +usr/include/PI/target/pi_clone_imp.h +usr/include/PI/target/pi_counter_imp.h +usr/include/PI/target/pi_imp.h +usr/include/PI/target/pi_learn_imp.h +usr/include/PI/target/pi_mc_imp.h +usr/include/PI/target/pi_meter_imp.h +usr/include/PI/target/pi_tables_imp.h +usr/include/gnmi/gnmi.grpc.pb.h +usr/include/gnmi/gnmi.pb.h +usr/include/google/rpc/code.grpc.pb.h +usr/include/google/rpc/code.pb.h +usr/include/google/rpc/status.grpc.pb.h +usr/include/google/rpc/status.pb.h +usr/include/p4/config/v1/p4info.grpc.pb.h +usr/include/p4/config/v1/p4info.pb.h +usr/include/p4/config/v1/p4types.grpc.pb.h +usr/include/p4/config/v1/p4types.pb.h +usr/include/p4/server/v1/config.grpc.pb.h +usr/include/p4/server/v1/config.pb.h +usr/include/p4/tmp/p4config.grpc.pb.h +usr/include/p4/tmp/p4config.pb.h +usr/include/p4/v1/p4data.grpc.pb.h +usr/include/p4/v1/p4data.pb.h +usr/include/p4/v1/p4runtime.grpc.pb.h +usr/include/p4/v1/p4runtime.pb.h +usr/lib/*/libpi*.so +usr/lib/*/libpi.a +usr/lib/*/libpi.la +usr/lib/*/libpi_dummy*.so +usr/lib/*/libpi_dummy.a +usr/lib/*/libpi_dummy.la +usr/lib/*/libpiall*.so +usr/lib/*/libpiall.a +usr/lib/*/libpiall.la +usr/lib/*/libpiconvertproto*.so +usr/lib/*/libpiconvertproto.a +usr/lib/*/libpiconvertproto.la +usr/lib/*/libpifecpp*.so +usr/lib/*/libpifecpp.a +usr/lib/*/libpifecpp.la +usr/lib/*/libpifegeneric*.so +usr/lib/*/libpifegeneric.a +usr/lib/*/libpifegeneric.la +usr/lib/*/libpifeproto*.so +usr/lib/*/libpifeproto.a +usr/lib/*/libpifeproto.la +usr/lib/*/libpigrpcserver*.so +usr/lib/*/libpigrpcserver.a +usr/lib/*/libpigrpcserver.la +usr/lib/*/libpip4info*.so +usr/lib/*/libpip4info.a +usr/lib/*/libpip4info.la +usr/lib/*/libpiprotobuf*.so +usr/lib/*/libpiprotobuf.a +usr/lib/*/libpiprotobuf.la +usr/lib/*/libpiprotogrpc*.so +usr/lib/*/libpiprotogrpc.a +usr/lib/*/libpiprotogrpc.la diff --git a/debian/p4lang-pi-libs.install b/debian/p4lang-pi-libs.install new file mode 100644 index 00000000..70dbef08 --- /dev/null +++ b/debian/p4lang-pi-libs.install @@ -0,0 +1,11 @@ +usr/lib/*/libpi.so.* +usr/lib/*/libpi_dummy.so.* +usr/lib/*/libpiall.so.* +usr/lib/*/libpiconvertproto.so.* +usr/lib/*/libpifecpp.so.* +usr/lib/*/libpifegeneric.so.* +usr/lib/*/libpifeproto.so.* +usr/lib/*/libpigrpcserver.so.* +usr/lib/*/libpip4info.so.* +usr/lib/*/libpiprotobuf.so.* +usr/lib/*/libpiprotogrpc.so.* diff --git a/debian/p4lang-pi-libs.lintian-overrides b/debian/p4lang-pi-libs.lintian-overrides new file mode 100644 index 00000000..0e2378c6 --- /dev/null +++ b/debian/p4lang-pi-libs.lintian-overrides @@ -0,0 +1 @@ +p4lang-pi-libs: package-name-doesnt-match-sonames libpi0 libpi-dummy0 libpiall0 libpiconvertproto0 libpifecpp0 libpifegeneric0 libpifeproto0 libpigrpcserver0 libpip4info0 libpiprotobuf0 libpiprotogrpc0 diff --git a/debian/python-p4lang-pi.install b/debian/python-p4lang-pi.install new file mode 100644 index 00000000..cd27be3f --- /dev/null +++ b/debian/python-p4lang-pi.install @@ -0,0 +1,39 @@ +usr/lib/python*/dist-packages/ +usr/lib/python*/dist-packages/gnmi/ +usr/lib/python*/dist-packages/gnmi/__init__.py +usr/lib/python*/dist-packages/gnmi/gnmi_pb2.py +usr/lib/python*/dist-packages/gnmi/gnmi_pb2_grpc.py +usr/lib/python*/dist-packages/google/ +usr/lib/python*/dist-packages/google/__init__.py +usr/lib/python*/dist-packages/google/rpc/ +usr/lib/python*/dist-packages/google/rpc/__init__.py +usr/lib/python*/dist-packages/google/rpc/code_pb2.py +usr/lib/python*/dist-packages/google/rpc/code_pb2_grpc.py +usr/lib/python*/dist-packages/google/rpc/status_pb2.py +usr/lib/python*/dist-packages/google/rpc/status_pb2_grpc.py +usr/lib/python*/dist-packages/p4/ +usr/lib/python*/dist-packages/p4/__init__.py +usr/lib/python*/dist-packages/p4/config/ +usr/lib/python*/dist-packages/p4/config/__init__.py +usr/lib/python*/dist-packages/p4/config/v1/ +usr/lib/python*/dist-packages/p4/config/v1/__init__.py +usr/lib/python*/dist-packages/p4/config/v1/p4info_pb2.py +usr/lib/python*/dist-packages/p4/config/v1/p4info_pb2_grpc.py +usr/lib/python*/dist-packages/p4/config/v1/p4types_pb2.py +usr/lib/python*/dist-packages/p4/config/v1/p4types_pb2_grpc.py +usr/lib/python*/dist-packages/p4/server/ +usr/lib/python*/dist-packages/p4/server/__init__.py +usr/lib/python*/dist-packages/p4/server/v1/ +usr/lib/python*/dist-packages/p4/server/v1/__init__.py +usr/lib/python*/dist-packages/p4/server/v1/config_pb2.py +usr/lib/python*/dist-packages/p4/server/v1/config_pb2_grpc.py +usr/lib/python*/dist-packages/p4/tmp/ +usr/lib/python*/dist-packages/p4/tmp/__init__.py +usr/lib/python*/dist-packages/p4/tmp/p4config_pb2.py +usr/lib/python*/dist-packages/p4/tmp/p4config_pb2_grpc.py +usr/lib/python*/dist-packages/p4/v1/ +usr/lib/python*/dist-packages/p4/v1/__init__.py +usr/lib/python*/dist-packages/p4/v1/p4data_pb2.py +usr/lib/python*/dist-packages/p4/v1/p4data_pb2_grpc.py +usr/lib/python*/dist-packages/p4/v1/p4runtime_pb2.py +usr/lib/python*/dist-packages/p4/v1/p4runtime_pb2_grpc.py diff --git a/debian/python-p4lang-pi.lintian-overrides b/debian/python-p4lang-pi.lintian-overrides new file mode 100644 index 00000000..1b169e41 --- /dev/null +++ b/debian/python-p4lang-pi.lintian-overrides @@ -0,0 +1 @@ +python-p4lang-pi: new-package-should-not-package-python2-module python-p4lang-pi diff --git a/debian/rules b/debian/rules new file mode 100755 index 00000000..c72478ac --- /dev/null +++ b/debian/rules @@ -0,0 +1,19 @@ +#!/usr/bin/make -f + +export DEB_BUILD_MAINT_OPTIONS = hardening=+all + +DH_VERBOSE = 1 + +%: + dh $@ --with python2,python3 + +override_dh_auto_configure: + dh_auto_configure -- --with-proto --without-fe-cpp --without-cli --without-internal-rpc --without-bmv2 --without-sysrepo + +override_dh_auto_build: + $(MAKE) all + +override_dh_auto_install: + dh_auto_install -- DESTDIR=$(CURDIR)/debian/tmp install + find $(CURDIR)/debian/tmp -name "*.pyc" | xargs rm -f + find $(CURDIR)/debian/tmp -name "*.pyo" | xargs rm -f diff --git a/debian/source/format b/debian/source/format new file mode 100644 index 00000000..163aaf8d --- /dev/null +++ b/debian/source/format @@ -0,0 +1 @@ +3.0 (quilt) From c30926aa1f1d8f3b1afbb437197384a757e9fd4b Mon Sep 17 00:00:00 2001 From: Thomas Dreibholz Date: Fri, 26 Mar 2021 11:55:35 +0100 Subject: [PATCH 2/4] Added packaging scripts. --- build-deb | 123 ++++++++++++++ clean-deb | 37 +++++ filter-empty-entries | 60 +++++++ make-deb | 352 +++++++++++++++++++++++++++++++++++++++++ make-ppa | 130 +++++++++++++++ make-upstream-package | 103 ++++++++++++ packaging.conf | 10 ++ renew-debian-changelog | 45 ++++++ 8 files changed, 860 insertions(+) create mode 100755 build-deb create mode 100755 clean-deb create mode 100755 filter-empty-entries create mode 100755 make-deb create mode 100755 make-ppa create mode 100755 make-upstream-package create mode 100644 packaging.conf create mode 100755 renew-debian-changelog diff --git a/build-deb b/build-deb new file mode 100755 index 00000000..f5760ad7 --- /dev/null +++ b/build-deb @@ -0,0 +1,123 @@ +#!/usr/bin/env bash +# +# Debian/Ubuntu Packaging Scripts +# Copyright (C) 2002-2021 by Thomas Dreibholz +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . +# +# 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) +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 diff --git a/clean-deb b/clean-deb new file mode 100755 index 00000000..40b83682 --- /dev/null +++ b/clean-deb @@ -0,0 +1,37 @@ +#!/usr/bin/env bash +# +# Debian/Ubuntu Packaging Scripts +# Copyright (C) 2002-2021 by Thomas Dreibholz +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . +# +# 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])* diff --git a/filter-empty-entries b/filter-empty-entries new file mode 100755 index 00000000..be669090 --- /dev/null +++ b/filter-empty-entries @@ -0,0 +1,60 @@ +#!/usr/bin/perl +# +# Debian/Ubuntu Packaging Scripts +# Copyright (C) 2002-2021 by Thomas Dreibholz +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . +# +# Contact: dreibh@iem.uni-due.de + +use warnings; +use strict; + +my $mode=0; +my $entryLines=0; +my $entry=""; + +while (my $text = ) { + chomp $text; + + if($entryLines == 0) { + if($text =~ /^[a-zA-Z].*$/) { + $entry = "$text\n\n"; + $entryLines = 1; + } + } + else { + if($text =~ /^[ \t]*$/) { + # Remove empty line. + } + elsif($text =~ /^ --.*$/) { + $entry = "$entry\n$text\n"; + if($entryLines > 1) { + print "$entry\n"; + } + + if($ARGV[0] !~ /^$/) { + if($text =~ /($ARGV[0])/) { + exit; + } + } + + $entryLines = 0; + } + else { + $entry = "$entry$text\n"; + $entryLines = $entryLines + 1; + } + } +} diff --git a/make-deb b/make-deb new file mode 100755 index 00000000..2d37b657 --- /dev/null +++ b/make-deb @@ -0,0 +1,352 @@ +#!/usr/bin/env bash +# +# Debian/Ubuntu Packaging Scripts +# Copyright (C) 2002-2021 by Thomas Dreibholz +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . +# +# Contact: dreibh@iem.uni-due.de + +# Bash options: +set -e + + +# --------------------------------------------------------------------------- +# USAGE: +# ./make-deb default => for Ubuntu REVU +# Note: Replaces "Maintainer" by Ubuntu Developers and +# writes original maintainer entry to "XSBC-Original-Maintainer" +# ./make-deb unstable => for Debian Mentors +# ./make-deb bionic|disco|... => for Launchpad PPA +# --------------------------------------------------------------------------- + + +# Set current Debian debhelper version here +# for building unstable/testing/stable packages +# (See https://packages.qa.debian.org/d/debhelper.html for latest version!) +DEBHELPER_LATEST_VERSION="13" + + +# ====== Obtain package and version information ============================= +DISTRIBUTIONS=`\ +( \ +while [ x$1 != "x" ] ; do \ + echo $1 + shift +done \ +) | sort -u` +if [ "${DISTRIBUTIONS}" == "" ] ; then + DISTRIBUTIONS="default" +fi + + +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) +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 + + +# ====== Run warp-and-sort tool ============================================= +if [ -e /usr/bin/wrap-and-sort ] ; then + echo -e "" + echo -e "\x1b[34m`date +%FT%H:%M:%S`: ====== Calling wrap-and-sort ==========================================\x1b[0m" + echo -e "" + wrap-and-sort -a -v +fi + + +# ====== Create upstream source package ===================================== +echo -e "" +echo -e "\x1b[34m`date +%FT%H:%M:%S`: ====== Creating upstream package ======================================\x1b[0m" +echo -e "" +if [ "${SKIP_PACKAGE_SIGNING}" != "" -a ${SKIP_PACKAGE_SIGNING} -eq 1 -o "${OVERRIDE_SKIP_PACKAGE_SIGNING}" == "1" ] ; then + ./make-upstream-package ${PACKAGE} ${UPSTREAM_VERSION} "${MAKE_DIST}" -skip-signing +else + ./make-upstream-package ${PACKAGE} ${UPSTREAM_VERSION} "${MAKE_DIST}" +fi + +for UPSTREAM_PACKAGE_TYPE in xz bz2 gz ; do + UPSTREAM_PACKAGE="`find . -maxdepth 1 -name "${PACKAGE}-${UPSTREAM_VERSION}.tar.${UPSTREAM_PACKAGE_TYPE}" -printf '%f'`" + if [ -e "${UPSTREAM_PACKAGE}" ] ; then + break + fi +done +if [ ! -e "${UPSTREAM_PACKAGE}" ] ; then + echo -e "\x1b[34mERROR: No upstream package (${PACKAGE}-${UPSTREAM_VERSION}.tar.*) found!\x1b[0m" + exit 1 +fi + + +# ====== Build source packages ============================================== +echo -e "" +echo -e "\x1b[34m`date +%FT%H:%M:%S`: ====== Building source packages =======================================\x1b[0m" +for DISTRIBUTION in ${DISTRIBUTIONS} ; do + + updatedDebhelperVersion=0 + + echo -e "" + echo -e "\x1b[34m------ Creating package for ${DISTRIBUTION} ------\x1b[0m" + + cp ${UPSTREAM_PACKAGE} ${PACKAGE}_${UPSTREAM_VERSION}.orig.tar.${UPSTREAM_PACKAGE_TYPE} + cp ${UPSTREAM_PACKAGE} ${PACKAGE}_${OUTPUT_VERSION}.orig.tar.${UPSTREAM_PACKAGE_TYPE} + cp ${UPSTREAM_PACKAGE} ${PACKAGE}_${DEBIAN_VERSION}.orig.tar.${UPSTREAM_PACKAGE_TYPE} + if [ ! ${SKIP_PACKAGE_SIGNING} == "1" -a ! "${OVERRIDE_SKIP_PACKAGE_SIGNING}" == "1" ] ; then + cp ${UPSTREAM_PACKAGE}.asc ${PACKAGE}_${UPSTREAM_VERSION}.orig.tar.${UPSTREAM_PACKAGE_TYPE}.asc + cp ${UPSTREAM_PACKAGE}.asc ${PACKAGE}_${OUTPUT_VERSION}.orig.tar.${UPSTREAM_PACKAGE_TYPE}.asc + cp ${UPSTREAM_PACKAGE}.asc ${PACKAGE}_${DEBIAN_VERSION}.orig.tar.${UPSTREAM_PACKAGE_TYPE}.asc + else + rm -f ${PACKAGE}_${UPSTREAM_VERSION}.orig.tar.${UPSTREAM_PACKAGE_TYPE}.asc + rm -f ${PACKAGE}_${OUTPUT_VERSION}.orig.tar.${UPSTREAM_PACKAGE_TYPE}.asc + rm -f ${PACKAGE}_${DEBIAN_VERSION}.orig.tar.${UPSTREAM_PACKAGE_TYPE}.asc + fi + rm -rf ${PACKAGE}-${UPSTREAM_VERSION} + rm -rf ${PACKAGE}-${UPSTREAM_VERSION}.orig + if [ "${UPSTREAM_PACKAGE_TYPE}" == "gz" ] ; then + tar xzf ${UPSTREAM_PACKAGE} + elif [ "${UPSTREAM_PACKAGE_TYPE}" == "bz2" ] ; then + tar xjf ${UPSTREAM_PACKAGE} + elif [ "${UPSTREAM_PACKAGE_TYPE}" == "xz" ] ; then + tar xJf ${UPSTREAM_PACKAGE} + else + echo 2>&1 "ERROR: Bad archive format: ${UPSTREAM_PACKAGE}" + exit 1 + fi + cp -r debian ${PACKAGE}-${UPSTREAM_VERSION} + find ${PACKAGE}-${UPSTREAM_VERSION} -name .svn | xargs --no-run-if-empty rm -rf + cd ${PACKAGE}-${UPSTREAM_VERSION} + + if [ "${DISTRIBUTION}" != "default" ] ; then + if [ "${DISTRIBUTION}" == "unstable" -o "${DISTRIBUTION}" == "testing" -o "${DISTRIBUTION}" == "stable" ] ; then + # Debian: Also remove Launchpad Bug IDs. + sed -e "s/${PACKAGE_DISTRIBUTION};/${DISTRIBUTION};/1" \ + -e "s/\(ubuntu\|ppa\)[0-9]//1" \ + -e "/(LP: #/D" \ + debian/changelog.new + else + # Ubuntu PPA + # Naming example: 2.7.7-1ubuntu~focal1 + # Ubuntu: Also remove Debian Bug IDs. + sed -e "s/${PACKAGE_DISTRIBUTION};/${DISTRIBUTION};/1" \ + -e "s/${PACKAGE_VERSION}/${OUTPUT_VERSION}~${DISTRIBUTION}1/1" \ + -e "/(Closes: #/D" \ + debian/changelog.new + + # ------ Old distributions not supporting c++/regex style symbols -- + if [ "${DISTRIBUTION}" == "dapper" -o \ + "${DISTRIBUTION}" == "edgy" -o \ + "${DISTRIBUTION}" == "feisty" -o \ + "${DISTRIBUTION}" == "hardy" -o \ + "${DISTRIBUTION}" == "intrepid" -o \ + "${DISTRIBUTION}" == "jaunty" -o \ + "${DISTRIBUTION}" == "karmic" -o \ + "${DISTRIBUTION}" == "lucid" ] ; then + # Just skip the symbols ... + find debian/ -maxdepth 1 -name "*.symbols" | xargs --no-run-if-empty rm -f + fi + fi + + # Remove additional newlines at the end of the file: + sed -i -e :a -e '/^\n*$/{$d;N;};/\n$/ba' debian/changelog.new + + mv debian/changelog.new debian/changelog + + # ------ Old distributions not supporting new Debian format ----------- + if [ "${DISTRIBUTION}" == "dapper" -o \ + "${DISTRIBUTION}" == "edgy" -o \ + "${DISTRIBUTION}" == "feisty" -o \ + "${DISTRIBUTION}" == "hardy" -o \ + "${DISTRIBUTION}" == "intrepid" -o \ + "${DISTRIBUTION}" == "jaunty" ] ; then + rm -rf debian/source + fi + + # ------ Use latest Debhelper for Debian ------------------------------ + if [ "${DISTRIBUTION}" == "unstable" -o "${DISTRIBUTION}" == "testing" -o "${DISTRIBUTION}" == "stable" ] ; then + # Update debhelper version: + echo "${DEBHELPER_LATEST_VERSION}" >debian/compat + sed -e "s/debhelper (.* [0-9]*)/debhelper (>= ${DEBHELPER_LATEST_VERSION})/g" debian/control.new + # Newer debhelper does not need "--parallel" for building: + sed -e "s/\(.*dh .. .*--buildsystem=cmake.*\)\(--parallel\)\(.*\)/\1\3/g" -e 's@[[:space:]]*$@@g' debian/rules.new + mv debian/control.new debian/control + mv debian/rules.new debian/rules + updatedDebhelperVersion=1 + fi + + else + # Ubuntu: Remove Debian Bug IDs. + sed -e "/(Closes: #/D" \ + debian/changelog.new + mv debian/changelog.new debian/changelog + sed -e "s/^Maintainer:/Maintainer: Ubuntu Developers \nXSBC-Original-Maintainer:/g" debian/control.new + mv debian/control.new debian/control + fi + + echo -e "" + echo -e "\x1b[34m------ Creating diff file ${PACKAGE}-${PACKAGE_VERSION}.diff.gz ------\x1b[0m" + ( + cd .. + diff -urN "--exclude=*~" "--exclude=.svn" "--exclude=.git" \ + ${PACKAGE}-${UPSTREAM_VERSION}.orig ${PACKAGE}-${UPSTREAM_VERSION} \ + | gzip -c >${PACKAGE}-${PACKAGE_VERSION}.diff.gz + ) + + + echo -e "" + echo -e "\x1b[34m------ Building source package ------\x1b[0m" + + # Without signature: + # debuild -us -uc + # For sources: + # debuild -S + # For binaries: + # debuild -b + # Use -i to ignore .svn files! + + if [ "${SKIP_PACKAGE_SIGNING}" == "" ] ; then + SKIP_PACKAGE_SIGNING=0 + fi + if [ $updatedDebhelperVersion -eq 0 ] ; then + opt="" + else + opt="--no-check-builddeps" # Needed for increased debhelper version! + fi + if [ ${SKIP_PACKAGE_SIGNING} -eq 1 -o "${OVERRIDE_SKIP_PACKAGE_SIGNING}" == "1" ] ; then + # Build source package without signature: + debuild ${opt} -us -uc -S -i || exit 1 + else + # Build source package including signature: + if [ "${MAINTAINER_KEY}" == "" ] ; then + echo >&2 "ERROR: MAINTAINER_KEY is not set!" + exit 1 + fi + debuild ${opt} -sa -S "-k${MAINTAINER_KEY}" -i || exit 1 + fi + + # Important: In /etc/pbuilderrc, set COMPONENTS="main universe"! + # Important: After that, update with option "--override-config"! + # sudo pbuilder update --override-config + + cd .. + + if [ "${DISTRIBUTION}" == "unstable" -o \ + "${DISTRIBUTION}" == "testing" -o \ + "${DISTRIBUTION}" == "stable" -o \ + "${DISTRIBUTION}" == "default" ] ; then + if [ "${DISTRIBUTION}" == "default" ] ; then + version=${PACKAGE_VERSION} + else + version=${DEBIAN_VERSION} + fi + dscFile=`ls ${PACKAGE}_${version}.dsc | tail -n1` + else + dscFile=`ls ${PACKAGE}_${OUTPUT_VERSION}~${DISTRIBUTION}[0-9].dsc | tail -n1` + fi + if [ ! -e "${dscFile}" ] ; then + echo -e "\x1b[34mERROR: ${dscFile} has not been generated successfully -> Aborting!\x1b[0m" + exit 1 + fi + +done + + +# ====== Show results ======================================================= +echo -e "" +echo -e "\x1b[34m`date +%FT%H:%M:%S`: ====== Results overview ============================================\x1b[0m" +echo -e "" + +echo -e "\x1b[34mUpload to PPA:\x1b[0m" +for DISTRIBUTION in ${DISTRIBUTIONS} ; do + if [ "${DISTRIBUTION}" == "unstable" -o \ + "${DISTRIBUTION}" == "testing" -o \ + "${DISTRIBUTION}" == "stable" -o \ + "${DISTRIBUTION}" == "default" ] ; then + if [ "${DISTRIBUTION}" == "default" ] ; then + ppa="revu" + version=${PACKAGE_VERSION} + else + ppa="mentors" + version=${DEBIAN_VERSION} + fi + changesFile=`ls ${PACKAGE}_${version}_source.changes | tail -n1` + else + ppa="ppa" + changesFile=`ls ${PACKAGE}_${OUTPUT_VERSION}~${DISTRIBUTION}[0-9]_source.changes | tail -n1` + fi + echo -e "\x1b[34m dput ${ppa} $changesFile\x1b[0m" +done +echo -e "" + +if [ -e make-symbols ] ; then + echo -e "\x1b[34m################################################################\x1b[0m" + echo -e "\x1b[34mDo not forget to run make-symbols after library version changes!\x1b[0m" + echo -e "\x1b[34m################################################################\x1b[0m" + echo -e "" +fi + +echo -e "\x1b[34mBuild Test Commands:\x1b[0m" +for DISTRIBUTION in ${DISTRIBUTIONS} ; do + if [ "${DISTRIBUTION}" == "unstable" -o \ + "${DISTRIBUTION}" == "testing" -o \ + "${DISTRIBUTION}" == "stable" -o \ + "${DISTRIBUTION}" == "default" ] ; then + if [ "${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}~${DISTRIBUTION}[0-9]_*.changes" + dscFile=`ls ${PACKAGE}_${OUTPUT_VERSION}~${DISTRIBUTION}[0-9].dsc | tail -n1` + fi + profile="ubuntu" + if [ "${DISTRIBUTION}" == "unstable" -o \ + "${DISTRIBUTION}" == "testing" -o \ + "${DISTRIBUTION}" == "stable" ] ; then + profile="debian" + fi + echo -e "\x1b[34m sudo pbuilder build ${dscFile} && lintian -iIEv --profile ${profile} --pedantic /var/cache/pbuilder/result/$changesFilesPattern\x1b[0m" +done +echo -e "" diff --git a/make-ppa b/make-ppa new file mode 100755 index 00000000..7f74be1c --- /dev/null +++ b/make-ppa @@ -0,0 +1,130 @@ +#!/usr/bin/env bash +# +# Packaging Scripts +# Copyright (C) 2002-2021 by Thomas Dreibholz +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . +# +# Contact: dreibh@iem.uni-due.de + +# Bash options: +set -e + +COPR=0 +DPUT=0 + +# NOTE: These are the supported distributions by Ubuntu Launchpad and Debian: +DPUT_DISTRIBUTIONS="precise trusty xenial bionic focal groovy hirsute unstable" + +while [ $# -gt 0 ] ; do + if [ "$1" == "dput" ] ; then + DPUT=1 + elif [ "$1" == "copr" ] ; then + COPR=1 + elif [ "$1" == "all" ] ; then + DPUT=1 + COPR=1 + else + echo >&2 "Usage: $0 [dput] [copr] [all]" + exit 1 + fi + shift +done + +if [ ${DPUT} -eq 0 -a ${COPR} -eq 0 ] ; then + COPR=1 + DPUT=1 +fi + +if [ ! -e debian/ ] ; then + DPUT=0 +fi +if [ ! -e rpm/ ] ; then + COPR=0 +fi + + +# ====== Build source packages ============================================== +./clean-deb +if [ ${DPUT} -ne 0 ] ; then + . ./packaging.conf + if [ "${NOT_TARGET_DISTRIBUTIONS}" == "" ] ; then + echo >&2 "ERROR: Define NOT_TARGET_DISTRIBUTIONS in packaging.conf!" + exit 1 + fi + buildForDistribution="" + for dputDistribution in ${DPUT_DISTRIBUTIONS} ; do + notATarget=0 + for notTargetDistribution in ${NOT_TARGET_DISTRIBUTIONS} ; do + if [ "${notTargetDistribution}" == "${dputDistribution}" ] ; then + notATarget=1 + break + fi + done + if [ $notATarget -eq 0 ] ; then + buildForDistribution="${buildForDistribution} ${dputDistribution}" + fi + done + + echo "Building for distributions:${buildForDistribution}" + ./make-deb ${buildForDistribution} +fi + +if [ ${COPR} -ne 0 ] ; then + if [ -e rpm -o -e ./make-srpm ] ; then + ./make-srpm || exit 1 + else + echo >&2 "ERROR: RPM files not found!" + exit 1 + fi +fi + + +# ====== dput =============================================================== +if [ ${DPUT} -ne 0 ] ; then + changeFiles=`find . -mindepth 1 -maxdepth 1 -name "*.changes"` + for changeFile in ${changeFiles} ; do + if [[ ${changeFile} =~ -[0-9]_source.changes$ ]] ; then + dput mentors ${changeFile} + else + dput ppa ${changeFile} + fi + done +fi + + +# ====== COPR =============================================================== +if [ ${COPR} -ne 0 ] ; then + PACKAGE=`grep "^Name:" rpm/*.spec | head -n1 | sed -e "s/Name://g" -e "s/[ \t]*//g"` + SRPM=`find ${HOME}/rpmbuild/SRPMS -name "${PACKAGE}-*.src.rpm"` + if [ ! -e "${SRPM}" ] ; then + echo >&2 "ERROR: ${PACKAGE}-*.src.rpm not found!" + exit 1 + fi + + COPR_CLI="" + for directory in /usr/bin /usr/local/bin ~/.local/bin ; do + if [ -x "${directory}/copr-cli" ] ; then + COPR_CLI="${directory}/copr-cli" + break + fi + done + if [ "${COPR_CLI}" == "" ] ; then + echo >&2 "ERROR: copr-cli not found!" + exit 1 + fi + echo "Using ${COPR_CLI}" + + ${COPR_CLI} build --nowait ppa ${SRPM} +fi diff --git a/make-upstream-package b/make-upstream-package new file mode 100755 index 00000000..75693cfc --- /dev/null +++ b/make-upstream-package @@ -0,0 +1,103 @@ +#!/usr/bin/env bash +# +# Packaging Scripts +# Copyright (C) 2017-2021 by Thomas Dreibholz +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . +# +# Contact: dreibh@iem.uni-due.de + +# Bash options: +set -e + + +# --------------------------------------------------------------------------- +# USAGE: +# ./make-upstream-package package_name version [-skip-signing] +# --------------------------------------------------------------------------- + + +# ====== Check arguments ==================================================== +if [ $# -lt 3 ] ; then + echo >&2 "Usage: $0 package_name version make_dist [-skip-signing]" + exit 1 +fi +PACKAGE="$1" +UPSTREAM_VERSION="$2" +MAKE_DIST="$3" +SKIP_PACKAGE_SIGNING=0 +shift ; shift ; shift +while [ $# -gt 0 ] ; do + if [ "$1" == "-skip-signing" ] ; then + SKIP_PACKAGE_SIGNING=1 + else + echo >&2 "ERROR: Bad argument $0!" + exit 1 + fi + shift +done + + +# ====== Create upstream source package ===================================== +echo -e "" +echo -e "\x1b[34m`date +%FT%H:%M:%S`: ====== Creating upstream package ======================================\x1b[0m" +echo -e "" +for UPSTREAM_PACKAGE_TYPE in xz bz2 gz ; do + printf "Looking for ${PACKAGE}-*.tar.${UPSTREAM_PACKAGE_TYPE} ... " + UPSTREAM_PACKAGE="`find . -maxdepth 1 -name "${PACKAGE}-*.tar.${UPSTREAM_PACKAGE_TYPE}" -printf '%f'`" + if [ -e "${UPSTREAM_PACKAGE}" ] ; then + echo "found!" + break + else + echo "not found" + fi +done +if [ ! -e "${UPSTREAM_PACKAGE}" ]; then + rm -f ${PACKAGE}-*.gz ${PACKAGE}"_"*.gz ${PACKAGE}-*.bz2 ${PACKAGE}"_"*.bz2 ${PACKAGE}-*.xz ${PACKAGE}"_"*.xz + + echo -e "\x1b[34m------ Running MAKE_DIST ... ------\x1b[0m" + echo "\$ $MAKE_DIST" + eval "$MAKE_DIST" + + echo -e "\x1b[34m------ Looking for upstream package ... ------\x1b[0m" + for UPSTREAM_PACKAGE_TYPE in xz bz2 gz ; do + UPSTREAM_PACKAGE="`find . -maxdepth 1 -name "${PACKAGE}-*.tar.${UPSTREAM_PACKAGE_TYPE}" -printf '%f'`" + if [ -e "${UPSTREAM_PACKAGE}" ] ; then + break + fi + done + if [ ! -e "${UPSTREAM_PACKAGE}" ] ; then + echo -e "\x1b[34mERROR: No upstream package (${PACKAGE}-*.tar.*) found!\x1b[0m" + exit 1 + fi + + rm -f "${UPSTREAM_PACKAGE}.asc" # Ensure that old signature file is removed! + echo -e "" +fi +echo -e "\x1b[34m==> Upstream package is ${UPSTREAM_PACKAGE} (type is ${UPSTREAM_PACKAGE_TYPE})\x1b[0m" +echo -e "" + + +# ====== Sign upstream source package ======================================= +if [ ! -e "${UPSTREAM_PACKAGE}.asc" ] ; then + if [ ! ${SKIP_PACKAGE_SIGNING} == "1" -a ! "${OVERRIDE_SKIP_PACKAGE_SIGNING}" == "1" ] ; then + echo -e "" + echo -e "\x1b[34m`date +%FT%H:%M:%S`: ====== Sign upstream package ==========================================\x1b[0m" + echo -e "" + echo -e "\x1b[34mSigning upstream package ${UPSTREAM_PACKAGE} ...\x1b[0m" + gpg -sab "${UPSTREAM_PACKAGE}" + else + rm -f "${UPSTREAM_PACKAGE}.asc" + fi +fi diff --git a/packaging.conf b/packaging.conf new file mode 100644 index 00000000..87b992bf --- /dev/null +++ b/packaging.conf @@ -0,0 +1,10 @@ +#!/bin/bash + +# --------------------------------------------------------- +CONFOPT="--prefix=/usr --with-proto --without-fe-cpp --without-cli --without-internal-rpc --with-bmv2 --without-sysrepo" +MAKE_DIST="./autogen.sh && ./configure $CONFOPT && make dist" +NOT_TARGET_DISTRIBUTIONS="lucid precise trusty xenial bionic" # <<-- Distrubutions which are *not* supported! +MAINTAINER="Thomas Dreibholz " +MAINTAINER_KEY="21412672518D8B2D1862EFEF5CD5D12AA0877B49" +SKIP_PACKAGE_SIGNING=0 # <<-- Must be set to 0 (=off) for PPA upload! +# --------------------------------------------------------- diff --git a/renew-debian-changelog b/renew-debian-changelog new file mode 100755 index 00000000..75459ccf --- /dev/null +++ b/renew-debian-changelog @@ -0,0 +1,45 @@ +#!/bin/bash + +. ./packaging.conf + +# ------ Revert debian/changelog and debian/control ------------------------- +# git checkout debian/changelog configure.ac + + +# ------ Current GIT version ------------------------------------------------ +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" -e "s/+.*//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) +PLAIN_VERSION=`echo $UPSTREAM_VERSION | sed -e "s/\([0-9\.]*\)[-+~].*$/\1/"` + +GIT_VERSION="g`env LANG=en date -u +"%Y%m%d%H%M"`" +GIT_ID="${GIT_VERSION}~`cat .git/ORIG_HEAD | cut -b 1-6`" # Name may not be too long! Just take 6 digits ... + +# ------ Change configure.ac ------------------------------------------------ +sed "s#AC_INIT(\[[a-zA-Z0-9-]*\],.*,#AC_INIT([p4lang-pi], [${PACKAGE_VERSION}+$GIT_ID],#g" configure.ac.new + +# ------ Create debian/changelog -------------------------------------------- +( + echo "p4lang-pi (${UPSTREAM_VERSION}+${GIT_ID}-1ppa1) unstable; urgency=medium" + echo "" + echo " * Self-made package" + echo "" + echo " -- $MAINTAINER `env LANG=en date +"%a, %02d %b %Y %H:%M:%S %z"`" +) | tee debian/changelog.new + + +# ------ Apply changes ------------------------------------------------------ +mv configure.ac.new configure.ac +mv debian/changelog.new debian/changelog From fd54a439c6f57ca07adcdfc85bb29f74b04acc6e Mon Sep 17 00:00:00 2001 From: Thomas Dreibholz Date: Fri, 26 Mar 2021 11:55:44 +0100 Subject: [PATCH 3/4] Added ReadMe file with introductions for building custom Debian/Ubuntu packages with pbuilder or Ubuntu Launchpad PPA. --- README.Debian | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 README.Debian diff --git a/README.Debian b/README.Debian new file mode 100644 index 00000000..de50cde0 --- /dev/null +++ b/README.Debian @@ -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: focal, groovy, hirsute, unstable, etc. +- Create source package and build using pbuilder: +./build-deb +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 From bde5b18fbff4f41bdcb04482f83c7307b836bcf1 Mon Sep 17 00:00:00 2001 From: Thomas Dreibholz Date: Fri, 26 Mar 2021 11:56:30 +0100 Subject: [PATCH 4/4] Added Linux Software Map (LSM) entry. --- p4lang-pi.lsm | 14 ++++++++++++++ 1 file changed, 14 insertions(+) create mode 100644 p4lang-pi.lsm diff --git a/p4lang-pi.lsm b/p4lang-pi.lsm new file mode 100644 index 00000000..334ee074 --- /dev/null +++ b/p4lang-pi.lsm @@ -0,0 +1,14 @@ +Begin4 +Title: p4lang-pi +Version: 0.1.0 +Entered-date: 2021-03-24 +Description: Protocol Independent API (PI or P4 Runtime) defines a set of + APIs that allow interacting with entities defined in a P4 + program. +Keywords: P4, Runtime +Author: Antonin Bas +Primary-site: https://github.com/p4lang/PI/tags +Original-site: https://github.com/p4lang/PI/tags +Platforms: Linux +Copying-policy: Apache +End