Skip to content

Commit afab386

Browse files
authored
package: introduce .deb packaging (#223)
2 parents 8a8a23d + 2dae649 commit afab386

10 files changed

Lines changed: 114 additions & 7 deletions

File tree

.github/actions/package/action.yml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ runs:
2929
env:
3030
GPG_PRIVATE_KEY: ${{ inputs.private_key }}
3131
GPG_PASSPHRASE: ${{ inputs.passphrase }}
32+
MAKE_DEB: 1
3233
run: bash ./package/docker-package.sh --sign
3334

3435
- name: List build artifacts
@@ -59,3 +60,11 @@ runs:
5960
build/release/helium-${{ steps.version.outputs.version }}-${{ env.ARCH }}_linux.tar.xz.asc
6061
if-no-files-found: error
6162
compression-level: 0
63+
64+
- name: Upload .deb artifact
65+
uses: actions/upload-artifact@v4
66+
with:
67+
name: helium-${{ steps.version.outputs.version }}-${{ env.ARCH }}-deb
68+
path: build/release/helium-bin_${{ steps.version.outputs.version }}-1_*.deb
69+
if-no-files-found: error
70+
compression-level: 0

.github/actions/release/action.yml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,13 @@ runs:
2525
path: ./release/
2626
merge-multiple: true
2727

28+
- name: Download .deb artifacts
29+
uses: actions/download-artifact@v4
30+
with:
31+
pattern: helium-*-deb
32+
path: ./release/
33+
merge-multiple: true
34+
2835
- name: List release files
2936
shell: bash
3037
run: ls -la release/
@@ -63,3 +70,4 @@ runs:
6370
release/helium-*.AppImage
6471
release/helium-*.AppImage.zsync
6572
release/helium-*_linux.tar.xz*
73+
release/helium-bin_*.deb

.github/workflows/build.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: Build Linux AppImage for Helium
1+
name: Build Linux release
22
on:
33
workflow_dispatch:
44
inputs:

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,9 @@ The `scripts/docker-build.sh` script will:
3030
Running `scripts/build.sh` directly will not work unless you're running a Debian-based distro and have all necessary dependencies installed. This repo is designed to avoid having to configure the building environment on your Linux installation.
3131

3232
### Packaging
33-
After building, run `scripts/package.sh`. Alternatively, you can run `package/docker-package.sh` to build inside a Docker image. If you would like to sign the resulting AppImage, you can pass the `--sign` argument.
33+
After building, run `scripts/package.sh`. Alternatively, you can run `package/docker-package.sh` to build inside a Docker image. Either of these scripts will create `tar.xz` and `AppImage` files under `build/`.
3434

35-
Either of these scripts will create `tar.xz` and `AppImage` files under `build/`.
35+
If you would like to also generate a .deb file, you can set `MAKE_DEB=1` when running the release script.
3636

3737
### Development
3838
By default, the build script uses tarball. If you need to use a source tree clone, you can run `scripts/docker-build.sh -c` instead. This may be useful if a tarball for a release isn't available yet.

docker/package.Dockerfile

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,16 @@ RUN echo 'debconf debconf/frontend select Noninteractive' | debconf-set-selectio
88
RUN apt -y update && apt -y upgrade
99

1010
## Install system dependencies
11-
RUN apt -y install binutils elfutils desktop-file-utils dpkg file imagemagick wget xz-utils pv curl jq python3 zsync gnupg
11+
RUN apt -y install binutils elfutils desktop-file-utils dpkg dpkg-dev fakeroot file git imagemagick wget xz-utils pv curl jq python3 zsync gnupg perl make liblocale-gettext-perl
12+
13+
## Install debbuild for .deb packaging
14+
RUN git clone --depth 1 --branch 24.12.0 https://github.com/debbuild/debbuild.git /tmp/debbuild \
15+
&& cd /tmp/debbuild \
16+
&& git checkout 65c140bf902aa4860709a899a0f197fd7aa05e56 \
17+
&& perl configure --prefix=/usr \
18+
&& make \
19+
&& make install \
20+
&& rm -rf /tmp/debbuild
1221

1322
RUN curl -s https://api.github.com/repos/AppImage/appimagetool/releases/tags/1.9.0 \
1423
| jq -r '.assets[].browser_download_url' \

package/apparmor.cfg

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
abi <abi/4.0>,
2+
include <tunables/global>
3+
4+
profile helium-bin "/opt/helium/helium" flags=(default_allow) {
5+
userns,
6+
include if exists <local/helium-bin>
7+
}

package/docker-package.sh

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ _git_submodule="helium-chromium"
88
_image="helium-chromium-trixie-slim:packager"
99
_user_uidgid="$(id -u):$(id -g)"
1010
_docker_image_args=()
11+
_make_deb=${MAKE_DEB:-0}
1112

1213
if [ "$_user_uidgid" != "0:0" ]; then
1314
_docker_image_args+=(--build-arg "UID=$(id -u)")
@@ -30,5 +31,6 @@ cd "${_root_dir}" && docker run --rm -i \
3031
-e APPIMAGE_EXTRACT_AND_RUN=1 \
3132
-e HOME=/home/builder \
3233
-e GNUPGHOME=/home/builder/.gnupg \
34+
-e MAKE_DEB=$_make_deb \
3335
-v "${_root_dir}:/repo" \
3436
"${_image}" bash "/repo/scripts/package.sh" "$@"

package/helium-bin.spec

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,15 +10,20 @@ URL: https://github.com/imputnet/helium-linux
1010
Source0: https://github.com/imputnet/helium-linux/releases/download/%{version}/helium-%{version}-x86_64_linux.tar.xz
1111
Source1: https://github.com/imputnet/helium-linux/releases/download/%{version}/helium-%{version}-arm64_linux.tar.xz
1212

13+
%if 0%{?debbuild}
14+
Packager: imput <helium@imput.net>
15+
Provides: www-browser
16+
%endif
17+
1318
%description
1419
Private, fast, and honest web browser based on Chromium
1520

1621
%prep
17-
%ifarch x86_64
22+
%ifarch x86_64 amd64
1823
%setup -q -n helium-%{version}-x86_64_linux
1924
%endif
2025

21-
%ifarch aarch64
26+
%ifarch aarch64 arm64
2227
%setup -q -T -b 1 -n helium-%{version}-arm64_linux
2328
%endif
2429

@@ -36,8 +41,13 @@ mkdir -p %{heliumdir} \
3641

3742
cp -a . %{heliumdir}
3843

44+
%if 0%{?debbuild}
45+
sed -Ei "s/(CHROME_VERSION_EXTRA=).*/\1deb/" \
46+
%{heliumdir}/helium-wrapper
47+
%else
3948
sed -Ei "s/(CHROME_VERSION_EXTRA=).*/\1rpm/" \
4049
%{heliumdir}/helium-wrapper
50+
%endif
4151

4252
install -m 644 product_logo_256.png \
4353
%{buildroot}%{_datadir}/icons/hicolor/256x256/apps/helium.png
@@ -60,16 +70,28 @@ ln -sf %{helium_base}/helium-wrapper \
6070
/usr/bin/update-desktop-database &> /dev/null || :
6171
/bin/touch --no-create %{_datadir}/icons/hicolor &>/dev/null || :
6272

73+
if [ -d /etc/apparmor.d ]; then
74+
cp %{helium_base}/apparmor.cfg /etc/apparmor.d/helium-bin
75+
apparmor_parser -r /etc/apparmor.d/helium-bin || :
76+
fi
77+
6378
%postun
6479
# Refresh icon cache and update desktop database
6580
/usr/bin/update-desktop-database &> /dev/null || :
6681
if [ $1 -eq 0 ] ; then
6782
/bin/touch --no-create %{_datadir}/icons/hicolor &>/dev/null
6883
/usr/bin/gtk-update-icon-cache %{_datadir}/icons/hicolor &>/dev/null || :
84+
85+
if [ -f /etc/apparmor.d/helium-bin ]; then
86+
apparmor_parser -R helium-bin || :
87+
rm -f /etc/apparmor.d/helium-bin
88+
fi
6989
fi
7090

7191
%posttrans
7292
/usr/bin/gtk-update-icon-cache %{_datadir}/icons/hicolor &>/dev/null || :
7393

7494
%changelog
95+
%if "%{_vendor}" != "debbuild"
7596
%autochangelog
97+
%endif

package/mkdeb.sh

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
#!/bin/bash
2+
set -euxo pipefail
3+
4+
_current_dir="$(cd "$(dirname "${BASH_SOURCE[0]}")" &>/dev/null && pwd)"
5+
_root_dir="$(cd "$_current_dir/.." && pwd)"
6+
_release_dir="$_root_dir/build/release"
7+
_spec="$_root_dir/package/helium-bin.spec"
8+
9+
_version=$(python3 "$_root_dir/helium-chromium/utils/helium_version.py" \
10+
--tree "$_root_dir/helium-chromium" \
11+
--platform-tree "$_root_dir" \
12+
--print)
13+
_tarball="$(realpath "${1:-}")"
14+
15+
if ! [ -f "$_tarball" ]; then
16+
echo "usage: $0 <path to .tar.xz from release.sh" >&2
17+
exit 1
18+
fi
19+
20+
_tarball_basename="$(basename "$_tarball")"
21+
case "$_tarball_basename" in
22+
*x86_64*) _deb_arch="amd64" ;;
23+
*arm64*) _deb_arch="arm64" ;;
24+
*) exit 1;;
25+
esac
26+
27+
_debbuild_dir=$(mktemp -d)
28+
trap 'rm -rf "$_debbuild_dir"' EXIT
29+
30+
mkdir -p "$_debbuild_dir"/{BUILD,SOURCES,SPECS,DEBS}
31+
ln -s "$_tarball" "$_debbuild_dir/SOURCES/"
32+
cp "$_spec" "$_debbuild_dir/SPECS/"
33+
34+
debbuild \
35+
--define "_topdir $_debbuild_dir" \
36+
--define "debbuild 1" \
37+
--define "version $_version" \
38+
--define "_arch $_deb_arch" \
39+
--define "dist %{nil}" \
40+
-bb "$_debbuild_dir/SPECS/helium-bin.spec"
41+
42+
mkdir -p "$_release_dir"
43+
mv "$_debbuild_dir"/DEBS/*/*.deb "$_release_dir/"
44+
ls "$_release_dir"/*.deb

scripts/package.sh

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ for file in $_files; do
5858
done
5959

6060
cp "$_root_dir/package/helium.desktop" "$_tarball_dir"
61+
cp "$_root_dir/package/apparmor.cfg" "$_tarball_dir"
6162
cp "$_root_dir/package/helium-wrapper.sh" "$_tarball_dir/helium-wrapper"
6263

6364
wait
@@ -110,8 +111,13 @@ appimagetool \
110111
popd
111112
wait
112113

114+
if [ "${MAKE_DEB:-0}" = 1 ]; then
115+
"$_root_dir/package/mkdeb.sh" "$TAR_PATH"
116+
fi
117+
113118
if [ -n "${SIGN_TARBALL:-}" ]; then
114-
gpg --detach-sign --passphrase "$GPG_PASSPHRASE" \
119+
gpg --batch --pinentry-mode loopback \
120+
--detach-sign --passphrase "$GPG_PASSPHRASE" \
115121
--output "$TAR_PATH.asc" "$TAR_PATH"
116122
fi
117123

0 commit comments

Comments
 (0)