From 77712923b685417161c3cc404eb49791569bbe83 Mon Sep 17 00:00:00 2001 From: Loic Rouchon Date: Sun, 7 Jan 2024 17:20:27 +0100 Subject: [PATCH] release: integrate debian build/publish steps directly in this repository as scripts in tools/packaging/debian --- tools/packaging/debian/.gitignore | 1 + tools/packaging/debian/Dockerfile | 23 ++++++++-- tools/packaging/debian/Makefile | 19 +++++--- tools/packaging/debian/README.md | 13 ++++++ tools/packaging/debian/build.sh | 35 +++++++++++++++ tools/packaging/debian/common.sh | 45 +++++++++++++++++++ .../packaging/debian/debian/.gitignore | 0 .../packaging/debian/debian/changelog | 0 {src => tools}/packaging/debian/debian/compat | 0 .../packaging/debian/debian/control | 0 .../packaging/debian/debian/copyright | 0 {src => tools}/packaging/debian/debian/rules | 0 .../packaging/debian/debian/source/format | 0 tools/packaging/debian/publish.sh | 11 +++++ 14 files changed, 137 insertions(+), 10 deletions(-) create mode 100644 tools/packaging/debian/.gitignore create mode 100644 tools/packaging/debian/README.md create mode 100755 tools/packaging/debian/build.sh create mode 100644 tools/packaging/debian/common.sh rename {src => tools}/packaging/debian/debian/.gitignore (100%) rename {src => tools}/packaging/debian/debian/changelog (100%) rename {src => tools}/packaging/debian/debian/compat (100%) rename {src => tools}/packaging/debian/debian/control (100%) rename {src => tools}/packaging/debian/debian/copyright (100%) rename {src => tools}/packaging/debian/debian/rules (100%) rename {src => tools}/packaging/debian/debian/source/format (100%) create mode 100755 tools/packaging/debian/publish.sh diff --git a/tools/packaging/debian/.gitignore b/tools/packaging/debian/.gitignore new file mode 100644 index 0000000..6ef50ea --- /dev/null +++ b/tools/packaging/debian/.gitignore @@ -0,0 +1 @@ +gpg/ diff --git a/tools/packaging/debian/Dockerfile b/tools/packaging/debian/Dockerfile index eadb676..c54153b 100644 --- a/tools/packaging/debian/Dockerfile +++ b/tools/packaging/debian/Dockerfile @@ -1,8 +1,18 @@ -FROM debian:bookworm +FROM ubuntu:23.10 -# Build dependencies -RUN apt update \ - && apt install -y \ +RUN apt update + +# Packaging essentials +RUN apt install -y \ + gpg \ + curl \ + build-essential \ + devscripts \ + debhelper \ + && apt clean + +# Symly build dependencies +RUN apt install -y \ openjdk-17-jdk-headless \ ant \ libpicocli-java \ @@ -10,3 +20,8 @@ RUN apt update \ VOLUME /workspace WORKDIR /workspace + +ENV DEBEMAIL='loic@loicrouchon.com' +ENV DEBFULLNAME='Loic Rouchon' +ENV PPA_URL='ppa:loicrouchon/symly' +ENV GPG_KEY_FINGERPRINT='C3BB9448B16C971103E876BF3A091A0DF2799262' diff --git a/tools/packaging/debian/Makefile b/tools/packaging/debian/Makefile index 97f76d4..e8bb7ad 100644 --- a/tools/packaging/debian/Makefile +++ b/tools/packaging/debian/Makefile @@ -7,15 +7,22 @@ PACKAGING_DIR=$(ROOT_DIR)/tools/packaging/debian build: podman run -ti \ -v "$(HOST_ROOT_DIR):$(ROOT_DIR)" \ - symly/debian-build-env:latest \ - ant -v -f "$(PACKAGING_DIR)/build.xml" + symly/ubuntu-build-env:latest \ + "$(PACKAGING_DIR)/build.sh" "$(VERSION)" -.PHONY: build-shell -build-shell: +.PHONY: publish +publish: podman run -ti \ -v "$(HOST_ROOT_DIR):$(ROOT_DIR)" \ - symly/debian-build-env:latest + symly/ubuntu-build-env:latest \ + "$(PACKAGING_DIR)/publish.sh" "$(VERSION)" + +.PHONY: shell +shell: + podman run -ti \ + -v "$(HOST_ROOT_DIR):$(ROOT_DIR)" \ + symly/ubuntu-build-env:latest .PHONY: build-env build-env: - podman build -t symly/debian-build-env:latest . + podman build -t symly/ubuntu-build-env:latest . diff --git a/tools/packaging/debian/README.md b/tools/packaging/debian/README.md new file mode 100644 index 0000000..f4048f5 --- /dev/null +++ b/tools/packaging/debian/README.md @@ -0,0 +1,13 @@ +# Debian packaging + +## Tooling + +```shell +make build-env +``` + +### Packaging & publication + +```shell +VERSION=xxx make build publish +``` diff --git a/tools/packaging/debian/build.sh b/tools/packaging/debian/build.sh new file mode 100755 index 0000000..670af13 --- /dev/null +++ b/tools/packaging/debian/build.sh @@ -0,0 +1,35 @@ +#!/usr/bin/env sh +set -ex + +cur_dir="$(dirname "$(realpath "$0")")" +. "${cur_dir}/common.sh" + +echo "Building debian source package ${package_version_dir}" + +rm -rf "${target_dir}" +mkdir -p "${target_dir}" +cd "${target_dir}" || exit 1 + +echo "Downloading upstream tarball from ${upstream_tarball_url}" +curl -sL "${upstream_tarball_url}" -o "${upstream_tarball}" + +echo "Unpacking upstream tarball ${upstream_tarball}" +tar xzf "${upstream_tarball}" + +echo "Repacking upstream tarball ${upstream_tarball} (get rid off root level directory)" +rm -f "${upstream_tarball}" +tar czf "${upstream_tarball}" "${package_version_dir}" + +echo "Add debian dir" +cd "${package_version_dir}" || exit 1 +cp -R "${cur_dir}/debian" "debian" + +echo "Build source and binary package package" +pwd +# Building the deb for 'all' arch first +dpkg-buildpackage --sign-key="${GPG_KEY_FINGERPRINT}" --build=all +# Building the source package after so thAT THE .changes does not reference the binary package for upload via dput +dpkg-buildpackage --sign-key="${GPG_KEY_FINGERPRINT}" --build=source + +display_artifacts +test_package diff --git a/tools/packaging/debian/common.sh b/tools/packaging/debian/common.sh new file mode 100644 index 0000000..2fb7242 --- /dev/null +++ b/tools/packaging/debian/common.sh @@ -0,0 +1,45 @@ +#!/usr/bin/env sh +set -ex + +package_name="symly" +version="$1" +if [ "${version}" = "" ]; then + echo "Missing version argument" + exit 1 +fi + +if ! (cat "${cur_dir}/debian/changelog" | grep -E "^${package_name} " | head -n 1 | grep -q "${package_name} (${version}-"); then + echo "Package ${package_name} does not have a changelog entry for version ${version}" + exit 1 +fi + +target_dir="${cur_dir}/target/${package_name}" +package_version_dir="${package_name}-${version}" +package_version_name="${package_name}_${version}" +upstream_tarball="${package_name}_${version}.orig.tar.gz" +upstream_tarball_url="https://github.com/loicrouchon/symly/archive/refs/tags/v${version}.tar.gz" + +cat "${cur_dir}/gpg/"*.key | gpg --import + +display_artifacts() { + ls -l "${target_dir}" + echo ".dsc content:" + cat "${target_dir}/${package_version_name}-"*.dsc + echo ".buildinfo content:" + cat "${target_dir}/${package_version_name}-"*.buildinfo + echo ".changes content:" + cat "${target_dir}/${package_version_name}-"*.changes +} + +test_package() { + apt install -y "${target_dir}/${package_version_name}-"*_all.deb + version_command_output="$(symly --version)" + if ! (echo "${version_command_output}" | grep -Eq "^Symly version ${version}"); then + echo "ERR: Failed to test 'symly --version' +ERR: Expecting: Symly version ${version} +ERR: But got: ${version_command_output}" + exit 1 + else + echo "test successful: ${version_command_output}" + fi +} diff --git a/src/packaging/debian/debian/.gitignore b/tools/packaging/debian/debian/.gitignore similarity index 100% rename from src/packaging/debian/debian/.gitignore rename to tools/packaging/debian/debian/.gitignore diff --git a/src/packaging/debian/debian/changelog b/tools/packaging/debian/debian/changelog similarity index 100% rename from src/packaging/debian/debian/changelog rename to tools/packaging/debian/debian/changelog diff --git a/src/packaging/debian/debian/compat b/tools/packaging/debian/debian/compat similarity index 100% rename from src/packaging/debian/debian/compat rename to tools/packaging/debian/debian/compat diff --git a/src/packaging/debian/debian/control b/tools/packaging/debian/debian/control similarity index 100% rename from src/packaging/debian/debian/control rename to tools/packaging/debian/debian/control diff --git a/src/packaging/debian/debian/copyright b/tools/packaging/debian/debian/copyright similarity index 100% rename from src/packaging/debian/debian/copyright rename to tools/packaging/debian/debian/copyright diff --git a/src/packaging/debian/debian/rules b/tools/packaging/debian/debian/rules similarity index 100% rename from src/packaging/debian/debian/rules rename to tools/packaging/debian/debian/rules diff --git a/src/packaging/debian/debian/source/format b/tools/packaging/debian/debian/source/format similarity index 100% rename from src/packaging/debian/debian/source/format rename to tools/packaging/debian/debian/source/format diff --git a/tools/packaging/debian/publish.sh b/tools/packaging/debian/publish.sh new file mode 100755 index 0000000..2967363 --- /dev/null +++ b/tools/packaging/debian/publish.sh @@ -0,0 +1,11 @@ +#!/usr/bin/env sh +set -ex + +cur_dir="$(dirname "$(realpath "$0")")" +. "${cur_dir}/common.sh" + +display_artifacts +test_package + +echo "Publishing debian source package ${package_version_dir} to ${PPA_URL}" +dput "${PPA_URL}" "${target_dir}/${package_version_name}-"*_source.changes