#1150273 autopkgtest: unshare does not reuse sbuild tarballs if XDG_CACHE_HOME is set

Package:
autopkgtest
Source:
autopkgtest
Submitter:
David Kalnischkies
Date:
2026-10-07 20:27:03 UTC
Severity:
normal
Tags:
#1150273#5
Date:
2026-10-07 20:25:36 UTC
From:
To:
Hi,

As per subject, if in your environment the variable XDG_CACHE_HOME is
set (and you don't pick a tarball explicitly with -t),
autopkgtest-virt-unshare will not pick up files from the directory
"${XDG_CACHE_HOME}/sbuild" but instead tries to attempt picking tarballs
from "/sbuild" ~ which probably fails, causing the automatic tarball
creation to step in (~ which probably works, but is a waste in this case).

This is due to the way the path is joined as joinpath() is documented
| Calling this method is equivalent to combining the path with each of
| the given pathsegments in turn

which implicitly refers to PurePath() documentation containing this:
| If a segment is an absolute path, all previous segments are ignored
| (like os.path.join())

So, the issue should be easy to resolve (tested locally):
```diff
--- a/virt/autopkgtest-virt-unshare
+++ b/virt/autopkgtest-virt-unshare
@@ -115,7 +115,7 @@ def parse_args():
         xdg_cache_home = pathlib.Path("~/.cache/sbuild").expanduser()
         if "XDG_CACHE_HOME" in os.environ:
             xdg_cache_home = pathlib.Path(os.environ["XDG_CACHE_HOME"]).joinpath(
-                "/sbuild"
+                "sbuild"
             )

         chroots = xdg_cache_home.glob(f"{args.release}-{args.arch}.t*")
```

If joinpath() didn't change behaviour, which seems likely, I presume
this was broken since unshare got implemented, just that it isn't used
much and for many folks the automatic tarball creation probably works
fine; the time/data waste compared to just reusing the cached sbuild
chroot is neglectable for them.

Maybe there should be a (debug) message indicating where autopkgtest
tries to look for tarballs. I did not add one through to not blow up
the diff & as -d and -dd did not activate the existing debug messages
in that code area for me.


If you wonder why this variable is set: guix ships a /etc/profile.d
snippet setting it (and a few more). diffoscope recommends guix.
apt helpfully installed guix for me recently as a new recommends,
subsequently sending me down various rabbit holes investigating
why everything broke for me for 'no reason' in strange ways…
including my own apt testing. APT is so heartless (sometimes).


Best regards

David Kalnischkies