Resolve config, state and work dirs via XDG paths #4
Loading…
Reference in a new issue
No description provided.
Delete branch "worktree-xdg-paths"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Why
First step toward pkgwatch managing itself from its own Forgejo releases: an installed
/usr/bin/pkgwatchhas no checkout to run from, sopackages.d/,state/andwork/can't be relative to the working directory.What
New
src/paths.rs: resolves the three directories per the XDG base-directory spec. The environment lookup is injectable, so the tests don't touch the real environment.~/.config/pkgwatch/packages.dPKGWATCH_CONFIG_DIR(the dir containingpackages.d)~/.local/state/pkgwatchPKGWATCH_STATE_DIR~/.cache/pkgwatchPKGWATCH_WORK_DIRPrecedence per directory: override, then the XDG variable (
XDG_CONFIG_HOME,XDG_STATE_HOME,XDG_CACHE_HOME), then the default under$HOME. Empty variables count as unset. Overrides are used verbatim (nopkgwatch/suffix) and exist for dry runs against scratch dirs, likePKGWATCH_REPO_DIRdoes for the pacman repo. RelativeXDG_*values are ignored, as the XDG spec requires, and a relative$HOMEis an error; honoring either would bring back the cwd dependence this PR removes.pipeline.rs:run_checkandrun_reviewusePathsinstead of the hardcoded relative constants. A missing config dir now fails with a hint namingPKGWATCH_CONFIG_DIRand the SPEC's migration notes.systemd/pkgwatch.service: dropsWorkingDirectory, which is now redundant. The unit still runs the release binary from the checkout.docs/SPEC.md: documents the paths table, precedence and migration steps.This branch also merges in master after #3, with two trivial import-line conflicts.
Behaviour change
Plain
cargo runin the repo no longer reads./packages.dor./state. The checkout'spackages.d/is now just the source to link from, not read on its own. With no config in place it fails withno package config at ~/.config/pkgwatch/packages.d (set PKGWATCH_CONFIG_DIR ...). The systemd timer will fail on every run until the XDG dirs are set up, and you'll get the failure notification.Migration is deliberately deferred until the remaining self-hosting features are in. When it happens, from the old checkout:
Skipping the state copy would make every package look new, including the pending scaleway-cli review.
work/is cache and can be dropped.Testing
cargo fmt --check,cargo clippy --all-targets -- -D warningsand the complexity lint are clean. 99 tests pass, 8 of them new forpaths(including relative-XDG and relative-HOME cases), in 20 of 20 runs.systemd-analyze verify --useris clean. I ran the built binary from/against scratch dirs, andreviewfound a pending entry there. I did not run a full check, which would publish for real. A single-agent review found no blocking bugs; its relative-path finding and doc nits are addressed in the last commit.Not changed
pipeline::custom_repo_dirstill resolvesPKGWATCH_REPO_DIRandHOMEitself, and.gitignorestill lists/stateand/work; both are harmless and left for a later cleanup.Next
Forgejo release source, release workflow and
packages.d/pkgwatch.toml(items 1-3 of the self-hosting plan).🤖 Generated with Claude Code
An installed pkgwatch has no checkout to run from, so packages.d/, state/ and work/ can no longer be relative to the working directory. New paths module resolves them per the XDG base-directory spec, with PKGWATCH_{CONFIG,STATE,WORK}_DIR overrides for dry runs. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>