Skip to content

Commit

Permalink
Merge branch 'task/#23160-fixup-debs' into 'integration'
Browse files Browse the repository at this point in the history
debian.native: add .deb packaging scripts

See merge request elektrobit/base-os/safu!23
  • Loading branch information
gehwolf committed Jun 14, 2024
2 parents 8352a3b + d2e6c7d commit f909954
Show file tree
Hide file tree
Showing 18 changed files with 236 additions and 11 deletions.
9 changes: 8 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
21 changes: 12 additions & 9 deletions ci/build_debs.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,27 +5,30 @@ export DEBEMAIL="[email protected]"

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
Expand Down
2 changes: 1 addition & 1 deletion cmake/project.cmake
Original file line number Diff line number Diff line change
@@ -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
Expand Down
10 changes: 10 additions & 0 deletions debian.native/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
/*.substvars
/files
/debhelper-build-stamp
/libsafu0/
/libsafu-dev/
/libmock-safu0/
/safu-doc/
/.debhelper/
/tmp/
/*.debhelper.log
50 changes: 50 additions & 0 deletions debian.native/README.md
Original file line number Diff line number Diff line change
@@ -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 [email protected] [@IsaacJT](https://github.com/IsaacJT)
5 changes: 5 additions & 0 deletions debian.native/changelog
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
safu (0.0.1) unstable; urgency=medium

* Dummy release.

-- Isaac True <[email protected]> Mon, 10 Jun 2024 16:53:43 +0200
63 changes: 63 additions & 0 deletions debian.native/control
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
Source: safu
Section: admin
Priority: optional
Maintainer: Isaac True <[email protected]>
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.
28 changes: 28 additions & 0 deletions debian.native/copyright
Original file line number Diff line number Diff line change
@@ -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.
9 changes: 9 additions & 0 deletions debian.native/devdoc-index.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
Developer documentation
==========================

.. toctree::
:maxdepth: 1
:caption: Contents:

DeveloperManual
documentation
1 change: 1 addition & 0 deletions debian.native/libmock-safu0.install
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
usr/lib/*/libmock_safu.so.*
5 changes: 5 additions & 0 deletions debian.native/libsafu-dev.install
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
usr/include/safu
usr/lib/*/cmake
usr/lib/*/pkgconfig
usr/lib/*/libmock_safu.so
usr/lib/*/libsafu.so
1 change: 1 addition & 0 deletions debian.native/libsafu0.install
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
usr/lib/*/libsafu.so.*
1 change: 1 addition & 0 deletions debian.native/not-installed
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
usr/lib/*/test
37 changes: 37 additions & 0 deletions debian.native/rules
Original file line number Diff line number Diff line change
@@ -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
1 change: 1 addition & 0 deletions debian.native/safu-doc.install
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
documentation/* /usr/share/doc/safu/
1 change: 1 addition & 0 deletions debian.native/safu-doc.lintian-overrides
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
safu-doc: zero-byte-file-in-doc-directory [usr/share/doc/safu/style.css]
1 change: 1 addition & 0 deletions debian.native/source/format
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
3.0 (native)
2 changes: 2 additions & 0 deletions debian.native/watch
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
version=4
https://github.com/Elektrobit/safu/tags .*/safu-(\d+).(\d+).(\d+).tar.gz

0 comments on commit f909954

Please sign in to comment.