Unprivileged "make install" currently returns an error. That looks bad.
It actually is not a real problem, because unprivileged "make install"
installs files into locations that are good for nothing, in the sense
that they don't constitute a meaningful or usable hierarchy of installed
files. Debugging / inspecting the install machinery itself is a valid
use case, though, and it's easier to explain to the unsuspecting user
that unprivileged installation is something akin to shooting range
training than why "make install" outright errors out, so fix the error
messages.
Signed-off-by: Jan Lindemann <jan@janware.com>
cmd_log_install() defaults $c_logfile to "install.log", so every
invocation without -l appends to an install.log in the current
directory. That's semantical nonsense.
Default $c_logfile to empty instead. The existing empty-$c_logfile
early exit already skips logging, so no -l now means no log, and
callers that want a log pass -l explicitly, as the packaging flow
does through INSTALL_LOG.
Assisted-by: unsloth/Qwen3.8-27B-GGUF:Q4_K_M (pi)
Signed-off-by: Jan Lindemann <jan@janware.com>
Don't start a fresh project with version 1.0.0-0-dev. By default no
project can honestly claim the level of maturity suggested by 1.0.0-0
with its first commit.
Signed-off-by: Jan Lindemann <jan@janware.com>
During a topdir "make all", caching variables is currently not the
first thing that happens. Instead, variables are cached as soon as a
project recurses into the make subdirectory. That was necessary,
because some makefiles were regenerated in the make subdirectory by
autoconf, potentially contributing variables that needed to be
cached.
As of now, autoconf is long gone and this is no longer true. And for
some variables, the two step process becomes involved, notably for
PYTHONPATH, which coding agents would like to look at from the topdir
very early on.
This commit moves the .project-cache.mk creation to topdir.mk, and
.projects-cache.mk creation to jw-pkg/Makefile to address that.
Signed-off-by: Jan Lindemann <jan@janware.com>
subpackages = "run, devel" is not tolerated by create-mkspec.sh. It
expects "run devel", which goes against the grain of the other
metadata, so make it at least tolerate the more common
comma-separated variant.
Signed-off-by: Jan Lindemann <jan@janware.com>
Generate a standard conftest.py, mostly for customizing pytest's
bombastic test header, which otherwise lets the more informative make
output look too pale in comparison.
Signed-off-by: Jan Lindemann <jan@janware.com>
Fix shellcheck SC2068 (unquoted array expansions), SC2145 (mixed
string/array arguments), SC2328 (redirection in command
substitution), SC2173 (untrapable signals), and SC2148 (missing
shebang) errors across 14 script files.
Also configure scripts/Makefile with --severity=error so that only
errors (not warnings or notes) cause check failures. To be tightened
by follow-up commits.
Assisted-by: unsloth/Qwen3.6-35B-A3B-GGUF:IQ4_NL and pi.dev
Signed-off-by: Jan Lindemann <jan@janware.com>
After a pipeline change, CI now runs "make all" in a repo's root,
which uncovers two problems:
1. The help integration test only succeeded as long CI didn't run
"make all" before "make test". That way, the checked out
repository lacked the generated __init__.py files needed for some
modular subcommands to be fully loaded, and hence, the test should
have failed. The entire machinery only worked because the
subcommands in question are not not essential to building jw-pkg
itself: "secrets" and "posix". So, this commit adapts the help
integration test to the new reality.
2. Regarding python-tools.sh: Commit 55060486 satisfies yapf in some
places of the source code, but in others not anylonger. So patch
python-tools.sh's newline handling again.
While not thematically similar, both fixes get baked into one commit
to satisfy the requirement that every single commit needs to pass
"make clean all check test" individually.
Signed-off-by: Jan Lindemann <jan@janware.com>
Commit 4e347683 removed a tralining newline after imports. Yapf
doesn't like that, so revert that change.
Signed-off-by: Jan Lindemann <jan@janware.com>
Make python-tools.sh generate empty __all__ as [] on one line instead
of multi-line format, and remove trailing blank line.
Signed-off-by: Jan Lindemann <jan@janware.com>
Add support for PY_INIT_SUBMODULES to py-mod.mk. If it is defined in
a Makefile including py-mod.mk, the listed submodules will be added
to __init__.py and thus included in the list of things that can be
imported from a module.
This commit also adds support for --submodules to python-tools.sh for
that to happen.
Signed-off-by: Jan Lindemann <jan@janware.com>
Letting python-tools.sh rewrite symbols is more robust than rewriting
an entire __init__.py with PY_INIT_FILTER in the including Makefile.
The latter can break in non-obvious ways if python-tools.sh changes
__init__.py's format.
Make python-tools.sh support --symbol-filter to remedy that. The
option takes an sed script which should expect a string of two
non-whitespace tokens: The module from which the symbol is imported,
and the name of the symbol in that module. It's output will then be
used as the symbol to be exported from __init__.py.
Also, support the PY_SYMBOL_FILTER variable in py-mod.mk. If it's
defined, it is used for --symbol-filter.
Signed-off-by: Jan Lindemann <jan@janware.com>
By the time projects-dir.mk is used during onboarding, it's already
cloned, and so is jw-pkg in all its glory. So better use a
ssh-wrapper.sh directly under jw-pkg's version control instead of
plainly generating one with echo some-script-logic > ssh-wrapper.sh.
This has the main benefit of allowing a more elaborate script. The
one added by this commit removes "-l user" from remotes which have a
standard-user@gitserver form, typically because they differentiate
users via their SSH pubkeys only, and which would deny access if both
-l user and standard-user@ were specified.
ssh-wrapper.sh still needs to be a target which is updated by a
recipe, because the version found in jw-pkg can't be trusted to be
executable during bootstrapping, because "make all" has not run, yet.
Signed-off-by: Jan Lindemann <jan@janware.com>
After release, pkg.sh pushes the changes to VERSION and HASH
upstream. Failures are masked, though, propagate them.
Unclear what motivated masking the error. Tracking that down with git
blame leads to build-package.sh, which was inherited from ytools,
where the change was introduced 2014 with the trust-inspiring
comment:
attempted fix for error during commit of version files in
build-package.sh
Signed-off-by: Jan Lindemann <jan@janware.com>
The generated code doesn't pass "make check": It would like to see a
newline after the import statement. Add that.
Signed-off-by: Jan Lindemann <jan@janware.com>
The previous commits have put rules for linting and formatting via
ruff, yapf, mypy and pyright into place. They are checked with the
make check target, and this commit adds the fixes for the target to
succeed.
It does some refactoring where type checking dug up dirty bits, and
also adds lots of churn in the Python code. To a good deal, that's
owed to mere formatting changes. It would have been better to
seperate those from syntax and refactoring fixes into multiple
commits, so that the interesting changes don't drown in the
formatting nose. However, that would have been a lot of additional
work only to be thrown away by later commits, hence this commit has a
big diff in one piece. The size of the diff is regrettable but
hopefully a one-off: What it buys is automatic format checking for CI
and predictble formats for smaller diffs in the future.
Rules that "make check" enforces are, in the following order
- Syntax checkers:
- ruff check .
- mypy .
- pyright
- Format check:
- yapf --diff --recursive .
The refactoring includes:
- Turn the Result class into a more elaborate object, capable of
doing more heavy lifting around stderr and stdout decoding,
summarizing outcome, and matching error strings.
Aside from fixing broken type checks, this also removes lots of
boilerplate calling code which is currently used for handling
possible call outcome scenarios. Trying to access an inexistent,
decoded string should raise a meaningful exception by itself now,
which removes lots of code with case distinctions.
- Fix Cmd type hierarchy:
- Add the AbstractCmd class above Cmd. This is necessary because
the checker rightfully complains it can't instantiate a Cmd
instance where constructor arguments were needed. They never
were, but the type used at the instantiating code's location in
jw.pkg.App so claims.
- Lots of sub- and sub-subcommands are derived from the base
class of the invoking command. That provides some properties
shared across the ancestor hierarchy of a command, but is
semantically unsound. Fix that by introducing jw.pkg.BaseCmd
class as a place to provide basic helpers shared across all
commands used in a jw.pkg.App's context, and derive all command
classes from that afresh. The parent command is still reachable
via a common parent property.
Formatting changes are conforming to PEP-8, mostly, with minor
tweaks. All in all they include the following changes.
- Remove # -*- coding: utf-8 -*-
The line was needed by Python 2 which is not supported anylonger.
For Python 3, the default encoding is UTF-8, anyway.
- Allow to run "make py-format" without having it produce any
changes. It's basically "yapf --in-place --recursive ." with some
code style settings, see conf/topdir/pyproject.toml. The settings
may be debatable. I've had custom tweaks in place on that target,
too, but then again, IDEs would have more hassle to integrate
that.
- Introduce a 88 character line length limit
- One import per line, reshuffle them semantically, see
[tool.isort] in pyproject.toml.
- Hide imports needed for type-checking only behind
if TYPE_CHECKING
- Spaces around assignments accounts for much churn. Having having
no spaces in inline parameter list assignments and default
parameter values would arguably be more compact where it's
useful. On the other hand, I have not found a code formatter
which allows spaces around assignments in parameter lists broken
into one per line and that's often better than a wall of text.
- Add two spaces before # export, as this seems to be mandated by
PEP-8
- Use single quotes by default
Signed-off-by: Jan Lindemann <jan@janware.com>
py-topdir.mk: Use ruff and yapf
- Use pyright for the target py-check-syntax
- Generate a $(TOPDIR)/pyrightconfig.json for that
- Add pyrightconfig-base.json because it's used by
pyrightconfig.json
- Add python3-pyright to pkg.requires.release, anticipating the use
of the py-syntax-check target by CI
Signed-off-by: Jan Lindemann <jan@janware.com>
- Use ruff and yapf for the targets py-check-syntax, py-format and
py-check-format.
- Add a pyproject.toml for those. It also includes configuration
for isort, albeit not being directly used in the linter targets.
- Make .gitignore igore that in newly created projects.
- Add ruff, yapf and isort to pkg.requires.release, anticipating
their use by CI.
Signed-off-by: Jan Lindemann <jan@janware.com>
The __init__.py files as gnerated by python-tools.sh contain multiple
issues, fix them:
- Make the machinery fail if the same type name is imported from
different modules
- Support relative imports from .Module import Module instead of
having to use the entire module path as import source
- Import types explicitly re-exported with "as":
from .Module import Module as Module
Otherwise ruff will regard the type as "imported but not used"
- Add "# ruff: noqa: E501" near the top. The import lines can get
long and are beyond manual control (except for renaming the
modules themselves, that is). This can cause ruff to fail, so get
it to accept long lines in __init__.py. The style violation
doesn't make much of a difference in generated code, anyway,
because nobody reads that. Plus what's happening in the code
isn't rocket science, so good style wouldn't help much with
understanding, either.
This promptly digs up two symbol name conflicts lib.pm.dpkg and
lib.pm.rpm. Fix them along with this commit to keep it from breaking the build.
Signed-off-by: Jan Lindemann <jan@janware.com>
Currently, completing a release works with a plain git push. It may
push to several repos, depending on how the client repo's origin's
pushurl is configured. Those repos may have different user names, and
if the ssh wrapper added -l via JW_PKG_SSH_EXTRA_OPTS, the push would
fail. Hence, disable JW_PKG_SSH_EXTRA_OPTS for that case.
Signed-off-by: Jan Lindemann <jan@janware.com>
janware upstream development server moved from git.janware.com to
devgit.janware.com. This commit follows the move with pretty much a
simple
s/git.janware.com/devgit.janware.com/
over jw-pkg. It found 14 matches, that's pretty bad.
FIXME: Reduce the redundancy, or, better, replace the
devgit.janware.com goodies by a more generally useful concept
altogether.
Signed-off-by: Jan Lindemann <jan@janware.com>
Rename command "distro" to "pkg" together with "info", its last
remaining subcommand. "distro" is often used in the sense of "Linux
distribution", which would be too narrow for the targets jw-pkg could
theoretically support.
Signed-off-by: Jan Lindemann <jan@janware.com>
jw-pkg is copied into $(TOPDIR)/bin during build, that's wrong.
Write a rule precisely targeted at installing /usr/bin/jw-pkg, and
cut all the scripts.mk machinery.
Also, make jw-pkg a relative link to avoid the respective RPM
warning.
Signed-off-by: Jan Lindemann <jan@janware.com>
log_start_stop() is responsible for logging markers at the beginning
and end of a decorated log. They should not be applied if pgit.sh is
run with --porcelain. In fact, they are, and vice versa. Fix that.
Signed-off-by: Jan Lindemann <jan@janware.com>
Set -o pipefail at the start of the script. This makes pgit.sh commit
work. Before it didn't, because run_git() doesn't return a proper
return value when it's used in a pipe with a cosmetic sed afterwards.
Signed-off-by: Jan Lindemann <jan@janware.com>
Log to stderr and add some ASCII-art around the output. Also, add a
--porcelain option to allow more stable output parsing. Subsequently,
use that option in make targets parsing the output, notably make diff
and make git-show-xxx.
Signed-off-by: Jan Lindemann <jan@janware.com>
Add the name of the operating system ID as taken from /etc/os-release
to $INSTALL_LOG. This should allow for easier post-mortem debugging
if multiple builds used the same file in /tmp and possibly also
prevent conflicts.
Signed-off-by: Jan Lindemann <jan@janware.com>
jw-pkg supports more than RPM-based package managers, but for
historic reasons, lots of its Makefile variables still have "RPM" in
their names. This is misleading. Replace "RPM" in variable names by
the more generic "PKG" where appropriate.
Signed-off-by: Jan Lindemann <jan@janware.com>
Maintainer scripts often mess with systemd services via systemctl. In
Docker containers, chroot environments or other environments not
governed by Systemd, systemctl will not exist or complain. This is a
frequent use case, worthy of providing a wrapper to catch and ignore
these cases conveniently.
Signed-off-by: Jan Lindemann <jan@janware.com>
There's no "Homepage" meta tag in the .deb files created by jw-pkg,
add one.
Also, generate an e-mail address <global.jw-maintainer>@janware.com
to go into the Maintainer field. Not ideal, but a low-hanging fruit.
Signed-off-by: Jan Lindemann <jan@janware.com>
pgit.sh logs "Running $0 $@ GIT_SSH=" which is not the exact command
line. Fix that, and prefix log messages with "pgit.sh".
Signed-off-by: Jan Lindemann <jan@janware.com>
A compiled release package is currently uploaded to a fixed
directory, determine it dynamically for every distro seperately.
Signed-off-by: Jan Lindemann <jan@janware.com>
Remove the now obsolete get-os.sh from jw-pkg. Use "jw-pkg.py distro
info" to get the information it used to provide.
Signed-off-by: Jan Lindemann <jan@janware.com>
pkg.run is not evaluated on Debian, fix that. For now it's hacked
into pkg.sh, which is bound to be replaced by Python. The limited
hassle is still worth the detour.
Signed-off-by: Jan Lindemann <jan@janware.com>