Commit Graph

1395 Commits

Author SHA1 Message Date
Allison Karlitskaya 4bdf01e366 various: many typing-related fixups
In addition to fixing some issues, testlib is now strictly typed.
2024-04-23 00:13:10 +02:00
Allison Karlitskaya 60d54b8a31 tools: rename vulture(- → _)suppressions
We are about to ask mypy to run on the entire source tree, and it
doesn't like having `-` in module names.  Use a `_` instead.
2024-04-23 00:13:10 +02:00
Martin Pitt 4d7fcbfebb tools: Depend on kdumpctl binary
`kdumpctl` moved from the kexec-tools to the kdump-utils package in
Fedora Rawhide, and the former does not require the latter. To make sure
we get the one we want, depend on the program path directly.

https://bugzilla.redhat.com/show_bug.cgi?id=2275385
2024-04-19 09:42:10 +02:00
Allison Karlitskaya 5b6c1ce8ae pyproject: enable 'preview' ruff rules
Now that we gate our ruff updates via the tasks container, we can afford
to be a bit more future-oriented here.

This brings in a nice raft of fix-ups, including my personal favourite:

  RUF003 Comment contains ambiguous `µ` (MICRO SIGN). Did you mean `μ` (GREEK SMALL LETTER MU)?

Sure... why not?

The majority of fixes here are from a single rule suggesting to rewrite

  a and b or c

as

  (a and b) or c

But in most (but not all) cases in our code we actually want to write
that as

  b if a else c

I've also added some type annotations to help me make the right choice
in places where it wasn't immediately clear.
2024-04-16 14:08:52 +02:00
Jelle van der Waa cb6da2602b lib: introduce an upload() helper for fsreplace1
Introduces a helper function which handles uploading a ReadableStream to
a server with `fsreplace1`, sending data in chunks, with proper flow
control and progress reporting.  This is made to be used for
cockpit-files but is re-usable for other plugins.

Add a React component to the playground as a proof of concept, and add a
couple of integration tests based on it.

Co-authored-by: Allison Karlitskaya <allison.karlitskaya@redhat.com>
2024-04-16 12:47:07 +02:00
Allison Karlitskaya eabef5a10a tools: add 'release' script
This is a new script for building Cockpit releases.  It essentially does
what we do now, except:

 - we use the container version specified in our .cockpit-ci/container
   file

 - we download everything with a single invocation of `git clone`, which
   downloads all the required submodules, but only does a shallow fetch

 - we run the build process entirely offline, inside of its own
   container

The new script is meant to be more accessible to anyone who may be
interested in running it, including outside of GitHub, and is written in
a way that attempts to convince its reader that nothing tricky is going
on.  It should always produce a byte-for-byte identical release as the
official one.  It acts as a convenient way to verify the reproducibility
and validity of a Cockpit release, and also as an alternative to
downloading the tarball from GitHub.
2024-04-03 07:24:50 +02:00
Jelle van der Waa 086c24c43e test: move select_pf5 from cockpit-files to Cockpit
The new PatternFly Select uses a Menu component for the entries so the
selectors changed. This test function comes from cockpit-files.
2024-03-20 16:39:38 +01:00
Martin Pitt 6be5f27fa8 tools: Fix pam_listfile PAM stage
This should be in "account" (aka. "denied access"), not "auth" (aka.
"provided wrong credentials"). Thanks to Stephen Gallagher for pointing
out!

Adjust testPamAccess accordingly, which now shows the corresponding
message.
2024-03-15 11:45:09 +01:00
Martin Pitt 0c69347fb1 tools: Print failure details
This might tell us what's wrong about that dmtf.org URL when running in
GitHub (issue #20167).
2024-03-13 16:30:00 +01:00
Martin Pitt 5659be3938 tools: Add AppArmor profile for cockpit-desktop
Ubuntu 24.04 LTS restricts user name spaces by default. Add an AppArmor
profile for cockpit-desktop to allow it. This is a no-op for older
releases.

See https://launchpad.net/bugs/2046477 for details.
2024-03-12 16:14:27 +01:00
Luna 50fc1b962e don't try and install pytest requirements on suse for now 2024-03-06 14:08:16 +01:00
Martin Pitt 429b3c286f Drop cockpit-appstream split
This was only a thing on RHEL 8, which we don't support on this branch
any more.
2024-02-16 14:19:05 +01:00
Jelle van der Waa 076f732ea8 tools: add dry run option to urls-check 2024-02-14 12:16:36 +01:00
Martin Pitt 59e1df60b3 workflows: Drop i386 unit test/container
We won't add a lot of new C code any more, valgrinding Python code isn't
very useful (or architecture specific), and more and more distributions
drop i386 support. Also, we still run the unit tests during RPM package
build through packit/COPR, which cover even more architectures.

This paves the way for dropping the unit test container altogether in
favor of running the tests in the cockpit/tasks container, once we agree
on how to build a proper staging setup.

Drop tools/valgrind.supp which was only relevant for i386.
2024-02-14 09:43:09 +01:00
Jelle van der Waa 808e75cc68 tools: update node_modules tool documentation
The /npm install workflow has been dropped for a while now in
ae9404596a.
2024-02-05 08:14:15 +01:00
Allison Karlitskaya 9b221db9b6 ruff: move linter settings to [lint] section
New ruff warns to stderr that the old way is deprecated.  That's enough
to convince test/static-code that an error is being reported.

Let's move this over.
2024-02-02 16:16:19 +01:00
Allison Karlitskaya df84772227 cockpit.print: add fsinfo support
Also make a minor tweak to literal handling so we can write `fnmatch=*`
instead of `fnmatch="'*'"`.  A `*` would never indicate an attempt to
express a complex Python literal and is invalid unless quoted.

You can now rather comfortably do something like:

  cpf fsinfo / type size user mode fnmatch=* | cockpit-bridge
2024-01-24 14:50:07 +01:00
Michael Biebl 087527f2a9 tools: Rely on pam.pc to get pam's libdir in Debian packaging
This will install the PAM modules into /usr once pam.pc switches over.

https://bugs.debian.org/1061198
2024-01-22 19:49:34 +01:00
Jelle van der Waa 757b8729ec tools: debian: suggest udisks2-btrfs 2024-01-15 17:53:16 +01:00
Jelle van der Waa 7ca4580070 tools: recommend udisks2-btrfs on non-RHEL distro's 2024-01-15 17:53:16 +01:00
Martin Pitt 8fb879870c session: Drop support for sssd < 2.6.1
All our supported distros have a newer version: Ubuntu 22.04 LTS has
2.6.3, Debian stable has 2.8.2, RHEL 8/9 have 2.9.3. So we can finally
drop support for the unsafe `FindByCertificate()` call which doesn't
validate certificates against the CA.
2024-01-10 21:58:57 +01:00
Marius Vollmer f0b0961515 storage: Redesign
Co-authored-by: Garrett LeSage <garrett@redhat.com>
2023-12-01 14:06:40 +01:00
Martin Pitt 5c824f83f2 tools: Drop cockpit-pcp on ix86 on recent Fedora/RHEL
The most recent PCP Fedora rawhide update [1] stopped building pcp on
ix86 for Fedora ≥ 40 and RHEL ≥ 10. Follow suit and disable building the
PCP bridge and the cockpit-package there.

[1] https://bodhi.fedoraproject.org/updates/FEDORA-2023-cf7eccd442
[2] fc70568e93?branch=rawhide
2023-11-21 09:00:43 +01:00
Martin Pitt 6c839c4a73 tools: mypy fixes/annotations for build-debian-copyright
Add type annotations/ignores to clean up mypy errors in scripts in src/
and tools/.

Rename the second `files` variable in build-debian-copyright as it was
previously shadowing an earlier `files` global variable with a different
type.
2023-11-02 09:45:34 +01:00
Jelle van der Waa cbfb1a0f43 test: apply eslint to .js files as well
We want to lint all our JavaScript code, this would trip over
tools/webpack-make.js as it's a shell script. Ignorning it still gives
an eslint warning so this has to be converted to a proper JavaScript
file.
2023-10-27 13:42:46 +02:00
Martin Pitt 75c8b25af6 build: Drop ssh manifest.json for pybridge install
Move the ssh manifest out of pkg/; there is nothing to be esbuilt or
watched, it's just a single configuration file for the cockpit-ssh
program.

We also don't need it with the Python bridge, as that handles remote
hosts internally. Direct remote logins from the login page call
cockpit-ssh directly, not via the manifest. So conditionalize its
installation on the C bridge.
2023-10-05 10:31:00 +02:00
Helmut Grohne c32d263058 tools: Read systemd unit dir from pkgconfig
Debian wants to change the value of systemdsystemunitdir in systemd.pc
to point below /usr. cockpit's upstream build system consumes this
variable while the Debian packaging hardcoded its current value.

The .pc file was moved out into systemd-dev in systemd 253-2, so add an
alternative build dependency to reduce the build dependency footprint on
new Debian/Ubuntu releases.

https://bugs.debian.org/1053112
2023-09-28 11:16:06 +02:00
Jelle van der Waa 1907213c2f ruff: Enable UP032 f-string rule
Convert .format() to f-strings with ruff's auto-fixer.
2023-09-27 17:44:24 +02:00
Allison Karlitskaya ba933040be client: Spawn cockpit-beiboot via `python3 -m`
This allows us to avoid installing an unnecessary wrapper in libexecdir.
2023-09-27 17:00:01 +02:00
Jelle van der Waa 4de8943d44 Makefile.am: cockpit_enable_python was dropped
The Python bridge is now default enabled in 14c07d7087 and
this also removed cockpit_enable_python in favour of explicitly enabling
the old bridge. As RHEL 8 ships the old bridge by default we need to
toggle this for the pybridge scenario.
2023-09-17 15:59:38 +02:00
Jelle van der Waa 3bd9a45a8a tools: sync Arch Linux upstream packaging changes
Upstream split cockpit-storaged/cockpit-packagekit into a new package
and has an alternative approach for disallowing root login where users
no longer opt in but get it by default.
2023-09-13 05:45:39 +02:00
Martin Pitt 094f87d635 tools: BuildRequires: python3-devel
Fedora packaging policy demands python3-devel [1]. RHEL 8 has multiple
Python versions available, and depending on the python3 binary can
possibly select the non-default one from a module (such as Python
3.11). Ensure that we build against 3.6 by requiring python3-devel
  instead.

https://issues.redhat.com/browse/RHEL-2215
https://issues.redhat.com/browse/RHEL-2218

[1] https://docs.fedoraproject.org/en-US/packaging-guidelines/Python/#_buildrequire_python3_devel
2023-09-12 09:22:22 +03:00
Martin Pitt 6283d5caf0 tools: Enable the Python bridge on stable Debian/Ubuntu
By now we have enough faith in it that we can drop the special case.
This only leaves the C bridge for RHEL/CentOS 8, which will be branched
off and thus disappear in about half a year.

Invoking pytests on Ubuntu 22.04 requires a special case for the old
pytest version unfortunately, but this will go away in ~ 9 months.
2023-09-11 18:16:48 +02:00
Martin Pitt 3d999aa2e2 tools: Explicitly set admin group on arch
Apparently the `wheel` group is not present any more in latest Arch's
build environment, so the auto-detection now falls back to "root".
2023-09-11 10:57:07 +02:00
Martin Pitt 14c07d7087 build: Make Python bridge the default
Replace --enable-pybridge with --enable-old-bridge, and flip the logic.
That way, it will slowly disappear as old distro releases become
unsupported. This also means that builders from upstream now get the
Python bridge by default.

The distcheck scenarios now apply to the Python bridge. Add a
`$DEB_PYTHON_INSTALL_LAYOUT` hack to work around
https://bugs.debian.org/1035546 to unbreak the installation of the
generated wrapper binaries, as by default they'd go into
prefix/usr/local/bin on Debian.

Add a new distcheck scenario for the C bridge, to ensure that we don't
break that.

https://issues.redhat.com/browse/COCKPIT-1037
2023-09-08 12:36:49 +02:00
Martin Pitt 0c23291419 tools: Change Debian pip install hack to use DEB_PYTHON_INSTALL_LAYOUT
This simplifies the hack: We no longer need the temporary symlink dance,
but let the upstream build system put the Python module directly into
the distro target path that `dh_python` will use anyway.
2023-09-08 12:36:49 +02:00
Martin Pitt bfd923947d tools: Fix "only arch all" Debian build
Similarly to commit 584cdfb6a0, remove the installed cockpit-beiboot
from the temporary install tree for arch-indep builds. That file was
added in commit fb673e0a7.
2023-09-07 10:03:25 +02:00
Martin Pitt fb673e0a7c pybridge: Move cockpit-beiboot from client into cockpit module
Start shipping it in the cockpit-bridge rpm/deb in libexecdir. This
paves the way for enabling this functionality in the cockpit/ws
container and other places, and reduces the flatpak special cases.

Note that this still keeps the beiboot functionality disabled for
standard package installs, as desired -- this needs to be explicitly
configured in `cockpit.conf`.
2023-08-25 18:17:26 +02:00
Martin Pitt 4b68be7012 tools: Fix building Debian source package after binary build
Building the binary and running the tests creates tmp/wheel and
.pytest_cache/, which are considered as unrepresentable source changes.
Let dh_clean remove them before building a source package.

Moreover, running the unit tests changes the "dev@cockpit-project.org"
in src/ssh/mock_rsa_key.pub to the local user@hostname. Our tests don't
explicitly do that, this smells like some libssh bug/weirdness. Until
this is investigated, just ignore the changes in that file for building
a source package.

https://bugs.debian.org/1044095
2023-08-24 10:38:08 +02:00
Martin Pitt 568caa7120 tools: Drop obsolete valgrind suppressions
These bugs got fixed years ago.
2023-08-23 10:04:37 +02:00
Simon Kobyda fbc262b159 Add "macro 'an-trap' not defined" warning to lintian overrides
As of groff 1.23.0 "an-trap" macro was renamed to "an-input-trap". This
change is already present in debian-testing.
However, xsltproc which we use to generate manpages still uses the old
macro, since it runs on Fedora 38 docbook.
2023-08-02 14:04:29 +02:00
Jelle van der Waa 3b6ac383df tools: don't parse --force as valid SHA
Closes #18929
2023-07-28 16:50:31 +02:00
Martin Pitt 8ec991b3ab tools: Suggest mdadm for cockpit-storaged
The latest libblockdev-mdraid package does not depend on `mdraid` any
more. That is okay, as it comes with some initrd and boot baggage, so we
don't want to force it upon every cockpit user either. Trying to create
an md array without mdadm installed gives a clear error message:

    Error creating RAID array: The 'mdadm' utility is not available

So just add a Suggests for it.

Thanks to Michael Biebl for pointing this out!
2023-07-18 11:28:42 +02:00
Martin Pitt 4d4dc4dab5 tools: Enable Python bridge on RHEL/CentOS 9 2023-07-18 09:29:34 +02:00
Martin Pitt 86510f802b tools: Enable Python bridge on Fedora 38 2023-07-17 18:58:50 +02:00
Allison Karlitskaya 1b715616f0 cockpit.print: add helper for packages reloading
...and fix up some handling of arguments on D-Bus commands.

Also: change all pass-through **kwargs to be typed as 'Any' instead of
'object.  This is more correct, since the kwargs might contain values
that are destined to be captured by the optional arguments of the nested
function calls, without further type checking.
2023-07-17 16:58:42 +02:00
Martin Pitt 4b046e0625 tools: Adjust Debian libblockdev-mdraid dependency for udisks 2.10
The most recent udisks2 version moved to libblockdev 3.0, which bumped
its soname to libblockdev-mdraid3. udisks2 2.10 has a hard dependency to
libblockdev-mdraid3, so we don't need to depend on the latter directly
any more. But keep an alternative dependency for older releases.

Fixes https://bugs.debian.org/1040803
2023-07-11 18:00:16 +02:00
Martin Pitt 226067b692 tools: Add font related Debian lintian overrides 2023-06-28 09:11:21 +02:00
Martin Pitt 59382a1b70 tools: Drop unused BSD-3-clause license paragraph from Debian copyright
Spotted by lintian.
2023-06-28 09:11:21 +02:00
Martin Pitt 6a7f15e35c tools: Clarify Debian cockpit-packagekit description
Sync it with the rpm.

Fixes lintian "extended-description-is-probably-too-short".
2023-06-28 09:11:21 +02:00