Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ jobs:
with:
name: ghostty-appimage-${{ matrix.arch }}
retention-days: 7
path: /tmp/ghostty-build/Ghostty*-${{ matrix.arch }}.AppImage*
path: dist

tag:
name: "👻 Tip Tag"
Expand Down
6 changes: 6 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -20,3 +20,9 @@ Sessionx.vim
tags
# Persistent undo
[._]*.un~

AppDir
ghostty-*
quick-sharun
uruntime2appimage
dist
68 changes: 0 additions & 68 deletions assets/ghostty.appdata.xml

This file was deleted.

22 changes: 0 additions & 22 deletions assets/ghostty.desktop

This file was deleted.

92 changes: 18 additions & 74 deletions build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,29 +4,23 @@ set -eux

ARCH="$(uname -m)"
GHOSTTY_VERSION="$(cat VERSION)"
TMP_DIR="/tmp/ghostty-build"
APP_DIR="${TMP_DIR}/ghostty.AppDir"
PUB_KEY="RWQlAjJC23149WL2sEpT/l0QKy7hMIFhYdQOFy0Z7z7PbneUgvlsnYcV"
UPINFO="gh-releases-zsync|$(echo "${GITHUB_REPOSITORY}" | tr '/' '|')|latest|Ghostty-*$ARCH.AppImage.zsync"
APPDATA_FILE="${PWD}/assets/ghostty.appdata.xml"
DESKTOP_FILE="${PWD}/assets/ghostty.desktop"
LIBS2BUNDLE="./bin/ghostty /usr/lib/libEGL* /usr/lib/gdk-pixbuf-*/*/*/*"

export ADD_HOOKS="self-updater.bg.hook"
export UPINFO="gh-releases-zsync|$(echo "${GITHUB_REPOSITORY}" | tr '/' '|')|latest|Ghostty-*$ARCH.AppImage.zsync"
export URUNTIME_PRELOAD=1
export DEPLOY_OPENGL=1
export EXEC_WRAPPER=1

BUILD_ARGS="
--summary all \
--prefix ${APP_DIR} \
-Doptimize=ReleaseFast \
-Dcpu=baseline \
-Dpie=true \
-Demit-docs \
-Dgtk-wayland=true \
-Dgtk-x11=true"

rm -rf "${TMP_DIR}"

mkdir -p -- "${TMP_DIR}" "${APP_DIR}/share/metainfo" "${APP_DIR}/shared/lib"

cd "${TMP_DIR}"

if [ "${GHOSTTY_VERSION}" = "tip" ]; then
wget "https://github.com/ghostty-org/ghostty/releases/download/tip/ghostty-source.tar.gz" -O "ghostty-${GHOSTTY_VERSION}.tar.gz"
wget "https://github.com/ghostty-org/ghostty/releases/download/tip/ghostty-source.tar.gz.minisig" -O "ghostty-${GHOSTTY_VERSION}.tar.gz.minisig"
Expand All @@ -45,76 +39,26 @@ tar -xzmf "ghostty-${GHOSTTY_VERSION}.tar.gz"
rm "ghostty-${GHOSTTY_VERSION}.tar.gz" \
"ghostty-${GHOSTTY_VERSION}.tar.gz.minisig"

BUILD_DIR="ghostty-${GHOSTTY_VERSION}"
BUILD_ARGS="${BUILD_ARGS} -Dversion-string=${GHOSTTY_VERSION}"

cd "${TMP_DIR}/${BUILD_DIR}"

#Fetch Zig Cache
if [ -f './nix/build-support/fetch-zig-cache.sh' ]; then
ZIG_GLOBAL_CACHE_DIR=/tmp/offline-cache ./nix/build-support/fetch-zig-cache.sh
BUILD_ARGS="${BUILD_ARGS} --system /tmp/offline-cache/p"
fi

# Build Ghostty with zig
zig build ${BUILD_ARGS}

# Prepare AppImage -- Configure launcher script, metainfo and desktop file with icon.
cd "${APP_DIR}"

cp "${APPDATA_FILE}" "share/metainfo/com.mitchellh.ghostty.appdata.xml"
cp "${DESKTOP_FILE}" "share/applications/com.mitchellh.ghostty.desktop"

ln -s "com.mitchellh.ghostty.desktop" "share/applications/ghostty.desktop"
ln -s "share/applications/com.mitchellh.ghostty.desktop" .
ln -s "share/icons/hicolor/256x256/apps/com.mitchellh.ghostty.png" .
ln -s "share/icons/hicolor/256x256/apps/com.mitchellh.ghostty.png" .DirIcon

# bundle all libs
xvfb-run -a -- sharun l -p -v -e -s -k ${LIBS2BUNDLE}

# preload libpixbufloader /w ld-preload-open as svg icons breaks
# either on ghostty tab bar or gnome-text-editor while config edit or both :(
mv ./shared/lib/gdk-pixbuf-2.0 ./
cp -rv /opt/path-mapping.so ./shared/lib/
cp -rv gdk-pixbuf-2.0/2.10.0/loaders/libpixbufloader_svg.so ./shared/lib/

echo 'path-mapping.so' >./.preload
echo 'PATH_MAPPING=/usr/lib/gdk-pixbuf-2.0:${SHARUN_DIR}/gdk-pixbuf-2.0' >>./.env

echo 'GHOSTTY_RESOURCES_DIR=${SHARUN_DIR}/share/ghostty' >>./.env
echo 'unset ARGV0' >>./.env

ln -s ./bin/ghostty ./AppRun
./sharun -g

VERSION="$(./AppRun --version | awk 'FNR==1 {print $2}')"
if [ -z "${VERSION}" ]; then
echo "ERROR: Could not get version from ghostty binary"
exit 1
fi

GHOSTTY_APPIMAGE="Ghostty-${VERSION}-${ARCH}.AppImage"

cd "${TMP_DIR}"

# create app image
cp "$(command -v uruntime)" ./uruntime
cp "$(command -v uruntime-lite)" ./uruntime-lite

# persist mount for faster launch times
sed -i 's|URUNTIME_MOUNT=[0-9]|URUNTIME_MOUNT=0|' ./uruntime-lite
(
cd "ghostty-${GHOSTTY_VERSION}"
zig build ${BUILD_ARGS}
)

# update info
./uruntime-lite --appimage-addupdinfo "${UPINFO}"
export OUTNAME="Ghostty-${GHOSTTY_VERSION}-${ARCH}.AppImage"
export DESKTOP="./ghostty-${GHOSTTY_VERSION}/zig-out/share/applications/com.mitchellh.ghostty.desktop"
export ICON="./ghostty-${GHOSTTY_VERSION}/zig-out/share/icons/hicolor/256x256/apps/com.mitchellh.ghostty.png"

echo "Generating AppImage"
./uruntime --appimage-mkdwarfs -f \
--set-owner 0 --set-group 0 \
--no-history --no-create-timestamp \
--compression zstd:level=22 -S26 -B8 \
--header uruntime-lite -i "${APP_DIR}" \
-o "${GHOSTTY_APPIMAGE}"
./quick-sharun ./ghostty-${GHOSTTY_VERSION}/zig-out/bin/ghostty
./uruntime2appimage

echo "Generating Zsync file"
zsyncmake ./*.AppImage -u ./*.AppImage
mkdir -p ./dist
mv -v ./*.AppImage* ./dist
69 changes: 21 additions & 48 deletions setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -19,43 +19,35 @@ ARCH="$(uname -m)"
ZIG_VERSION="${ZIG_VERSION:-0.13.0}"
PANDOC_VERSION="$(get_latest_gh_release 'jgm/pandoc')"
MINISIGN_VERSION="$(get_latest_gh_release 'jedisct1/minisign')"
SHARUN_VERSION="$(get_latest_gh_release 'VHSgunzo/sharun')"
URUNTIME_VERSION="$(get_latest_gh_release 'VHSgunzo/uruntime')"

GITHUB_BASE="https://github.com"
PANDOC_BASE="${GITHUB_BASE}/jgm/pandoc/releases/download/${PANDOC_VERSION}"
MINISIGN_URL="${GITHUB_BASE}/jedisct1/minisign/releases/download/${MINISIGN_VERSION}/minisign-${MINISIGN_VERSION}-linux.tar.gz"
URUNTIME_URL="${GITHUB_BASE}/VHSgunzo/uruntime/releases/download/${URUNTIME_VERSION}/uruntime-appimage-dwarfs-${ARCH}"
URUNTIME_LITE_URL="${GITHUB_BASE}/VHSgunzo/uruntime/releases/download/${URUNTIME_VERSION}/uruntime-appimage-dwarfs-lite-${ARCH}"
LLVM_BASE="${GITHUB_BASE}/pkgforge-dev/llvm-libs-debloated/releases/download/continuous"

GH_BASE="https://github.com"
GH_USER_CONTENT="https://raw.githubusercontent.com"

PANDOC_BASE="${GH_BASE}/jgm/pandoc/releases/download/${PANDOC_VERSION}"
MINISIGN_URL="${GH_BASE}/jedisct1/minisign/releases/download/${MINISIGN_VERSION}/minisign-${MINISIGN_VERSION}-linux.tar.gz"
ZIG_URL="https://ziglang.org/download/${ZIG_VERSION}/zig-linux-${ARCH}-${ZIG_VERSION}.tar.xz"
SHARUN_URL="${GITHUB_BASE}/VHSgunzo/sharun/releases/download/${SHARUN_VERSION}/sharun-${ARCH}"
LD_PRELOAD_OPEN="${GITHUB_BASE}/fritzw/ld-preload-open.git"

DEBLOATED_PKGS="${GH_USER_CONTENT}/pkgforge-dev/Anylinux-AppImages/refs/heads/main/useful-tools/get-debloated-pkgs.sh"
SHARUN="${GH_USER_CONTENT}/pkgforge-dev/Anylinux-AppImages/refs/heads/main/useful-tools/quick-sharun.sh"
URUNTIME="${GH_USER_CONTENT}/pkgforge-dev/Anylinux-AppImages/refs/heads/main/useful-tools/uruntime2appimage.sh"

case "${ARCH}" in
"x86_64")
PANDOC_URL="${PANDOC_BASE}/pandoc-${PANDOC_VERSION}-linux-amd64.tar.gz"
LLVM_URL="${LLVM_BASE}/llvm-libs-nano-x86_64.pkg.tar.zst"
LIBXML_URL="${LLVM_BASE}/libxml2-iculess-x86_64.pkg.tar.zst"
MESA_URL="${LLVM_BASE}/mesa-mini-x86_64.pkg.tar.zst"
;;
"aarch64")
PANDOC_URL="${PANDOC_BASE}/pandoc-${PANDOC_VERSION}-linux-arm64.tar.gz"
LLVM_URL="${LLVM_BASE}/llvm-libs-nano-aarch64.pkg.tar.xz"
LIBXML_URL="${LLVM_BASE}/libxml2-iculess-aarch64.pkg.tar.xz"
MESA_URL="${LLVM_BASE}/mesa-mini-aarch64.pkg.tar.xz"
;;
*)
echo "Unsupported ARCH: '${ARCH}'"
exit 1
;;
esac

# Debloated llvm and libxml2 without libicudata
wget "${LLVM_URL}" -O /tmp/llvm-libs.pkg.tar.zst
wget "${LIBXML_URL}" -O /tmp/libxml2.pkg.tar.zst
wget "${MESA_URL}" -O /tmp/mesa-mini.pkg.tar.zst
pacman -U --noconfirm /tmp/*.pkg.tar.zst
# Install Debloated Pkgs
wget "${DEBLOATED_PKGS}" -O /tmp/get-debloated-pkgs.sh
chmod a+x /tmp/get-debloated-pkgs.sh
sh /tmp/get-debloated-pkgs.sh --add-opengl --prefer-nano gtk4-mini libxml2-mini

# Download & install other dependencies
# zig: https://ziglang.org
Expand All @@ -65,17 +57,6 @@ wget "${ZIG_URL}" -O /tmp/zig-linux.tar.xz
tar -xJf /tmp/zig-linux.tar.xz -C /opt
ln -s "/opt/zig-linux-${ARCH}-${ZIG_VERSION}/zig" /usr/local/bin/zig

# uruntime: https://github.com/VHSgunzo/uruntime
rm -rf /usr/local/bin/uruntime
wget "${URUNTIME_URL}" -O /tmp/uruntime
chmod +x /tmp/uruntime
mv /tmp/uruntime /usr/local/bin/uruntime

rm -rf /usr/local/bin/uruntime-lite
wget "${URUNTIME_LITE_URL}" -O /tmp/uruntime-lite
chmod +x /tmp/uruntime-lite
mv /tmp/uruntime-lite /usr/local/bin/uruntime-lite

# minisign: https://github.com/jedisct1/minisign
rm -rf /usr/local/bin/minisign
wget "${MINISIGN_URL}" -O /tmp/minisign-linux.tar.gz
Expand All @@ -88,21 +69,13 @@ wget "${PANDOC_URL}" -O /tmp/pandoc-linux.tar.gz
tar -xzf /tmp/pandoc-linux.tar.gz -C /tmp
mv /tmp/"pandoc-${PANDOC_VERSION}"/bin/* /usr/local/bin

# sharun: https://github.com/VHSgunzo/sharun
rm -rf /usr/local/bin/sharun
wget "${SHARUN_URL}" -O /usr/local/bin/sharun
chmod +x /usr/local/bin/sharun

# ld-preload-open: https://github.com/fritzw/ld-preload-open
rm -rf /opt/path-mapping.so
git clone "${LD_PRELOAD_OPEN}"
(
cd ld-preload-open
make all
mv ./path-mapping.so ../
)
rm -rf ld-preload-open
mv ./path-mapping.so /opt/path-mapping.so
# Sharun
wget "${SHARUN}" -O quick-sharun
chmod +x quick-sharun

# Sharun
wget "${URUNTIME}" -O uruntime2appimage
chmod +x uruntime2appimage

# Cleanup
pacman -Scc --noconfirm
Expand Down