Commit graph

235 commits

Author SHA1 Message Date
5d95ca01ca jw.pkg.cmds.distro.backend.suse.Util.zypper(): Add verbose
Add boolean parameter verbose to zypper(), causing the obvious.

Signed-off-by: Jan Lindemann <jan@janware.com>
2026-03-03 11:24:19 +01:00
fc1431ec48 jw.pkg.cmds.distro.backend.suse.Util.zypper(): Add sudo
Add boolean parameter sudo to zypper(), doing the obvious.

Signed-off-by: Jan Lindemann <jan@janware.com>
2026-03-03 11:24:15 +01:00
0b3f12866c jw.pkg.cmds.distro.backend.*._sudo(): Pass *args on
Pass *args and **kwargs on unchanged to run_sudo().

Signed-off-by: Jan Lindemann <jan@janware.com>
2026-03-03 11:24:10 +01:00
7fcb031795 jw.pkg.lib.App.__run(): Use return value as exit status
If a Cmd-classes's _run() method returns an integer between 0 and
255, use that as the program's exit status.

Signed-off-by: Jan Lindemann <jan@janware.com>
2026-03-03 11:23:32 +01:00
565946643b jw.pkg.*.run_xxx(): Return exit status
Most run_xxx() return stdout and stderr. There's no way, really, for
the caller to get hold of the exit code of the spawned executable. It
can pass throw=true, catch, and assume a non-zero exit status. But
that's not semantically clean, since the spawned function can well be
a test function which is expected to return a non-zero status code,
and the caller might be interested in what code that was, exactly.

The clearest way to solve this is to return the exit code as well.
This commit does that.

Signed-off-by: Jan Lindemann <jan@janware.com>
2026-03-03 11:23:30 +01:00
03fca61248 jw.pkg.App.distro_id: Don't return opensuse
get-os.sh returned "suse" for SuSE-like distros, and that seems more
appropriate since SLES is not OpenSUSE but should share and ID with
other SuSE variants.

Signed-off-by: Jan Lindemann <jan@janware.com>
2026-03-03 05:11:59 +01:00
d22074abf9 jw.pkg.cmds.distro.Cmd._backend_path: Fix suse mapping
App.distro_id used to return "opensuse-tumbleweed", analogous to
what's in ID@/etc/os-release, but now returns "opensuse", and the
"tumbleweed" goes into "codename". That matches more what Debian-like
distributions do, but it confuses _backend_path. Adapt it to map the
new distro_id correctly.

Signed-off-by: Jan Lindemann <jan@janware.com>
2026-03-03 04:27:50 +01:00
6483de1a8f jw.pkg.App.get_os(): Don't use get-os.sh
Remove get-os.sh from App.py to reduce redunancy.

Signed-off-by: Jan Lindemann <jan@janware.com>
2026-03-02 12:55:36 +00:00
1da00283d1 jw.pkg.cmds.projects.CmdOsCascade: Remove
CmdOsCascade is superseeded by CmdInfo. Use the latter and retire the
former.

Signed-off-by: Jan Lindemann <jan@janware.com>
2026-03-02 12:55:36 +00:00
e2e1b3388c jw.pkg.cmds.distro.CmdInfo: Add class
CmdInfo provides what "projects os-cascade" provided as "distro info
--format '%{cascade}'" plus additional macros: %{id}, %{name},
%{codename} and ${gnu-triplet}.

Signed-off-by: Jan Lindemann <jan@janware.com>
2026-03-02 12:55:36 +00:00
f58e9fe298 jw.pkg.App: Add more distro_xxx properties
In addition to the existing propert distro_id, add the properties
distro_codename, distro_name, distro_cascade and distro_gnu_triplet.

Signed-off-by: Jan Lindemann <jan@janware.com>
2026-03-02 12:00:12 +01:00
11379f4830 jw.pkg.cmds.projects.CmdGetAuthInfo: --remote-owner-base
Support --remote-owner-base in the command CmdGetAuthInfo. Make it
return what currently --remote-base returned: A URL including the
user / organization specific prefix of the Git remote's URL that
jw-pkg was pulled from.

   https://my-company.com/src/theowner/jw-pkg.git

would have a --remote-owner-base of

   https://my-company.com/src/theowner

Also, change what --remote-base returns to

   https://my-company.com/src

Signed-off-by: Jan Lindemann <jan@janware.com>
2026-02-27 22:54:15 +01:00
8dcaa1a6a1 jw.pkg.cmds.projects.CmdListRepos: --from-owner
Rename the --from-user option to --from-owner. Forgejo supports users
and organizations under the more general term "owner", so that's the
better term.

Signed-off-by: Jan Lindemann <jan@janware.com>
2026-02-27 17:12:11 +01:00
956235276a jw.pkg.cmds.projects.CmdListRepos: Beautify logging
list-repos tries /users/ and /orgs/ to find a working repo URL in a
Forgejo instance, logs a failure and doesn't log anything if it finds
one that works. In the context, that can be mildly confusing,
beautify the output somewhat.

Signed-off-by: Jan Lindemann <jan@janware.com>
2026-02-27 17:08:28 +01:00
afc77ab61d jw.pkg.lib.util.run_curl(): Beautify logging
Make some incomprensible parser error messages if run_curl() returns
nothing slightly less incomprehensible.

Signed-off-by: Jan Lindemann <jan@janware.com>
2026-02-27 17:03:26 +01:00
6c1f0f4c95 jw-pkg.py: CmdListRepos: Take base-url argument seriously
base-url is not used as a prefix in its entirety, but massaged in a
janware-specific way. Still is, but at least this commit is a step
towards being more generic.

Signed-off-by: Jan Lindemann <jan@janware.com>
2026-02-27 09:19:51 +01:00
b81406e11a run_cmd() and friends: Make args a list[str]
This is a code maintenance commit: some run_xxx() helper functions
take a string, some a list, and some just digest all arguments and
pass them on as a list to exec() to be executed. That's highly
inconsistent. This commit changes that to list-only.

Except for the run_cmd() method of SSHClient, which is still run as a
shell method, because, erm, it's a shell. Might be changed in the
future for consistency reasons.

Signed-off-by: Jan Lindemann <jan@janware.com>
2026-02-27 09:09:10 +01:00
881a915098 jw/pkg/cmds/distro/CmdPkg: Add distro pkg ls
Add the distro subcommand class CmdPkg, together with a first
subcommand ls, which prints a list of files contained in a package.

Signed-off-by: Jan Lindemann <jan@janware.com>
2026-02-24 14:53:18 +01:00
aebd9bb5e6 jw.pkg.cmds.distro.lib.rpm.list_files(): Add function
Add a function list_files, which takes a package name and returns the
contained files in a list.

Signed-off-by: Jan Lindemann <jan@janware.com>
2026-02-24 14:53:17 +01:00
2906c697de jw.pkg.lib.util.run_cmd(): Add stderr to exception
If an error happens, append stderr to the exception thrown.

Signed-off-by: Jan Lindemann <jan@janware.com>
2026-02-24 14:53:17 +01:00
a160555596 jw.pkg.cmds.Cmd._add_subcommands(): Generic detection
Deduce module search path for the calling module's subcommands
directly from the module path of the calling module. That's more
generic than the previous detection algorithm, because it recursively
works for subcommands of subcommands as well.

Signed-off-by: Jan Lindemann <jan@janware.com>
2026-02-24 14:53:17 +01:00
595995e084 jw.pkg.cmds: Replace split('\n') by splitlines()
splitlines() removes empty lines, so use it and save some lines of
code.

Signed-off-by: Jan Lindemann <jan@janware.com>
2026-02-24 14:53:05 +01:00
c8036ad216 jw-pkg.sh: Print help for missing subcommands
Print a help message if no subcommand is specified for one of the
comamnds "distro" and "projects".

Signed-off-by: Jan Lindemann <jan@janware.com>
2026-02-24 14:52:25 +01:00
e5e0cf9930 jw.pkg.lib.Cmd._run(): Call parent._run()
jw.pkg.lib.Cmd._run() is abstract, but it's nice to give it a default
implementation which calls self.parent._run() in case parent is also
a command class. That allows for some default processing in _run()
for each node up the parent chain.

The children / derived classes just need to make sure all classes in
the hierarchy do:

    async def _run(self, args):
      return await super()._run(args)
      ... add main command logic here ..

Signed-off-by: Jan Lindemann <jan@janware.com>
2026-02-20 19:30:22 +01:00
6916d7edc8 jw.pkg.lib.util.run_sudo(): Add parameter verbose
Add parameter verbose to run_sudo() and pass it on to run_cmd().

Signed-off-by: Jan Lindemann <jan@janware.com>
2026-02-20 19:30:22 +01:00
d814052aac jw.pkg.cmds.projects.CmdBuild: --source-profile -> --env-reinit
Replace --source-profile by --env-reinit and --env-keep to allow more
fine-grained control over environment manipulation.

Signed-off-by: Jan Lindemann <jan@janware.com>
2026-02-19 08:22:43 +01:00
b3fd624a3f jw.pkg.lib.util.get_profile_env(): add -> keep
Replace the boolean parameter "add" with the richer "keep":

  - False            -> Don't keep anything
  - True             -> Keep what's in the current environment
  - List of strings  -> Keep those variables

Signed-off-by: Jan Lindemann <jan@janware.com>
2026-02-19 07:52:53 +01:00
230eacac8b jw.pkg.cmds.projects.CmdBuild: Add --source-profile
Add --source-profile=[no|add|replace] to the projects build command,
doing the obvious thing.

Signed-off-by: Jan Lindemann <jan@janware.com>
2026-02-18 14:22:27 +01:00
2d1beeebb0 jw.pkg.lib.util.get_profile_env(): Add function
Add a function get_profile_env(), a function returning environment
variables from /etc/profile. Pass add=True to add its contents to the
existing environment dictionary, overwriting old entries, or pass
False to get the pristine content.

Signed-off-by: Jan Lindemann <jan@janware.com>
2026-02-18 14:18:46 +01:00
e104fa2e46 jw.pkg.lib.util.run_cmd(): Add output_encoding
Add a parameter "output_encoding" to run_cmd(). The parameter allows
the caller to specify if the output encoding should be detected as is
by passing None (the default), if the output should be returned as
undecoded bytes by passing the special string "bytes", or if the
output should be treated as the encoding with the specified name and
decoded to strings.

Signed-off-by: Jan Lindemann <jan@janware.com>
2026-02-18 13:38:12 +01:00
82c6a44ad6 jw.pkg.lib.util.run_cmd(): Fix mode:auto
In cmd_input == "mode:auto", the interactive variable is currently
not set due to a typo. Fix that.

Signed-off-by: Jan Lindemann <jan@janware.com>
2026-02-18 13:31:26 +01:00
f8dc8ee6d1 jw.pkg.lib.util.run_cmd(): Honour env in PTY mode
The evironment passed to run_cmd() via env is currently not honoured
with mode:interactive. Fix that.

Signed-off-by: Jan Lindemann <jan@janware.com>
2026-02-18 13:29:48 +01:00
838b745581 jw.pkg.cmds.projects.CmdBuild: Use run_cmd("make")
Use run_cmd() for centralized process handling, instead of
hand-rolled Popen().

Signed-off-by: Jan Lindemann <jan@janware.com>
2026-02-18 11:37:40 +01:00
0cb6a7972c jw.pkg.cmds.projects.CmdBuild: Make run_make() async
Make the call chain to Popen(make ...) async, in preparation for the
next commit.

Signed-off-by: Jan Lindemann <jan@janware.com>
2026-02-18 11:36:14 +01:00
75faf02232 jw.pkg.lib.util.run_cmd(): Add title parameter
Allow the caller to choose which title should be used for the
command's logging output box.

Signed-off-by: Jan Lindemann <jan@janware.com>
2026-02-18 11:31:53 +01:00
7eb15f2477 jw.pkg.lib: Don't log {e}
Don't log an Exception as {e} but as str(e) producing nicer output.
Or as repr(e) if a backtrace is requested, because to people who can
read backtraces, type info might be of interest. Also, remove
pointless time stamps, those belong into the logging framework.

Signed-off-by: Jan Lindemann <jan@janware.com>
2026-02-18 11:31:13 +01:00
d7f9fc7260 CmdAuthInfo: Fix no output
jw-pkg.py projects get-auth-info doesn't print anything, fix that.

Signed-off-by: Jan Lindemann <jan@janware.com>
2026-02-18 01:20:26 +01:00
4153fa7c05 jw.pkg.cmds.distro.CmdDelete: Add command
Add command to delete named packages, along with an implementation
for OpenSUSE.

Signed-off-by: Jan Lindemann <jan@janware.com>
2026-02-18 01:20:26 +01:00
3ceb2b71b7 jw.pkg.cmds.distro.CmdSelect: Add command
Add the sub-command select to jw-pkg.py distro, along with an
Implementation for OpenSUSE.

Signed-off-by: Jan Lindemann <jan@janware.com>
2026-02-18 01:20:26 +01:00
81833e049a jw.pkg.cmds.distro.lib.rpm: Add module
Add a place to bundle utilities for RPM-backed distributions.

Signed-off-by: Jan Lindemann <jan@janware.com>
2026-02-18 01:20:26 +01:00
18747b8254 jw.pkg.cmds.distro.lib.Package: Add class
Add a package metadata abstraction.

Signed-off-by: Jan Lindemann <jan@janware.com>
2026-02-18 01:20:26 +01:00
6c98c9b650 jw.pkg.cmds.distro.lib: Add Module
Add a place to for distribution related utilities.

Signed-off-by: Jan Lindemann <jan@janware.com>
2026-02-18 01:20:26 +01:00
f991bbfcd9 jw.pkg.cmds.distro.backend.suse.Util.rpm(): Add method
Signed-off-by: Jan Lindemann <jan@janware.com>
2026-02-18 01:20:26 +01:00
421e75fc91 jw.pkg.cmds.distro.backend.*.Util: Backend -> ..Util
Derive all jw.pkg.cmds.distro.backend.*.Util classes from the common
base class jw.pkg.cmds.distro.backend.Util.

Signed-off-by: Jan Lindemann <jan@janware.com>
2026-02-18 01:20:25 +01:00
3c8f57f636 jw.pkg.cmds.distro.backend.Util: Add class
Add a common base class for all jw.pkg.cmds.distro.backend.*.Util
classes.

Signed-off-by: Jan Lindemann <jan@janware.com>
2026-02-18 01:20:25 +01:00
7181849002 jw.pkg.cmds.distro.backend.*.*: Util -> BeXxx
Don't derive the Backend classes from distro-specifiy Util classes
anylonger, but from command-specific BeXxx base classes.

Signed-off-by: Jan Lindemann <jan@janware.com>
2026-02-18 01:20:25 +01:00
63395f414f jw.pkg.cmds.distro.backend.*.*: Use util
Don't call self.some_utility() anylonger, make it
self.util.some_utility().

Signed-off-by: Jan Lindemann <jan@janware.com>
2026-02-18 01:20:25 +01:00
82e92ac068 jw.pkg.cmds.distro.backend.Backend: Add property util
Add a property .util to the Backend class, instanciated on demand
from to the respective distribution directory's Util class.

Signed-off-by: Jan Lindemann <jan@janware.com>
2026-02-18 01:20:25 +01:00
78835ecc9c jw.pkg.cmds.distro.Cmd: Add property util
Provide a property .util from Cmd, instanciated on demand from to the
respective distribution directory's Util class.

Signed-off-by: Jan Lindemann <jan@janware.com>
2026-02-18 01:20:25 +01:00
05f3f33931 jw.pkg.cmds.distro.backend.*.Base -> Util
Rename the class Base of all distribution backends to Util. It
contains distribution specifics, but is not going to be the base
class anymore shortly.

Signed-off-by: Jan Lindemann <jan@janware.com>
2026-02-18 01:20:25 +01:00