Skip to content

Commit 78b24c1

Browse files
authored
build with sharun and debloated llvm libs (pkgforge-dev#29)
* use sharun to bundle dependencies * add `lib4bin` dependencies * make sure opengl gets bundled
1 parent dc17d20 commit 78b24c1

File tree

3 files changed

+31
-48
lines changed

3 files changed

+31
-48
lines changed

.github/workflows/ci.yaml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@ jobs:
2525
runs-on: ubuntu-24.04
2626
container:
2727
image: ghcr.io/pkgforge-dev/archlinux:latest
28-
options: "--privileged --cap-add SYS_ADMIN --device /dev/fuse"
2928
steps:
3029
- name: Checkout ghostty-appimage
3130
uses: actions/checkout@v4

build.sh

Lines changed: 19 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
set -e
44

55
export ARCH="$(uname -m)"
6+
export APPIMAGE_EXTRACT_AND_RUN=1
67

78
GHOSTTY_VERSION="$(cat VERSION)"
89
TMP_DIR="/tmp/ghostty-build"
@@ -11,6 +12,7 @@ PUB_KEY="RWQlAjJC23149WL2sEpT/l0QKy7hMIFhYdQOFy0Z7z7PbneUgvlsnYcV"
1112
UPINFO="gh-releases-zsync|$(echo "${GITHUB_REPOSITORY:-no-user/no-repo}" | tr '/' '|')|latest|*$ARCH.AppImage.zsync"
1213
APPDATA_FILE="${PWD}/assets/ghostty.appdata.xml"
1314
DESKTOP_FILE="${PWD}/assets/ghostty.desktop"
15+
LIB4BN="https://raw.githubusercontent.com/VHSgunzo/sharun/refs/heads/main/lib4bin"
1416

1517
rm -rf "${TMP_DIR}"
1618

@@ -49,59 +51,34 @@ zig build \
4951

5052
cd "${APP_DIR}"
5153

52-
# bundle all libs
53-
ldd ./usr/bin/ghostty | awk -F"[> ]" '{print $4}' | xargs -I {} cp --update=none -v {} ./usr/lib
54-
55-
# ld-linux contains x86-64 instead of x86_64
56-
case "${ARCH}" in
57-
"x86_64")
58-
ld_linux="ld-linux-x86-64.so.2"
59-
;;
60-
"aarch64")
61-
ld_linux="ld-linux-aarch64.so.1"
62-
;;
63-
*)
64-
echo "Unsupported ARCH: '${ARCH}'"
65-
exit 1
66-
;;
67-
esac
54+
cp "${APPDATA_FILE}" "usr/share/metainfo/com.mitchellh.ghostty.appdata.xml"
6855

69-
cp -v /usr/lib/libpthread.so.0 ./usr/lib
56+
# Fix Gnome dock issues -- StartupWMClass attribute needs to be present.
57+
cp "${DESKTOP_FILE}" "usr/share/applications/com.mitchellh.ghostty.desktop"
58+
# WezTerm has this, it might be useful.
59+
ln -s "com.mitchellh.ghostty.desktop" "usr/share/applications/ghostty.desktop"
7060

71-
if ! mv ./usr/lib/${ld_linux} ./ld-linux.so; then
72-
cp -v /usr/lib/${ARCH}-linux-gnu/${ld_linux} ./ld-linux.so
73-
fi
61+
ln -s "usr/share/applications/com.mitchellh.ghostty.desktop" .
62+
ln -s "usr/share/icons/hicolor/256x256/apps/com.mitchellh.ghostty.png" .
7463

75-
strip -s -R .comment --strip-unneeded ./usr/lib/lib*
64+
# bundle all libs
65+
wget "$LIB4BN" -O ./lib4bin
66+
chmod +x ./lib4bin
67+
xvfb-run -a -- ./lib4bin -p -v -e -s -k ./usr/bin/ghostty /usr/lib/libEGL*
68+
rm -rf ./usr/bin
7669

7770
# Prepare AppImage -- Configure launcher script, metainfo and desktop file with icon.
78-
cat <<'EOF' >./AppRun
79-
#!/usr/bin/env sh
80-
81-
HERE="$(dirname "$(readlink -f "$0")")"
82-
unset ARGV0
83-
export GHOSTTY_RESOURCES_DIR="${HERE}/usr/share/ghostty"
84-
exec "${HERE}"/ld-linux.so --library-path "${HERE}"/usr/lib "${HERE}"/usr/bin/ghostty "$@"
85-
EOF
71+
echo 'unset ARGV0' > ./.env
72+
echo 'GHOSTTY_RESOURCES_DIR=${SHARUN_DIR}/usr/share/ghostty' >> ./.env
73+
ln -s ./bin/ghostty ./AppRun
74+
./sharun -g
8675

87-
chmod +x AppRun
88-
89-
export VERSION="$(./AppRun --version 2>/dev/null | awk 'FNR==1 {print $2}')"
76+
export VERSION="$(./AppRun --version | awk 'FNR==1 {print $2}')"
9077
if [ -z "$VERSION" ]; then
9178
echo "ERROR: Could not get version from ghostty binary"
9279
exit 1
9380
fi
9481

95-
cp "${APPDATA_FILE}" "usr/share/metainfo/com.mitchellh.ghostty.appdata.xml"
96-
97-
# Fix Gnome dock issues -- StartupWMClass attribute needs to be present.
98-
cp "${DESKTOP_FILE}" "usr/share/applications/com.mitchellh.ghostty.desktop"
99-
# WezTerm has this, it might be useful.
100-
ln -s "com.mitchellh.ghostty.desktop" "usr/share/applications/ghostty.desktop"
101-
102-
ln -s "usr/share/applications/com.mitchellh.ghostty.desktop" .
103-
ln -s "usr/share/icons/hicolor/256x256/apps/com.mitchellh.ghostty.png" .
104-
10582
cd "${TMP_DIR}"
10683

10784
# create app image

setup.sh

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -29,37 +29,44 @@ esac
2929
rm -rf "/usr/share/libalpm/hooks/package-cleanup.hook"
3030

3131
# Update & install OS base dependencies
32-
buildPkgs="base-devel freetype2 oniguruma wget fuse file zsync appstream"
32+
buildPkgs="base-devel freetype2 oniguruma wget mesa file zsync appstream xorg-server-xvfb patchelf binutils strace"
3333
ghosttyPkgs="gtk4 libadwaita"
3434
pacman -Syu --noconfirm
3535
pacman -Syw --noconfirm ${buildPkgs} ${ghosttyPkgs}
3636
pacman -Syq --needed --noconfirm ${buildPkgs} ${ghosttyPkgs}
3737

38+
# Add debloated version of llvm-libs
39+
LLVM_URL="$(wget https://api.github.com/repos/pkgforge-dev/llvm-libs-debloated/releases -O - \
40+
| sed 's/[()",{} ]/\n/g' | grep -i "https.*nano.*$ARCH.pkg.tar.*" | head -1)"
41+
wget "$LLVM_URL" -O ./llvm-libs.pkg.tar.zst
42+
pacman -U --noconfirm ./llvm-libs.pkg.tar.zst
43+
rm -f ./llvm-libs.pkg.tar.zst
44+
3845
# Download & install other dependencies
3946
# appimagetool: https://github.com/AppImage/appimagetool
4047
if [ ! -f '/usr/local/bin/appimagetool' ]; then
41-
wget -q "${APPIMAGE_URL}" -O /tmp/appimagetool.AppImage
48+
wget "${APPIMAGE_URL}" -O /tmp/appimagetool.AppImage
4249
chmod +x /tmp/appimagetool.AppImage
4350
mv /tmp/appimagetool.AppImage /usr/local/bin/appimagetool
4451
fi
4552

4653
# minisign: https://github.com/jedisct1/minisign
4754
if [ ! -f '/usr/local/bin/minisign' ]; then
48-
wget -q "${MINISIGN_URL}" -O /tmp/minisign-linux.tar.gz
55+
wget "${MINISIGN_URL}" -O /tmp/minisign-linux.tar.gz
4956
tar -xzf /tmp/minisign-linux.tar.gz -C /tmp
5057
mv /tmp/minisign-linux/"${ARCH}"/minisign /usr/local/bin
5158
fi
5259

5360
# zig: https://ziglang.org
5461
if [ ! -d "/opt/zig-linux-${ARCH}-${ZIG_VERSION}" ]; then
55-
wget -q "${ZIG_URL}" -O /tmp/zig-linux.tar.xz
62+
wget "${ZIG_URL}" -O /tmp/zig-linux.tar.xz
5663
tar -xf /tmp/zig-linux.tar.xz -C /opt
5764
ln -s "/opt/zig-linux-${ARCH}-${ZIG_VERSION}/zig" /usr/local/bin/zig
5865
fi
5966

6067
# pandoc: https://github.com/jgm/pandoc
6168
if [ ! -f '/usr/local/bin/pandoc' ]; then
62-
wget -q "${PANDOC_URL}" -O /tmp/pandoc-linux.tar.gz
69+
wget "${PANDOC_URL}" -O /tmp/pandoc-linux.tar.gz
6370
tar -xzf /tmp/pandoc-linux.tar.gz -C /tmp
6471
mv /tmp/"pandoc-${PANDOC_VERSION}"/bin/* /usr/local/bin
6572
fi

0 commit comments

Comments
 (0)