A directory node of the store, the root included, stats as a directory, but
a get on it falls through to the key lookup below its parent and fails with
a FileNotFoundError naming a path the caller never asked for: get() on the
root fails with an empty name, get() on a branch with its parent's compound
path.
Raise IsADirectoryError from _get() when the path is a directory on the
host, after the compound and the blob lookups, so get() and stat() agree: a
directory stats as FT_DIR and refuses a get.
Assisted-by: unsloth/Qwen3.8-27B-GGUF:Q4_K_M with pi.dev v1.5.0
Signed-off-by: Jan Lindemann <jan@janware.com>
KvFile.__init__() accepts a host FileContext plus an optional Distro, and
the two may live on different hosts. In effect, files are read from one
host based on another host's package set, which may have its use cases but
is generally undesirable. The context parameter also breaks the uniformity
of the store constructors: Sops, TarGpg, and Vault are constructed from a
URI alone, and FileContext.create() needs a special case that builds the
kvfile store's inner context before handing it to the constructor.
This commit has KvFile constructed from a URI alone like the other stores.
The URI's authority names the host, no authority means "local", and the
constructor builds the inner context through FileContext.create() with
chroot off, forwarding the store's constructor parameters to it. The inner
context is always an exec context, which the distro derivation needs: it is
lazy, Distro.instantiate() runs on the first file listing, with the
JW_DEFAULT_PKG_FILTER environment variable as the default package filter,
as before.
Adapt all call sites:
- FileContext.create(): the kvfile case returns KvFile(uri) directly.
- FilesContext: the distro parameter goes; the store URI is derived from
the exec context's scheme, authority, and path, so a local context with a
hostname in its URI stays local.
- DistroContext.install(): the kvfile source wrap goes; the compounds read
directly through the source context with parse_kv().
- The store tests monkey-patch Distro.instantiate() for the stores that
list something
Assisted-by: unsloth/Qwen3.8-27B-GGUF:Q4_K_M with pi.dev v1.5.0
Signed-off-by: Jan Lindemann <jan@janware.com>
KvFile contains symbol names "addr" or "entry" which look better defined
than they are. I prefer sticking to well-defined names like "path". "path"
in itself is ambiguous and makes it necessary to understand its context,
but so be it: At least it's used uniformly throughout the codebase and
makes it even more obvious that the function it's used in needs to bear a
meaningful name. Which is what this commit does, along with renaming some
member variables to more self-explanatory variants.
In detail, __addr() composes a host path from the URI path and the store's
relpath, __resolve() strips the store's suffixes, __entry_kv() and
__is_entry() operate on a config path that has a .jw-secret file, __subtree
holds the path component of the URI, and __raw holds the context under the
FcCache. The local variables config, entry, real, and blob do not name the
things they hold either.
- The __addr() method becomes __host_path(), its parameter is named
relpath.
- The __resolve() method becomes __strip_suffix().
- The __entry_kv() and __is_entry() methods become __compound_kv() and
__is_compound(), their parameters are named config_path.
- The __subtree and __raw members become __root and __inner.
- The locals config, entry, real, and blob become config_path, compound,
host_path, and secret_path.
Update the error messages and the comments that name the old symbols to use
the new ones.
Assisted-by: unsloth/Qwen3.8-27B-GGUF:Q4_K_M with pi.dev v1.5.0
Signed-off-by: Jan Lindemann <jan@janware.com>
KvFile works but is up for a major refactoring: It features an unnecessary
amount of special cases, and its private method names are not
self-explanatory enough. First thing to remove are the code comments,
because they would account for much churn and would be obsolete afterwards
anyway. This commit does it now in the expectation that the move from
package- to path-based filters will also touch KvFile.
Signed-off-by: Jan Lindemann <jan@janware.com>
Uri exposes the query as a raw string only, so a consumer that wants the
query's key/value pairs has to parse the string itself with urllib.parse.
Add a cached property query_dict that returns None when the Uri has no
query and a dictionary of the query's key/value pairs when it does.
Assisted-by: unsloth/Qwen3.8-27B-GGUF:Q4_K_M with pi.dev v1.5.0
Signed-off-by: Jan Lindemann <jan@janware.com>
The --pkg-filter flag and the JW_DEFAULT_PKG_FILTER env read live in the
jw.pkg.App, but the filter could have its merits in every application
deriving from lib.ExecApp, so heave the package filter machinery into
ExecApp: flag, filter resolution and the cached pkg_filter property. Then
have jw.pkg.App use self.pkg_filter.
Signed-off-by: Jan Lindemann <jan@janware.com>
Assisted-by: unsloth/Qwen3.8-27B-GGUF:Q4_K_M with pi.dev v1.5.0
__copy_tree() is a closure inside copy(), and per janware coding
conventions, closures should be defined at the top of a function with
preceding code, so move it to the top of copy().
Signed-off-by: Jan Lindemann <jan@janware.com>
lib.Uri doesn't support query strings, and this commit adds support: Expose
the query as a property, keep it through the path replacement methods, and
show it in the full forms.
Signed-off-by: Jan Lindemann <jan@janware.com>
Assisted-by: unsloth/Qwen3.8-27B-GGUF:Q4_K_M with pi.dev v1.4.0
c5ad946d6 (lib.distros.Distro.install_*(): Add install_deps) removed the
Distro.install() only_update parameter's default = False. The commit also
enforced the parameter's effect on Debian-based distros, but that doesn't
make it a reason for the default's removal. jw-nettools relies on it, so
add it back.
Signed-off-by: Jan Lindemann <jan@janware.com>
A put() that leaves the stored content unchanged is silently skipped. Add
debug logging to make the decision more obvious.
Signed-off-by: Jan Lindemann <jan@janware.com>
jw-pkg secrets compile-templates iterates over all selected templates and
compiles secrets from it - unless it encounters one that can't be compiled
for whatever reason, in which case the iteration errors out without
compiling the remaining secrets.
Add a -k / --keep-going option that makes the iteration not abort over
failed compilations but continue through the remaining templates, then
report an error status at the end.
The integration test gains a good sibling of the failing fixture template:
a fail-fast run must not reach it, and a keep-going run must compile it and
still fail the command.
Signed-off-by: Jan Lindemann <jan@janware.com>
Assisted-by: unsloth/Qwen3.8-27B-GGUF:Q4_K_M with pi.dev v1.4.0
Add an additional option -x, which inhibits dependency resolution during
installation of packages.
Signed-off-by: Jan Lindemann <jan@janware.com>
Assisted-by: unsloth/Qwen3.8-27B-GGUF:Q4_K_M with pi.dev v1.4.0
The install methods of Distro inconsistently resolve dependencies or don't
depending on the descendant's implementation. Pin that more unambigously by
adding a new parameter install_deps, defaulting to True, to the following
methods of lib.Distro:
_install_local_files()
_install_urls()
_install_urls_and_names()
install()
The implementations in lib.distros.* make use of the new
lib.pm.*.install_packages() method introduced by the previous commit.
Add a unit test directory per Distro descendant.
Assisted-by: unsloth/Qwen3.8-27B-GGUF:Q4_K_M with pi.dev v1.4.0
Signed-off-by: Jan Lindemann <jan@janware.com>
Currently, jw-pkg install is sometimes left to the high-level package
manager, which is allowed to install dependencies along, and that's
sometimes unwanted, but there's no backend in the low-level package manager
module lib.pm to allow specifying that. This commit adds it:
lib.pm.*.install_packages().
The functions install a list of local package files using the low-level
package managers rpm / dpkg, bypassing the high-level package managers yum
/ apt / zypper.
pm.rpm runs rpm -U and pm.dpkg runs dpkg -i. Every file is classified
against the installed state of its package, queried by name: a file
for a package that is not installed is installed fresh, a file with
another version installed is upgraded, and a file whose version is already
installed is reinstalled when force is set and skipped otherwise. On rpm,
plain -U refuses a package that is already installed, and --reinstall
aborts the transaction when a file of the incoming package differs from
the installed one, so the upgrades run before the reinstalls and the
same-version files need force.
With only_update, a file for a package that is not installed raises before
anything is installed.
The dpkg route is gated on an apt simulation, because dpkg -i leaves a
half-configured package when a dependency is missing: the simulation runs
first and the install is refused when it would install or remove anything
but the given files' own packages.
Assisted-by: unsloth/Qwen3.8-27B-GGUF:Q4_K_M with pi.dev v1.4.0
Signed-off-by: Jan Lindemann <jan@janware.com>
Add a version field to the Package class and make query_packages() fill it.
It's very much distribution and package dependent what shape that version
has, so from Package's perspective, it's just a str-typed member.
Further improvements and fixes:
- Make query_packages() accept throw, defaulting to the previous behaviour,
so a caller that wants to be prepared for a missing package / an empty
result can pass throw = False.
- Make dpkg's _run() and run_dpkg_query() forward ec and the remaining
keyword arguments on the sudo path, which dropped them before.
Add unit tests for the file type tree and its StatResult predicates.
Assisted-by: unsloth/Qwen3.8-27B-GGUF:Q4_K_M with pi.dev v1.4.0
Signed-off-by: Jan Lindemann <jan@janware.com>
Tonight's CI upgraded dput from 1.2.4 to 1.2.6 on Kali Linux and
subsequently failed:
xzcat /tmp/20261027-010000-rollout-failed.log.xz | grep -ai -C 1 checksum
Trying to upload package to janware-debian
Checksum doesn't match for dist/src/jw-pkg_1.0.0-281.dsc
make[1]: *** [make/pkg-dist.mk:288: pkg-release-reinstall] Error 1
The dput config generated for debian uploads sets hash = sha, while the
Files: section of a .changes file only carries MD5 checksums. dput verifies
each listed file by comparing the configured hash of the file against
that MD5 column, so a sha verification can never match and the upload is
rejected at the first file, the .dsc.
Set the option to md5, the only hash the .changes Files: section carries
and dput's built-in default.
Not sure, yet, if this is a fix or a workaround of a dput bug.
Assisted-by: unsloth/Qwen3.8-27B-GGUF:Q4_K_M with pi.dev v1.4.0
Signed-off-by: Jan Lindemann <jan@janware.com>
The postinst generator looks up the install log line of each file with a
regex grep on the file path, and the dots of the path match any character.
When the grep returns several lines, milk_install_log_spec_attr() passes
the extra lines through, so the emitted chown and chmod commands split
across lines, dpkg -i reports errors for the fragments, and the owner and
mode of the file are not applied.
Match the end of the log line against the file path literally and take the
first match. The install log line ends in the file path, but may carry a
build prefix before it, so the literal comparison of the tail of the line
selects exactly the line of the file, for plain and %config entries alike.
Assisted-by: unsloth/Qwen3.8-27B-GGUF:Q4_K_M with pi.dev v1.4.0
Signed-off-by: Jan Lindemann <jan@janware.com>
argcomplete 3.7 declares BaseCompleter.__call__() with an Iterable return,
and mypy rejects the None-returning override in NoopCompleter. Return an
empty list instead.
Signed-off-by: Jan Lindemann <jan@janware.com>