Skip to content

Commit

Permalink
Simplify to dpkg-deb
Browse files Browse the repository at this point in the history
My first iteration of this used debuild to produce a .deb package, as
recommended in the [Guide for Debian
Maintainers](https://www.debian.org/doc/manuals/debmake-doc/index.en.html).
However, it's become clear that it will be difficult to get a PPA
working because there's not official Ubuntu/Debian zig package, which
makes it difficult to use as part of your tool chain. (PPAs work by
uploading source .deb packages and building binary packages on
launchpad's build servers, which requires zig to be available as an
official package.)

Instead, I'm opting to simplify this build process by using `dpkg-deb`
to build a binary `.deb` package, doing away with the
currently-unnecessary complexity of debuild. I still believe we can
upload this binary .deb package to an apt repository somewhere, just not
a Launchpad PPA.
  • Loading branch information
mkasberg committed Jan 2, 2025
1 parent 3e77252 commit 38e2406
Show file tree
Hide file tree
Showing 11 changed files with 59 additions and 93 deletions.
34 changes: 9 additions & 25 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,6 @@ on:
branches:
- main
workflow_dispatch:
inputs:
release_version:
description: If empty, rest with build artifact. If nonempty, release that version.
type: string
required: false

permissions:
contents: write
Expand All @@ -21,7 +16,6 @@ jobs:
strategy:
matrix:
ubuntu_version: ["22.04", "24.04", "24.10"]
build_type: ["source", "binary"]
runs-on: ubuntu-latest
container:
image: ubuntu:${{ matrix.ubuntu_version }}
Expand All @@ -34,30 +28,20 @@ jobs:

- name: Set Release Distribution
run: |
if [ "${{ matrix.ubuntu_version }}" = "22.04" ]; then
UBUNTU_DIST="jammy"
elif [ "${{ matrix.ubuntu_version }}" = "24.04" ]; then
UBUNTU_DIST="noble"
else
UBUNTU_DIST="oracular"
fi
sed -i "s/UNRELEASED/$UBUNTU_DIST/" debian/changelog
- name: Build Ghostty
run: ./build-ghostty.sh "${{ matrix.ubuntu_version }}"

- name: Lint .deb Package
run: |
ARGS=""
if [ "${{ matrix.build_type }}" = "source" ]; then
ARGS="-S"
fi
echo "build-ghostty ARGS: $ARGS"
./build-ghostty.sh "$ARGS"
echo $PWD
ls
lintian ghostty_*.deb || true # Lintian shouldn't fail our build yet
- name: Upload Artifact
if: inputs.release_version == ''
uses: actions/upload-artifact@v4
with:
name: package-${{ matrix.build_type }}-${{ matrix.ubuntu_version }}
name: package-${{ matrix.ubuntu_version }}
retention-days: 7
path: |
ghostty_*.*
path: ghostty_*.deb
12 changes: 3 additions & 9 deletions debian/control → DEBIAN/control
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,11 @@ Source: ghostty
Section: utils
Priority: optional
Maintainer: Mike Kasberg <[email protected]>
Build-Depends: debhelper-compat (= 13), libgtk-4-dev, libadwaita-1-dev, libonig-dev, libbz2-dev
Standards-Version: 4.6.1
Homepage: https://ghostty.org/
Rules-Requires-Root: no
#Vcs-Git: https://salsa.debian.org/debian/ghostty.git
#Vcs-Browser: https://salsa.debian.org/debian/ghostty

Package: ghostty
Architecture: any
Multi-Arch: foreign
Depends: ${misc:Depends}, ${shlibs:Depends}
Version: 1.0.1-0~ppa2
Architecture: amd64
Depends: libadwaita-1-0, libc6, libfontconfig1, libfreetype6, libglib2.0-0t64, libgtk-4-1, libharfbuzz0b, libonig5, libx11-6
Description: Fast, feature-rich, and cross-platform terminal emulator.
Ghostty is a terminal emulator that differentiates itself by being fast,
feature-rich, and native. While there are many excellent terminal emulators
Expand Down
54 changes: 44 additions & 10 deletions build-ghostty.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,17 @@ set -e

GHOSTTY_VERSION="1.0.1"

DEBEMAIL="[email protected]"
DEBFULLNAME="Mike Kasberg"
DEBUILD_DPKG_BUILDPACKAGE_OPTS="-i -I -us -uc"
DEBUILD_LINTIAN_OPTS="-i -I --show-overrides"
DEB_BUILD_MAINT_OPTIONS="hardening=+all"
if [ "$1" = "22.04" ]; then
UBUNTU_DIST="jammy"
elif [ "$1" = "24.04" ]; then
UBUNTU_DIST="noble"
else
UBUNTU_DIST="oracular"
fi

#FULL_VERSION="$GHOSTTY_VERSION-0~${UBUNTU_DIST}1"
FULL_VERSION="$GHOSTTY_VERSION-0~ppa2"


# Fetch Ghostty Source
wget -q "https://release.files.ghostty.org/$GHOSTTY_VERSION/ghostty-$GHOSTTY_VERSION.tar.gz"
Expand All @@ -18,11 +24,39 @@ minisign -Vm "ghostty-$GHOSTTY_VERSION.tar.gz" -P RWQlAjJC23149WL2sEpT/l0QKy7hMI
rm ghostty-$GHOSTTY_VERSION.tar.gz.minisig

tar -xzmf "ghostty-$GHOSTTY_VERSION.tar.gz"
ln -s "ghostty-$GHOSTTY_VERSION.tar.gz" "ghostty_$GHOSTTY_VERSION.orig.tar.gz"

cp -r debian "ghostty-$GHOSTTY_VERSION/debian"

# Build Ghostty
cd "ghostty-$GHOSTTY_VERSION"

debuild --prepend-path /usr/local/bin -us -uc $@
# On Ubuntu it's libbz2, not libbzip2
sed -i 's/linkSystemLibrary2("bzip2", dynamic_link_opts)/linkSystemLibrary2("bz2", dynamic_link_opts)/' build.zig

# Fetch Zig Cache
ZIG_GLOBAL_CACHE_DIR=/tmp/offline-cache ./nix/build-support/fetch-zig-cache.sh

# Build Ghostty with zig
zig build \
--summary all \
--prefix ./zig-out/usr \
--system /tmp/offline-cache/p \
-Doptimize=ReleaseFast \
-Dcpu=baseline \
-Dpie=true \
-Demit-docs \
-Dversion-string=$GHOSTTY_VERSION

# Debian control files
cp -r ../DEBIAN/ ./zig-out/DEBIAN/

# Changelog and copyright
mkdir -p ./zig-out/usr/share/doc/ghostty/
cp ../copyright ./zig-out/usr/share/doc/ghostty/
cp ../changelog.Debian ./zig-out/usr/share/doc/ghostty/
sed -i "s/DIST/$UBUNTU_DIST/" zig-out/usr/share/doc/ghostty/changelog.Debian
gzip -n -9 zig-out/usr/share/doc/ghostty/changelog.Debian

# Compress manpages
gzip -n -9 zig-out/usr/share/man/man1/ghostty.1
gzip -n -9 zig-out/usr/share/man/man5/ghostty.5

dpkg-deb --build zig-out ghostty_${FULL_VERSION}_amd64.deb
mv ghostty_${FULL_VERSION}_amd64.deb ../
4 changes: 2 additions & 2 deletions debian/changelog → changelog.Debian
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
ghostty (1.0.1-0~ppa1) UNRELEASED; urgency=low
ghostty (1.0.1-0~ppa1) DIST; urgency=low

* https://ghostty.org/docs/install/release-notes/1-0-1

-- Mike Kasberg <[email protected]> Tue, 31 Dec 2024 14:45:00 -0700

ghostty (1.0.0-0~ppa1) UNRELEASED; urgency=low
ghostty (1.0.0-0~ppa1) DIST; urgency=low

* Initial release.

Expand Down
File renamed without changes.
1 change: 0 additions & 1 deletion debian/install

This file was deleted.

14 changes: 0 additions & 14 deletions debian/patches/000-libbz2.patch

This file was deleted.

1 change: 0 additions & 1 deletion debian/patches/series

This file was deleted.

29 changes: 0 additions & 29 deletions debian/rules

This file was deleted.

1 change: 0 additions & 1 deletion debian/source/format

This file was deleted.

2 changes: 1 addition & 1 deletion setup-env.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ DEBIAN_FRONTEND="noninteractive"
ZIG_VERSION="0.13.0"

# Install Build Tools
apt-get -qq update && apt-get -qq -y install build-essential debhelper devscripts pandoc libonig-dev libbz2-dev wget
apt-get -qq update && apt-get -qq -y install build-essential libonig-dev libbz2-dev lintian pandoc wget

wget -q "https://github.com/jedisct1/minisign/releases/download/0.11/minisign-0.11-linux.tar.gz"
tar -xzf minisign-0.11-linux.tar.gz
Expand Down

0 comments on commit 38e2406

Please sign in to comment.