Commit graph

168 commits

Author SHA1 Message Date
Freya Gustavsson
c958a4d176 git: Add configure~ to gitignore
As part of running `./autogen.sh` I get a `configure~` generated
alongside `configure`. This seems to be an intermittent step and should
be ignored.

For reference, this is ignored by automake itself
080b6dbea2/.gitignore (L1)

Signed-off-by: Freya Gustavsson <freya@venefilyn.se>
2026-02-10 13:13:57 +01:00
Allison Karlitskaya
751f9b2ca6 src: merge ws-only code into src/ws
There's an awful lot of code in `src/common` and `src/websocket` which
is used only by `cockpit-ws`.  Move all of those files (and the tests
for them) into `src/ws`.

Assisted-by: Claude <noreply@anthropic.com>
2026-01-29 21:02:59 +01:00
Martin Pitt
dbb75c5a98 containers/ws: Add quick iteration developer target
Add a `make ws-container-build-tree` target which copies the bundles and
binaries from the build tree into the container image. This is much
faster than a full image-prepare and building rpms in a VM.

This could be optimized further to not always reinstall the rpms during
each container build, but reuse these layers. However, the Containerfile
currently does the `ADD .` before the dnf install, and all the install
steps happen in an order which breaks efficient caching. This is
annoyingly hard to fix (cue: `COPY` and `ADD` barf with nonexisting
files/directories, even with globbing).

Only use when you know what you are doing -- if it breaks, you get to
keep both halves.
2026-01-23 16:09:26 +01:00
Freya Gustavsson
23e095b9d3 doc: Move build workflow to AsciiDoc
With the created AsciiDoc files for documentation we can now update our
build structure to generate the HTML and Manpage files both during build
and package distribution.

Changes
- Uses AsciiDoctor or asciidoc-py and a2x to generate HTML and Manpages.
- Generated HTML and Manpage files moved to `doc/output/`.
- Support packaging docs on all distributions Cockpit deploys to.
- Add package dependencies for AsciiDoctor and asciidoc-py.
- Safety fallback in automake file to search for either asciidoctor or
  asciidoc-py in terms of priority.

Known issues
- Links in guide pages goes to new files for the pages themselves, which
  meant we now generate HTML files for all `.adoc` files and not just
  `index.html`.

With the removal of fonts we also managed to break the build pipeline
that automake generated for us. As the doc guide fonts make rule was
removed, which relied on `$(DIST_STAMP)` rule, automake optimized the
build process and in turn broke the workflow. As a workaround the
`$(DIST_STAMP)` rule was added to the index rule as a dep to help
automake generate it the way we want it.

As the workaround is a hack and not a real solution, this needs to be
fixed in another PR to make sure these dependency issues do not occur if
we were to remove `$(DIST_STAMP)` from a rule.

We also need the `$(DIST_STAMP)` to appear last in the doc generation or
something, likely race condition, may cause the `index.html` to only
contain `{}`.

Related-to: https://github.com/cockpit-project/cockpit/issues/22648
Related-to: https://github.com/cockpit-project/cockpit/issues/22647
Co-authored-by: Aleksandra Fedorova <afedorova@redhat.com>
Signed-off-by: Freya Gustavsson <freya@venefilyn.se>
2025-12-16 09:41:37 +01:00
Martin Pitt
3e98bd82fb build: Only include actually bundled npm modules into the spec
Our package.json's `dependencies` has transitive/optional dependencies
which don't actually end up in the bundle, e.g. `argparse`,
`attr-accept`, or `js-tokens`; or `react-dropzone` which is a
`@patternfly/react-table` dependency, but not actually used in
cockpit.

The next commit will aggravate this further.

So make the computation of the `Provides: bundled(npm(..))` lines more
precise: Ask esbuild about which modules it actually included, which it
tells us via the "metafile". Change build.js to always output that (drop
the `--metafile` option), compute a ./runtime-npm-modules.txt list, and
use that to build the spec file.

Ported from https://github.com/cockpit-project/cockpit-files/commit/e15a518fddad1
2025-11-19 11:53:54 +01:00
Martin Pitt
544a4ae50b gitignore: Fix appdata.xml
The file was renamed in commit f459553303.
2025-01-13 12:54:29 +01:00
Alice Brooks
8878ebddeb .gitignore: Ignore test results 2025-01-08 17:48:11 +01:00
Allison Karlitskaya
436b7af01b .gitignore: only ignore cockpit.socket
We only dynamically generate a single .socket file now.  The rest of
them are in version control and installed verbatim.
2024-11-22 09:54:17 +01:00
Allison Karlitskaya
8463df0251 src: move PolKit policy from bridge/ to systemd/
This isn't really a systemd file, but it fits in well with the rest of
the systems integration stuff in that directory.  Besides: this isn't
tied to the C bridge anymore: we use it from Python as well, and will be
getting rid of the C bridge soon.

There's a theoretical functional change here which makes no difference
in practice: we now install the policy file unconditionally.  We'll soon
remove the `--disable-polkit` option anyway, and the only two things
that call `--disable-polkit` don't call `make install`
(`tools/make-dist` and the flatpak build).
2024-10-07 15:10:54 +02:00
Martin Pitt
86bf3626e2 ssh: Drop cockpit-ssh
Nothing uses this any more, superseded by cockpit-beiboot. This gets rid
of the libssh build dependency.

Drop the `Provides: cockpit-ssh` from Debian. No package ever related to
that virtual package name, and it's meaningless these days.
2024-09-30 09:36:34 +02:00
Allison Karlitskaya
0c1029c980 build: rename fail.html.c to fail-html.c
We hardcode the failure page into cockpit-ws because we want to be able
to serve it even in situations where the install is totally broken.  We
do that by use of a very trivial script which escapes the html file as a
string in a temporary .c file which gets included as part of cockpit-ws.

Unfortunately, the name of that file — fail.html.c — was poorly chosen.

make has a built-in implicit rule for turning %.c into % by running the
C compiler.  When it sees that fail.html is older than fail.html.c it
concludes that the correct thing to do is to bring it up to date by
compiling it, replacing the original HTML page with a binary.  That's
wrong of course, and doesn't work anyway, since there's no main().

The only reason that this hasn't been a problem up to now is that there
seems to be some complicated side-effects caused by having .html
included in our TEST_EXTENSIONS list, but the next commit wants to
remove that.

Let's just avoid the problem up by calling the file by a different name
that won't match that implicit rule.

While we're at it, remove a single stray tab character that somehow made
its way into the fail page.
2024-08-14 12:53:09 +02:00
Allison Karlitskaya
ffe62648fd test/static-code: tweak Typescript config again
Having `checkLib: false` in `tsconfig.conf` is a bad idea: it means that
if we want to check `.d.ts` files, we need a separate invocation of the
typescript compiler to do that.  It also means that `.d.ts` files won't
be checked in your editor by default.  Our workaround for this in
`test/static-code` only checks `cockpit.d.ts`, and we'll soon have other
declaration files.

We've been using `checkLib: false` as a crutch to avoid reporting errors
against `node_modules/`.  The relevant TypeScript issue is still
unaddressed: https://github.com/microsoft/TypeScript/issues/30511

Modify `test/static-code` to only report errors if errors were found on
something outside of node_modules, but in that case, report all errors.
We do this with two invocations of `tsc`, to keep things simple, but
we'll only do the second invocation if we're reporting errors.  To keep
things speedy, we turn on "incremental" mode (which writes a cache file
to speed things up).  `.gitignore` that.  It now takes only ~2s to do an
incremental check in the "no errors" case.

By default, `tsc` outputs a very nice format that shows the exact
content of errors, but this doesn't work by default in
`test/static-code` because we capture the output before displaying it.
Detect if we're running on a TTY (or if `FORCE_COLOR=1` as from our
workflows) and enable the "pretty" output in that case.
2024-07-02 18:59:08 +02:00
Martin Pitt
0763c94bcd gitignore: Re-ignore built tmpfiles.d file
Commit 930d957325 renamed/moved the file, but forgot to adjust
.gitignore.
2024-06-24 10:06:08 +02:00
Allison Karlitskaya
747f1cb0ac .gitignore: add .tox 2023-07-17 16:58:42 +02:00
Allison Karlitskaya
7a9f3396f4 tools: remove jumpstart from make-dist
Remove the jumpstart-related options as well as the default behaviour of
using jumpstart if dist/ is missing.
2023-03-21 17:43:12 +01:00
Martin Pitt
18576f7d18 build: Put webpacked unit tests into ./qunit/
This separates the bits which we want to install from the generated
QUnit tests, which should stay in the build tree. This will become
relevant once we drop Makefile.deps and its WEBPACK_INSTALL variable.
2023-03-20 15:20:38 +01:00
Martin Pitt
1e3f1083df pkg: Move AppStream metadata files to src/appstream/
These are the only files which get put into pkg/ during build. This is
conceptually awkward, as we want to treat pkg/ as pure source for
webpack related input, and not write make-built files into $(srcdir).

It's also technically awkward, as we soon want to drop the Makefile.deps
mechanism, and instead have a global dynamic pkg/ → dist/ dependency.
`make` changing files in pkg/ would unnecessarily build the webpack at
each invocation.

So move them to src/appstream/ instead. They fit better there, as they
are not part of webpacks (in dist/), and are better handled by make than
by webpack.
2023-03-20 15:20:38 +01:00
Simon Kobyda
d0159d9f22 Add *.swp pattern into .gitignore 2023-02-15 16:47:22 +01:00
Martin Pitt
7f3eca3dfb .gitignore: Drop cockpit-bridge.pyz
The pyz got dropped in commit e218b37d63.
2023-01-13 11:57:35 +01:00
Allison Karlitskaya
1404e2712f test: build a wheel for the pybridge scenario
Since we dropped the Makefile rule for creating cockpit-bridge.pyz, the
pybridge scenario has been broken.

Add some minimal pyproject.toml metadata required to build a wheel of
the Python package.  Build this wheel on the outside, and inject it into
the VM via image-customize.

Note: we no longer bother with building the C parts of the package
anymore — we rely on the distro packages already present in the image.
2022-11-18 17:26:08 +01:00
Allison Karlitskaya
1ced362e6f git: Add systemd_ctypes as submodule
Doing it this way instead of ad-hoc allows us to improve the way we run
the unit-tests container: we can now check out the submodule as part of
the preparation step, eliminating the need for network access inside the
container.
2022-11-04 17:42:27 +01:00
Allison Karlitskaya
53d569624d python: add a framework for unit testing
Set up pytest and coverage via pyproject.toml.  Add some hints for
static linters, as well.

Add some tests for the Transport classes.  These already found several
bugs (fixed in previous commits).
2022-11-04 17:42:27 +01:00
Allison Karlitskaya
bbccd8f8a2 python: Add build system integration
Add support for creating cockpit-bridge.pyz as a zipapp, containing the
Python bridge, systemd_ctypes, plus a full set of packages from dist/.
Add a target `make pycheck` to run the QUnit tests against this new
bridge package.
2022-07-07 16:50:22 +02:00
Allison Karlitskaya
c9344d25f2 build: fix valgrind --suppressions= logic
The logic is broken for builddir != srcdir builds, since it doesn't
include $(srcdir).  It's also a bit silly to explicitly list all of the
files when we can easily do it with `$(wildcard)`.

Switch to `$(wildcard)`, include `$(srcdir)` and inline the whole thing.
2022-06-14 11:13:05 +02:00
Jelle van der Waa
ade3ff7cbd .gitignore: add version.m4
Introduced in e2f2d830e1
2022-06-07 17:07:36 +02:00
Allison Karlitskaya
31d36929d7 .gitignore: fix sort order 2022-06-01 21:11:25 +02:00
Allison Karlitskaya
79cfdf9b22 .gitignore: add doc output
ac7b5b2fc8 changed the location of the
docs output but didn't add it to .gitignore.

Do that now.
2022-06-01 21:11:25 +02:00
Allison Karlitskaya
e515f95fb5 flatpak: significantly simplify scripts
Drop the weird thing where we source the 'prepare' script and do some
stuff before running the 'prepare' function defined inside of it.  This
is now a simple script, with two arguments: the source location and the
checksum.  If the source is unspecified, it will be created.  If the
checksum is omitted, and the source is local, it will be calculated.

The prepare script writes the manifest to the working directory where it
was invoked and prints the name of the file to stdout.

Adjust containers/flatpak/install for these changes, and take advantage
of the fact that the output is now placed in the working directory:
change to tmp/ first, and do the build there as well.  That lets us
clean up some .gitignore noise as well.

We drop the update-flathub machinery for now.  It'll be brought back
very soon as part of a revamped release script.
2022-05-23 11:35:44 +02:00
Marius Vollmer
6dbdc39a7b test: Add --coverage option 2022-04-04 09:42:17 +02:00
Allison Karlitskaya
c73eec9e34 client: install metainfo file
Create a tool to turn the point form notes in our tags into a proper set
of <release/> tags for metainfo and fill this information in when
building a tarball.

Install the metainfo if building with --enable-client.  Validate it
at install time as part of building the flatpak — since we no longer
handle it separately, it's more difficult to do that from the outside
now.

Strip the old metainfo handling out of the containers/flatpak scripts.
Add a nice automake-style output for generating the manifest .yml.

This will simplify the process of releasing the flatpak.

The version of Python we have on the GitHub `ubuntu-latest` runner is
lacking the `indent` function in ElementTree, so add a hack to disable
it.  We do it this way to make it easier to back this out in the future.
2022-04-01 16:40:26 +02:00
Martin Pitt
1804884bc8 po: Translate messages from our extension AppStream metadata
Extract *.metainfo.xml strings into our PO template, and use po files to
generate the installed metainfo.xml files.

Amend the distcheck unit test to ensure that translatable strings are
extracted from our cockpit webapp AppStream data (which was already the
case) as well as for our extensions (which is fixed with this commit).

Adjust package build dependencies to ensure gettext support. Current
gettext version 0.21 ships `metainfo.its`, for older releases (RHEL
8 and Ubuntu 20.04) this needs the additional appstream package.

Fixes https://bugzilla.redhat.com/show_bug.cgi?id=2018389
2022-03-21 11:13:48 +01:00
Allison Karlitskaya
bcb0e2ec11 tools: add tool to create compile_commands.json
Add a new script, tools/make-compile-commands, which can generate the
compile_commands.json script used by many static analysis tools.

Run the script at the end of ./configure.
2022-03-15 11:37:21 +01:00
Allison Karlitskaya
fd7ab0225b build: remove custom install rules for webpack
Now that we don't have to deal with on-the-fly compression of .gz files,
we can use a much easier approach to installing our webpack output.

automake's nobase_ prefix is pretty much exactly designed for this sort
of "preserve tree structure" installation.  There's only one catch:
since we have no way to drop the `dist/` prefix, we do a workaround:
create a symlink from `cockpit/` to `dist/` and install the files, via
that symlink, directly into `$(datadir)`.

That gets us names like `/usr/share/cockpit/base1/cockpit.js.gz`, as
before.

It also means that it's now possible to point XDG_DATA_DIRS directly at
the build directory, for testing purposes.

One issue this introduces is how to deal with the manifests for pcp and
ssh: the tar rule managed to strip the pkg/ prefix from those, but now
we have to install them a bit more explicitly.
2022-03-11 17:12:37 +01:00
Allison Karlitskaya
6e05c1468e build: drop tar tricks in dist-hook
We use a dist-hook combined with tar for some fairly complicated
reasons, constituting one of the most non-obvious corners of the build
system.  The main reasons for that are:

 1) directly adding a list of files in git to EXTRA_DIST is not
    something that can be done reasonably in make syntax, and
    particularly when we also need it to work when building from tar

 2) (and this is complicated) we support typing `make dist` directly
    after configuring the package in order to get a .tar release,
    containing the files built by webpack (which will be implicitly
    built as a part of `make dist`).  We know what files to ship because
    `webpack-make` writes a set of `Makefile.deps` files, setting the
    `WEBPACK_INPUTS` and `WEBPACK_OUTPUTS` variables.  At the time of
    the first `make dist` invocation on the freshly-configured project,
    we immediately call `make distdir-am` which is what invokes
    webpack-make.  However: this invocation of make doesn't get a chance
    to include the Makefiles that weren't present at the time it was
    invoked, and as a result, doesn't have access to the final values of
    `WEBPACK_INPUTS` and `WEBPACK_OUTPUTS`.  We've solved this by using
    `dist-hook` (which gets a fresh recursive make invocation, and a new
    chance to read the Makefiles.deps).

  3) we want to make some minor adjustments to the distdir (adding a
     .tarball file, adjusting timestamps, etc).

Our use of tar is pretty evil here, though, and it breaks badly when
combined with out-of-tree builds.  It turns out that automake has quite
some logic for dealing with VPATH demangling, if only we can get the
files that we want to ship into `EXTRA_DIST` at the time of the `make
distdir-am` invocation.

We achieve this by using our (already existing) `distdir:` target
override to gain more control over the `make distdir-am` invocation.
The three points above are addressed, as follows:

  1) If we're in a git tree, we create (or update) a .committed_files
     file on `make dist` and pass its contents to be added to
     `EXTRA_DIST` in the `make distdir-am` invocation.  We add this file
     itself to the dist, avoiding the need to use `find` in the
     "non-git" case.

  2) By adding `$(DISTFILES)` as a dependency of the `distdir:` target,
     we can be sure our webpack (and other things in parallel) will be
     built by the time we do the recursive `make distdir-am` invocation.
     This specifically means that the Makfefile.deps will be available
     to be included, allowing `WEBPACK_INPUTS` and `WEBPACK_OUTPUTS` to
     be added to `EXTRA_DIST` in the usual way.

  3) We can make our minor adjustments to the distdir directly from the
     `distdir:` target, after the `make distdir-am` invocation.

In addition to working with out-of-tree builds, the new approach is, to
my eye, much easier to understand in depth.
2022-03-10 00:11:14 +01:00
Allison Karlitskaya
f87b0481a6 .gitignore: more cleanup
Drop all .gitignore files in subdirectories, leaving only the toplevel.

The rules contained in those files were mostly outdated, which shows the
usefulness of having one file in a central location.

Add a couple of more general-purpose rules for things like coverage data
(--enable-coverage) and make some of the wildcard rules more specific
(and self-documenting).
2022-02-28 12:30:51 +01:00
Allison Karlitskaya
efddbb590a build: build selinux policy "upstream"
Take the SELinux policy building out of the spec file and add a proper
set of Makefile rules for it.  Stop blanket-disting the selinux/
subdirectory, and treat it more like a normal source directory.

The new rules are only enabled if --enable-selinux-policy=<type> is
explicitly given.

From the parts remaining in the spec file, clean them up a bit: remove
the with_selinux conditional and use the pre- and post- rules
unconditionally: we're only building the cockpit-ws package, anyway, in
exactly the case that we'd want SELinux policy enabled.

We can also make use of the macro provided by the selinux-policy package
to avoid having to guess the version number for ourselves.  We need to
keep our own dependencies (instead of using %selinux_requires), though
for two reasons:

  - chicken and egg problem: without a static BuildRequires on
    selinux-policy, the macros themselves wouldn't be available during
    the SRPM build, which means that we don't know that we need
    selinux-policy.

  - the post dependencies defined by the macro are a bit too aggressive
    and aren't conditional on selinux being available at all.  This
    would break container builds, for example.

Our %build stage now consists of a single %configure invocation and a
single %make_build invocation.
2022-01-26 13:19:08 +01:00
Allison Karlitskaya
b34acdfcb7 build: produce static cockpit.spec for release
When building a release, let's include a complete tools/cockpit.spec.

First, the existing tools/cockpit.spec isn't a valid spec file at all,
because it requires pre-processing before it can be used.  Rename it to
cockpit.spec.in to reflect this reality.

Replace the %{}-style variable substitutions with @@-style ones to make
it clear that these substitutions are not RPM variables, and that
they're handled on a different level.

Drop the existing tools/gen-spec-dependencies (with replaces its output
in-place) and tools/min-base-version (called from gen-spec-dependencies)
with a single script which operates more like a standard shell utility,
with a separate output file.  This tool expands all of the @@ variables.

Drop the extra hacks from tools/make-srpm, as they are no longer needed.

We can also reduce the CentOS 8 hacks in our .packit.yml file, but
unfortunately we still need to produce a valid spec file during the
`post-upstream-clone` phase, because packit cannot continue without it.
There's a --build-all flag to create-spec (and some small changes to the
spec file) to reproduce the old "one srpm please" behaviour.
2022-01-20 16:41:04 +01:00
Allison Karlitskaya
4a30d1d26d .gitignore: add some package building stuff
These files are generated if we attempt to do an in-place rpm build, so
let's ignore them.
2022-01-18 18:44:11 +01:00
Allison Karlitskaya
afc72e4a28 .gitignore: try again with the sorting thing
I have no idea how this got messed up in the first place, but it's
obviously wrong, so let's fix it.
2022-01-18 18:44:11 +01:00
Allison Karlitskaya
d1aad92bf3 .gitignore: ignore test-*.log and test-*.trs
These are generated by `make check`.
2022-01-18 12:50:18 +01:00
Allison Karlitskaya
4a0e79f26d build: have autoconf generate cockpit-desktop
We could easily be using autoconf to generate cockpit-desktop, so let's
move it over, reducing one user of the SUBST_RULE.
2022-01-10 17:40:33 +01:00
Allison Karlitskaya
1ca495779d src/systemd: new directory
Our increasingly large web of systemd integration mostly lives in
src/ws/, for mostly historical reasons.  These days, cockpit-tls has
at least as much integration with systemd as does cockpit-ws, and
cockpit-session is about to gain some.

Move everything to a new src/systemd/ directory.
2022-01-10 17:40:33 +01:00
Allison Karlitskaya
293a928e62 .gitignore: clean up
Remove many ancient and unused patterns, and sort the remaining items.
2022-01-10 13:12:17 +01:00
Allison Karlitskaya
4f799b9b74 src: remove use of glib-compile-resources
We use glib-compile-resources to get a single html file bundled.  That
seems like overkill.

Ideally, we'd use #embed for this, but that seems like it'll take a
while longer, so use a small Python script to convert the .html into C,
and compile the resulting file in the usual way.

Formerly, cockpitwebresponse would default to serving a minimalist
internally-hardcoded document for errors, unless the resource was
provided.  Since this resource was provided from both -bridge and -ws,
the internal document was only used for testing.  That was for good
reason: the full document would be a pain to test on, and we'd have to
update the tests any time someone modified the html.

Let's turn the logic around there and default to the real document and
give the tests a mechanism to inject their minimal one.  We use a
pointer instead of a constant, allowing it to be directly overridden
from the tests, and simplifying the code in cockpitwebresponse a bit.

We tried another approach with the usual `ld -b binary` tricks to
convert the file directly to a linkable symbol, but this was causing
strange crashes on rhel and fedora.  Going via C is a sure thing.
2021-12-17 17:41:22 +01:00
Allison Karlitskaya
c293934538 flatpak: add packaging metadata and scripts
Add some scripts and metadata to support packaging cockpit-client as a
flatpak.

Add a GitHub workflow to do some initial smoke testing of the flatpak
(thanks Martin!).
2021-11-24 12:19:32 +01:00
Allison Karlitskaya
eee7be8bad .gitignore: add 'tags'
automake has a rule for generating this file, so git should ignore it.
2021-11-10 15:47:17 +01:00
Allison Karlitskaya
caf88b5556 ws: remove remotectl
There are no more users of remotectl, so remove it, along with its
tests, docs, and various packaging, build system, and VCS detritus.
2021-09-01 07:42:24 +02:00
Jelle van der Waa
9624fef85c .gitignore: Generalize ignoring test output files
Ignore all Test file extensions in a general manner so for example
Test*.gz is not missing.
2021-08-04 10:46:50 +02:00
Allison Karlitskaya
dce34671bb .gitignore: ignore /bots even if it's a symlink
Having a / at the end of the ignore pattern causes a symlink not to be
ignored.  For some time now, tools/make-bots can put a symlink there, so
ignore that too.
2021-07-28 11:12:01 +02:00
Allison Karlitskaya
b6509b3a73 webpack-jumpstar.tar: include tree id in tar
Add the output of `git rev-parse HEAD^{tree}` to the archive.
2021-07-27 10:44:58 +02:00