Skip to content

Commit

Permalink
release: integrate debian build/publish steps directly in this reposi…
Browse files Browse the repository at this point in the history
…tory as scripts in tools/packaging/debian
  • Loading branch information
loicrouchon committed Jan 7, 2024
1 parent 71405dc commit 6126c95
Show file tree
Hide file tree
Showing 14 changed files with 137 additions and 10 deletions.
1 change: 1 addition & 0 deletions tools/packaging/debian/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
gpg/
23 changes: 19 additions & 4 deletions tools/packaging/debian/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,12 +1,27 @@
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 \
&& apt clean

VOLUME /workspace
WORKDIR /workspace

ENV DEBEMAIL='loic@loicrouchon.com'
ENV DEBFULLNAME='Loic Rouchon'
ENV PPA_URL='ppa:loicrouchon/symly'
ENV GPG_KEY_FINGERPRINT='C3BB9448B16C971103E876BF3A091A0DF2799262'
19 changes: 13 additions & 6 deletions tools/packaging/debian/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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 .
13 changes: 13 additions & 0 deletions tools/packaging/debian/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# Debian packaging

## Tooling

```shell
make build-env
```

### Packaging & publication

```shell
VERSION=xxx make build publish
```
35 changes: 35 additions & 0 deletions tools/packaging/debian/build.sh
Original file line number Diff line number Diff line change
@@ -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
45 changes: 45 additions & 0 deletions tools/packaging/debian/common.sh
Original file line number Diff line number Diff line change
@@ -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
}
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
11 changes: 11 additions & 0 deletions tools/packaging/debian/publish.sh
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit 6126c95

Please sign in to comment.