diff --git a/README.md b/README.md index 4a3eecd..743d403 100644 --- a/README.md +++ b/README.md @@ -48,11 +48,18 @@ or use the CI hooks Scripts to be used by CI pipelines to build , run various tests and checks. +### debian.native + +Contains Debian packaging scripts for building the current source tree as .deb +packages. This is primarily for CI pipelines to automatically verify if the +packages are buildable or if anything needs to be changed. + +See `debian.native/README.md` for more information. + ### documentation More detailed documentation on the event logging and management system. - ### src Contains the actual productive sources. diff --git a/ci/build_debs.sh b/ci/build_debs.sh index 95bd282..d74ac6e 100755 --- a/ci/build_debs.sh +++ b/ci/build_debs.sh @@ -5,27 +5,30 @@ export DEBEMAIL="noreply@test.com" CODENAME="${1:-jammy}" +echo "Building .deb packages for series ${CODENAME}" +echo "---" +echo "NOTICE: make sure to clean up before running this! Debhelper will complain otherwise" + # Install dependencies apt-get update apt-get install -y git debhelper devscripts equivs software-properties-common fakeroot add-apt-repository -y ppa:elos-team/ppa -# Get the packaging scripts from the debian branch -git fetch origin -git checkout origin/debian/main -- debian +# Use the native packaging folder for building the .debs +rm -rf debian +cp -rv debian.native debian -# Use native packaging so we don't need to muck about with tarballs -echo "3.0 (native)" > debian/source/format +# parse the version from the project.cmake file +VERSION="$(sed -n "s/^.*VERSION\s\+\([0-9]\+\.[0-9]\+\.[0-9]\+\).*$/\1/p" cmake/project.cmake)~test" # Add a new changelog entry -dch --local="+gitlab-ci" --distribution "${CODENAME}" "Gitlab CI/CD test build for branch ${CI_COMMIT_BRANCH}" +git config --global --add safe.directory "$(pwd)" +dch --newversion="${VERSION}" \ + --distribution "${CODENAME}" "Test build" # Install dependencies yes | mk-build-deps -ir || true -# Make sure to remove any temporary files that may have been created -git clean -fxd - # Ignore Lintian errors from the native packaging mkdir -p debian/source echo "malformed-debian-changelog-version" >> debian/source/lintian-overrides diff --git a/cmake/project.cmake b/cmake/project.cmake index 9767c73..1839559 100644 --- a/cmake/project.cmake +++ b/cmake/project.cmake @@ -1,5 +1,5 @@ # SPDX-License-Identifier: MIT -set(SAFU_VERSION 0.54.0) +set(SAFU_VERSION 0.54.1) # Attention: Aside from the version, as many things as possible in this file # should be put into functions, as this solves potential issues with commands diff --git a/debian.native/.gitignore b/debian.native/.gitignore new file mode 100644 index 0000000..ba8edb5 --- /dev/null +++ b/debian.native/.gitignore @@ -0,0 +1,10 @@ +/*.substvars +/files +/debhelper-build-stamp +/libsafu0/ +/libsafu-dev/ +/libmock-safu0/ +/safu-doc/ +/.debhelper/ +/tmp/ +/*.debhelper.log diff --git a/debian.native/README.md b/debian.native/README.md new file mode 100644 index 0000000..be4ecf9 --- /dev/null +++ b/debian.native/README.md @@ -0,0 +1,50 @@ +# safu Debian Packaging Scripts + +## Overview + +This directory contains Debian packaging scripts for building the current source +tree as .deb packages. This is primarily for CI pipelines to automatically +verify if the packages are buildable or if anything needs to be changed. This is +not intended to be used directly for building .deb packages for new releases. + +## Building + +The .deb packages are constructed in the standard Debian way using `debhelper`. +The easiest way to build the packages is to just call the `ci/build_debs.sh` +script from the top-level directory from inside a Docker/Podman container, which +will automatically install all of the necessary dependencies, set the package +version, and build the packages using `debhelper`. + +It's possible to do this all in one line to verify if the packages are buildable +on various Debian-based distributions and series. E.g., to build it on Ubuntu +Jammy: + +```bash +podman run --rm -v $(pwd):/build -w /build ubuntu:jammy ci/build_debs.sh +``` + +Please note that there are some dependencies which are not (yet) in the Debian +or Ubuntu archives. These have been built and published for Ubuntu in the +[elos PPA](https://launchpad.net/~elos-team/+archive/ubuntu/ppa), which is +automatically added by the `ci/build_debs.sh` script. This currently restricts +builds using the script to Ubuntu systems, as PPAs are not available on other +distributions. + +## Extending + +The Debian packaging scripts leverage the existing CMake build system used by +safu to build everything, meaning that very little, if anything, generally +needs to be changed inside the packaging scripts when a code change is made to +safu. The major exception to this is when new libraries or files need to be +installed. + +In most cases, new files and/or folders can be added to the `.install` file +corresponding to the package name that the new files and/or folders should +belong to. + +New packages must be added to the `control` file, and their respective files +should be added to a new `.install` file matching the name of the new package. + +## Packaging Script Maintainer + +* Isaac True isaac.true@emlix.com [@IsaacJT](https://github.com/IsaacJT) diff --git a/debian.native/changelog b/debian.native/changelog new file mode 100644 index 0000000..de93a9e --- /dev/null +++ b/debian.native/changelog @@ -0,0 +1,5 @@ +safu (0.0.1) unstable; urgency=medium + + * Dummy release. + + -- Isaac True Mon, 10 Jun 2024 16:53:43 +0200 diff --git a/debian.native/control b/debian.native/control new file mode 100644 index 0000000..0848b22 --- /dev/null +++ b/debian.native/control @@ -0,0 +1,63 @@ +Source: safu +Section: admin +Priority: optional +Maintainer: Isaac True +Build-Depends: + debhelper-compat (= 13), + cmake, + git, + libcmocka-mocks-dev, + pkg-config, + pandoc, + pandoc-plantuml-filter, + graphviz, +Rules-Requires-Root: no +Standards-Version: 4.6.0.1 +Homepage: https://github.com/Elektrobit/safu +Vcs-Browser: https://github.com/Elektrobit/safu +Vcs-Git: https://github.com/Elektrobit/safu + +Package: libsafu0 +Section: libs +Architecture: any +Depends: + ${misc:Depends}, + ${shlibs:Depends}, +Description: Common utility API's used in elos and samconf + Library of common utility API's used in elos and samconf. + . + Runtime library package. + +Package: libmock-safu0 +Section: libs +Architecture: any +Depends: + ${misc:Depends}, + ${shlibs:Depends}, +Description: Library of common utility API's used in elos and samconf (mocks) + Library of common utility API's used in elos and samconf. + . + Mock library package. + +Package: libsafu-dev +Section: libdevel +Architecture: any +Depends: + ${misc:Depends}, + libsafu0 (= ${binary:Version}), + libmock-safu0 (= ${binary:Version}), + libcmocka-mocks-dev, +Description: Library of common utility API's used in elos and samconf (development) + Library of common utility API's used in elos and samconf. + . + Development package. + +Package: safu-doc +Section: doc +Architecture: all +Depends: + ${misc:Depends}, +Description: Library of common utility API's used in elos and samconf (documentation) + Library of common utility API's used in elos and samconf. + . + Documentation package. diff --git a/debian.native/copyright b/debian.native/copyright new file mode 100644 index 0000000..5fd2db6 --- /dev/null +++ b/debian.native/copyright @@ -0,0 +1,28 @@ +Format: https://www.debian.org/doc/packaging-manuals/copyright-format/1.0/ +Upstream-Name: safu +Upstream-Contact: https://github.com/Elektrobit/safu/issues +Source: https://github.com/Elektrobit/safu + +Files: * +Copyright: 2023, Elektrobit GmbH + 2023, emlix GmbH +License: MIT + +License: MIT + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + . + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + . + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. diff --git a/debian.native/devdoc-index.md b/debian.native/devdoc-index.md new file mode 100644 index 0000000..78308a5 --- /dev/null +++ b/debian.native/devdoc-index.md @@ -0,0 +1,9 @@ +Developer documentation +========================== + +.. toctree:: + :maxdepth: 1 + :caption: Contents: + + DeveloperManual + documentation diff --git a/debian.native/libmock-safu0.install b/debian.native/libmock-safu0.install new file mode 100644 index 0000000..96dc7cd --- /dev/null +++ b/debian.native/libmock-safu0.install @@ -0,0 +1 @@ +usr/lib/*/libmock_safu.so.* diff --git a/debian.native/libsafu-dev.install b/debian.native/libsafu-dev.install new file mode 100644 index 0000000..368e228 --- /dev/null +++ b/debian.native/libsafu-dev.install @@ -0,0 +1,5 @@ +usr/include/safu +usr/lib/*/cmake +usr/lib/*/pkgconfig +usr/lib/*/libmock_safu.so +usr/lib/*/libsafu.so diff --git a/debian.native/libsafu0.install b/debian.native/libsafu0.install new file mode 100644 index 0000000..fec6e34 --- /dev/null +++ b/debian.native/libsafu0.install @@ -0,0 +1 @@ +usr/lib/*/libsafu.so.* diff --git a/debian.native/not-installed b/debian.native/not-installed new file mode 100644 index 0000000..f37d233 --- /dev/null +++ b/debian.native/not-installed @@ -0,0 +1 @@ +usr/lib/*/test diff --git a/debian.native/rules b/debian.native/rules new file mode 100755 index 0000000..b59a8bb --- /dev/null +++ b/debian.native/rules @@ -0,0 +1,37 @@ +#!/usr/bin/make -f + +export DEB_BUILD_MAINT_OPTIONS = hardening=+all optimize=-lto + +%: + dh $@ --buildsystem=cmake --builddirectory=debian/build + +override_dh_auto_build: + dh_auto_build -- all safu_doc + + mkdir -p debian/build/documentation/developer + + pandoc --from gfm --to rst \ + -o debian/build/documentation/developer/DeveloperManual.rst \ + documentation/developer.md + + pandoc --from gfm --to rst \ + -o debian/build/documentation/developer/documentation.rst \ + documentation/documentation.md + + pandoc --from gfm --to rst \ + -o debian/build/documentation/developer/index.rst \ + debian/devdoc-index.md + +override_dh_install: + dh_install + # Do not ship plantuml source files + find debian/ -name \*.plantuml -delete + +override_dh_compress: + # Do not compress .md files + dh_compress --exclude=.md + +override_dh_clean: + dh_clean + + rm -f documentation/images/*.png diff --git a/debian.native/safu-doc.install b/debian.native/safu-doc.install new file mode 100644 index 0000000..1105926 --- /dev/null +++ b/debian.native/safu-doc.install @@ -0,0 +1 @@ +documentation/* /usr/share/doc/safu/ diff --git a/debian.native/safu-doc.lintian-overrides b/debian.native/safu-doc.lintian-overrides new file mode 100644 index 0000000..3286941 --- /dev/null +++ b/debian.native/safu-doc.lintian-overrides @@ -0,0 +1 @@ +safu-doc: zero-byte-file-in-doc-directory [usr/share/doc/safu/style.css] diff --git a/debian.native/source/format b/debian.native/source/format new file mode 100644 index 0000000..89ae9db --- /dev/null +++ b/debian.native/source/format @@ -0,0 +1 @@ +3.0 (native) diff --git a/debian.native/watch b/debian.native/watch new file mode 100644 index 0000000..b9e7f91 --- /dev/null +++ b/debian.native/watch @@ -0,0 +1,2 @@ +version=4 +https://github.com/Elektrobit/safu/tags .*/safu-(\d+).(\d+).(\d+).tar.gz