Commit Graph

16575 Commits

Author SHA1 Message Date
Panu Matilainen 5f98b1aa48 Document the main differences between rpm-sequoia and internal parser
Fixes: #2346
2023-08-29 13:19:15 +03:00
Panu Matilainen 3687458aa0 Add a build tunables section to the reference manual
The descriptions are terse and I've inevitably missed a whole bunch
of stuff here, but it's a start.

Fixes: #2466
2023-08-29 13:01:36 +03:00
Panu Matilainen 33c0478f96 Drop an extraneous Dependencies section from the spec manual 2023-08-29 13:01:36 +03:00
Panu Matilainen c10877b6bc Polish the build process docs a bit
Replace source links to documentation (we have it now!) and various
more cosmetic tweaks.
2023-08-29 13:01:36 +03:00
Panu Matilainen 21457de886 Fix misleading error message on some invalid filetrigger conditions (#2584)
We used to test the first argument in parseScript() and then again
for all arguments in parseRCPOT(), with different error messages in
each case as if they were separate issues. Only, the one in parseRCPOT()
didn't get a chance to execute because it was caught by checkDep() before
it (probably added after the file trigger check was initially added) and
so for invalid file trigger conditions (such as an unexpanded macro), you'd
get a very misleading error about dependency tokens where an absolute path
is expected, and worse, it was reporting an incorrect line and a line
number while at it.

Measure twice, cut once doesn't apply here. Check once and be consistent
about reporting it. Due to the way triggers are handled, we can't
report the line number correctly so don't even try, the wrong line
number is far worse than not having it at all. Add some tests to go.

Fixes: #2584
2023-08-23 15:01:53 +03:00
Panu Matilainen 3be76d7144 Default to C.UTF-8 locale, allow fallback to C
Mostly everything around us is UTF-8 these days, we need to get on with
the times. Especially now that glibc >= 2.35 finally supports it too.
Default to C.UTF-8 but allow disabling it via cmake option to fallback
to the traditional C locale instead.

Fixes: #2587
2023-08-23 15:01:28 +03:00
Panu Matilainen 59bbb932e5 Behave more consistently when target arch %optflags are not defined
You're about to fall into a deep dark hole, proceed at your own risk.

When building for a target architecture with no defined %optflags
(such as noarch), one would think that %optflags would be empty. Not so in
rpm, instead we get %optflags for the detected architecture, and there
are packages which rely on this behavior. And in this particular dark
corner, buildarchtranslate is not applied so one can get drastically
different %optflags than you'd get without an explicit --target, on the
same system. Which can break builds.

This behavior is just WRONG, %optflags should always reflect the target
architecture. But as long as there's no %_host_optflags, lets at least try
to be consistent about it. When we fall back to detected architecture
%optflags, at least use the ones after buildarchtranslate to return
consistent data within a host.

This supposedly fixes the case where our newly added x86_64
subarchitecture definitions haven't been overridden in vendor config and
somebody's noarch package uses cmake to install data, and falls over due
to nonsensical optflags from rpm.

Initial report: https://bugzilla.redhat.com/show_bug.cgi?id=2231727
2023-08-23 11:55:31 +03:00
Panu Matilainen 0e336e24c9 Move the %_sysusersdir definition to a more logical spot
Commit c7fd9fed99 introduced %_sysusersdir
into the group of global configure-related macros but that's not what
it's related to at all, it's only related to our sysusers integration
feature. Move it where it really belongs.
2023-08-22 14:15:29 +03:00
Panu Matilainen 24f974cff9 Revert recent %_root_prefix macro addition (RhBug:2233454)
Commit cececfb685 introduced %_root_prefix
macro but this clashes with pre-existing use in scl-utils:
https://bugzilla.redhat.com/show_bug.cgi?id=223345:

Just query the value from pkg-config if available and otherwise use
hardcoded value pointing to /usr instead. We don't need an intermediate
global macro for this.
2023-08-22 14:15:29 +03:00
Daan De Meyer aa0d6d8109 Add aliases for weak dependency queries to rpmspec.
These are all available on the rpm CLI so let's make them available
on the rpmspec CLI as well.
2023-08-21 12:10:13 +03:00
Michal Domonkos 5e9c71296e Avoid warning about double --chdir in "make check"
Newer versions of Bubblewrap emit a warning for some select options
(--chdir included) about only the last occurrence having effect, which
is what happens in "make check" due to the --chdir override.

Instead, just cd to the /srv directory in a shell and then run rpmtests
from there, sigh.  It's not the prettiest but it's better than always
printing the spurious warning.
2023-08-17 18:13:15 +02:00
Michal Domonkos 94ee5c6c23 Prevent build dir from becoming annoyingly sticky
With OverlayFS and unshare(1) being used in the test-suite, some of the
directories in the test tree, sandbox and rpmtests.dir/ end up missing
read/write or execute (for directories) permissions which means removing
them requires excessive force in the form of "unshare -r rm -rf".

CMake is clever enough to adjust the permissions behind the scenes on
"make clean" but manual removal should just work too, so fix that with
chmod(1) in the clean_up() trap.
2023-08-17 18:13:15 +02:00
Michal Domonkos 4fa0026430 Move exit trap to a function in mktree.fedora
This is more flexible as we can now add more commands to the trap, see
the next commit.

No functional changes.
2023-08-17 18:13:15 +02:00
Michal Domonkos 87f1b4545b Enable DNS resolution in "make shell"
Networking is currently enabled in test containers (we don't use
--unshare-net) but for domain names to be resolvable, we need an
/etc/resolv.conf, too, so add it from the host, similar to how e.g.
Podman does it.

We don't need network access in the test-suite but it can be handy for
interactive testing in "make shell", e.g. to allow gdb to fetch
debuginfo data through debuginfod automatically.
2023-08-17 18:13:15 +02:00
Michal Domonkos 3701e4893e Export the same DNF command-line in "make env"
When managing the test tree with DNF, it's actually desirable to use the
same options that were used during the tree construction (especially the
cachedir), so just do that.
2023-08-17 18:13:15 +02:00
Michal Domonkos c3ecf8ac44 Extend the MOTD in "make env" with a bit more info 2023-08-17 18:13:15 +02:00
Michal Domonkos 8e9ff82f55 Terminate stray bwrap processes on test failures 2023-08-17 18:13:15 +02:00
Michal Domonkos db35781bf1 Point RPM to correct database in Dockerfile
This just mirrors what mktree.fedora does already, and is only relevant
in "make shell" when using the mktree.podman backend, no other
functional change here.
2023-08-17 18:13:15 +02:00
Michal Domonkos 2585481662 Set standard, consistent HOME path in tests
Use /root instead of / (in runroot) or $PWD (in atlocal).  We already do
this in "make shell" so that the root user's dotfiles (e.g. ~/.bashrc)
are loaded from the base image, this commit extends that to "make env"
and fixes the following:

  - Calling "runroot rpm -qa" interactively now works as expected since
    the rpmdb from the base image built by mktree.fedora (which
    overrides %_dbpath in /root/.rpmmacros) is used

  - The user's native prompt is now used, instead of the shell's default

This commit has no effect on the tests themselves since we initialize an
empty rpmdb before use anyway.

There was no technical reason for HOME being set to /, really, other
than it being a historical artifact from the fakechroot era.
2023-08-17 18:13:15 +02:00
Michal Domonkos 1c3264ed88 Fix infinite recursion in "make env"
Using which(1) in a shell function that's supposed to shadow the
original command is silly, it just results in a recursive call.  What
was I thinking?

Instead, use "command" which is a better fit, see "help command".
2023-08-16 13:31:01 +02:00
Michal Domonkos 44c76481e7 Clean up dnf() function in "make env"
The "function" keyword is not needed (not POSIX either) and which(1) is
better than hardcoding the path.

No functional change.
2023-08-16 10:27:29 +03:00
Michal Domonkos ebd0905a3f Simplify BYPRODUCTS in "make tree"
The inner structure of mktree.output/ should be treated as an
implementation detail of the mktree backend in use.  All we care for
here is that it's purged on a "make clean".

No functional change since only mktree.fedora uses this directory
currently and it already recreates the other contents (inst/) on each
rebuild anyway.
2023-08-16 10:27:29 +03:00
Michal Domonkos e1ff74c4e5 Support common mktree.fedora image in build dirs
Using multiple out-of-source build directories (e.g. for topic branches
or experiments) currently means redownloading and recreating the base OS
image in each of them.  This is slow, ineffective and just not needed
since the image isn't specific to the build and can just be reused.

To fix it, if a mktree.output/ directory exists in the source directory,
use that, otherwise just use the build directory like we always did so
that all build artifacts remain in the build directory unless told
otherwise (which some may prefer).

This means the feature can be enabled by simply creating an empty
mktree.output/ directory in the source directory.  This is inspired by
mkosi(1), much like many other things in mktree.

We shall document this later, too.

If the source directory happens to be a git-worktree(1), go look into
the common worktree for mktree.output/.  This ensures that worktrees, if
one uses them, are not treated as separate source directories and will
reuse the same image, too.

If using a common mktree.output/, also use a common mktree.cache/ (DNF
metadata and package cache) as separating those two makes little sense
in such a case.
2023-08-16 10:27:29 +03:00
Panu Matilainen 095502dc09 Stop looking for apparently non-existent 7zip command
Since the initial commit 185596818f, we've
primarily looked for a command named "7zip" but defaulted to 7za when
not found. Looking closer it seems that there never was any command
called 7zip at all, at least in the OSS landscape. So don't default to
something that doesn't even exist, which also means we'll land on an
actually working value if/when 7z[a] doesn't happen to be present at
build-time (there's no other reason for it to be there).

Related to #2608
2023-08-16 10:18:20 +03:00
Panu Matilainen f9775b454e Look for alternative implementations of 7zip, like autoconf did
Fixes a regression from the cmake transition where we'd just assume 7zip
as the name of the executable when previously we looked through 7zip,
7za and 7a. Resume the former behavior.

Fixes: #2608
2023-08-15 14:38:21 +03:00
Panu Matilainen bbb289e303 Unroll the utility finding loop in cmake for flexibility + readability
We need more flexibility than a simple array can provide, and with
all the name munging, it's not particularly obvious as to what
values are set and how. Supposedly no functional changes here.
2023-08-15 14:38:21 +03:00
Panu Matilainen 194eb10166 Remove duplicate line
Initially accidentally added in 9e8f57bf7a
and then amusingly commit 1bd14464b9
indentation fixed.

Fixes: #2613
2023-08-14 10:00:46 +03:00
Dirk Müller 2240955422 Rewrite --last to just use sed for formatting
This is the only dependency on awk in the runtime commandline part of
rpm, which is bloating minimal container images a bit. We can rewrite
that into a single sed statement. We love you anyway, awk.
2023-08-10 09:57:42 +03:00
Michal Domonkos 2043f2ac57 Bump actions/checkout from v2 to latest (v3)
This should've been part of the previous commit, just got forgotten.
2023-08-03 17:07:42 +02:00
Neal Gompa d4cad0f26a CI: Add initial GitHub Actions configuration
Fixes: #2569
2023-08-03 16:15:05 +02:00
Michal Domonkos 2387539460 Add support for --interactive in mktree.podman
Pass this option, if specified, to $PODMAN.  This is needed for
unattended use of mktree.podman where no tty is allocated, such as
GitHub Actions.

Use it as follows:

  ./mktree.podman check --interactive=false ...

Default to true (by keeping -i in the command line) still, it allows
CTRL-C to work when running the script interactively.

Based on a patch by @Conan-Kudo.
2023-08-03 16:15:05 +02:00
Michal Domonkos 39ebe1e623 Update translation submodule for new translations 2023-08-01 14:33:36 +02:00
Michal Domonkos 1d8a67485f Add back ima-evm-utils to mktree.fedora, oops
We actually do need this library in the test tree, in case the build is
configured with -DWITH_IMAEVM=ON which links librpmsign to it, it's not
a plugin.  We already include libfsverity for the same reason.

This is a fixup for commit 4c41faf7a5.
2023-08-01 12:30:27 +02:00
Michal Domonkos 02a5151e3e Remove forgotten ENABLE_CI cmake option
We no longer have the ci/ directory as the Dockerfile has been moved to
tests/ and the "make ci" target is now added automatically if Podman or
Docker is available, so no need for ENABLE_CI anymore.
2023-08-01 11:38:10 +02:00
Michal Domonkos 35a3d22930 Add back Docker support to CMake
When using the mktree.podman backend (either through "make check"
directly or "make ci"), detect and choose Docker if Podman is not
available.

This fixes a regression from the original "make ci" where we also
supported Docker, and should've been part of commit
3b2e5eba18.
2023-08-01 11:38:10 +02:00
Michal Domonkos 4c41faf7a5 Minimize the package set in mktree.fedora
We don't need audit and ima-evm-utils, those are for the plugins which
we disable in the tests.  We do, however, need popt and shadow-utils
(pulled in by the above) so list those explicitly.

This also conveniently removes systemd (pulled in by audit) which we no
longer need since commit 2bdd7d7cbd.  To
future-proof, though, exclude systemd-udev which is not needed in
containers.

Lastly, remove gdb-headless which is redundant since we already install
gdb-minimal.

As a nice side effect, this fixes the spurious warning during the DNF
transaction that comes from systemctl(1) through the %systemd_post macro
used by audit (about requiring a /proc mount in the installroot).
2023-07-31 14:35:20 +02:00
Michal Domonkos d7f7c8b1d3 Disable systemd-inhibit in mktree.fedora
This plugin doesn't work with --installroot and only prints a spurious
warning, disable it.

Refactor the contents of .rpmmacros now that we have more than one line
in it.
2023-07-31 14:35:20 +02:00
Michal Domonkos a1ca8e345d Merge mktree.native into mktree.fedora
Don't make any assumptions about how other Linux distros would need to
implement the mktree interface.  We simply don't know how much logic
could be shared between such native backends before some are actually
written.

Right now, we only have one such backend, for Fedora, that's a sample
size too small to draw any conclusions.  Let's worry about refactoring
when it actually makes sense and stick with the most basic layout till
then.

As an example, while unshare(1) works for running DNF as an unprivileged
user, it does not seem to work with other package managers and tools
that I've tried such as zypper or debootstrap.  Those may need another
way of doing this or even require sudo(8).  Also, --map-auto only exists
in the newer unshare(1) versions, older versions would need manual
mapping.

This also simplifies the "env" command quite a bit, which is nice.

No functional changes otherwise.
2023-07-28 17:06:05 +02:00
Zoltán Böszörményi fde03ae33d
Allow setting platform macro settings externally (#2585)
* Allow setting platform macro settings externally

By default, rpm installs a series of default platforms based on
the CPU architecture names in subdirectories called

    /usr/lib/platform/<arch>-<os>

This is enough for regular Linux distributions. However, some
distributions may use more specific platform names that refer to
particular computer systems, like SBCs or specific CPU tuning when
compiling.

If the platform subdirectory does not exist in /usr/lib/platform
then rpmbuild does not work.

Allow creating such custom platform subdirectory with feeding
the necessary data using external variables: RPM_CUSTOM_ARCH,
RPM_CUSTOM_ISANAME, RPM_CUSTOM_ISABITS, RPM_CUSTOM_CANONARCH
and RPM_CUSTOM_CANONCOLOR

Signed-off-by: Zoltán Böszörményi <zboszor@gmail.com>

---------

Signed-off-by: Zoltán Böszörményi <zboszor@gmail.com>
Co-authored-by: Florian Festi <ffesti@redhat.com>
2023-07-28 12:16:56 +02:00
Florian Festi 077afb8592 Set default shell to /sbin/nologin
as this is the default location. Moving the the /bin and /sbin content
into the /usr directories is a distribution dependent thing inherited
from the Fedora script.
2023-07-28 09:46:01 +02:00
Florian Festi 3e820eaa4c Check inside --root when querying for files
rpm -qf checks if the argument actually exists if it can't be found in
the rpmdb and gives different messages based on that.

This was done without taking the root dir into account leading to wrong
messages if the file only exists in the root dir but not outside.

Resolves: #2576
2023-07-26 15:46:43 +02:00
Florian Festi 3fa2ae78db Duplicate filename before passing it to basename
basename is allowed change the string passed to it. While we don't need
the filename after that just casting away the const seems a bit too
hacky.
2023-07-26 15:35:13 +02:00
Calvin Buckley b2e67642fd Fix missing basename include on macOS 2023-07-26 15:35:13 +02:00
Calvin Buckley f07875392a Fix missing signal.h include
macOS doesn't include this by default, so the signal functions
won't be found with -Wimplicit-function-declaration.
2023-07-26 15:35:13 +02:00
Florian Festi 2bdd7d7cbd Replace systemd-sysusers by new sysusers.sh script
for user and group creation. It creates system users and groups based
on files in the format described in sysusers.d(5) using useradd and groupadd.

Only supports the --root, --replace and -help parameters.
2023-07-26 12:34:47 +02:00
Michal Domonkos 68a36d1d85 Mount the common tree snapshot as read-only
This ensures no single test can (accidentally or intentionally) alter
the shared tree and influence the subsequent tests.

It also makes us comply with the following OverlayFS requirement:

    Changes to the underlying filesystems while part of a mounted
    overlay filesystem are not allowed. If the underlying filesystem is
    changed, the behavior of the overlay is undefined, though it will
    not result in a crash or deadlock.

This could have previously been violated when running parallel tests.

Contrary to what I thought in commit
    cf8716f204,
to make this work, all we need is to mount a new tmpfs at /tmp in the
snapshot, as that's where some of the processes (patch(1) in particular)
need to write.

Update the comment in mktree.rootfs accordingly, too.
2023-07-25 21:49:58 +02:00
Michal Domonkos 3b2e5eba18 Add mktree.podman backend
This backend uses Podman with the bundled Dockerfile to build the test
image.  RPM is built in a container as that's part of the Dockerfile.

This makes the test-suite more portable since only Podman needs to be
installed when using this backend.  That's especially useful in a CI
environment where we may not have a native backend for whatever OS the
VM is running, e.g. Ubuntu LTS in Semaphore CI.

Since it must be able to run without a build system in place, make it
also usable as a standalone script.  For more portability, allow for
Docker to be selected in place of Podman by invoking it via a symlink
(multi-call).

We used to have a "make ci" target previously, add it back now and point
it to the script.

Make it also serve as a fallback backend now.
2023-07-25 19:54:48 +02:00
Michal Domonkos d30f55fde0 Add mktree.rootfs backend
Useful when building RPM in a disposable container or VM, see the
comment block for details.  This is also a prerequisite for the next
commit.
2023-07-25 19:54:48 +02:00
Michal Domonkos 750923966a Refactor cmake
No functional change, just prepare the ground for the next commit.
2023-07-25 19:54:48 +02:00
Michal Domonkos fb7835ba94 Add mktree.common
No functional change, just prepare the ground for the next commits.
2023-07-25 19:54:48 +02:00