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>
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>
Add a command "exec", which takes its arguments and runs it as a
shell command within all projects in $PGIT_SH_PROJECTS.
Signed-off-by: Jan Lindemann <jan@janware.com>
PGIT_SH_PROJECTS currently only sets the projects to operate on for
the get command. Extend this to all commands. And replace the
environment variable by a command-line option, likely after this
script has been ported to Python.
Signed-off-by: Jan Lindemann <jan@janware.com>
"clone" in the Git sense means to copy a remote project over from
scratch. pgit.sh clone has come from that, but has since evolved into
something different, a mixture of clone, pull and fetch, so find a
different name. "get" seems generic enough and doesn't clash with a
Git meaning. Adapt variable names accordingly across the project.
Signed-off-by: Jan Lindemann <jan@janware.com>
Continue to name variables in pgit.sh somewhat more consistently,
notably turn somevar into some_var. Plus some additional cleanup.
Still not a beauty.
Signed-off-by: Jan Lindemann <jan@janware.com>
The fat marker with counter (# ==== [1/1] Fetching ...) is
distracting if shown for only one project, so only show a regular
marker without counter.
Signed-off-by: Jan Lindemann <jan@janware.com>
If "current-branch" is specified within --refspec, either as from-ref
or as to-ref, expand that to the branch the working directory has
currently checked out.
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>
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>
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>
Among other atrocities, the Debian path filter contains some horrible
redundancies in an sed regular expression. Be a little less redundant
about it.
Signed-off-by: Jan Lindemann <jan@janware.com>
Not logging any attribute for links, as it's now, breaks Debian's
parser. So, log %attr(0777, $owner, $mode). This fixes the parser on
the Debian side and hopefully leaves the RPM side intact.
Signed-off-by: Jan Lindemann <jan@janware.com>
Calling make git-pull-xxx from a projects directory stops iterating
projects if one has a dirty workspace. Calling --autostash fixes
that.
With this in place, a failed rebase leaves the local changes behind
stashed. So, after manually fixing the rebase, the stash needs to be
manually reapplied. The commands that led up to the failure are
logged right before, so I have hope that this is learnable, and not
too much of a footgun.
Signed-off-by: Jan Lindemann <jan@janware.com>
Before merging the remote branch, do a rebase. This may fail and
prompt conflict resolution, but that seems the canonical outcome for
the common use case "interactive make git pull-xxx" with master
out-of-sync.
Signed-off-by: Jan Lindemann <jan@janware.com>
Retire pkg-manager.sh and replace it by the cleaner "jw-pkg.sh
distro" command, essentially providing the same functionality and
nearly the same command-line interface.
Not-so-fun-fact:
jw-pkg > git diff --stat jw-devops/master
...
71 files changed, 732 insertions(+), 340 deletions(-)
400 LOC more. That's what the move from a shell script to the more
maintainable Python versions costs. Still a good idea, and the
enhanced extensibility might pay off in terms of LOC with other shell
scripts in the future.
Signed-off-by: Jan Lindemann <jan@janware.com>
jw-projects.py is now a multi-call executable, with "projects" being
just one of its subcommands. Rename it to jw-pkg.py to reflect that.
Signed-off-by: Jan Lindemann <jan@janware.com>
In the os_cascade() function, don't roll own logic, call the richer
jw-projects.py projects os-cascade instead.
Signed-off-by: Jan Lindemann <jan@janware.com>
Reorganize the Python module structure. Placing the command classes
under jw.cmds.projects instead of jw.build.cmds will allow to add a
nested command structure, with the current commands, being mostly
related to building software, found below a "projects" toplevel
command.
Other conceivable commands could be "package" for packaging, or
"distro" for commands wrapping the distribution's package manager.
Signed-off-by: Jan Lindemann <jan@janware.com>
This reverts commit 98188eab23.
__init__.py alone is not enough to resolve the jw module in all
circumnstances, so go back to the old symbolic links solution.
Signed-off-by: Jan Lindemann <jan@janware.com>
$(TOPDIR)/scripts contains a symbolic link jw -> ../src/python/jw, to
allow jw-python.py access to the in-repo module jw.pkg. Should be
fine now even on Windows, OTOH, it's also solvable via __init__.py,
so do that.
Signed-off-by: Jan Lindemann <jan@janware.com>
To support minimal environments, notably minimal Docker containers
which don't have /usr/bin/sudo by the time pkg-manager.sh is invoked
(possibly to install sudo), support running all commands without
invoking sudo first. Of course this only works if invoked as root.
Note that this is still somewhat hacky, command-line parsing needs to
be cleaned up.
Signed-off-by: Jan Lindemann <jan@janware.com>
To avoid network errors while fetching tags, run
git submodule foreach --recursive 'git fetch --tags -f origin
i.e. only fetch tags from origin, which by convention points to
git.janware.com.
Signed-off-by: Jan Lindemann <jan@janware.com>
On pull / clone operations, run
git submodule foreach --recursive 'git fetch --tags'
Notably the Bootstrap package needs the tags to check out different
Bootstrap versions.
Signed-off-by: Jan Lindemann <jan@janware.com>
pkg.sh by default doesn't pack up version control metadata. Passing
-a or --include-vcs-files includes them in the source packages.
Signed-off-by: Jan Lindemann <jan@janware.com>
scm.sh ls-files by defaults does not list the VSC metadata files.
Passing -a includes them in the output.
Signed-off-by: Jan Lindemann <jan@janware.com>