All your machines, one app. For you and your AI agents: agent sessions, desktops, files, logs and GitHub across your Macs, Linux and Windows machines, with an MCP server.
Linux packages: .deb, .rpm, Arch, AppImage, and the AUR
Adib Hanna36bd6873b914
diff --git a/.github/workflows/release.yml b/.github/workflows/release.ymlindex b67cae5..986e924 100644--- a/.github/workflows/release.yml+++ b/.github/workflows/release.yml@@ -120,15 +120,33 @@ jobs:path: dist/agents- run: chmod +x dist/agents/*- run: scripts/package-linux.sh --skip-agents+ - run: scripts/linux-packages.sh- name: It runs hererun: |tar -xzf dist/Muxin-*-linux-${{ matrix.arch }}.tar.gz -C "$RUNNER_TEMP""$RUNNER_TEMP/Muxin/muxin" --version"$RUNNER_TEMP/Muxin/agents/muxen-agent-linux-${{ matrix.arch }}" hash+ dist/Muxin-*-linux-${{ matrix.arch }}.AppImage --appimage-extract-and-run --version+ # Each package installs with its dependencies on a fresh system, and runs.+ - name: The .deb on Ubuntu+ run: |+ sudo apt-get install -y -qq ./dist/Muxin-*-linux-${{ matrix.arch }}.deb+ muxin --version && muxen --version+ sudo apt-get remove -y -qq muxin+ - name: The .rpm on Fedora+ run: docker run --rm -v "$PWD/dist:/d" fedora:latest sh -c 'dnf install -y -q /d/Muxin-*-linux-${{ matrix.arch }}.rpm && muxin --version'+ - name: The Arch package+ if: matrix.arch == 'x86_64'+ run: docker run --rm -v "$PWD/dist:/d" archlinux:latest sh -c 'sed -i "/^\[options\]/a DisableSandbox" /etc/pacman.conf && pacman -Sy --noconfirm >/dev/null && pacman -U --noconfirm /d/Muxin-*-linux-x86_64.pkg.tar.zst && muxin --version'- uses: actions/upload-artifact@v7with:name: linux-${{ matrix.arch }}- path: dist/Muxin-*-linux-${{ matrix.arch }}.tar.gz+ path: |+ dist/Muxin-*-linux-${{ matrix.arch }}.tar.gz+ dist/Muxin-*-linux-${{ matrix.arch }}.deb+ dist/Muxin-*-linux-${{ matrix.arch }}.rpm+ dist/Muxin-*-linux-${{ matrix.arch }}.pkg.tar.zst+ dist/Muxin-*-linux-${{ matrix.arch }}.AppImageif-no-files-found: error# x64 and Arm, each built on its own kind of machine.diff --git a/README.md b/README.mdindex 04400e1..1dfd794 100644--- a/README.md+++ b/README.md@@ -27,7 +27,12 @@ Agents can also **borrow a machine as a work environment**: an [agent workspace]Download the app from the [latest release](https://github.com/LumaryLabsLLC/muxin/releases/latest):- **macOS** 12 or later, Apple silicon and Intel: `Muxin-<version>-macos.dmg`. Open it and drag Muxin to Applications. It's signed and notarized.-- **Linux** with glibc 2.35 or newer (Ubuntu 22.04, Debian 12, Fedora 36 and later): `Muxin-<version>-linux-x86_64.tar.gz`, or `linux-aarch64` on Arm. Unpack it and run `./Muxin/install.sh`, which installs it for you, no root needed.+- **Linux** with glibc 2.35 or newer (Ubuntu 22.04, Debian 12, Fedora 36, openSUSE Tumbleweed, RHEL 10 and later), for Intel and AMD (`x86_64`) or Arm (`aarch64`):+ - Debian and Ubuntu: `Muxin-<version>-linux-x86_64.deb`, then `sudo apt install ./Muxin-<version>-linux-x86_64.deb`.+ - Fedora, openSUSE and RHEL: `Muxin-<version>-linux-x86_64.rpm`, then `sudo dnf install ./Muxin-<version>-linux-x86_64.rpm` (or `zypper install`).+ - Arch: `yay -S muxin-bin` from the [AUR](https://aur.archlinux.org/packages/muxin-bin), or `Muxin-<version>-linux-x86_64.pkg.tar.zst` with `sudo pacman -U`.+ - Any distribution: `Muxin-<version>-linux-x86_64.AppImage`. Make it executable and run it; it needs no FUSE 2.+ - Or `Muxin-<version>-linux-x86_64.tar.gz`: unpack it and run `./Muxin/install.sh`, which installs it for you, no root needed.- **Windows 11**: `Muxin-<version>-windows-x64-setup.exe`, or `windows-arm64` on Windows on Arm. The installer isn't signed yet, so Windows may say "Windows protected your PC": click **More info**, then **Run anyway**.Or with [Homebrew](https://brew.sh), on macOS and Linux:diff --git a/RELEASING.md b/RELEASING.mdindex 2b0346b..18cacef 100644--- a/RELEASING.md+++ b/RELEASING.md@@ -9,6 +9,10 @@ files in a **draft** GitHub release on this repository to look over and publish.| `Muxin-<version>-macos.dmg` | The app for Apple silicon and Intel Macs (macOS 12 or later), signed with the Developer ID and notarized || `Muxin-<version>-linux-x86_64.tar.gz` | The app for Linux on Intel and AMD (glibc 2.35 or newer: Ubuntu 22.04, Debian 12, Fedora 36 and later), with `install.sh` || `Muxin-<version>-linux-aarch64.tar.gz` | The same for Linux on Arm |+| `Muxin-<version>-linux-<arch>.deb` | Debian and Ubuntu packages (x86_64 and aarch64) |+| `Muxin-<version>-linux-<arch>.rpm` | Fedora, openSUSE and RHEL 10 packages |+| `Muxin-<version>-linux-<arch>.pkg.tar.zst` | Arch packages (`pacman -U`) |+| `Muxin-<version>-linux-<arch>.AppImage` | The app for any distribution, in one file || `Muxin-<version>-windows-x64-setup.exe` | The Windows installer (for the user, no administrator needed) || `Muxin-<version>-windows-x64.zip` | The same, unpacked || `Muxin-<version>-windows-arm64-setup.exe` | The installer for Windows on Arm (which runs the x64 one too, emulated) |@@ -18,7 +22,11 @@ files in a **draft** GitHub release on this repository to look over and publish.Each one carries the agent for every platform (`agents/`), which the appinstalls on the machines it connects to. The Arm builds are made on GitHub'sArm machines (`ubuntu-22.04-arm`, `windows-11-arm`), and each Linux and Windows-build runs its `muxin --version` and agent there before it's kept.+build runs its `muxin --version` and agent there before it's kept. The Linux+packages come from `scripts/linux-packages.sh` (nfpm and appimagetool, pinned+by checksum), and each one is installed on a fresh system first: the .deb on+the runner, the .rpm in Fedora, the Arch package in Arch (x86_64), and the+AppImage run as it is.## Making a release@@ -42,6 +50,7 @@ gh run watch # the build: about 30 minutesgh release view v0.2.0 # the draft and its filesgh release edit v0.2.0 --draft=false # publish itscripts/homebrew.sh 0.2.0 --push # then the Homebrew cask+scripts/aur.sh 0.2.0 --push # and the AUR package```If a job fails for a reason outside the code, like a dropped connection to@@ -60,6 +69,15 @@ it moves up only once the release is published: `scripts/homebrew.sh <version>--push` writes it from the release's `SHA256SUMS.txt`, commits and pushes it.`brew upgrade --cask muxin` gets it from then on.+## The AUR++`yay -S muxin-bin` installs Muxin on Arch from the+[AUR](https://aur.archlinux.org/packages/muxin-bin): a PKGBUILD that unpacks a+release's Linux tarball into `/usr/lib/muxin`, like the release's own Arch+package. `scripts/aur.sh <version> --push` writes the PKGBUILD and `.SRCINFO`+from the release's `SHA256SUMS.txt`, commits and pushes them with your AUR ssh+key, once the release is published.+To try the pipeline without a release, run the workflow by hand (Actions ›release › Run workflow, or `gh workflow run release`). It builds the same filesand keeps them on the run as artifacts.diff --git a/scripts/aur.sh b/scripts/aur.shnew file mode 100755index 0000000..6568808--- /dev/null+++ b/scripts/aur.sh@@ -0,0 +1,123 @@+#!/bin/sh+# Brings Muxin's AUR package (muxin-bin: `yay -S muxin-bin`) up to a+# published release: its PKGBUILD and .SRCINFO, with the release's version and+# the Linux tarballs' checksums from its SHA256SUMS.txt. It installs the app+# like the .pkg.tar.zst on the release does: /usr/lib/muxin, `muxin` and+# `muxen` in /usr/bin, the app menu entry and icon.+#+# scripts/aur.sh 0.5.2 # write it in a clone of the AUR repo and commit+# scripts/aur.sh 0.5.2 --push # and push it (your AUR ssh key)+#+# AUR_DIR=<folder> uses a clone you already have. MUXIN_SUMS_FILE replaces+# the release's checksums (a local test). See RELEASING.md.+set -eu++cd "$(dirname "$0")/.."+usage="usage: scripts/aur.sh <version> [--push]"+version=${1:?$usage}+version=${version#v}+push=+case "${2:-}" in+ --push) push=1 ;;+ "") ;;+ *) echo "$usage" >&2; exit 2 ;;+esac++sums=$(if [ -n "${MUXIN_SUMS_FILE:-}" ]; then cat "$MUXIN_SUMS_FILE"; else gh release download "v$version" -p SHA256SUMS.txt -O -; fi)+sha() { echo "$sums" | awk -v f="$1" '$2 == f || $2 == "*" f { print $1 }'; }+x86_64=$(sha "Muxin-$version-linux-x86_64.tar.gz")+aarch64=$(sha "Muxin-$version-linux-aarch64.tar.gz")+[ -n "$x86_64" ] && [ -n "$aarch64" ] || {+ echo "error: v$version's SHA256SUMS.txt doesn't have the Linux tarballs" >&2+ exit 1+}+release=https://github.com/LumaryLabsLLC/muxin/releases/download/v$version+desc="All your machines in one app, for you and your AI agents"+depends="glibc libxcb libxkbcommon libxkbcommon-x11 vulkan-icd-loader"++aur=${AUR_DIR:-}+if [ -z "$aur" ]; then+ aur=$(mktemp -d)+ # An empty repository the first time: pushing to it creates the package.+ git clone --quiet ssh://[email protected]/muxin-bin.git "$aur" 2>/dev/null || git -C "$aur" init --quiet -b master+ git -C "$aur" remote get-url origin >/dev/null 2>&1 || git -C "$aur" remote add origin ssh://[email protected]/muxin-bin.git+fi++cat > "$aur/PKGBUILD" <<'EOF'+# Maintainer: Adib Hanna <[email protected]>+#+# Muxin (yay -S muxin-bin): written by scripts/aur.sh in+# https://github.com/LumaryLabsLLC/muxin from each release.++pkgname=muxin-bin+pkgver=@VERSION@+pkgrel=1+pkgdesc="@DESC@"+arch=('x86_64' 'aarch64')+url="https://muxin.dev"+license=('Apache-2.0')+depends=(@DEPENDS@)+optdepends=('wayland: to run in a Wayland session'+ 'vulkan-driver: to draw its window (Mesa or your GPU maker'"'"'s)')+provides=('muxin')+conflicts=('muxin')+options=('!strip' '!debug')+source_x86_64=("Muxin-${pkgver}-linux-x86_64.tar.gz::https://github.com/LumaryLabsLLC/muxin/releases/download/v${pkgver}/Muxin-${pkgver}-linux-x86_64.tar.gz")+source_aarch64=("Muxin-${pkgver}-linux-aarch64.tar.gz::https://github.com/LumaryLabsLLC/muxin/releases/download/v${pkgver}/Muxin-${pkgver}-linux-aarch64.tar.gz")+sha256sums_x86_64=('@SHA_X86_64@')+sha256sums_aarch64=('@SHA_AARCH64@')++package() {+ cd "${srcdir}/Muxin"++ # The app, beside the agent builds it sets up on your machines.+ install -Dm755 muxin "${pkgdir}/usr/lib/muxin/muxin"+ install -dm755 "${pkgdir}/usr/lib/muxin/agents"+ install -m755 agents/* "${pkgdir}/usr/lib/muxin/agents/"++ # The command, and its name from before (Muxen).+ install -dm755 "${pkgdir}/usr/bin"+ ln -s /usr/lib/muxin/muxin "${pkgdir}/usr/bin/muxin"+ ln -s /usr/lib/muxin/muxin "${pkgdir}/usr/bin/muxen"++ install -Dm644 muxin.desktop "${pkgdir}/usr/share/applications/muxin.desktop"+ install -Dm644 muxin.png "${pkgdir}/usr/share/icons/hicolor/512x512/apps/muxin.png"+ install -Dm644 LICENSE NOTICE THIRD_PARTY_NOTICES.md -t "${pkgdir}/usr/share/licenses/${pkgname}/"+}+EOF+quoted=$(for d in $depends; do printf "'%s' " "$d"; done | sed 's/ $//')+sed -i.bak -e "s|@VERSION@|$version|" -e "s|@DESC@|$desc|" -e "s|@DEPENDS@|$quoted|" \+ -e "s|@SHA_X86_64@|$x86_64|" -e "s|@SHA_AARCH64@|$aarch64|" "$aur/PKGBUILD"+rm -f "$aur/PKGBUILD.bak"++# What `makepkg --printsrcinfo` writes for that PKGBUILD (no Arch tools needed).+{+ printf 'pkgbase = muxin-bin\n'+ printf '\tpkgdesc = %s\n\tpkgver = %s\n\tpkgrel = 1\n\turl = https://muxin.dev\n' "$desc" "$version"+ printf '\tarch = x86_64\n\tarch = aarch64\n\tlicense = Apache-2.0\n'+ for d in $depends; do printf '\tdepends = %s\n' "$d"; done+ printf '\toptdepends = wayland: to run in a Wayland session\n'+ printf "\toptdepends = vulkan-driver: to draw its window (Mesa or your GPU maker's)\n"+ printf '\tprovides = muxin\n\tconflicts = muxin\n\toptions = !strip\n\toptions = !debug\n'+ for a in x86_64 aarch64; do+ eval "sum=\$$a"+ printf '\tsource_%s = Muxin-%s-linux-%s.tar.gz::%s/Muxin-%s-linux-%s.tar.gz\n' "$a" "$version" "$a" "$release" "$version" "$a"+ printf '\tsha256sums_%s = %s\n' "$a" "$sum"+ done+ printf '\npkgname = muxin-bin\n'+} > "$aur/.SRCINFO"+echo "▸ $aur: muxin-bin $version-1"++cd "$aur"+git add PKGBUILD .SRCINFO+if git diff --cached --quiet; then+ echo "▸ already at $version"+ exit 0+fi+git commit --quiet -m "muxin-bin $version-1"+if [ -n "$push" ]; then+ git push --quiet origin HEAD:master+ echo "▸ pushed: yay -S muxin-bin gets it"+else+ echo "Push it from $aur: git push origin HEAD:master"+fidiff --git a/scripts/linux-packages.sh b/scripts/linux-packages.shnew file mode 100755index 0000000..48b8f99--- /dev/null+++ b/scripts/linux-packages.sh@@ -0,0 +1,193 @@+#!/bin/sh+# Makes Muxin's Linux packages from what scripts/package-linux.sh staged in+# dist/linux/Muxin, for this machine's architecture, next to the tarball:+#+# dist/Muxin-<version>-linux-<arch>.deb Debian, Ubuntu+# dist/Muxin-<version>-linux-<arch>.rpm Fedora, openSUSE, RHEL 10+# dist/Muxin-<version>-linux-<arch>.pkg.tar.zst Arch+# dist/Muxin-<version>-linux-<arch>.AppImage any distribution+#+# The packages put the app in /usr/lib/muxin, `muxin` (and `muxen`, its name+# from before) in /usr/bin, and Muxin in the app menu; they ask for the+# libraries it loads (xcb, xkbcommon, Vulkan) and glibc 2.35 or newer. The+# AppImage carries the same folder and runs without FUSE 2.+#+# nfpm, appimagetool and the AppImage runtime are pinned and checked against+# their SHA-256; they're fetched into target/tools the first time.+set -eu++cd "$(dirname "$0")/.."+version=$(sed -n 's/^version = "\(.*\)"/\1/p' Cargo.toml | head -n1)+arch=$(uname -m)+stage=dist/linux/Muxin+[ -x "$stage/muxin" ] || { echo "error: no app in $stage: run scripts/package-linux.sh first" >&2; exit 1; }++nfpm_version=2.47.0+appimagetool_version=1.9.1+runtime_version=20251108+case $arch in+ x86_64)+ goarch=amd64+ nfpm_sha=0660ca602b2d2d2ae4781a06c692b3eeb9d437ffea05b831d76e41f4a3188783+ appimagetool_sha=ed4ce84f0d9caff66f50bcca6ff6f35aae54ce8135408b3fa33abfc3cb384eb0+ runtime_sha=2fca8b443c92510f1483a883f60061ad09b46b978b2631c807cd873a47ec260d+ nfpm_file=nfpm_${nfpm_version}_Linux_x86_64.tar.gz ;;+ aarch64)+ goarch=arm64+ nfpm_sha=1c0f5f2999b9a974bfb04fdb0cc3306096de530ac5dbb25d739cc5f5219c919c+ appimagetool_sha=f0837e7448a0c1e4e650a93bb3e85802546e60654ef287576f46c71c126a9158+ runtime_sha=00cbdfcf917cc6c0ff6d3347d59e0ca1f7f45a6df1a428a0d6d8a78664d87444+ nfpm_file=nfpm_${nfpm_version}_Linux_arm64.tar.gz ;;+ *) echo "error: no packages for $arch" >&2; exit 1 ;;+esac++tools=target/tools+mkdir -p "$tools"+# fetch <url> <file> <sha256>: downloads once, and only keeps a file that matches.+fetch() {+ if [ -f "$2" ] && echo "$3 $2" | sha256sum -c --status; then+ return+ fi+ curl -fsSL --retry 3 -o "$2.part" "$1"+ echo "$3 $2.part" | sha256sum -c --status || { rm -f "$2.part"; echo "error: $1 doesn't match its checksum" >&2; exit 1; }+ mv "$2.part" "$2"+}+fetch "https://github.com/goreleaser/nfpm/releases/download/v$nfpm_version/$nfpm_file" "$tools/$nfpm_file" "$nfpm_sha"+fetch "https://github.com/AppImage/appimagetool/releases/download/$appimagetool_version/appimagetool-$arch.AppImage" "$tools/appimagetool-$arch.AppImage" "$appimagetool_sha"+fetch "https://github.com/AppImage/type2-runtime/releases/download/$runtime_version/runtime-$arch" "$tools/runtime-$arch" "$runtime_sha"+tar -xzf "$tools/$nfpm_file" -C "$tools" nfpm+chmod +x "$tools/nfpm" "$tools/appimagetool-$arch.AppImage"++# The .deb, .rpm and Arch package, from one description.+config=dist/linux/nfpm.yaml+cat > "$config" <<EOF+name: muxin+arch: $goarch+platform: linux+version: $version+release: 1+section: devel+priority: optional+maintainer: Lumary Labs <[email protected]>+vendor: Lumary Labs LLC+homepage: https://muxin.dev+license: Apache-2.0+description: |-+ All your machines in one app, for you and your AI agents.+ Muxin runs AI coding agents on your Macs, Linux servers and Windows PCs,+ shows their screens, moves files between them and looks after their+ services, from one window or from your agents through MCP.+contents:+ - src: $stage/muxin+ dst: /usr/lib/muxin/muxin+ file_info: { mode: 0755 }+ - src: $stage/agents/+ dst: /usr/lib/muxin/agents/+ file_info: { mode: 0755 }+ - src: /usr/lib/muxin/muxin+ dst: /usr/bin/muxin+ type: symlink+ - src: /usr/lib/muxin/muxin+ dst: /usr/bin/muxen+ type: symlink+ - src: $stage/muxin.desktop+ dst: /usr/share/applications/muxin.desktop+ file_info: { mode: 0644 }+ - src: assets/brand/icon-128.png+ dst: /usr/share/icons/hicolor/128x128/apps/muxin.png+ file_info: { mode: 0644 }+ - src: assets/brand/icon-512.png+ dst: /usr/share/icons/hicolor/512x512/apps/muxin.png+ file_info: { mode: 0644 }+ - src: LICENSE+ dst: /usr/share/doc/muxin/LICENSE+ packager: deb+ - src: NOTICE+ dst: /usr/share/doc/muxin/NOTICE+ packager: deb+ - src: THIRD_PARTY_NOTICES.md+ dst: /usr/share/doc/muxin/THIRD_PARTY_NOTICES.md+ packager: deb+ - src: LICENSE+ dst: /usr/share/licenses/muxin/LICENSE+ packager: rpm+ - src: NOTICE+ dst: /usr/share/licenses/muxin/NOTICE+ packager: rpm+ - src: THIRD_PARTY_NOTICES.md+ dst: /usr/share/licenses/muxin/THIRD_PARTY_NOTICES.md+ packager: rpm+ - src: LICENSE+ dst: /usr/share/licenses/muxin/LICENSE+ packager: archlinux+ - src: NOTICE+ dst: /usr/share/licenses/muxin/NOTICE+ packager: archlinux+ - src: THIRD_PARTY_NOTICES.md+ dst: /usr/share/licenses/muxin/THIRD_PARTY_NOTICES.md+ packager: archlinux+overrides:+ deb:+ depends:+ - libc6 (>= 2.35)+ - libxcb1+ - libxkbcommon0+ - libxkbcommon-x11-0+ - libvulkan1+ recommends:+ - mesa-vulkan-drivers+ - libwayland-client0+ rpm:+ depends:+ - libc.so.6(GLIBC_2.35)(64bit)+ - libxcb.so.1()(64bit)+ - libxkbcommon.so.0()(64bit)+ - libxkbcommon-x11.so.0()(64bit)+ - libvulkan.so.1()(64bit)+ recommends:+ - mesa-vulkan-drivers+ archlinux:+ depends:+ - glibc+ - libxcb+ - libxkbcommon+ - libxkbcommon-x11+ - vulkan-icd-loader+EOF+for packager in deb rpm archlinux; do+ case $packager in+ deb) ext=deb ;;+ rpm) ext=rpm ;;+ archlinux) ext=pkg.tar.zst ;;+ esac+ out=dist/Muxin-$version-linux-$arch.$ext+ "$tools/nfpm" package --config "$config" --packager "$packager" --target "$out" >/dev/null+ echo "Built $out ($(du -h "$out" | cut -f1))"+done++# The AppImage: the same folder, run by AppRun.+appdir=dist/linux/Muxin.AppDir+rm -rf "$appdir"+mkdir -p "$appdir/usr/lib/muxin" "$appdir/usr/share/applications" "$appdir/usr/share/icons/hicolor/512x512/apps" "$appdir/usr/share/doc/muxin"+cp -R "$stage/muxin" "$stage/agents" "$appdir/usr/lib/muxin/"+cp "$stage/muxin.desktop" "$appdir/muxin.desktop"+cp "$stage/muxin.desktop" "$appdir/usr/share/applications/muxin.desktop"+cp assets/brand/icon-512.png "$appdir/muxin.png"+cp assets/brand/icon-512.png "$appdir/usr/share/icons/hicolor/512x512/apps/muxin.png"+ln -s muxin.png "$appdir/.DirIcon"+cp LICENSE NOTICE THIRD_PARTY_NOTICES.md "$appdir/usr/share/doc/muxin/"+cat > "$appdir/AppRun" <<'EOF'+#!/bin/sh+# Muxin's AppImage: the app lives in usr/lib/muxin, beside its agents.+here=$(dirname "$(readlink -f "$0")")+exec "$here/usr/lib/muxin/muxin" "$@"+EOF+chmod +x "$appdir/AppRun"+out=dist/Muxin-$version-linux-$arch.AppImage+# --appimage-extract-and-run: appimagetool is an AppImage itself, and build+# machines (containers, CI) often have no FUSE.+ARCH=$arch "$tools/appimagetool-$arch.AppImage" --appimage-extract-and-run --no-appstream \+ --runtime-file "$tools/runtime-$arch" "$appdir" "$out" > dist/linux/appimagetool.log 2>&1 \+ || { cat dist/linux/appimagetool.log >&2; echo "error: appimagetool failed" >&2; exit 1; }+chmod +x "$out"+echo "Built $out ($(du -h "$out" | cut -f1))"diff --git a/scripts/package-linux.sh b/scripts/package-linux.shindex 5afcc22..ec6b966 100755--- a/scripts/package-linux.sh+++ b/scripts/package-linux.sh@@ -2,7 +2,8 @@# Builds Muxin for Linux and packs it: dist/Muxin-<version>-linux-<arch>.tar.gz,# with the app, the agent builds it sets up on each machine (agents/, made by# scripts/build-agents.sh), a desktop entry and an install.sh that puts it in-# ~/.local for the user.+# ~/.local for the user. scripts/linux-packages.sh then makes the .deb, .rpm,+# Arch package and AppImage from the same folder.## Needs: Rust, and GPUI's libraries (Debian/Ubuntu: libxkbcommon-dev# libxkbcommon-x11-dev libwayland-dev libvulkan-dev libfontconfig-devdiff --git a/src/shell_command.rs b/src/shell_command.rsindex 3bbf114..9826d80 100644--- a/src/shell_command.rs+++ b/src/shell_command.rs@@ -4,7 +4,8 @@//! folder isn't writable) and ~/.local/bin on Linux; on Windows, this//! executable's folder added to the user's PATH. `muxen`, its name from//! before, goes beside it (on Windows, muxen.cmd ships next to muxin.exe).-//! When Homebrew installed the app, its link is the one in the PATH.+//! When Homebrew or a Linux package installed the app, its link is the one in+//! the PATH; an AppImage links the AppImage file, not its temporary mount.use std::path::{Path, PathBuf};@@ -22,8 +23,8 @@ pub struct Status {pub note: Option<String>,/// "other" that install may replace: a link to another copy of Muxin.pub replaceable: bool,- /// Homebrew put it there (`brew install --cask muxin`), and takes it away.- pub homebrew: bool,+ /// Homebrew or the app's Linux package put it there, and takes it away.+ pub managed: bool,}/// Whether `muxin` is in the PATH and runs this copy of Muxin.@@ -51,6 +52,13 @@ pub fn remove() -> Result<Status, String> {}fn this_exe() -> Result<PathBuf, String> {+ // An AppImage runs from a mount that's gone once it quits: the command+ // runs the AppImage file instead.+ if cfg!(target_os = "linux")+ && let Some(file) = std::env::var_os("APPIMAGE").map(PathBuf::from).filter(|f| f.is_file())+ {+ return Ok(std::fs::canonicalize(&file).unwrap_or(file));+ }let exe = std::env::current_exe().map_err(|e| format!("Couldn't tell where Muxin is: {e}"))?;Ok(std::fs::canonicalize(&exe).unwrap_or(exe))}@@ -61,7 +69,8 @@ fn this_exe() -> Result<PathBuf, String> {#[cfg(unix)]fn is_ours(target: &Path) -> bool {let s = target.to_string_lossy();- target.file_name().is_some_and(|n| n == "muxin" || n == "muxen") || s.contains("Muxin.app/") || s.contains("Muxen.app/")+ let name = target.file_name().map(|n| n.to_string_lossy().to_lowercase()).unwrap_or_default();+ name == "muxin" || name == "muxen" || (name.starts_with("muxin") && name.ends_with(".appimage")) || s.contains("Muxin.app/") || s.contains("Muxen.app/")}#[cfg(unix)]@@ -85,16 +94,31 @@ mod imp {link.with_file_name("muxen")}- /// Homebrew's link, when Homebrew installed this copy (`brew install --cask muxin`).- fn homebrew_link(exe: &Path) -> Option<PathBuf> {+ /// Who installed this copy and its link, when that wasn't Muxin: Homebrew+ /// (`brew install --cask muxin`), or the .deb, .rpm or Arch package (the+ /// app in /usr/lib/muxin, the link in /usr/bin).+ #[derive(Clone, Copy, PartialEq, Debug)]+ pub(super) enum Manager {+ Homebrew,+ Package,+ }++ fn managed_link(exe: &Path) -> Option<(PathBuf, Manager)> {+ let runs_this = |link: &Path| std::fs::canonicalize(link).is_ok_and(|r| r == exe);+ if cfg!(target_os = "linux") && exe.starts_with("/usr/lib/muxin") && runs_this(Path::new("/usr/bin/muxin")) {+ return Some((PathBuf::from("/usr/bin/muxin"), Manager::Package));+ }let prefixes = std::env::var_os("HOMEBREW_PREFIX").map(PathBuf::from).into_iter().chain(["/opt/homebrew", "/usr/local", "/home/linuxbrew/.linuxbrew"].map(PathBuf::from));- prefixes.filter(|p| p.join("Caskroom/muxin").is_dir()).map(|p| p.join("bin/muxin")).find(|link| std::fs::canonicalize(link).is_ok_and(|r| r == exe))+ prefixes.filter(|p| p.join("Caskroom/muxin").is_dir()).map(|p| p.join("bin/muxin")).find(|link| runs_this(link)).map(|link| (link, Manager::Homebrew))}pub fn status(exe: &Path) -> Status {- if let Some(link) = homebrew_link(exe) {- let note = Some("Homebrew put it there with the app.".into());- return Status { state: "installed", path: link.display().to_string(), target: Some(exe.display().to_string()), note, replaceable: false, homebrew: true };+ if let Some((link, by)) = managed_link(exe) {+ let note = Some(match by {+ Manager::Homebrew => "Homebrew put it there with the app.",+ Manager::Package => "Muxin's package put it there with the app.",+ });+ return Status { state: "installed", path: link.display().to_string(), target: Some(exe.display().to_string()), note: note.map(Into::into), replaceable: false, managed: true };}match link_path() {Ok(link) => status_at(&link, exe),@@ -115,7 +139,7 @@ mod imp {let resolved = std::fs::canonicalize(&link).ok();let shown = target.as_ref().map(|t| t.display().to_string());let ours = target.as_deref().is_some_and(is_ours);- let other = |note: &str, replaceable| Status { state: "other", path: path.clone(), target: shown.clone(), note: Some(note.into()), replaceable, homebrew: false };+ let other = |note: &str, replaceable| Status { state: "other", path: path.clone(), target: shown.clone(), note: Some(note.into()), replaceable, managed: false };match resolved {Some(r) if r == exe => {// The old name still runs another copy: offer to point it here too.@@ -123,7 +147,7 @@ mod imp {let alias_elsewhere = std::fs::read_link(&alias).is_ok_and(|t| is_ours(&t)) && std::fs::canonicalize(&alias).ok().as_deref() != Some(exe);if alias_elsewhere {let target = std::fs::read_link(&alias).ok().map(|t| t.display().to_string());- return Status { state: "other", path: alias.display().to_string(), target, note: Some("It runs another copy of Muxin.".into()), replaceable: true, homebrew: false };+ return Status { state: "other", path: alias.display().to_string(), target, note: Some("It runs another copy of Muxin.".into()), replaceable: true, managed: false };}Status { state: "installed", path: path.clone(), target: shown.clone(), note: in_path_note(&link), ..Default::default() }}@@ -145,7 +169,7 @@ mod imp {}pub fn install(exe: &Path) -> Result<(), String> {- if homebrew_link(exe).is_some() {+ if managed_link(exe).is_some() {return Ok(());}install_at(&link_path()?, exe)@@ -168,8 +192,10 @@ mod imp {}pub fn remove(exe: &Path) -> Result<(), String> {- if homebrew_link(exe).is_some() {- return Err("Homebrew put it there. It goes when you uninstall Muxin with brew uninstall --cask muxin.".into());+ match managed_link(exe) {+ Some((_, Manager::Homebrew)) => return Err("Homebrew put it there. It goes when you uninstall Muxin with brew uninstall --cask muxin.".into()),+ Some((_, Manager::Package)) => return Err("Muxin's package put it there. It goes when you uninstall the package.".into()),+ None => {}}remove_at(&link_path()?)}@@ -316,6 +342,7 @@ mod tests {assert!(is_ours(Path::new("/Applications/Muxin.app/Contents/MacOS/muxin")));assert!(is_ours(Path::new("/Applications/Muxen.app/Contents/MacOS/muxen")));assert!(is_ours(Path::new("/home/me/.cargo/bin/muxin")));+ assert!(is_ours(Path::new("/home/me/Applications/Muxin-0.5.2-linux-x86_64.AppImage")));assert!(!is_ours(Path::new("/usr/bin/python3")));}diff --git a/src/ui/settings/shell.rs b/src/ui/settings/shell.rsindex ac8f5cc..23e5e7c 100644--- a/src/ui/settings/shell.rs+++ b/src/ui/settings/shell.rs@@ -64,8 +64,8 @@ impl SettingsPage {// Before it asks: macOS shows its own password prompt for /usr/local/bin.st.status.as_ref().filter(|s| s.state == "missing" && cfg!(target_os = "macos")).map(|_| "macOS may ask for your password to add it there.".to_string())});- // Homebrew's link goes when Homebrew uninstalls the app.- let state = st.status.as_ref().filter(|s| !s.homebrew).map(|s| (s.state, s.replaceable));+ // Homebrew's or the package's link goes when they uninstall the app.+ let state = st.status.as_ref().filter(|s| !s.managed).map(|s| (s.state, s.replaceable));let button = match state {Some(("missing", _)) => Some(Button::new("shell-install", "Install").icon("plus").style(ButtonStyle::Primary).loading(st.busy).on_click(cx.listener(|this, _, _, cx| this.run_shell(Some(true), cx)))),Some(("other", true)) => Some(Button::new("shell-replace", "Use this copy").icon("refresh-cw").loading(st.busy).on_click(cx.listener(|this, _, _, cx| this.run_shell(Some(true), cx)))),