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>
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>
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>
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>
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>
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>
Make some incomprensible parser error messages if run_curl() returns
nothing slightly less incomprehensible.
Signed-off-by: Jan Lindemann <jan@janware.com>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
Add more fields to the OS cascade returned by App.os_cascade, based
on the ID field in /etc/os-release. This includes some new ones,
prefixed by pkg-, revealing which package format is used.
Signed-off-by: Jan Lindemann <jan@janware.com>
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>
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>