Commit graph

65 commits

Author SHA1 Message Date
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
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
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
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
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
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
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
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
2cc3b59e75 jw.pkg.cmds.distro.backend.BackendCmd -> Backend
Rename jw.pkg.cmds.distro.backend.BackendCmd to Backend, because it's
not necessarily a command, i.e. doesn't necessarily have a run()
method. It's more of a distribution abstraction of the steps needed
for for a specific command, the run() method itself is implemented in
jw.pkg.cmds.distro.CmdXxx.

This commit is the beginning of a bigger move to change the
distribution backend class hierarchy. At the end of this change set,
the backend command should not derive the backend classes from a base
specific to the respective distribution, but from an abstract base
class specific to the command run. The distribution specifics are
then going to be encapsulated in another class called "Util", an
instance of which is going to be provided to the backend as .util
member.

Signed-off-by: Jan Lindemann <jan@janware.com>
2026-02-18 01:20:25 +01:00
b1d4e20295 jw.pkg.util: Add sudo()
Move the body of BackendCmd.sudo() into a function. The rationale
behind that is that its functionality is independent of the calling
object for the most part, so having it in a function instead of a
method is the more modular pattern.

Signed-off-by: Jan Lindemann <jan@janware.com>
2026-02-18 01:20:25 +01:00
26e739ca0d src.python.jw.pkg.App: Add property distro_id
Add @property App.distro_id, returning the ID field of
/etc/os-release. It is supposed to be the most specific part of the
OS cascade.

Signed-off-by: Jan Lindemann <jan@janware.com>
2026-02-15 16:13:21 +00:00
bdb6ae69b3 apt-get install: Add --fix-broken to commandline
apt-get install suggests it wants to be called with -f to clean up
some mess left behind from a previous install. Adding -f in the hope
add it to the install options by default. OTOH, it wants to be called
that without arguments, not sure if always passing it along is a good
idea.

The man page says:

    -f, --fix-broken

   Fix; attempt to correct a system with broken dependencies in
   place. This option, when used with install/remove, can omit any
   packages to permit APT to deduce a likely solution. If packages
   are specified, these have to completely correct the problem. The
   option is sometimes necessary when running APT for the first time;
   APT itself does not allow broken package dependencies to exist on
   a system. It is possible that a system's dependency structure can
   be so corrupt as to require manual intervention (which usually
   means using dpkg --remove to eliminate some of the offending
   packages). Use of this option together with -m may produce an
   error in some situations. Configuration Item:
   APT::Get::Fix-Broken.

Also turn the short options -yq into long options --yes --quiet for
more obvious debugging if something goes awry.

Signed-off-by: Jan Lindemann <jan@janware.com>
2026-02-15 16:13:12 +00:00
75041d5505 src/python/jw/pkg/cmds/CmdDistro: Fix ID regex
The ID regex on /etc/os-release also matches ID_LIKE, which is
obviously nonsense. Fix that.

Signed-off-by: Jan Lindemann <jan@janware.com>
2026-02-14 20:58:33 +01:00
2f49bc18d4 jw.pkg.cmds.distro.Cmd._backend: Support Kali Linux
If Kali Linux is detected as distribution, use the Debian backend for
package management.

Signed-off-by: Jan Lindemann <jan@janware.com>
2026-02-14 20:41:41 +01:00
060ff5159b jw.pkg.cmds.projects.CmdGetAuthInfo: Fix run_cmd()
CmdGetAuthInfo calls run_cmd() with a list instead of a *-expanded
list of arguments. Fix this to match the current run_cmd() prototype.

And think again if the current prototype conforms to the priciple of
least surprise: Most exec- / run- / whatever- functions do expect
ether a string to be run by the shell, or an argv list.

Signed-off-by: Jan Lindemann <jan@janware.com>
2026-02-14 19:18:48 +01:00
0bc06b7c41 jw.pkg.cmds.distro.backend.BackendCmd: Add sudo(opts)
Prepending --login to the argument list of BackendCmd.sudo() fails if
run as root, because BackendCmd.sudo() detects that and leaves the
/usr/bin/sudo out from the exec call. Fix that by adding an
opts: list[str] parameter to sudo, defaulting to an empty list, with
options that should be passed to /usr/bin/sudo.

Signed-off-by: Jan Lindemann <jan@janware.com>
2026-02-14 09:20:24 +01:00
ffb84ad8c0 jw.pkg.cmds.distro.backend.Base: sudo --login
On OpenSUSE, run sudo with --login. This picks up a possible
ZYPP_CONF config variable definition in /etc/profile.

Signed-off-by: Jan Lindemann <jan@janware.com>
2026-02-12 20:38:12 +01:00
d50a33d9ab jw.pkg.cmds.lib.Cmd: Define run()
Define run(), which calls _run() in the abstract base class Cmd, not
in lib.Cmd. Otherwise lib.Cmd is not abstract, which will predictably
confuse including code outside of jw-pkg.

Signed-off-by: Jan Lindemann <jan@janware.com>
2026-02-10 10:00:46 +01:00
a55dd8175c jw.pkg.cmds.projects.CmdProjectDir: Fix warning typo
Trying to find the directory of a project should log a warning. It
throws an exception instead. Fix that.

Signed-off-by: Jan Lindemann <jan@janware.com>
2026-02-02 15:56:19 +01:00
e075e8902b jw.pkg.cmds.CmdDistro: Default --interactive to true
Better safe than sorry: If things are to happen unattendedly, enforce
the need to explicitly request that.

Signed-off-by: Jan Lindemann <jan@janware.com>
2026-01-29 11:32:32 +01:00
6ca4af77d7 jw.pkg.App: Code beautification
Major - but not yet sufficient - code beautification starting from
jw.pkg.App.

  - Make more methods private
  - Rename methods to be more self-explanatory
  - Same for method arguments, notably clean up some inconsistent
    uses of "module" vs "project"
  - Add more type hints

Fix API breakage in the command modules.

Signed-off-by: Jan Lindemann <jan@janware.com>
2026-01-29 11:32:14 +01:00
2bbf5bd8e7 jw.pkg.cmds.projects.CmdRequiredOsPkg: Support --quote
--quote puts double quotation marks around the listed dependencies,
protecting version requirements (>= 1.0) and parenthesis "perl(GD)"
from the shell.

Signed-off-by: Jan Lindemann <jan@janware.com>
2026-01-29 11:28:17 +01:00
26bfda109c cmds.projects.CmdListRepos: Try Forgejo users and orgs
A "username" in jw-pkg terms, as in $(CLONE_FROM_USER), is not
sufficient to identify a remote API URL on a Forgejo server, it can
denote both an organization and a user, so try organizations first,
then users, and stop on the first occasion found.

Signed-off-by: Jan Lindemann <jan@janware.com>
2026-01-28 18:11:10 +01:00
45af308ae6 jw.pkg.cmds.distro.backend.arch: Add Module
Add Arch backend for pacman-based package management.

Signed-off-by: Jan Lindemann <jan@janware.com>
2026-01-28 18:11:09 +01:00
f6a8b6307a jw.pkg.cmds.distro.backend.redhat: Add Module
Add backend for YAM-based package management, as used by RHEL,
Fedora, CentOS.

Signed-off-by: Jan Lindemann <jan@janware.com>
2026-01-28 18:11:09 +01:00
3ca544a32d jw.pkg.cmds.distro.backend.suse: Add Module
Add backend code for package managing on OpenSUSE Tumbleweed,
Slowroll, LEAP, SLES and SLED.

Signed-off-by: Jan Lindemann <jan@janware.com>
2026-01-28 18:11:09 +01:00
58e56648d2 jw.pkg.cmds.distro.backend.debian: Add Module
Add backend code for Debian-like package managing.

Signed-off-by: Jan Lindemann <jan@janware.com>
2026-01-28 18:11:09 +01:00
674e51a7b2 jw.pkg.cmds.distro.backend: Add module
Add directory to host distro backends.

Signed-off-by: Jan Lindemann <jan@janware.com>
2026-01-28 18:11:09 +01:00