Commit Graph

16450 Commits

Author SHA1 Message Date
Panu Matilainen 119350cd9a Show the tag number for unknown tags in --xml output
--xml is only really useful for diagnostics, and for that purpose in
particular, showing "(unknown)" text instead of the tag number
for unknown tags is just offensively dumb. No more!
2023-06-13 14:58:09 +03:00
Ralf Habacker 0830d4876b Add doc note that getopt processing only supports short options
See #2541
2023-06-13 13:58:51 +03:00
Ralf Habacker c8f06a5353 Add doc note about 'disabled option processing'
See #2541
2023-06-13 13:58:51 +03:00
Panu Matilainen 995d1b3fc9 Drop unnecessary internal includes from the IMA plugin 2023-06-13 12:57:26 +03:00
Florian Festi df8d1fb1b3 Add %specpartsdir to macros.in
so it can be configured from the spec file

Also move the dir beside the %buildsubdir as %{buildsubdir}-SPECPARTS so
it doesn't pollute the %buildsubdir.

Resolves: #2532
2023-06-13 12:04:54 +03:00
Panu Matilainen 9fce490988 Fix error handling of rpm.execute() and rpm.redirect2null()
The error handling of these Lua functions is wrong in so many ways I
wont list them all here, but eg. rpm.execute() tries to find an
strerror() string for an exit code of a process, returns a waitpid()
error with code 0 and string "success" and rpm.redirect2null() always
returns a failure despite success and never any meaningful error code.
The latter probably did the right thing when it was in lposix.c but
the pushresult() and pusherror() versions in rpmlua.c are rather
different.

To sort the mess, handle the actual error code checking at call site
and the pushfoo() functions do just that: push the result on the stack
and nothing else. Add some test-cases to go.

Fixes: #2528
2023-06-13 11:58:19 +03:00
Arun Ajith S 26d3802390 rpmrc: Fix how x86 models are derived
The code to autodetect x86 CPU model runs the cpuid instruction after
setting up 1 in eax. This gives the processor signature back in eax
which encodes the model number.

As per Intel Application Note 485 and AMD publication #25481, when
deriving model, we should look at both the base model in eax[7:4] and
the extended model in eax[19:16]. However current code is only looking
at base model and this causes some newer CPUs like Icelake(Model 0x6a)
to be detected wrongly as Pentium 3(Model 0x0a).

Note that this code is only exercised when rpm is built as 32-bit
binary because all of this is within a `#if defined(__i386__)`.

Because of this misdetection on Icelake, `setarch x86_64 rpm --showrc`
has `pentium3` as the `installed arch` instead of the expected `x86_64`.
It doesn't have `x86_64` as one of the `compatible archs` as expected.
Attempting to install a x86_64 rpm with `setarch x86_64 rpm -i` is
failing with `is intended for a different architecture` errors.

```
ARCHITECTURE AND OS:
build arch            : i386
compatible build archs: pentium3 i686 i586 i486 i386 noarch fat
build os              : Linux
compatible build os's : Linux
install arch          : pentium3
install os            : Linux
compatible archs      : pentium3 i686 i586 i486 i386 noarch fat
compatible os's       : Linux
```

Fix the code to also consider extended model and extended family when
applicable. The implementation is similar to the one in the linuxi
kernel.

References:
https://www.scss.tcd.ie/~jones/CS4021/processor-identification-cpuid-instruction-note.pdf
https://www.amd.com/system/files/TechDocs/25481.pdf
https://elixir.bootlin.com/linux/v6.3.6/source/arch/x86/lib/cpu.c#L19

Fixes: #2535
2023-06-09 10:17:25 +03:00
Florian Festi e9f95c5985 Add RPM_LD_FLAGS to build environment
Added in Fedora in 2011 to allow to %define _hardened_build 1 in one's
specfile and have all the necessary gcc and ld flags configured in the
common cases.

See also rhbz#728974 and FESCO ticket 563 (https://pagure.io/fesco/issue/563)
2023-06-08 12:13:49 +03:00
Florian Festi 51c596a6c8 Move dbus announce plugin config to DATADIR
Users are not supposed to meddle with this. So it really should not go
into /etc.

Use the DATADIR from dbus-1 and not our own install prefix.

Resolves: #2474
2023-06-05 10:18:39 +03:00
Panu Matilainen 6caf2a5f58 Remove obscure check for package build time from --rebuilddb (#2527)
Back in 1997, commit be0b90359b added a
sanity check for --rebuilddb operation, skipping headers which lack
some basic tags. Name, version and release are real requirements for
packages, but checking for buildtime is odd, and plain wrong.
Yes, we expect that to be present in packages built by rpm, but that's
not used for any processing and certainly is not required for a package
to be installable. And if it can be installed then it can't be
right to throw it away when rebuilding, leaving untrackable orphan
files in the process.

It is also documented as informational and optional by LSB. While
severely outdated, it is right on this account.

Fixes: #2527
2023-06-01 10:47:46 +03:00
Panu Matilainen 9f568c459e Export rpmGlobPath() to Lua as rpm.glob()
Lua doesn't ship with batteries, or glob functionality. It's not
unthinkable that packagers and macro writers may find globbing useful
in this space.
2023-05-30 12:10:10 +03:00
Panu Matilainen 636eaddf03 Fix Lua docs rpmio mode table rendering (missing newline) 2023-05-30 11:52:58 +03:00
Panu Matilainen b38077eae0 Add %{rpmversion} builtin macro for getting the running rpm version
Seems like a useful thing to have, and a bit crazy that we haven't had any
reasonable mechanism for this before now.

Fixes: #2523
2023-05-30 10:34:08 +03:00
Panu Matilainen 83413bfd39 Revert %_smp_build_ncpus change to a parametric macro (RhBug:2210347)
Commit a213101bc3 changed %_smp_build_ncpus
into a parametric macro, but this breaks common usage via the Lua macros
table as parametric macros are returned as closures rather than the
expanded value.

This seems like a design flaw of the macros table, but as an immediate
remedy for the breakage, add another layer of indirection to revert
%_smp_build_ncpus back to a non-parametric macro.

Fixes %constrain_build macro in Fedora, which ironically is made obsolete by
the change that (unintentionally) broke it.
2023-05-29 11:04:51 +03:00
Panu Matilainen 015c829c76 Macro documentation improvements
Use tables where they make sense, group builtins by category that
can be linked to, add version introduced where relevant. In addition,
some awkward/misleading wordings fixed.
2023-05-26 11:19:22 +03:00
Panu Matilainen 03525592c9 Fix a copy-paste --help description of --whatconflicts (RhBug:2208661) 2023-05-23 12:46:22 +03:00
Panu Matilainen acfe252822 Fix undefined symbols from plugins in some circumstances
Another bit lost in the cmake transition: plugin linkage to librpm and
librpmio. In rpm itself this doesn't really matter because the running
process supplies the necessary symbols but it's a different story when eg
a Python process uses dlopen()'ed bindings.
2023-05-22 17:29:23 +02:00
Florian Festi 021a7d3aaa Use mkdir -p for creating SPECPARTS dir
to not error out when invoking %setup more than once or shipping the
directory in the sources.
2023-05-17 17:40:11 +02:00
Michal Domonkos 2df8008d22 Enable large file support on 32-bit systems again
Replace 32-bit sizes in types like off_t with 64-bits when building on
32-bit architectures, to enable large file support there.

This fixes a nasty regression introduced in the cmake transition.  As
autotools would set this flag to 64 automatically for us, applications
linking against librpm (such as libdnf, librepo, libsolv or drpm) are
already adapted to that and are also building with the value of 64
(explicitly, we never exported this flag through pkg-config ourselves).
However, us suddenly expecting 32-bits in those types on 32-bit systems
can blow up badly e.g. in functions that take an off_t parameter, like
Fseek().

There perhaps aren't that many low-level users of librpm but drpm is one
such example where exactly this happens when built against our current
master.  It calls headerRead(), leading to Fseek() which receives a
64-bit offset parameter where it expects a 32-bit one, thus silently
overwriting the following parameter from 1 to 0 (SEEK_CUR to SEEK_SET)
which messes up the whole reading sequence in drpm's rpm_read(),
producing a failure in drpm's test suite that doesn't make any sense at
first sight.

While at it, also export the flag through pkg-config so that anyone
linking against librpm is now guaranteed to work correctly even if they
don't set the flag themselves (kudos to Petr Pisar for suggesting this).
2023-05-17 14:06:41 +02:00
Panu Matilainen 93ee7d9c61 Silence an apparent false positive warning from gcc in -Og mode
Haven't looked at the assembler but I don't see how xx could be
uninitialized by the time it gets to the if(), regardless of the
optimization used.
2023-05-11 09:30:10 +03:00
Panu Matilainen ae1b8c8c4e Test for the variable rather than it's expansion in cmake files
Testing for the expansion was a cmake newbie mistake that can go wrong
in weird ways, test for the variable instead, consistently. Don't try to be
clever with for-loops, just test for each case separately. This makes it
greppable as well.
2023-05-09 15:45:29 +03:00
Florian Festi d18d6ce41d Fix bzip2 detection
HAVE_BZLIB_H was not set due to a typo leading to the bz2 support not
being compiled in although the library was detected correctly.
2023-05-09 10:08:12 +03:00
Panu Matilainen 760eb86380 Verify user/group in tests when possible
Take advantage of root(less) aware $VERIFYOPTS added in commit
fb040f16ec.
2023-05-05 13:16:40 +03:00
Panu Matilainen f4c6fc4c17 Don't mask the user verify fail on invalid symlink test
This test only runs as root so let it do its job.
2023-05-05 13:16:40 +03:00
Panu Matilainen a97c376f37 Fix thinko in archive size tag(s) description
The archive size tags are on the uncompressed archive, an apparent
thinko in 5032470056.

Fixes: #2498
2023-05-03 11:03:22 +03:00
Florian Festi 07d5746261 Remove second share/ dir from infodir and mandir
cmake variables and the derived macros.

CMAKE_INSTALL_INFODIR and  CMAKE_INSTALL_MANDIR already include the
datarootdir. So just prepending the prefix is sufficient.
2023-05-02 12:55:04 +03:00
Panu Matilainen 14aac7d27e Fix file signatures getting loaded when not asked for
Our compound masks for disabling file info bits per operation never got
updated to include the two separate file signature types. This was
discovered by rpm-ostree on older rpm version crashing on an IMA signature
despite passing in RPMFI_FLAGS_ONLY_FILENAMES.

Add the file signatures to the most obvious masks, and add a simple test
as well.

Fixes: #2425
2023-04-28 12:57:21 +03:00
Panu Matilainen e6a44dbbf9 Make the higher level file info selection flags available to Python
These disabler flags have little other purpose than optimizing cases
where you know you only need a certain subset of files for large
number of packages. Rather than expose all the individual flags,
export just the per-operation level masks to Python.
2023-04-28 12:57:21 +03:00
Michal Domonkos 607e60bffe Fix leftover "lua.h" import from days long gone
We used to bundle our own Lua interpreter but that's not the case for a
while...

No functional change.
2023-04-25 15:04:06 +03:00
Michal Domonkos 49befbc123 Use CMake Lua module
While many distros ship a pkg-config file for Lua, the upstream source
tree does not provide one and so we shouldn't rely on it.  Turns out,
CMake provides a native Lua module so just use that.

Unfortunately, the package doesn't define any IMPORTED target so add our
own, similarly to how we did this recently with libmagic and libimaevm.

Of particular note is that this adds an implicit dependency between
CMake and Lua (e.g. Lua 5.4 support was only added in CMake 3.18), but
that hopefully won't have much impact on most OS installations out
there.

Fixes: #2247
2023-04-25 15:04:06 +03:00
Neal H. Walfield 87b9e0c28c Add pgpVerifySignature2() and pgpPrtParams2()
Add new functions pgpVerifySignature2() and pgpPrtParams2(), which are
like their earlier versions, but optionally return descriptive error
messages (in the case of failure) or lints (in the case of success).
Adjust tests accordingly.

This requires rpm-sequoia 1.4 or later.

See https://github.com/rpm-software-management/rpm-sequoia/issues/39
and
https://github.com/rpm-software-management/rpm/issues/2127#issuecomment-1482646398

Fixes #2483.
2023-04-20 14:08:55 +03:00
Panu Matilainen 293b625f3a Bump CI to Fedora 38 2023-04-19 10:34:32 +03:00
Panu Matilainen 2e25f20f0d Have dist (and snapshot) targets automatically pull in the po submodule 2023-04-13 10:36:57 +03:00
Panu Matilainen c32ad282bf Revert "Oops, require translations for dist tarballs"
This is actually the wrong thing to depend on.

This reverts commit 4e69677ecd.
2023-04-13 10:31:10 +03:00
Panu Matilainen 4e69677ecd Oops, require translations for dist tarballs 2023-04-13 10:12:40 +03:00
Panu Matilainen 6c8b56e398 Document the library version update scheme 2023-04-12 11:27:43 +03:00
Panu Matilainen 7baaf865bc Bump the soname in anticipation of the 4.19 alpha release
We've removed a tonne of obsolete APIs in this release so...
2023-04-12 10:47:31 +03:00
Florian Festi 2080896ce5 Install /etc/dbus-1/system.d/org.rpm.conf
which was accidentially dropped when converting to cmake

Use CMAKE_INSTALL_FULL_SYSCONFDIR as it expands to /etc instead of
/usr/etc

Resolves: #2474
2023-04-11 15:49:44 +03:00
Michal Domonkos 909d237b5e Handle IMA as an imported target, take II
Another attempt at commit 7184fb8013.
2023-04-11 13:50:43 +03:00
Panu Matilainen 62395521a9 Axe outdated multiple build areas doc 2023-04-11 13:32:20 +03:00
Michal Domonkos b75ae820be Don't rely on pkg-config for libmagic just yet
This fixes a regression from automake where we also didn't use
pkg-config for libmagic.

Fixes: #2246
2023-04-11 13:23:21 +03:00
Panu Matilainen d648cb305c Include pre-built API docs and man pages in dist tarballs
There are multiple strange details buried in this all, such as
having to run the main tarball creation in VERBATIM mode due to
git submodule foreach variables, and because of that we can't use
globs in the other commands but have to mask them behind other rules
to do other steps and then concatenate the tarballs at end.

On the build side we need to manually test for the presence of pre-built
content in the source directory (normally that content would be in
binary directories) and install differently in absence of the tooling
that could actually build those docs.

While at it, put both the API docs and man pages in their expected
destinations, install(FILES .. TYPE MAN) is not aware of sections
(🤦) and just puts stuff into the root man directory. With
DOC that is expected, but not where packaging expects to find it.
Except that we're now *installing* the API docs too, put them under
rpm/API docs without any extra html directories in between.
2023-04-11 13:13:23 +03:00
Panu Matilainen 587b53cf6b Match the produced (compressed) tarball name in the target name 2023-04-11 13:13:23 +03:00
Panu Matilainen df6d4e388a Add ChangeLog to the dist tarball 2023-04-11 13:13:23 +03:00
Florian Festi 429bc295a7 Use WITH_IMAEVM in cmake file
as that's was we actually use
2023-04-11 08:19:59 +03:00
Florian Festi ea71755e37 Add WITH_FAPOLICYD build option
defaulting to ON. The if clauses were already in place just the option
line was missing.
2023-04-11 08:19:59 +03:00
Panu Matilainen 589fb0e3aa Revert "Handle IMA as an imported target"
This has brainfarts and is broken.

This reverts commit 7184fb8013.
2023-04-06 11:59:00 +03:00
Panu Matilainen f8ee4a17f7 Bump our CMake requirement to 3.18
We already violate the 3.12 requirement in a place or two, and
there are many nice things in the later releases. 3.18 is three years
old and is available pretty much anywhere that is even remotely relevant
for us.
2023-04-06 11:35:27 +03:00
Panu Matilainen 7184fb8013 Handle IMA as an imported target
Most of our dependencies are imported targets already, so while for just
one site this isn't actually any shorter in terms of LoC it's more
consistent with the surroundings in the consuming site, and more so if
we ever need to link to this from some other place.
2023-04-06 11:07:04 +03:00
Panu Matilainen c61da285a1 Let cmake handle checking for mandatory components
Both find_path() and find_library() accept REQUIRED argument, use it
instead of rolling our own.
2023-04-06 11:07:04 +03:00