Skip to content

Instantly share code, notes, and snippets.

@pansapiens
Created June 6, 2026 03:12
Show Gist options
  • Select an option

  • Save pansapiens/57d08c6ff616e4b2bced300dc5449d46 to your computer and use it in GitHub Desktop.

Select an option

Save pansapiens/57d08c6ff616e4b2bced300dc5449d46 to your computer and use it in GitHub Desktop.
Build a Debian/Ubuntu package for Antigravity IDE 2.x
#!/bin/bash
set -euo pipefail
# Allow overriding the package version and URL via environment variables
VERSION="${VERSION:-}"
URL="${URL:-}"
if [ -z "${VERSION}" ] || [ -z "${URL}" ]; then
echo "Attempting to dynamically fetch latest version and URL..."
if HTML_CONTENT=$(curl -s -L -f --compressed "https://antigravity.google/download"); then
if JS_FILE=$(echo "${HTML_CONTENT}" | grep -o -E "main-[a-zA-Z0-9_.-]+\.js" | head -n 1); then
if FETCHED_URL=$(curl -s -L -f --compressed "https://antigravity.google/${JS_FILE}" | grep -o -E "https://[^\"'>[:space:]]+/linux-x64/Antigravity(%20| )IDE\.tar\.gz" | head -n 1); then
FETCHED_URL="${FETCHED_URL// /%20}"
if [[ "${FETCHED_URL}" =~ /stable/([^/]+)/linux-x64/ ]]; then
DIR_VERSION="${BASH_REMATCH[1]}"
FETCHED_VERSION="${DIR_VERSION%%-*}"
if [ -z "${VERSION}" ]; then
VERSION="${FETCHED_VERSION}"
fi
if [ -z "${URL}" ]; then
URL="${FETCHED_URL}"
fi
echo "Successfully fetched version: ${VERSION}"
echo "Fetched URL: ${URL}"
fi
fi
fi
fi
fi
# Fallback to default values if not successfully set
if [ -z "${VERSION}" ] || [ -z "${URL}" ]; then
echo "Dynamic fetch failed or was bypassed. Using hardcoded fallbacks."
VERSION="${VERSION:-2.0.4}"
URL="${URL:-https://edgedl.me.gvt1.com/edgedl/release2/j0qc3/antigravity/stable/2.0.4-6381998290370560/linux-x64/Antigravity%20IDE.tar.gz}"
fi
WORKSPACE_DIR="/home/perry/Desktop/software/Antigravity_IDE"
BUILD_DIR="${WORKSPACE_DIR}/build_temp"
# Clean up any existing directory from previous aborted builds
if [ -d "${BUILD_DIR}" ]; then
rm -rf "${BUILD_DIR}"
fi
# Create package staging directory structures
mkdir -p "${BUILD_DIR}/extracted"
mkdir -p "${BUILD_DIR}/pkg/DEBIAN"
mkdir -p "${BUILD_DIR}/pkg/opt/antigravity-ide"
mkdir -p "${BUILD_DIR}/pkg/usr/share/applications"
mkdir -p "${BUILD_DIR}/pkg/usr/share/pixmaps"
mkdir -p "${BUILD_DIR}/pkg/usr/bin"
echo "Downloading Antigravity IDE..."
curl -L -o "${BUILD_DIR}/Antigravity_IDE.tar.gz" "${URL}"
echo "Extracting archive..."
tar -xzf "${BUILD_DIR}/Antigravity_IDE.tar.gz" -C "${BUILD_DIR}/extracted"
# Dynamically locate the main application directory to avoid hardcoding naming variations
EXTRACTED_DIR=$(find "${BUILD_DIR}/extracted" -maxdepth 2 -type f -name "antigravity-ide" -exec dirname {} \; | head -n 1)
if [ -z "${EXTRACTED_DIR}" ]; then
echo "Error: Could not locate antigravity-ide binary in extracted archive." >&2
exit 1
fi
echo "Copying application files..."
cp -r "${EXTRACTED_DIR}"/* "${BUILD_DIR}/pkg/opt/antigravity-ide/"
echo "Copying icon..."
cp "${BUILD_DIR}/pkg/opt/antigravity-ide/resources/app/resources/linux/code.png" "${BUILD_DIR}/pkg/usr/share/pixmaps/antigravity-ide.png"
echo "Creating CLI symlink..."
ln -s "/opt/antigravity-ide/bin/antigravity-ide" "${BUILD_DIR}/pkg/usr/bin/antigravity-ide"
echo "Creating desktop entry..."
cat << 'EOF' >"${BUILD_DIR}/pkg/usr/share/applications/antigravity-ide.desktop"
[Desktop Entry]
Name=Antigravity IDE
Comment=Antigravity Code Editor
GenericName=Text Editor
Exec=/opt/antigravity-ide/antigravity-ide %F
Icon=antigravity-ide
Type=Application
StartupNotify=true
StartupWMClass=antigravity-ide
Categories=Utility;TextEditor;Development;IDE;
MimeType=text/plain;inode/directory;
Actions=new-empty-window;
[Desktop Action new-empty-window]
Name=New Empty Window
Exec=/opt/antigravity-ide/antigravity-ide --new-window %F
Icon=antigravity-ide
EOF
echo "Creating DEBIAN/control..."
cat << EOF >"${BUILD_DIR}/pkg/DEBIAN/control"
Package: antigravity-ide
Version: ${VERSION}
Section: devel
Priority: optional
Architecture: amd64
Depends: libasound2, libatk1.0-0, libc6, libcairo2, libcups2, libdbus-1-3, libexpat1, libfontconfig1, libfreetype6, libgbm1, libglib2.0-0, libgtk-3-0, libnspr4, libnss3, libpango-1.0-0, libpangocairo-1.0-0, libsecret-1-0, libx11-6, libx11-xcb1, libxcb1, libxcomposite1, libxcursor1, libxdamage1, libxext6, libxfixes3, libxi6, libxrandr2, libxrender1, libxss1, libxtst6, libgl1
Maintainer: Antigravity IDE Team <support@antigravity.google>
Description: Antigravity IDE - Code Editor
A powerful agentic AI coding assistant and IDE.
EOF
# The postinst script is run as root by the package manager during installation.
# This allows us to set setuid on the chrome-sandbox binary.
echo "Creating DEBIAN/postinst..."
cat << 'EOF' >"${BUILD_DIR}/pkg/DEBIAN/postinst"
#!/bin/bash
set -e
# Make chrome-sandbox setuid root to enable Chromium's SUID sandbox
if [ -f "/opt/antigravity-ide/chrome-sandbox" ]; then
chown root:root "/opt/antigravity-ide/chrome-sandbox"
chmod 4755 "/opt/antigravity-ide/chrome-sandbox"
fi
# Ensure executable permissions on essential binaries
chmod +x "/opt/antigravity-ide/antigravity-ide"
chmod +x "/opt/antigravity-ide/chrome_crashpad_handler"
chmod +x "/opt/antigravity-ide/bin/antigravity-ide"
# Update Gnome desktop entries cache
if [ -x "$(command -v update-desktop-database)" ]; then
update-desktop-database -q
fi
EOF
# Make postinst executable so dpkg can run it
chmod 755 "${BUILD_DIR}/pkg/DEBIAN/postinst"
# Build the package. We use --root-owner-group so the built archive structure is
# owned by root:root rather than the local building user.
echo "Building deb package..."
dpkg-deb --root-owner-group --build "${BUILD_DIR}/pkg" "${WORKSPACE_DIR}/antigravity-ide_${VERSION}_amd64.deb"
# Clean up build artifacts
rm -rf "${BUILD_DIR}"
echo "Build complete: ${WORKSPACE_DIR}/antigravity-ide_${VERSION}_amd64.deb"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment