# Copyright 2026 Gentoo Authors # Distributed under the terms of the GNU General Public License v2 EAPI=8 inherit desktop unpacker xdg MY_PN="${PN/-bin/}" # Upstream package release (patrickjaja/claude-desktop-bin tag suffix) MY_PKGREL="2" DESCRIPTION="Claude Desktop - AI assistant application for Linux (unofficial)" HOMEPAGE="https://claude.ai https://github.com/patrickjaja/claude-desktop-bin" SRC_URI="https://github.com/patrickjaja/claude-desktop-bin/releases/download/v${PV}-${MY_PKGREL}/${PN}_${PV}-${MY_PKGREL}_amd64.deb" S="${WORKDIR}" LICENSE="all-rights-reserved" SLOT="0" KEYWORDS="-* ~amd64" RESTRICT="mirror strip bindist" RDEPEND=" >=app-accessibility/at-spi2-core-2.46.0:2 dev-libs/expat dev-libs/glib:2 dev-libs/nspr dev-libs/nss media-libs/alsa-lib media-libs/mesa net-print/cups sys-apps/dbus x11-libs/cairo x11-libs/gdk-pixbuf:2 x11-libs/gtk+:3 x11-libs/libdrm x11-libs/libX11 x11-libs/libxcb x11-libs/libXcomposite x11-libs/libXdamage x11-libs/libXext x11-libs/libXfixes x11-libs/libxkbcommon x11-libs/libXrandr x11-libs/pango x11-misc/xdg-utils " QA_PREBUILT="*" src_install() { # .deb places electron + app in usr/lib/claude-desktop/ — install to /opt/claude-desktop/ mkdir -p "${ED}/opt/${MY_PN}" || die cp -r "${S}/usr/lib/${MY_PN}/"* "${ED}/opt/${MY_PN}" || die # Chrome sandbox: setuid root with restricted permissions (Electron pattern) if [[ -f "${ED}/opt/${MY_PN}/chrome-sandbox" ]]; then fperms 4755 "/opt/${MY_PN}/chrome-sandbox" fi # Wrapper script with Wayland and proxy support cat > "${T}/${MY_PN}" <<-'WRAPPER' || die #!/bin/bash INSTALL_DIR="/opt/claude-desktop" export ELECTRON_OZONE_PLATFORM_HINT="${ELECTRON_OZONE_PLATFORM_HINT:-auto}" # Proxy support PROXY_ARGS="" PROXY_URL="${https_proxy:-${HTTPS_PROXY:-${http_proxy:-${HTTP_PROXY:-}}}}" NO_PROXY_LIST="${no_proxy:-${NO_PROXY:-}}" if [ -n "$PROXY_URL" ]; then PROXY_ARGS="--proxy-server=$PROXY_URL" [ -n "$NO_PROXY_LIST" ] && PROXY_ARGS="$PROXY_ARGS --proxy-bypass-list=$NO_PROXY_LIST" fi exec "$INSTALL_DIR/electron" \ "$INSTALL_DIR/resources/app.asar" \ ${WAYLAND_DISPLAY:+--enable-features=WaylandWindowDecorations} \ $PROXY_ARGS "$@" WRAPPER dobin "${T}/${MY_PN}" # Desktop file - prefer upstream, fallback to generated if [[ -f "${S}/usr/share/applications/${MY_PN}.desktop" ]]; then sed -i \ -e "s|Exec=.*|Exec=${MY_PN} %U|g" \ -e "s|Icon=.*|Icon=${MY_PN}|g" \ "${S}/usr/share/applications/${MY_PN}.desktop" || die domenu "${S}/usr/share/applications/${MY_PN}.desktop" else make_desktop_entry "${MY_PN}" "Claude Desktop" "${MY_PN}" "Office;Utility;Chat;" fi # Icons (upstream provides 256x256) local size icon_path for size in 16 24 32 48 64 128 256 512; do icon_path="${S}/usr/share/icons/hicolor/${size}x${size}/apps/${MY_PN}.png" if [[ -f "${icon_path}" ]]; then newicon -s ${size} "${icon_path}" ${MY_PN}.png fi done } pkg_postinst() { xdg_pkg_postinst elog "Claude Desktop has been installed to /opt/${MY_PN}" elog "" elog "To launch: ${MY_PN}" elog "" elog "This is an unofficial community port of Claude Desktop" elog "for Linux. It is not officially supported by Anthropic." elog "" elog "Upstream: https://github.com/patrickjaja/claude-desktop-bin" elog "Official: https://claude.ai" }