Commit graph

57 commits

Author SHA1 Message Date
Allison Karlitskaya
10de075181 build: write a bare minimal PEP 517 build backend
Drop our dependency on setuptools and write our own PEP 517 build
backend.  This turns out to be relatively straightforward — only ~100
lines, and avoids the workarounds we had to do to prevent setuptools
from trying to write to the source tree.  It's also dramatically
faster.

While we're at it, we can now fix a long-standing nag: we now have a
proper place to make sure that `modules/checkout` gets called before
building an sdist or a wheel.  That means that you can run `tox` or `pip
install .` in a freshly checked-out tree and expect correct results.

We have to add a command-line interface to support wheel creation on
RHEL8, where pip is not yet PEP517-aware.

We don't implement any optional features of PEP 517 and we also don't
support editable installs.
2023-05-12 11:01:02 +02:00
Allison Karlitskaya
71922374f0 build: simplify handling of systemd_ctypes and ferny
Drop our attempts to cache ferny and systemd_ctypes — it's just not
worth it.  Both of them are tiny.

Instead, establish that we expect submodules in modules/ to be checked
out, generally.  Add a (trivial) script to do that and call it from a
bunch of "entry point" type places.

Note: we don't dist modules/checkout, and even if we did, it wouldn't
work, since it needs to be run in a git checkout.  We therefore also
carefully avoid adding calls to this script from anything that lands in
the tarball.
2023-03-20 16:23:23 +01:00
Martin Pitt
a0dfdca0b9 autogen: Copy automake tools
Building the dist tarball in the current Fedora 37 cockpit/tasks
container now fails when running as user podman container, when using
systemd-homed:

    cp: failed to preserve ownership for 'cockpit-279.39.gb4b41375f/tools/compile': Value too large for defined data type

This was due to a change in systemd 251 with mapped user IDs[1][2].

Work around this by copying the files instead of symlinking them. That
is the default behaviour anyway, and does not hurt much: git trees are
regularly cleaned by developers anyway, and dist tarballs contain a copy
either way.

[1] 1d679b208d/NEWS (L789)
[2] https://bugzilla.redhat.com/show_bug.cgi?id=2144558
2022-11-22 19:54:46 +01:00
Martin Pitt
ec81f06390 tools: Drop create-spec
Keep `Version: 0` in the spec file. This works fine with `autogen rpm`, `dnf
builddep, and Packit. It was the last macro, so now it's a real working .spec.
This avoids having to invoke this script all the time.

This simplifies our packit config a bit and stops swimming against the stream.

The only place where we want a real version is `make dist`, so that built RPMs
have a correct version. Rework the rule to modify the file in-place in distdir.

Unfortunately this uncovers another packit bug: If the .spec file is not
in the same directory as the tarball, `packit srpm` gets upset:
<https://github.com/packit/packit/issues/1621>. Work around that by
copying the spec to the root directory, and pointing to it.
2022-06-15 18:29:15 +02:00
Allison Karlitskaya
e2f2d830e1 build: change approach to versioning
Currently, we choose the version number that we use at the time that
./autogen.sh is first run.  That means that if you configure your tree
and hack on it for a while, making commits as you go, the
overly-specific version number will soon be out of date.  This version
number is the number used when building tarballs for testing.  Even
switching to old branches on previous versions can result in the version
number not being updated.

Let's move to automake's suggested approach[1] to dynamic versioning by
introducing a `version.m4` file.  We write that file from two places:

 - `./autogen.sh` writes an approximate version number (the last release)
   appended by +git (eg. "270+git")

 - from `make dist` we write the value we find in `$(VERSION)` and call
   autoreconf to update the configure script accordingly

The expectation is now that anyone who calls `make dist` should specify
the VERSION explicitly.  That's two places:

 - from `tools/make-dist` we specify the full `git describe` style
   version

 - from the release workflow we specify the tag name

Since the only thing that uses `make dump-dist` anymore is
`tools/make-dist`, and since it now provides its own version number, we
can drop the rule and print the filename directly.

Since we move to `version.m4`-style versioning, our tarballs will no
longer contain the `.tarball` file.

Finally, since we're going to end up having more tarballs created, with
various version numbers, add `cockpit-*.tar.xz` to `CLEANFILES` to help
keep things under control.

[1] https://www.gnu.org/software/automake/manual/html_node/Rebuilding.html
2022-06-01 21:11:25 +02:00
Allison Karlitskaya
d126de6a64 scripts: stop abusing realpath -m
Many of our scripts follow the pattern of using something like

    cd "$(realpath -m $0/../../..)"

in order to change to the top source directory.  The idea of applying
`..` to a regular file (`$0`, the path to the script itself) is a bit
weird, but the `realpath -m` (`--canonicalize-missing`) flag allows that
by ignoring the content of the filesystem.  In effect, the first `..`
removes the basename, and then the remaining `../..` express the
location of the top directory relative to the directory containing the
script.

Experiments building Cockpit in container environments have shown that
`realpath -m` is non-POSIX.

There's an alternative, however, and it has the advantage of not using
any external tools at all: we can do the first step of removing the
basename by using shell parameter expansion: `"${0%/*}"`.  From there,
we can just append the correct number of `../..` to get the desired
path:

    cd "${0%/*}/../.."

Update this pattern (and similar) in all the scripts which use it.
2022-05-23 11:35:44 +02:00
Allison Karlitskaya
76ffdd0d4a autogen.sh: drop ./autogen.sh mock
This isn't used by anything anymore.
2022-03-10 00:11:14 +01:00
Allison Karlitskaya
6231d1c675 autogen.sh: --disable-doc for ./autogen.sh mock
This lets us take a pass on a dependency on xmlto.
2022-03-07 14:49:15 +01:00
Allison Karlitskaya
5e3cd775cf autogen.sh: fix ./autogen.sh mock loop
When running `./autogen.sh mock` we call back into `./autogen.sh` again,
by mistake, instead of invoking the just-created `./configure` script.
That causes autoreconf to run a second time.

Fix that to call `./configure` directly.
2022-02-28 12:30:51 +01:00
Allison Karlitskaya
859640cc4c autogen.sh: add a 'mock' option
This autoreconfs and configures cockpit using mocked dependencies, in
order to be able to "make dist" with as few dependencies as possible.
2022-01-28 07:50:54 +01:00
Allison Karlitskaya
23c88ef199 autogen.sh: add 'rpm' option
When run as `./autogen.sh rpm` then configure the package in exactly the
same way as it would be configured by RPM for a build on this system.
2022-01-28 07:50:54 +01:00
Jelle van der Waa
cae678d488 build: Remove obsolete autoconf macros
AC_HELP_STRING has been obsolete and replaced with AS_HELP_STRING since
2003. Since autoconf 2.70 obsolete construct warnings are enabled by
default, as autoconf < 2.70 is still widely used obsolete
warnings are now explicitly enabled in `./autogen.sh`.

https://www.gnu.org/software/autoconf/manual/autoconf-2.67/html_node/Pretty-Help-Strings.html

AC_ISC_POSIX and AC_HEADER_STDC macros are both obsolete and no longer
required. AC_ISC_POSIX checks for "Interactive Corporation Unix" which
is no longer sold and Sun dropped support for it in 2006.
AC_HEADER_STDC checks if the system has C header files conforming to
ANSI C89, which all current systems should have now.

The obsolete AC_PROG_CC_C99 macro checks if the C compiler is in C99
mode and if not tried to make it so. Since at least GCC 5.4.0 is
-std=gnu11 if no options are provided.
2021-08-04 13:05:03 +02:00
Allison Karlitskaya
4537d8b3db autogen.sh: minimalistic rewrite
Take the axe to autogen.sh and replace it with a clean minimalistic
rewrite.
2021-06-30 18:03:34 +02:00
Allison Karlitskaya
ad94be8020 build: move a message
This message is Very Important.  We wouldn't want to see it lost.

Also: direct ./configure users can now too share in the joy of seeing
it.
2021-06-30 18:03:34 +02:00
Allison Karlitskaya
c47b712452 build: drop "maintainer mode"
This hasn't really been in vogue for a long time.  Drop it.
2021-06-30 18:03:34 +02:00
Allison Karlitskaya
cc19439ddc build: drop glib-gettext
I tried to move over to standard upstream gettext, but I noticed that
our gettext stuff is sufficiently "custom" that we don't actually use
this in any meaningful way.  We even define our own "update-po" rule,
for example.

Just drop it.
2021-06-30 18:03:34 +02:00
Allison Karlitskaya
e60d25dd92 pixel tests: checkout submodule on demand
Move the call to `test/common/pixel-tests pull` from `autogen.sh` to
`testlib.py`, just before the pixels are compared.

Only do the checkout if there isn't already a checkout there.

This is a first step only: we probably also want to do more complicated
checks to see if we need to update the submodule to a different version,
even if the directory already exists.
2021-06-24 16:52:05 +02:00
Allison Karlitskaya
8842a4f0e4 test: check out the bots on an as-needed basis
Most python things that need to use the bots first import parent.py to
set up the path to enable importing things from the bots directory.

Use this as a nice place for a hook to check out the bots, if they're
not already there.

With this in place, we no longer need the blanket call in autogen.
2021-06-24 14:37:41 +02:00
Katerina Koukiou
ac2f8e5786 test/run: pull pixel test reference before running tests 2021-06-17 12:57:32 +02:00
Allison Karlitskaya
96ca10b587 node_modules: convert to git submodule
Turn node_modules into a git submodule that we can cache locally and
check out quickly.  Add a tools/node-modules script to support checking
out existing versions and creating and pushing new versions.

This depends on an already-existing cockpit-project/node-cache
repository on github.

The biggest benefit here is that normal users won't need to run npm
anymore.  Additionally, there will be no "node modules out of date"
messages anymore: they'll be updated automatically, as-needed.

Drop tools/npm-install, as we no longer need it.
2021-05-17 20:10:39 +02:00
Martin Pitt
673dacecb8 Restore package-lock.json from cached dist tarballs
Commit d3f51710dd moved from node_modules/.stamp to package-lock.json
as our canonical stamp file, which regressed make_dist. This fixes
running autogen/configure/make dist with pre-built dist again, as it
does not pointlessly rebuild everything again.

In autogen.sh, don't run npm install if package-lock.json already
exists.
2021-04-22 16:00:00 +02:00
Allison Karlitskaya
8f32022472 all: drop NO_NPM mode
This provided a nice workaround for the pain of running `npm install`,
but we are about to solve this problem in a different way.

Let's start by removing this workaround.
2021-04-20 11:08:08 +02:00
Allison Karlitskaya
59072e1ff1 autogen: check for glib-gettextize
Our configure.ac includes AM_GLIB_GNU_GETTEXT, which is pretty
oldschool.  We should definitely move away from that, as per:

  https://wiki.gnome.org/Initiatives/GnomeGoals/GettextMigration
  https://wiki.gnome.org/MigratingFromIntltoolToGettext

Until that time, however, add an explicit check for it in ./autogen.sh
to prevent autoreconf from failing with a message about "undefined macro
AM_GLIB_GNU_GETTEXT".

More to the point, though: this has the added side-effect of giving
LGTM/Semmle's deptrace machinery a chance to understand the dependency
and install the correct packages for us:

  https://blog.semmle.com/cplusplus-projects-lgtm/
2021-04-02 17:08:56 +02:00
Allison Karlitskaya
a0b1fe4406 build: split out and conditionalise npm install
Move our retry logic for `npm install` out of ./autogen.sh into
tools/npm-install.  Call it from ./autogen.sh but only conditionally, if
NO_NPM is not set to "1".
2021-01-15 07:40:36 +01:00
Allison Karlitskaya
845ff8053a autogen: Unsplit a line
This looks like overzealous line splitting.
2021-01-15 07:40:36 +01:00
Allison Karlitskaya
77dffb5d0b build: Generate node_modules/README at dist time
Store this file in tools/ and copy it over at 'make dist'.  This makes
it a lot easier to clean up the node_modules directory: we just have to
delete it.  It also makes it easier to check for the directory being
missing: then we can skip `npm prune`.
2021-01-15 07:40:36 +01:00
Matej Marušák
f4ca8cdc59 tools: Introduce make-bots script
Projects should be able to prepare bots on their own without running
`./configure` first. Therefore introduce this tool which can do exactly
that.

Closes #12920
2019-10-07 11:42:16 +02:00
Martin Pitt
8a7067cf8d
build: Support CI testing against a bots project PR
* If `$COCKPIT_BOTS_REF` is set, check out that bots version instead of
   master.

 * Use git cache in $XDG_CACHE_HOME if available. Our CI uses that to
   save downloads, and it does not get in the way for local developers.

 * Stop duplicating code in autogen.sh, just call `make bots`. The tree
   is configured at this point.

Ported from https://github.com/cockpit-project/starter-kit/pull/233

Closes #12908
2019-10-02 22:19:02 +02:00
Martin Pitt
3dd8f097e0
build: Don't clobber an existing bots checkout
Commit cea63000a was a thinko -- for our CI we *don't* want our test to
clobber a pre-existing bots/ checkout, as we often use this to run tests
against an updated image or to validate a changes to the bots project.

On developer machines, bots may also be a symlink to an actual bots
directory in development, so don't clobber that.

Closes #12905
2019-10-02 09:56:03 +02:00
Sanne Raymaekers
cea63000a4 Makefile: Add bots target
Closes #12875
2019-09-23 17:33:47 +02:00
Allison Karlitskaya
44a8198766 autogen.sh: make npm install *more* robust
There is a category of failure of 'npm install' that leaves
node_modules/ in a corrupt state and won't be fixed by just running 'npm
install' again.  Try harder.

Closes #12537
2019-08-10 10:23:15 +02:00
Allison Karlitskaya
c047d26df7 build: don't delete test/ directories in autogen
autogen.sh contains an unsafe invocation of find|xargs to iterate over
the node_modules and delete all test directories that it finds (with the
goal of reducing the size of the cache tarball by removing unit tests).

This is a pretty strange thing to do to the node_modules directory,
particularly when you contemplate incremental invocations of 'npm
install'.  The same effect can be accomplished by using tar --exclude
when creating the tarball.  Do that instead.

Closes #12535
2019-08-09 15:25:04 +02:00
Allison Karlitskaya
ce6edaabbc autogen.sh: give npm install a few tries
`npm install` is sometimes flaky, which can ruin an entire tests run on
semaphore.  If it fails, try a couple more times.
2019-07-08 21:18:09 +02:00
Allison Karlitskaya
0f5bfe32bb autogen: Check npm version
Make sure we have at least npm 3.  This will prevent others from wasting
time trying to chase down the dependencies problems reported by older
versions (such as the one found in Debian).

Closes #8987
2018-04-12 19:13:33 +02:00
Martin Pitt
c5ba7d1efa tools: Fix broken dist paths with out of tree builds
Running `make dist` in an out-of-tree build that is not underneath
srcdir previously resulted in a broken tarball, containing pkg/* and
node_modules/* under a path to the srcdir.

E. g., diffing file lists between an in-tree and out-of-tree dist
tarball looked like this:

  -cockpit-154.x/pkg/lib/journal.js
  +cockpit-154.x/upstream/cockpit/pkg/lib/journal.js

Avoid this by putting pkg and node_modules symlinks into the build dir
and chopping off absolute build dir prefixes in webpack-make, instead of
creating path prefixes to the srcdir.

Change the invocation of webpack-make to always pass a canonical
absolute $SRCDIR, so that maybePushInput() does not have to handle
different cases of absolute vs. relative srcdir.
2017-10-23 17:18:17 -07:00
Stef Walter
986c1bee1b Remove usage of Bower in favor of NPM
Bower is unreliable, and we have to clear out the whole thing
in autogen.sh. Now that we're using webpack for bundling, we can
just bundle from nodejs modules instead.

This should solve bot problems that timeout when updating the modules
as well as allow automatically updating dependencies.

After this commit developers need to clear out their build and
run autogen.sh again from scratch.

    $ git clean -fdx
    $ mkdir build
    $ cd build
    $ ../autogen.sh --prefix=/usr
    $ make -j8 all

Closes #6814
2017-06-09 10:38:46 +02:00
Stef Walter
06ca1b812c dist: Symlink the dist directory during autogen.sh
A 'dist' directory is used by both the 'webpack' workflow
and the 'make' workflow. When switching between these two
workflows it's confusing to have two dist directories.

Help the user create one dist directory by just doing it in
autogen.sh

Closes #5659
2017-01-09 11:38:52 +02:00
Stef Walter
df13e4104f po: Refactor and remove cruft from our intltool usage
We're not a standard intltool project, so lets just focus on
the stuff we use and need:

 * Install mo files in LC_MESSAGES
 * Install po.xx.js files
 * Have a standard update-po target
 * Detect unmarked translations in 'make check'

Closes #5362
2016-11-18 14:11:02 +02:00
Stef Walter
8b2e3daeaa autogen.sh: Add force flag to bower update command
This prevents bower from asking silly questions about versions.
We already specify all the versions in the file.

Closes #5408
2016-11-17 17:22:30 +02:00
Stef Walter
5d7f1165b1 lib: Use bower_components to normalize build time deps
Now that we're fully moved to webpack we can have a more
traditional model for our build time dependencies, and solve
several problems in the process.

 1. Having a bower_components/ directory makes the project
    behave in a more standard way for other javascript developers.

 2. Populating bower_components/ at autogen.sh time rather than
    committing the changes allows the project to behave as
    expected for packagers who want to understand dependencies.

 3. A separate bower_components/ directory lets us more simply
    build a cockpit-deps-122.tar.gz style tarball ... although
    that's for a later commit.

 4. Moving our own common code into pkg/lib allows us to run
    normal unit tests against it rather than having all such
    tests in the playground. Again implemented in a later commit.
2016-11-07 10:49:08 +02:00
Stef Walter
f5b0ca9ec7 Lock down versions of javascript dependencies
For package.json and devel time dependencies, we have problems
with newer versions not being supported by the versions of
Node that are included in distros. So we have to be careful
for updates. We don't mind micro updates. That is the
third digit of the semver number.

However for Bower packages, and particularly those that are
included in Cockpit itself, each point update needs explicit
testing through our integration tests. So we lock these ones
down tightly.

In addition prune the node_modules directory during autogen.sh

Closes #5266
2016-10-31 11:38:02 +02:00
Stef Walter
a0a7d1e1a0 autogen.sh: Don't remove Makefile when NOREDIRECTMAKEFILE
Closes #4311
Reviewed-by: Peter <petervo@redhat.com>
2016-04-28 06:39:24 -07:00
Lars Uebernickel
b3b6fe8389 Test tarballs that are similar to release tarballs
Call `make dist` outside of the test VMs instead of calling autogen.sh
inside. Adjust the debian and rpm packaging to reflect that.

Tests are now running on tarballs that are more similar to release
tarballs and test packages are more similar to packages that
distributions ship.

The system running the tests must now also have build dependencies
installed.

make-source, the script that prepares the tarball, tries not to
interfere too much with existing builds. It configures the package in
tmp-dist/ without setting up the redirect Makefile. However, due to
limitations in autotools, it must use an existing in-tree configuration.

Closes #4178
Reviewed-by: Stef Walter <stefw@redhat.com>
2016-04-18 11:30:26 +02:00
Stef Walter
4b18cbcbfb tools: Run 'npm install' in make-source when necessary
If package.json has changed or no node_modules exists run
npm install during tools/make-source

This lets the verify machines get the right node modules
into the builder vms.

Closes #4150
Reviewed-by: Dominik Perpeet <dperpeet@redhat.com>
2016-04-05 15:09:10 -07:00
Stef Walter
1987f01bb3 Distribute dependencies and their licenses
Distribute devel dependencies in the tarball, and include
licenses appropriately.

To do this we need to make two changes:
 * Use xz to compress the tarball, so that it stays relatively small
 * Use the tar-pax format because file names get very long.

Closes #3436

Reviewed-by: Dominik Perpeet <dperpeet@redhat.com>
2016-01-14 09:32:15 +01:00
Stef Walter
4570de5865 Have autogen.sh put in a redirect Makefile
In cases where the user is using an out of tree build directory
(they should be) we put in a redirect Makefile so they can still
run 'make' commands from the top of $srcdir

Closes #3359
Reviewed-by: Marius Vollmer <marius.vollmer@redhat.com>
2015-12-22 10:47:00 +02:00
Stef Walter
0081e0ad4b tools: Move package.json and node_modules to top level
This lets us be very clear about where these development
dependencies are coming from, and/or should be.

Certain distros would like to replace these with their
own copies. They should be linked into the same locations
as they would be if they were placed there by 'npm install'

Closes #3257
Reviewed-by: Marius Vollmer <marius.vollmer@redhat.com>
 * Fixed typo in comment
2015-12-01 16:41:58 +02:00
Stef Walter
d5bcb568b3 legacy: Actually embed storaged in our build system
And call it cockpit-lvm. The reason for this is that we would have
conflicting bus names, polkit permissions, unit files, and all
sorts of bits with storaged 0.x anyway.

storaged 0.x is in the process of being replaced with storaged 2.x,
and this is already happening in the distros.

Since we were the only consumers of storaged 2.x, rename everything
bring it in and kill the external storaged project.

Closes #2097
Reviewed-by: Peter <petervo@redhat.com>
2015-04-02 14:07:48 -07:00
petervo
ab482d4f2c configure: Build storaged in project
Builds storaged as cockpit-storaged to avoid
collisions with storaged v2.

Signed-off-by: Stef Walter <stefw@redhat.com>
 * Pull in build fixes from storaged
2015-04-02 14:07:45 -07:00
Stef Walter
f0a658628b tools: Use package.json to identify which nodejs deps to install
Fixes #1498
Closes #1502
Reviewed-by: Marius Vollmer <marius.vollmer@redhat.com>
2014-11-21 14:56:47 +02:00