Repository navigation
Detect damaged package records before updating - #11478
yashranaway wants to merge 8 commits into
Conversation
Automated AI review
Outcome: The new stop message gives no working repair for the records it catches, so every later The stop message gives no working repairThe message does not say how to restore the entry. With Suggested change: print the sequence that worked in testing for each damaged record: Reproducer (pacman 7.1.0, throwaway root)For a package that no repository has, the same sequence worked in testing with What the stop message ("Restore this package's database entry and reinstall it before retrying omarchy update.") takes in practice, on a throwaway pacman root. It needs Reviewed head: a886c18. Run with pacman v7.1.0 (libalpm v16.0.1) and fakeroot 1.37.2. #!/bin/bash
# What "restore this package's database entry and reinstall it" takes, on a
# throwaway pacman root. Needs pacman, fakeroot, bsdtar and repo-add; writes only
# inside a temporary directory and never touches the system database.
set -u
lab=$(mktemp -d)
trap 'rm -rf "$lab"' EXIT
mkdir -p "$lab"/{root,db,cache,gpg,hooks,log,repo}
cat >"$lab/pacman.conf" <<EOF
[options]
RootDir = $lab/root
DBPath = $lab/db
CacheDir = $lab/cache
LogFile = $lab/log/pacman.log
GPGDir = $lab/gpg
HookDir = $lab/hooks
Architecture = auto
SigLevel = Never
[lab]
Server = file://$lab/repo
EOF
: >"$lab/fakeroot.state"
pm() {
fakeroot -i "$lab/fakeroot.state" -s "$lab/fakeroot.state" -- \
pacman --config "$lab/pacman.conf" --noconfirm "$@"
}
show() {
printf '$ pacman'
printf ' %q' "$@"
echo
pm "$@" 2>&1 | grep -E '^(error|demo:|No database errors|reinstalling|installing)'
echo "exit=${PIPESTATUS[0]}"
}
# A package "demo" with two files, in a local repository.
pkg=$lab/build
mkdir -p "$pkg/usr/share/demo"
yes payload | head -c 65536 >"$pkg/usr/share/demo/snapshot.bin"
echo notes >"$pkg/usr/share/demo/notes.txt"
cat >"$pkg/.PKGINFO" <<EOF
pkgname = demo
pkgver = 1.0-1
pkgdesc = demo
builddate = 1700000000
packager = demo
size = 65542
arch = any
EOF
(cd "$pkg" && bsdtar -czf "$lab/repo/demo-1.0-1-any.pkg.tar.gz" --uid 0 --gid 0 .PKGINFO usr)
repo-add -q "$lab/repo/lab.db.tar.gz" "$lab/repo/demo-1.0-1-any.pkg.tar.gz"
pm -Sy >/dev/null 2>&1 && pm -S demo >/dev/null 2>&1 || { echo "setup failed"; exit 1; }
record=$lab/db/local/demo-1.0-1
echo "## 1. The #11316 shape: empty desc and files, truncated payload"
: >"$record/desc"
: >"$record/files"
: >"$lab/root/usr/share/demo/snapshot.bin"
show -Dk
echo
echo "## 2. Reinstalling it, as the message says"
show -S demo
echo
echo "## 3. Rewriting the record first, then reinstalling"
show -S --dbonly demo
show -S demo
echo "snapshot.bin is $(stat -c %s "$lab/root/usr/share/demo/snapshot.bin") bytes again"
echo
echo "## 4. desc and files missing (interrupted before pacman wrote them)"
rm "$record/desc" "$record/files"
show -S --dbonly demo
show -S --overwrite '*' demo
echo
echo "## 5. Removing the record, then rewriting it and reinstalling"
echo "\$ rm -r $record"
rm -r "$record"
show -S --dbonly demo
show -S demo
show -DkActual output: Exit status of the script: 0 (stderr empty). Sections 2 and 4 are the literal "reinstall it" and the obvious variants; sections 3 and 5 are what works. More findings: a damaged
|
|
Moved the check before keyring updates, report every damaged record, and added manual backup/repair/reinstall steps. Database and update-boundary regressions pass; the CLI suite hits the same VS Code assertion on base. |
[High impact] The PR appears safe to merge; no outstanding findings or new actionable issues were identified. SummaryThe PR adds a read-only check for missing or empty local package descriptions and missing file-list records. It runs before update preparation and when the package-update command is invoked directly, stopping on damage and printing manual repair guidance. Both previous findings were addressed, and their threads are resolved.
|
|
Thanks, the repair steps read well now. This conflicts with |
# Conflicts: # test/shell.d/fixtures/sudo-boundary-test.sh
|
I merged current quattro and resolved the test conflict at 5f930ac. I kept both checks because the keyring update uses pacman before the system-package step, while that step can also run directly. A damaged record stops at the first check, so the report prints once. The focused update tests pass. |
Stops updates when an interrupted package transaction has left empty or missing database records. Addresses #11316.
<<<< AI wording below >>>>
Problem
After an interrupted package transaction, a local package record can have an empty
descfile. Pacman can accept that state and let a later update complete while the package remains damaged.Addresses the damaged database records reported in #11316.
Fix
Check the configured local package database before pruning, snapshots or keyring installation, and when the package-update command runs directly. Report every missing or empty description and missing file-list record. Empty file lists remain valid. Print manual backup, database repair and reinstall commands without changing any records automatically. This does not detect every damaged installed payload or truncated file list.
Verification
bash test/shell.d/update-package-database-test.shpasses. Changed Bash files pass syntax checks andgit diff --checkpasses. Update sequencing, locking, disk-space, conflict handling and user-PATH regressions also pass. The CLI suite stops at the same VS Code theme assertion on this branch and the unmodified base.Review follow-up, 1 October
Unreadable or nontraversable database records stop verification. Repair instructions restore a known dependency install reason and explicitly report when that metadata is missing.
Focused regressions, command metadata, Bash syntax, and diff checks pass. Hardware and live Hyprland behavior were not exercised on this host.