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>
git-pull-<username> doesn't use pgit.sh if username == login.
pgit.sh should handle that case fine now, so remove the distinction
from topdir.mk and make it in one place, i.e. pgit.sh. This has the
additional advantage that pull as done by pgit.sh conveniently uses
--autostash.
Signed-off-by: Jan Lindemann <jan@janware.com>
The cases from-user == login and from-user != login have different
code paths and can be streamlined somewhat, so do that.
Signed-off-by: Jan Lindemann <jan@janware.com>
Purging the environment of pkg-release-reinstall did a tad too much:
Add SSH_AUTH_SOCK back to allow SSH agent-based authentication to go
through.
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>
Change commit message of first commit from "initial checkin" to
"First commit", because that's more to the point.
Signed-off-by: Jan Lindemann <jan@janware.com>
sudo is certainly not needed for the run package (which in itself is
hardly useful at all), so move that dependency into the devel
package. Same for gawk. /opt/jw-pkg/bin/get-os.sh depends on it,
but I don't see where else but in a -devel context that would matter.
And if it breaks something, it is going to be an easy fix without
awk.
Signed-off-by: Jan Lindemann <jan@janware.com>
--source-profile=replace should be passed to all
jw-pkg.py projects build pkg-*install
invocations. Those invocations typically happen in the context of
pkg-%install, so add that target, specializing the pkg-% target.
The problem this solves is that /etc/profile is currently read only
once before bootstrapping all software on a pristine system is
started. This might lead to the situation that package A has
installed environment variable definitions into /etc/profile.d,
package B needs them for building, but never gets to read them.
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>
dc945537 (pkg.sh log-install: Log %attr(0777, ...) for links) fixed
packaging symlink for Debian-based distros, but produces a warning on
RPM based distros: Links may not have explicit attributes, so go back
to not specifying them at all for RPM.
Signed-off-by: Jan Lindemann <jan@janware.com>
To complement git-pull-maintainer with something more generic, also
suitable for other SCMs, add the target pull-maintainer and make
pkg-release-reinstall depend on it. Currently only visible in the
context of pkg-% targets, scope might be expanded if need be.
Signed-off-by: Jan Lindemann <jan@janware.com>
Use pgit.sh to for the git-pull-% target. This should make
git-pull-maintainer work. To limit the blast radius for now, only use
it if the source user differs from the invoking user.
Signed-off-by: Jan Lindemann <jan@janware.com>
Multiple variables are redundantly defined both for a project and for
the multiple-projects toplevel directory. Add a place to maintain
them centrally, and add PGIT_SH as a first variable.
Signed-off-by: Jan Lindemann <jan@janware.com>
Add an init target. Use it if you want to tell the Makefile: _Just_
initalize the build machinery and nothing else, don't pull and build
everything else you can. Not strictly necessary, most of the time
pulling everything is what's wanted, and that does the init anyway.
Signed-off-by: Jan Lindemann <jan@janware.com>
The target pkg-delete-ours, invoked from the projects directory,
should wipe all packages from the system which have been created and
installed via jw-pkg.
Currently they are selected via url =~ janware. This is a default
string which can be overridden by redefining JANWARE_PACKAGE_FILTER.
This might not be the most generic name, but is kind of consistent
and will be matched once all variables get renamed to a more generic
naming scheme.
This currently does not get all packages: Some are not labeled with
URLs matching "janware", because jw-pkg is only used as a convenient
way to package other people's open source projects.
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>
This commit allows pgit.sh to target not only multiple projects below
a projects-directory, but also one single project. If invoked from
the toplevel directory of a project, it uses that as the only project
it should deal with. This is meant to facilitate running the same VCS
abstraction logic for one project as for many projects. The project
or projects to deal with should probably be specified on the command
line, but changing the auto-detection mechanism buys us what we want
for now with low hassle.
Signed-off-by: Jan Lindemann <jan@janware.com>
Some variable names are too short for global scope ($p, $pdir,
$pdirs), among others. For those mentioned: Make them longer and more
descriptive.
Also add a variable project_name, which denotes what a project is in
a remote repository, and which is currently but not necessarily
always the same as the project directory.
Signed-off-by: Jan Lindemann <jan@janware.com>