Make the desktop a proper Arch desktop: pacman, sudo, utilities and touch right-click

The KDE desktop package now records every package it ships in pacman's
database and carries a pinned droiddeck repository built from the same
Arch Linux ARM snapshot, so pacman installs software that matches the
desktop's Qt and KDE versions and never upgrades what DroidDeck ships.
sudo, su and sudoedit run commands as root through a small preload, and
pacman hooks refuse to remove or replace DroidDeck's own packages and
remember user installs so they come back after runtime updates.

Adds zip, 7zip, unrar, less, man pages, htop, git, wget, wl-clipboard,
xclip, KCalc, Okular, Filelight, KFind, System Monitor, Elisa and
Discover, pins Kate to the panel, and hides technical menu entries.
Updates KWin to 6.8.1 to match the repository.

A two-finger tap now right-clicks on the desktop, and the Android
clipboard is only pushed into the session when it changed, so files
copied in Dolphin stay pasteable after leaving the app.
This commit is contained in:
maxjivi05 committed 2026-10-27 15:17:15 -04:00
1 parent c9044a27e3
commit 49201e1afa
50 files changed
+1051 -15

No files matched your search

+1 -1
View File
@@ -6,7 +6,7 @@ here=$(cd "$(dirname "$0")" && pwd)
source "$here/kwin.env"
source "$here/mesa.env"
version=$DESKTOP_KWIN_VERSION
source_sha=4bfaf31e29a8f9fdf231dc3bbb9b09b0ce07cae9fee7a01cfc86425ece796258
source_sha=f3d725f81061c1ba97fdef8aeb2101a5c5e03c77f11e9a2abaa1dfed4489d3b6
mirror=https://fl.us.mirror.archlinuxarm.org/aarch64
builder=68B3537F39A313B3E574D06777193F152BDBE6A6
work=$(mktemp -d)
+7 -1
View File
@@ -38,6 +38,12 @@ while read -r entry sum; do
done < "$work/pkglist.txt"
cp -a "$here/overlay/." "$work/root/"
mkdir -p "$work/root/usr/lib/droiddeck"
${CC_AARCH64:-aarch64-linux-gnu-gcc} -shared -fPIC -O2 -Wall -Wextra \
-o "$work/root/usr/lib/droiddeck/libdroiddeck-root.so" "$here/root/root.c" -ldl
${STRIP_AARCH64:-aarch64-linux-gnu-strip} --strip-unneeded "$work/root/usr/lib/droiddeck/libdroiddeck-root.so"
python3 "$here/pacman-db.py" "$work/db" "$pkgs" "$work/pkglist.txt" "$here/runtime-packages.txt" \
"$here/mirror.txt" "${DESKTOP_KDE_RELEASE_TAG:-}" "$work/root" "$out/repo"
if [ -n "${KDE_KWIN_OVERRIDE:-}" ]; then
kwin_package=$(awk '$1 ~ /^extra\/kwin-.*-aarch64\.pkg\.tar\./ {print $1}' "$work/pkglist.txt")
@@ -61,7 +67,7 @@ if [ -d "$work/root/usr/share/locale" ]; then
echo "i18n: $(wc -l < "$out/desktop-kde.i18n.txt") language packs"
fi
rm -rf "$work/root/usr/share/doc" "$work/root/usr/share/man" "$work/root/usr/share/info" \
rm -rf "$work/root/usr/share/doc" "$work/root/usr/share/info" \
"$work/root/usr/share/gtk-doc" "$work/root/usr/include" "$work/root/usr/lib/pkgconfig" \
"$work/root/usr/lib/cmake" "$work/root/usr/share/help"
find "$work/root/usr/share/locale" -mindepth 1 -maxdepth 1 -type d ! -name 'en*' -exec rm -rf {} + 2>/dev/null || true
+1 -1
View File
@@ -1 +1 @@
DESKTOP_KWIN_VERSION=6.8.0
DESKTOP_KWIN_VERSION=6.8.1
+16
View File
@@ -0,0 +1,16 @@
neovim
tmux
screen
rsync
jq
ripgrep
fd
bat
ncdu
btop
fastfetch
lsof
strace
python-pip
nodejs
npm
@@ -0,0 +1,7 @@
[Desktop Entry]
Type=Application
Name=Restore pacman packages
Exec=/usr/share/droiddeck/pacman/restore
NoDisplay=true
OnlyShowIn=KDE;
X-KDE-autostart-phase=2
+20
View File
@@ -0,0 +1,20 @@
#!/bin/bash
dir=/usr/share/droiddeck/pacman
[ -r "$dir/pacman.conf" ] || exec /usr/bin/pacman "$@"
"$dir/prepare" || exit 1
if [ "$(id -u)" = 0 ]; then
letters= install=1
for arg in "$@"; do
case $arg in
--) break ;;
--sync) letters+=S ;;
--search|--info|--clean|--groups|--list|--print|--print-format|--downloadonly|--needed) install=0 ;;
--*) ;;
-*) letters+=${arg#-} ;;
esac
done
case $letters in *S*) ;; *) install=0 ;; esac
case $letters in *[sicglpw]*) install=0 ;; esac
[ "$install" = 1 ] && set -- --needed "$@"
fi
exec /usr/bin/pacman --config "$dir/pacman.conf" "$@"
+32
View File
@@ -0,0 +1,32 @@
#!/bin/bash
login=0 command= shell=
while [ $# -gt 0 ]; do
case $1 in
-|-l|--login) login=1; shift ;;
-c|--command) [ $# -ge 2 ] || { echo "su: option requires an argument -- 'c'" >&2; exit 1; }; command=$2; shift 2 ;;
--command=*) command=${1#*=}; shift ;;
-s|--shell) [ $# -ge 2 ] || { echo "su: option requires an argument -- 's'" >&2; exit 1; }; shell=$2; shift 2 ;;
--shell=*) shell=${1#*=}; shift ;;
-m|-p|--preserve-environment|-P|--pty|-f|--fast) shift ;;
-h|--help) echo "usage: su [-] [-c command] [-s shell] [root]"; exit 0 ;;
-V|--version) echo "DroidDeck su: runs a root shell inside the DroidDeck desktop"; exit 0 ;;
--) shift; break ;;
-*) echo "su: invalid option -- '${1#-}'" >&2; exit 1 ;;
*) break ;;
esac
done
user=${1:-root}
[ $# -gt 0 ] && shift
case $user in
root|0|"$(id -un 2>/dev/null)") ;;
*) echo "su: user $user does not exist or the user entry does not contain all the required fields" >&2; exit 1 ;;
esac
args=()
[ "$login" = 1 ] && args+=(-i)
if [ -n "$shell" ]; then
if [ -n "$command" ]; then exec /usr/local/bin/sudo "${args[@]}" "$shell" -c "$command" "$@"; fi
exec /usr/local/bin/sudo "${args[@]}" "$shell" "$@"
fi
if [ -n "$command" ]; then exec /usr/local/bin/sudo "${args[@]}" -s "$command"; fi
[ "$login" = 1 ] && exec /usr/local/bin/sudo -i
exec /usr/local/bin/sudo -s
+94
View File
@@ -0,0 +1,94 @@
#!/bin/bash
lib=/usr/lib/droiddeck/libdroiddeck-root.so
me=${0##*/}
usage() {
echo "usage: $me [-EHiknsSv] [-u user] [-g group] [-D directory] [--] command [arg ...]"
echo " $me -e file ..."
}
known_user() {
case $1 in
''|root|0|'#0'|"$(id -un 2>/dev/null)"|"#$(id -ru 2>/dev/null)") return 0 ;;
esac
echo "$me: unknown user $1" >&2
exit 1
}
login=0 shell=0 edit=0 background=0 dir=
[ "$me" = sudoedit ] && edit=1
while [ $# -gt 0 ]; do
case $1 in
--) shift; break ;;
-h|--help) usage; exit 0 ;;
-V|--version) echo "DroidDeck sudo: runs commands as root inside the DroidDeck desktop"; exit 0 ;;
-l|--list) echo "User $(id -un 2>/dev/null) may run the following commands on $(uname -n):"; echo " (ALL : ALL) ALL"; exit 0 ;;
-v|--validate|-K|--remove-timestamp) exit 0 ;;
-k|--reset-timestamp) shift; [ $# -eq 0 ] && exit 0 ;;
-i|--login) login=1; shift ;;
-s|--shell) shell=1; shift ;;
-e|--edit) edit=1; shift ;;
-b|--background) background=1; shift ;;
-E|--preserve-env|--preserve-env=*|-H|--set-home|-n|--non-interactive|-S|--stdin|-P|--preserve-groups|-A|--askpass|-B|--bell|-N|--no-update) shift ;;
-u|--user|-g|--group) [ $# -ge 2 ] || { usage >&2; exit 1; }; known_user "$2"; shift 2 ;;
--user=*|--group=*) known_user "${1#*=}"; shift ;;
-u*|-g*) known_user "${1:2}"; shift ;;
-D|--chdir) [ $# -ge 2 ] || { usage >&2; exit 1; }; dir=$2; shift 2 ;;
--chdir=*) dir=${1#*=}; shift ;;
-p|--prompt|-C|--close-from|-r|--role|-t|--type|-T|--command-timeout|-R|--chroot) [ $# -ge 2 ] || { usage >&2; exit 1; }; shift 2 ;;
--prompt=*|--close-from=*|--role=*|--type=*|--command-timeout=*) shift ;;
-[A-Za-z][A-Za-z]*)
flags=${1#-}; shift
split=()
while [ -n "$flags" ]; do
split+=("-${flags:0:1}")
case ${flags:0:1} in
u|g|D|p|C|r|t|T|R) [ -n "${flags:1}" ] && split+=("${flags:1}"); flags= ;;
*) flags=${flags:1} ;;
esac
done
set -- "${split[@]}" "$@"
;;
-*) echo "$me: invalid option -- '${1#-}'" >&2; usage >&2; exit 1 ;;
*) break ;;
esac
done
if [ "$edit" = 1 ]; then
[ $# -gt 0 ] || { usage >&2; exit 1; }
editor=${SUDO_EDITOR:-${VISUAL:-${EDITOR:-nano}}}
exec $editor "$@"
fi
if [ ! -r "$lib" ]; then
echo "$me: $lib is missing; reinstall the desktop from DroidDeck's Desktop page" >&2
exit 1
fi
case ":${LD_PRELOAD:-}:" in
*":$lib:"*) ;;
*) export LD_PRELOAD="$lib${LD_PRELOAD:+:$LD_PRELOAD}" ;;
esac
export SUDO_USER=${SUDO_USER:-$(id -un 2>/dev/null)}
export SUDO_UID=${SUDO_UID:-$(id -ru 2>/dev/null)}
export SUDO_GID=${SUDO_GID:-$(id -rg 2>/dev/null)}
export SUDO_COMMAND="$*"
[ -z "$dir" ] || cd "$dir" || exit 1
target_shell=$(getent passwd "$(id -un 2>/dev/null)" | cut -d: -f7)
target_shell=${target_shell:-/bin/bash}
if [ "$login" = 1 ]; then
cd "${HOME:-/root}" 2>/dev/null
if [ $# -gt 0 ]; then set -- "$target_shell" -l -c "$*"; else set -- "$target_shell" -l; fi
elif [ "$shell" = 1 ]; then
if [ $# -gt 0 ]; then set -- "${SHELL:-$target_shell}" -c "$*"; else set -- "${SHELL:-$target_shell}"; fi
elif [ $# -eq 0 ]; then
usage >&2
exit 1
elif ! command -v "$1" >/dev/null 2>&1; then
echo "$me: $1: command not found" >&2
exit 1
fi
if [ "$background" = 1 ]; then
"$@" &
exit 0
fi
exec "$@"
+1
View File
@@ -0,0 +1 @@
sudo
@@ -0,0 +1,6 @@
[Desktop Entry]
Type=Application
Name=Avahi Zeroconf Browser
Exec=/usr/bin/avahi-discover
Icon=network-wired
NoDisplay=true
@@ -0,0 +1,6 @@
[Desktop Entry]
Type=Application
Name=Avahi SSH Server Browser
Exec=/usr/bin/bssh
Icon=network-wired
NoDisplay=true
@@ -0,0 +1,6 @@
[Desktop Entry]
Type=Application
Name=Avahi VNC Server Browser
Exec=/usr/bin/bvnc
Icon=network-wired
NoDisplay=true
@@ -0,0 +1,6 @@
[Desktop Entry]
Type=Application
Name=Foot Server
Exec=foot --server
Icon=foot
NoDisplay=true
@@ -0,0 +1,6 @@
[Desktop Entry]
Type=Application
Name=Foot Client
Exec=footclient
Icon=foot
NoDisplay=true
@@ -0,0 +1,6 @@
[Desktop Entry]
Type=Application
Name=Hardware Locality lstopo
Exec=lstopo
Icon=hwloc
NoDisplay=true
@@ -0,0 +1,6 @@
[Desktop Entry]
Type=Application
Name=IBus Preferences
Exec=ibus-setup
Icon=ibus-setup
NoDisplay=true
@@ -0,0 +1,6 @@
[Desktop Entry]
Type=Application
Name=Qt V4L2 test Utility
Exec=qv4l2
Icon=qv4l2
NoDisplay=true
@@ -0,0 +1,6 @@
[Desktop Entry]
Type=Application
Name=Qt V4L2 video capture utility
Exec=qvidcap
Icon=qvidcap
NoDisplay=true
@@ -0,0 +1 @@
/dev/null
@@ -0,0 +1 @@
/dev/null
@@ -0,0 +1 @@
/dev/null
@@ -0,0 +1 @@
/dev/null
@@ -0,0 +1 @@
/dev/null
@@ -0,0 +1 @@
/dev/null
@@ -0,0 +1 @@
/dev/null
@@ -0,0 +1 @@
/dev/null
@@ -0,0 +1 @@
/dev/null
@@ -0,0 +1,11 @@
[Trigger]
Operation = Install
Operation = Upgrade
Operation = Remove
Type = Package
Target = *
[Action]
Description = Remembering the packages you installed...
When = PostTransaction
Exec = /usr/share/droiddeck/pacman/remember
@@ -0,0 +1,55 @@
#!/usr/bin/python3
import hashlib
import os
import shutil
import sys
SHARE = "/usr/share/droiddeck/pacman"
LIB = "/var/lib/pacman"
STATE = os.path.join(LIB, "droiddeck-desktop")
def digest(path):
with open(path, "rb") as f:
return hashlib.sha256(f.read()).hexdigest()
def main():
for path in ("/var/cache/pacman/pkg", os.path.join(LIB, "sync"), "/etc/pacman.d/hooks", "/var/log"):
os.makedirs(path, exist_ok=True)
stamp = digest(os.path.join(SHARE, "desktop-packages.txt")) + " " + digest(os.path.join(SHARE, "droiddeck.db"))
try:
with open(STATE) as f:
if f.read().strip() == stamp:
return 0
except OSError:
pass
want = dict(line.split() for line in open(os.path.join(SHARE, "desktop-packages.txt")) if line.strip())
local = os.path.join(LIB, "local")
for entry in os.listdir(local):
desc = os.path.join(local, entry, "desc")
if not os.path.isfile(desc):
continue
name = version = None
with open(desc, encoding="utf-8", errors="replace") as f:
lines = f.read().split("\n")
for i, line in enumerate(lines[:-1]):
if line == "%NAME%":
name = lines[i + 1]
elif line == "%VERSION%":
version = lines[i + 1]
if name in want and version != want[name]:
shutil.rmtree(os.path.join(local, entry))
shutil.copyfile(os.path.join(SHARE, "droiddeck.db"), os.path.join(LIB, "sync", "droiddeck.db"))
with open(STATE + ".tmp", "w") as f:
f.write(stamp + "\n")
os.replace(STATE + ".tmp", STATE)
return 0
if __name__ == "__main__":
try:
sys.exit(main())
except OSError as e:
print(f"error: could not prepare pacman's database: {e}", file=sys.stderr)
sys.exit(1)
@@ -0,0 +1,5 @@
#!/bin/bash
packages=$(tr '\n' ' ')
echo "error: ${packages% } came with DroidDeck, so pacman can't remove or replace it." >&2
echo "error: DroidDeck updates these itself; packages you installed with pacman are yours to change." >&2
exit 1
@@ -0,0 +1,9 @@
#!/bin/bash
dir=/usr/share/droiddeck/pacman
state=/root/.local/share/droiddeck/pacman
mkdir -p "$state"
/usr/bin/pacman --config "$dir/pacman.conf" -Qqe 2>/dev/null | grep -vxF -f "$dir/system-packages.txt" > "$state/packages.txt.tmp"
mv -f "$state/packages.txt.tmp" "$state/packages.txt"
[ -s "$state/restored" ] || sha256sum "$dir/droiddeck.db" | cut -d' ' -f1 > "$state/restored"
rm -f /var/cache/pacman/pkg/*.pkg.tar.* /var/cache/pacman/pkg/*.pkg.tar.*.sig 2>/dev/null
exit 0
@@ -0,0 +1,31 @@
#!/bin/bash
dir=/usr/share/droiddeck/pacman
state=/root/.local/share/droiddeck/pacman
list=$state/packages.txt
log=/root/.cache/droiddeck/pacman-restore.log
[ -s "$list" ] && [ -r "$dir/pacman.conf" ] || exit 0
pacman() { /usr/local/bin/pacman "$@"; }
"$dir/prepare" || exit 0
snapshot=$(sha256sum "$dir/droiddeck.db" | cut -d' ' -f1)
mapfile -t missing < <(grep -vxF -f <(pacman -Qq 2>/dev/null) "$list")
done_for=$(cat "$state/restored" 2>/dev/null)
[ ${#missing[@]} -eq 0 ] && [ "$done_for" = "$snapshot" ] && exit 0
attempt="$snapshot ${missing[*]}"
[ "$(cat "$state/attempted" 2>/dev/null)" = "$attempt" ] && exit 0
echo "$attempt" > "$state/attempted"
mkdir -p "${log%/*}"
notify() { notify-send -a DroidDeck -i system-software-update "$@" 2>/dev/null; }
notify "Restoring your packages" "Reinstalling software you added with pacman after a DroidDeck update."
export LD_PRELOAD="/usr/lib/droiddeck/libdroiddeck-root.so${LD_PRELOAD:+:$LD_PRELOAD}"
{
date
ok=1
[ "$done_for" = "$snapshot" ] || pacman -Su --noconfirm || ok=0
[ ${#missing[@]} -eq 0 ] || pacman -S --needed --noconfirm "${missing[@]}" || ok=0
} >> "$log" 2>&1
if [ "$ok" = 1 ]; then
echo "$snapshot" > "$state/restored"
notify "Packages restored" "Your pacman packages are installed again."
else
notify "Some packages couldn't be restored" "See $log, then try sudo pacman -S in Konsole."
fi
@@ -14,6 +14,14 @@ kickoff.currentConfigGroup = ["Shortcuts"];
kickoff.writeConfig("global", "Alt+F1");
kickoff.currentConfigGroup = ["General"];
kickoff.writeConfig("icon", "distributor-logo-steamdeck");
kickoff.writeConfig("favorites", [
"preferred://browser",
"applications:org.kde.dolphin.desktop",
"applications:org.kde.konsole.desktop",
"applications:org.kde.kate.desktop",
"applications:org.kde.discover.desktop",
"applications:systemsettings.desktop",
]);
panel.addWidget("org.kde.plasma.pager");
@@ -24,6 +32,7 @@ tasks.writeConfig("launchers", [
"preferred://filemanager",
"preferred://browser",
"applications:org.kde.konsole.desktop",
"applications:org.kde.kate.desktop",
]);
panel.addWidget("org.kde.plasma.marginsseparator");
@@ -0,0 +1,11 @@
panels().forEach(function (panel) {
panel.widgets("org.kde.plasma.icontasks").forEach(function (tasks) {
tasks.currentConfigGroup = ["General"];
var launchers = tasks.readConfig("launchers");
if (typeof launchers === "string") launchers = launchers.length ? launchers.split(",") : [];
if (launchers.indexOf("applications:org.kde.kate.desktop") < 0) {
launchers.push("applications:org.kde.kate.desktop");
tasks.writeConfig("launchers", launchers);
}
});
});
+266
View File
@@ -0,0 +1,266 @@
#!/usr/bin/env python3
import base64
import gzip
import hashlib
import io
import os
import re
import subprocess
import sys
import tarfile
import time
REPOS = ("core", "extra", "alarm")
FIELDS = ("NAME", "VERSION", "BASE", "DESC", "URL", "ARCH", "BUILDDATE", "INSTALLDATE", "PACKAGER", "SIZE",
"GROUPS", "LICENSE", "VALIDATION", "REPLACES", "DEPENDS", "OPTDEPENDS", "CONFLICTS", "PROVIDES", "XDATA")
PKGINFO = {"pkgname": "NAME", "pkgbase": "BASE", "pkgver": "VERSION", "pkgdesc": "DESC", "url": "URL",
"builddate": "BUILDDATE", "packager": "PACKAGER", "size": "SIZE", "arch": "ARCH", "license": "LICENSE",
"replaces": "REPLACES", "group": "GROUPS", "conflict": "CONFLICTS", "provides": "PROVIDES",
"depend": "DEPENDS", "optdepend": "OPTDEPENDS", "xdata": "XDATA"}
BLOCKED = re.compile(r"^(sudo|opendoas|doas|mkinitcpio.*|linux|linux-.*|.*-firmware|firmware-.*|grub|uboot-.*|"
r"raspberrypi-.*|archlinuxarm-keyring|pacman|pacman-mirrorlist)$")
ALARM = "http://mirror.archlinuxarm.org/aarch64"
RELEASES = "https://github.com/Droid-Deck/DroidDeck-Components/releases/download"
BUILDER = "68B3537F39A313B3E574D06777193F152BDBE6A6"
def read_entry(path):
fields, key = {}, None
for name in ("desc", "depends"):
file = os.path.join(path, name)
if not os.path.exists(file):
continue
for line in open(file, encoding="utf-8", errors="replace"):
line = line.rstrip("\n")
if line.startswith("%") and line.endswith("%") and len(line) > 2:
key = line.strip("%")
fields[key] = []
elif line == "":
key = None
elif key:
fields[key].append(line)
return fields
def write_fields(fields, order):
out = []
for key in order:
values = fields.get(key)
if values:
out.append("%" + key + "%\n" + "".join(v + "\n" for v in values))
return "\n".join(out)
def dep_name(dep):
return re.split(r"[<>=]", dep, maxsplit=1)[0]
def asset_name(name):
return re.sub(r"[^A-Za-z0-9._-]", ".", name)
def package_members(path):
if path.endswith(".zst"):
data = subprocess.run(["zstd", "-dc", path], check=True, stdout=subprocess.PIPE).stdout
return tarfile.open(fileobj=io.BytesIO(data), mode="r:")
return tarfile.open(path)
def mtree_md5(raw):
sums = {}
for line in gzip.decompress(raw).decode("utf-8", "replace").splitlines():
if not line.startswith("./"):
continue
parts = line.split()
path = re.sub(r"\\([0-7]{3})", lambda m: chr(int(m.group(1), 8)), parts[0][2:])
for part in parts[1:]:
if part.startswith("md5digest="):
sums[path] = part.split("=", 1)[1]
return sums
def local_record(path, installed):
with package_members(path) as tar:
info, mtree, install, files = None, None, None, []
for member in tar:
name = member.name.removeprefix("./")
if name == ".PKGINFO":
info = tar.extractfile(member).read().decode("utf-8", "replace")
elif name == ".MTREE":
mtree = tar.extractfile(member).read()
elif name == ".INSTALL":
install = tar.extractfile(member).read()
elif name in (".BUILDINFO", ".CHANGELOG") or not name:
continue
else:
files.append(name.rstrip("/") + ("/" if member.isdir() else ""))
if info is None or mtree is None:
raise SystemExit(f"{path}: no .PKGINFO or .MTREE")
fields, backup = {}, []
for line in info.splitlines():
if " = " not in line or line.startswith("#"):
continue
key, value = line.split(" = ", 1)
if key == "backup":
backup.append(value)
elif key in PKGINFO:
fields.setdefault(PKGINFO[key], []).append(value)
fields["INSTALLDATE"] = [str(installed)]
fields["VALIDATION"] = ["pgp"]
for dir_ in sorted({f.rsplit("/", 1)[0] + "/" for f in files if "/" in f.rstrip("/")}):
parts = dir_.rstrip("/").split("/")
for i in range(1, len(parts) + 1):
entry = "/".join(parts[:i]) + "/"
if entry not in files:
files.append(entry)
sums = mtree_md5(mtree)
listing = "%FILES%\n" + "".join(f + "\n" for f in sorted(set(files)))
if backup:
listing += "\n%BACKUP%\n" + "".join(f"{b}\t{sums.get(b, '')}\n" for b in backup)
return fields, listing, mtree, install
def fetch(dest, *urls):
for url in urls:
if subprocess.run(["curl", "-fsSL", "--retry", "6", "--retry-delay", "5", "--retry-all-errors",
"-o", dest, url]).returncode == 0:
return
raise SystemExit(f"could not download {os.path.basename(dest)}")
def main():
dbdir, cache, pkglist, runtime_file, mirror_file, tag, root, repo = sys.argv[1:9]
here = os.path.dirname(os.path.abspath(__file__))
installed = int(os.environ.get("SOURCE_DATE_EPOCH", time.time()))
entries = {}
for source, path in [("extra", os.path.join(here, "pins"))] + [(r, os.path.join(dbdir, "x_" + r)) for r in REPOS]:
for entry in sorted(os.listdir(path)):
fields = read_entry(os.path.join(path, entry))
name = fields.get("NAME", [None])[0]
if name and name not in entries:
entries[name] = (source, fields)
by_file = {fields["FILENAME"][0]: name for name, (_, fields) in entries.items()}
runtime = dict(line.split() for line in open(runtime_file) if len(line.split()) == 2)
shipped = {}
for line in open(pkglist):
file = line.split()[0].split("/", 1)[1]
shipped[by_file[file]] = file
local = os.path.join(root, "var/lib/pacman/local")
os.makedirs(local, exist_ok=True)
for name, file in sorted(shipped.items()):
fields, listing, mtree, install = local_record(os.path.join(cache, file), installed)
if fields["NAME"][0] != name:
raise SystemExit(f"{file}: .PKGINFO names {fields['NAME'][0]}, not {name}")
record = os.path.join(local, f"{name}-{fields['VERSION'][0]}")
os.makedirs(record, exist_ok=True)
with open(os.path.join(record, "desc"), "w") as out:
out.write(write_fields(fields, FIELDS))
with open(os.path.join(record, "files"), "w") as out:
out.write(listing)
with open(os.path.join(record, "mtree"), "wb") as out:
out.write(mtree)
if install:
with open(os.path.join(record, "install"), "wb") as out:
out.write(install)
system = set(runtime) | set(shipped)
available = {n for n in entries if not BLOCKED.match(n)} | system
providers = {}
for name in available:
if name in entries:
for p in entries[name][1].get("PROVIDES", []):
providers.setdefault(dep_name(p), name)
satisfied = set(system)
for name in system:
if name in entries:
satisfied.update(dep_name(p) for p in entries[name][1].get("PROVIDES", []))
wanted = [l.strip() for l in open(mirror_file) if l.strip() and not l.startswith("#")]
mirrored, queue = set(), list(wanted)
while queue:
dep = dep_name(queue.pop())
if dep in satisfied:
continue
name = dep if dep in available and dep in entries else providers.get(dep)
if name is None:
raise SystemExit(f"mirror.txt: nothing in the repository provides {dep}")
if name in mirrored or name in system:
continue
mirrored.add(name)
queue.extend(entries[name][1].get("DEPENDS", []))
os.makedirs(repo, exist_ok=True)
for name in sorted(mirrored):
source, fields = entries[name]
file = fields["FILENAME"][0]
dest = os.path.join(repo, asset_name(file))
if not os.path.exists(dest) or hashlib.sha256(open(dest, "rb").read()).hexdigest() != fields["SHA256SUM"][0]:
fetch(dest, f"{ALARM}/{source}/{file}")
if hashlib.sha256(open(dest, "rb").read()).hexdigest() != fields["SHA256SUM"][0]:
raise SystemExit(f"{file}: sha256 differs from the repository database's")
signature = fields.get("PGPSIG", [None])[0]
sig = dest + ".sig"
if signature:
with open(sig, "wb") as out:
out.write(base64.b64decode(signature))
else:
fetch(sig, f"{ALARM}/{source}/{file}.sig")
check = subprocess.run(["gpgv", "--status-fd", "1", "--keyring", os.path.join(here, "archlinuxarm-builder.gpg"),
sig, dest], stdout=subprocess.PIPE, stderr=subprocess.DEVNULL, text=True).stdout
if not re.search(rf"^\[GNUPG:\] VALIDSIG .* {BUILDER}$", check, re.M):
raise SystemExit(f"{file}: no valid Arch Linux ARM Build System signature")
if not signature:
fields["PGPSIG"] = [base64.b64encode(open(sig, "rb").read()).decode()]
os.remove(sig)
print(f"pacman: {len(shipped)} install records, {len(mirrored)} mirrored packages, "
f"{sum(os.path.getsize(os.path.join(repo, asset_name(entries[n][1]['FILENAME'][0]))) for n in mirrored) // 1048576} MiB")
order = ["FILENAME", "NAME", "BASE", "VERSION", "DESC", "GROUPS", "CSIZE", "ISIZE", "MD5SUM", "SHA256SUM", "PGPSIG",
"URL", "LICENSE", "ARCH", "BUILDDATE", "PACKAGER", "REPLACES", "CONFLICTS", "PROVIDES", "DEPENDS",
"OPTDEPENDS", "MAKEDEPENDS", "CHECKDEPENDS", "XDATA"]
buffer = io.BytesIO()
with tarfile.open(fileobj=buffer, mode="w:gz", format=tarfile.GNU_FORMAT) as db:
for name in sorted(available):
if name in entries and (name not in runtime or name in shipped or runtime[name] == entries[name][1]["VERSION"][0]):
fields = dict(entries[name][1])
else:
fields = {"FILENAME": [f"{name}-{runtime[name]}-aarch64.pkg.tar.xz"], "NAME": [name],
"VERSION": [runtime[name]], "ARCH": ["aarch64"]}
if name in mirrored:
fields["FILENAME"] = [asset_name(fields["FILENAME"][0])]
data = write_fields(fields, order).encode()
folder = f"{name}-{fields['VERSION'][0]}"
info = tarfile.TarInfo(folder)
info.type, info.mode, info.mtime = tarfile.DIRTYPE, 0o755, installed
db.addfile(info)
info = tarfile.TarInfo(folder + "/desc")
info.size, info.mode, info.mtime = len(data), 0o644, installed
db.addfile(info, io.BytesIO(data))
with open(os.path.join(repo, "droiddeck.db"), "wb") as out:
out.write(buffer.getvalue())
share = os.path.join(root, "usr/share/droiddeck/pacman")
os.makedirs(os.path.join(share, "hooks"), exist_ok=True)
with open(os.path.join(share, "droiddeck.db"), "wb") as out:
out.write(buffer.getvalue())
with open(os.path.join(share, "system-packages.txt"), "w") as out:
out.write("".join(n + "\n" for n in sorted(system)))
with open(os.path.join(share, "desktop-packages.txt"), "w") as out:
out.write("".join(f"{n} {entries[n][1]['VERSION'][0]}\n" for n in sorted(shipped)))
with open(os.path.join(share, "hooks", "droiddeck-system.hook"), "w") as out:
out.write("[Trigger]\nOperation = Upgrade\nOperation = Remove\nType = Package\n")
out.write("".join(f"Target = {n}\n" for n in sorted(system)))
out.write("\n[Action]\nDescription = Keeping the packages DroidDeck installed...\nWhen = PreTransaction\n"
"Exec = /usr/share/droiddeck/pacman/refuse\nNeedsTargets\nAbortOnFail\n")
server = f"{RELEASES}/{tag}" if tag else f"{RELEASES}/unpublished"
template = open(os.path.join(here, "pacman.conf.in")).read()
with open(os.path.join(share, "pacman.conf"), "w") as out:
out.write(template.replace("@SERVER@", server).replace("@ALARM@", ALARM))
print(f"pacman: repository {server}, {len(available)} packages ({len(system)} installed by DroidDeck)")
if __name__ == "__main__":
main()
+22
View File
@@ -0,0 +1,22 @@
[options]
RootDir = /
DBPath = /var/lib/pacman/
CacheDir = /var/cache/pacman/pkg/
LogFile = /var/log/pacman.log
GPGDir = /etc/pacman.d/gnupg/
HookDir = /etc/pacman.d/hooks/
HookDir = /usr/share/droiddeck/pacman/hooks/
HoldPkg = pacman glibc
Architecture = aarch64
Color
ParallelDownloads = 4
DisableSandbox
SigLevel = Required DatabaseOptional
LocalFileSigLevel = Optional
NoExtract = usr/share/doc/* usr/share/gtk-doc/* usr/share/help/*
[droiddeck]
Server = @SERVER@
CacheServer = @ALARM@/extra
CacheServer = @ALARM@/core
CacheServer = @ALARM@/alarm
+190
View File
@@ -0,0 +1,190 @@
#define _GNU_SOURCE
#include <dlfcn.h>
#include <errno.h>
#include <grp.h>
#include <pwd.h>
#include <sys/stat.h>
#include <sys/syscall.h>
#include <sys/types.h>
#include <unistd.h>
#define REAL(name) static __typeof__(name) *real_##name; if (!real_##name) real_##name = dlsym(RTLD_NEXT, #name)
static uid_t real_uid(void) { return (uid_t)syscall(SYS_getuid); }
static gid_t real_gid(void) { return (gid_t)syscall(SYS_getgid); }
uid_t getuid(void) { return 0; }
uid_t geteuid(void) { return 0; }
gid_t getgid(void) { return 0; }
gid_t getegid(void) { return 0; }
int getresuid(uid_t *r, uid_t *e, uid_t *s) {
if (r) *r = 0;
if (e) *e = 0;
if (s) *s = 0;
return 0;
}
int getresgid(gid_t *r, gid_t *e, gid_t *s) {
if (r) *r = 0;
if (e) *e = 0;
if (s) *s = 0;
return 0;
}
int setuid(uid_t u) { (void)u; return 0; }
int seteuid(uid_t u) { (void)u; return 0; }
int setgid(gid_t g) { (void)g; return 0; }
int setegid(gid_t g) { (void)g; return 0; }
int setreuid(uid_t r, uid_t e) { (void)r; (void)e; return 0; }
int setregid(gid_t r, gid_t e) { (void)r; (void)e; return 0; }
int setresuid(uid_t r, uid_t e, uid_t s) { (void)r; (void)e; (void)s; return 0; }
int setresgid(gid_t r, gid_t e, gid_t s) { (void)r; (void)e; (void)s; return 0; }
int setgroups(size_t n, const gid_t *list) { (void)n; (void)list; return 0; }
int initgroups(const char *user, gid_t group) { (void)user; (void)group; return 0; }
static int owner_result(int rc) {
if (rc != 0 && (errno == EPERM || errno == EINVAL)) {
errno = 0;
return 0;
}
return rc;
}
int chown(const char *path, uid_t u, gid_t g) {
REAL(chown);
return owner_result(real_chown(path, u, g));
}
int lchown(const char *path, uid_t u, gid_t g) {
REAL(lchown);
return owner_result(real_lchown(path, u, g));
}
int fchown(int fd, uid_t u, gid_t g) {
REAL(fchown);
return owner_result(real_fchown(fd, u, g));
}
int fchownat(int dirfd, const char *path, uid_t u, gid_t g, int flags) {
REAL(fchownat);
return owner_result(real_fchownat(dirfd, path, u, g, flags));
}
static struct passwd *as_root_user(struct passwd *pw) {
if (pw && pw->pw_uid == real_uid()) {
pw->pw_uid = 0;
pw->pw_gid = 0;
}
return pw;
}
static struct group *as_root_group(struct group *gr) {
if (gr && gr->gr_gid == real_gid()) gr->gr_gid = 0;
return gr;
}
struct passwd *getpwuid(uid_t uid) {
REAL(getpwuid);
return as_root_user(real_getpwuid(uid == 0 ? real_uid() : uid));
}
struct passwd *getpwnam(const char *name) {
REAL(getpwnam);
return as_root_user(real_getpwnam(name));
}
struct passwd *getpwent(void) {
REAL(getpwent);
return as_root_user(real_getpwent());
}
int getpwuid_r(uid_t uid, struct passwd *pw, char *buf, size_t len, struct passwd **out) {
REAL(getpwuid_r);
int rc = real_getpwuid_r(uid == 0 ? real_uid() : uid, pw, buf, len, out);
if (rc == 0) as_root_user(*out);
return rc;
}
int getpwnam_r(const char *name, struct passwd *pw, char *buf, size_t len, struct passwd **out) {
REAL(getpwnam_r);
int rc = real_getpwnam_r(name, pw, buf, len, out);
if (rc == 0) as_root_user(*out);
return rc;
}
struct group *getgrgid(gid_t gid) {
REAL(getgrgid);
return as_root_group(real_getgrgid(gid == 0 ? real_gid() : gid));
}
struct group *getgrnam(const char *name) {
REAL(getgrnam);
return as_root_group(real_getgrnam(name));
}
int getgrgid_r(gid_t gid, struct group *gr, char *buf, size_t len, struct group **out) {
REAL(getgrgid_r);
int rc = real_getgrgid_r(gid == 0 ? real_gid() : gid, gr, buf, len, out);
if (rc == 0) as_root_group(*out);
return rc;
}
int getgrnam_r(const char *name, struct group *gr, char *buf, size_t len, struct group **out) {
REAL(getgrnam_r);
int rc = real_getgrnam_r(name, gr, buf, len, out);
if (rc == 0) as_root_group(*out);
return rc;
}
static int shown_mode(int rc, struct stat *st) {
if (rc == 0 && S_ISDIR(st->st_mode) && (st->st_mode & 0777) == 0700) st->st_mode = (st->st_mode & ~0777) | 0755;
return rc;
}
int stat(const char *path, struct stat *st) {
REAL(stat);
return shown_mode(real_stat(path, st), st);
}
int lstat(const char *path, struct stat *st) {
REAL(lstat);
return shown_mode(real_lstat(path, st), st);
}
int fstat(int fd, struct stat *st) {
REAL(fstat);
return shown_mode(real_fstat(fd, st), st);
}
int fstatat(int dirfd, const char *path, struct stat *st, int flags) {
REAL(fstatat);
return shown_mode(real_fstatat(dirfd, path, st, flags), st);
}
int statx(int dirfd, const char *path, int flags, unsigned int mask, struct statx *st) {
REAL(statx);
int rc = real_statx(dirfd, path, flags, mask, st);
if (rc == 0 && S_ISDIR(st->stx_mode) && (st->stx_mode & 0777) == 0700) st->stx_mode = (st->stx_mode & ~0777) | 0755;
return rc;
}
int stat64(const char *path, struct stat64 *st) {
REAL(stat64);
return shown_mode(real_stat64(path, st), (struct stat *)st);
}
int lstat64(const char *path, struct stat64 *st) {
REAL(lstat64);
return shown_mode(real_lstat64(path, st), (struct stat *)st);
}
int fstat64(int fd, struct stat64 *st) {
REAL(fstat64);
return shown_mode(real_fstat64(fd, st), (struct stat *)st);
}
int fstatat64(int dirfd, const char *path, struct stat64 *st, int flags) {
REAL(fstatat64);
return shown_mode(real_fstatat64(dirfd, path, st, flags), (struct stat *)st);
}
+20
View File
@@ -26,3 +26,23 @@ noto-fonts-emoji
xdg-utils
firefox
mpv
zip
unzip
7zip
unrar
less
man-db
man-pages
htop
wl-clipboard
xclip
git
wget
kcalc
okular
filelight
kfind
plasma-systemmonitor
elisa
discover
flatpak-kcm
+1 -1
View File
@@ -35,7 +35,7 @@ cat > /usr/share/applications/droiddeck-steam-x64.desktop <<'ENTRY'
Type=Application
Name=Steam x86-64 (FEX, experimental)
Comment=Valve's x86-64 Linux client under FEX, in its own home with its own login
Exec=qterminal -e /usr/local/bin/droiddeck-steam-x64
Exec=konsole -e /usr/local/bin/droiddeck-steam-x64
Icon=steam
Categories=System;
ENTRY