Skip to content

Commit

Permalink
Merge branch 'task/#23466-Debian_packaging_fixes' into 'integration'
Browse files Browse the repository at this point in the history
task/#23466-Debian_packaging_fixes

See merge request elektrobit/base-os/elos!100
  • Loading branch information
gehwolf committed Jul 3, 2024
2 parents 4a64c11 + d276fae commit 4769676
Show file tree
Hide file tree
Showing 6 changed files with 154 additions and 2 deletions.
3 changes: 3 additions & 0 deletions ci/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,11 @@ RUN apt-get update \
clang-tidy \
cmake \
curl \
debhelper \
expat \
gdb \
git \
git-buildpackage \
gnuplot \
jq \
libcmocka-dev \
Expand All @@ -39,6 +41,7 @@ RUN apt-get update \
libssl-dev \
linux-tools-generic \
locales \
moreutils \
net-tools \
netcat \
ninja-build \
Expand Down
116 changes: 116 additions & 0 deletions ci/create_debian_release.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,116 @@
#!/bin/bash -e

function print_help() {
echo "$0 [-r|-p|-a|-h] <x.y.z>"
echo -e "-r\tonly do the debian/main release"
echo -e "-p\tonly do the pristine tar build and update"
echo -e "-a\tdo all (default)"
echo -e "-h\tprint help"
}

function setup_env() {
export GIT_AUTHOR_NAME="Wolfgang Gehrhardt"
export GIT_COMMITTER_NAME="${GIT_AUTHOR_NAME}"
export DEBNAME="${GIT_AUTHOR_NAME}"

export EMAIL=${EMAIL-"[email protected]"}
export GIT_AUTHOR_EMAIL="${EMAIL}"
export GIT_COMMITTER_EMAIL="${EMAIL}"
export DEBMAIL="${EMAIL}"

git config --local user.name "${GIT_AUTHOR_NAME}"
git config --local user.email "${GIT_AUTHOR_EMAIL}"
}

function create_and_publish_debian_main() {
gbp import-ref -u "${NEW_VERSION}" --debian-branch "$(git branch --show-current)"

cp debian/changelog debian.native/
cp debian/gbp.conf debian.native/
git rm -rf debian/
cp -arv debian.native debian
rm debian/README.md
echo "3.0 (quilt)" > debian/source/format

dch -M "--newversion=${NEW_VERSION}-1" "New upstream tag ${NEW_VERSION}"
git add debian/ && git commit -m "New upstream tag ${NEW_VERSION}"
git checkout HEAD -- debian.native && git clean -fxd -- debian.native
}

function install_dependencies() {
./ci/install_deps.py

DEP_LIST="cmocka_extensions cmocka_mocks safu samconf"
for dependency in ${DEP_LIST}; do
pushd "build/deps/src/${dependency}"
git checkout debian/main
gbp buildpackage --git-ignore-branch --git-compression=xz -uc -us
case "${dependency}" in
cmocka_mocks)
sudo find ../ -type f -name "libmock-*_*.deb" -exec dpkg -i {} \;
;;
safu)
sudo find ../ -type f -name "libsafu*_*.deb" -exec dpkg -i {} \;
sudo find ../ -type f -name "libmock-safu*_*.deb" -exec dpkg -i {} \;
;;
samconf)
sudo find ../ -type f -name "libsamconf*_*.deb" -exec dpkg -i {} \;
sudo find ../ -type f -name "libmock-samconf*_*.deb" -exec dpkg -i {} \;
;;
esac
sudo find ../ -type f -name "*$(echo "${dependency}"| tr '_' '-')*-dev_*.deb" -exec dpkg -i {} \;
popd
done

rm -rf build/
}

function create_and_publish_pristine_tar() {
install_dependencies
sudo gbp buildpackage --git-ignore-branch --git-compression=xz --git-ignore-new -uc -us
}

UPDATE_RELEASE=0
UPDATE_PRISTINE=0
UPDATE_ALL=1

while getopts "raph" opt; do
case $opt in
r) UPDATE_RELEASE=1;;
p) UPDATE_PRISTINE=1;;
a) UPDATE_ALL=1;;
h) print_help; exit 0;;
\?) echo "Invalid option: -$OPTARG"; print_help; exit 1;;
esac
done
NEW_VERSION=${!OPTIND}

if [ -z "$NEW_VERSION" ]; then
echo "Error: Version number is required."
print_help
exit 1
fi

if [ $UPDATE_RELEASE -eq 0 ] && [ $UPDATE_PRISTINE -eq 0 ]; then
UPDATE_ALL=1
else
UPDATE_ALL=0
fi

echo "Create release: ${NEW_VERSION}"

setup_env

# workaround: the docker container already contains a working libmongoc build
# from source, because the one from the official repositories is broken.
# Remove this when nosql-plugin and dependency to libmongoc is removed.
sudo apt-get update
sudo apt-get install libmongoc-dev

if [ $UPDATE_ALL -eq 1 ] || [ $UPDATE_RELEASE -eq 1 ]; then
create_and_publish_debian_main
fi

if [ $UPDATE_ALL -eq 1 ] || [ $UPDATE_PRISTINE -eq 1 ]; then
create_and_publish_pristine_tar
fi
26 changes: 26 additions & 0 deletions ci/updateversion.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
#!/bin/sh -e
#
# Update all version numbers to given version
#

CMD_PATH=$(cd "$(dirname "$0")" && pwd)
BASE_DIR=${CMD_PATH%/*}
PROJECT_NAME=$(basename $BASE_DIR)

INPUTFILE_CMAKE="$BASE_DIR/cmake/project.cmake"

if [ $# -ne 1 ];
then
echo "Usage: $0 <version>"
exit 1
fi
VERSION=$1

# update version in cmake project file
sed -i "s,^set(ELOS_VERSION .*\$,set(ELOS_VERSION ${VERSION})," "${INPUTFILE_CMAKE}"

git add -p

git commit -m "elos: Update to ${VERSION}"
echo "New version:"
git show
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(ELOS_VERSION 0.59.1)
set(ELOS_VERSION 0.59.2)

# 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
7 changes: 7 additions & 0 deletions debian.native/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,13 @@ 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.

## Release

To prepare a new release on `debian/main` run
1. `git checkout -b <task/-new-release> origin/debian/main`
2. `./ci/docker-run.sh ./ci/create_debian_release.sh <x.y.z>`
3. push branch and create MR for **debian/main** , not *main* and not *integration*!

## Packaging Script Maintainer

* Isaac True [email protected] [@IsaacJT](https://github.com/IsaacJT)
2 changes: 1 addition & 1 deletion debian.native/copyright
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ Upstream-Contact: https://github.com/Elektrobit/elos/issues
Source: https://github.com/Elektrobit/elos

Files: *
Copyright: 2023, Elektrobit GmbH
Copyright: 2023, Elektrobit Automotive GmbH
2023, emlix GmbH
License: MIT

Expand Down

0 comments on commit 4769676

Please sign in to comment.