Commit Graph

16717 Commits

Author SHA1 Message Date
Panu Matilainen 8de699ee70 Issue a warning when passing arguments to non-parametric macros
This should be an error for consistency with other macro argument
checking but as there appear to be usages in the wild, make it a
warning for now.

Fixes: #2932
2024-03-14 10:30:30 +01:00
Michal Domonkos 5ace145d40 Accept alternative awk implementations in cmake
Now that we can, emulate the AC_PROG_AWK macro that we used in the
autotools era.
2024-03-14 10:04:47 +01:00
Michal Domonkos 78fd1fc05f Sanitize awk and find-debuginfo paths in macros
Commit adad2be2e4 moved the detection of
awk outside of makemacros() so that we could require it at build time,
but that isn't ideal.  These are two separate use cases, really, they
just happen to involve awk in both cases.

In the first case (build time), keep using find_program(REQUIRED) as
normal, however for makemacros(), revert back to the custom findutil()
function.

The find-debuginfo script is the same story so fix that too while at it.
In practice, it's not likely for there to be multiple implementations of
this script installed on the build system for this to matter, so this
change is mostly just for the sake of consistency.

Also add a short description of findutil() to make its purpose a bit
clearer to the casual onlooker.

Fixes: #2926
2024-03-14 10:04:47 +01:00
Panu Matilainen 4cb7aaa6da Fix dependency generators sometimes dying with SIGPIPE
If a dependency generator dies while we're still writing to its stdin,
it causes us to die rather randomly. Typically happens with fake
dependency generators that don't actually bother reading their input
and/or write anything back. This is almost certainly the ghost failure
we've occasionally seen in the test-suite too (#2470).

Resurrect the explicit SIG_IGN that got removed apparently in commit
375a6b5630, and restore SIG_DFL in the
child. The matter was further confused by NSPR (which we once relied on)
always setting SIGPIPE to SIG_IGN.

Suggested-by: Michael Schroeder <mls@suse.de>

Fixes: #2949
2024-03-14 09:48:25 +01:00
Panu Matilainen f4e7418389 Add a path lookup example for Python bindings 2024-03-13 15:10:00 +02:00
Panu Matilainen 0644ba5755 Really allow qualifiers like pre/post/meta for weak dependencies
Commit ddbf30cf96 neglected to update the
preamble table types for the weak dependency tags, so it never worked.
Add a test to ensure it works and stays that way.

Test depends on 078ccae5a655e044a9b867206cf4215acb3f0113

Fixes: #624
2024-03-13 08:34:23 +01:00
Panu Matilainen 9cb05896f7 Add the ability to pass qualifiers to our dependency tests 2024-03-13 08:34:23 +01:00
Michal Domonkos adad2be2e4 Make Awk a required program in cmake
We need Awk in the build process (twice) so make it required at
configure time, and remove the now redundant findutil() call in
makemacros().

Fixes: #2926
2024-03-12 15:09:28 +02:00
Zbigniew Jędrzejewski-Szmek 689f1d8d3e docs: mention systemd-standalone-sysusers
Also fix some typos and add punctuation.

Follow-up for 44afd5b49c.
2024-03-11 13:40:44 +01:00
Panu Matilainen c0412b9d87 Kick out an "experimental" %_query_selector_match from 2001
Something like this can't really be a macro configurable between such
wildly differing purposes, especially when callers almost certainly
expect the traditional default behavior anyway. I can't see anybody
missing this.

Besides nuking an apparently unnecessary feature and weird logic (how
many levels of default do you want?), it eliminates an unwanted
static initializer relying on a non-enum value of an enum variable.
2024-03-11 13:37:34 +01:00
Panu Matilainen e56d1c4f71 Fix a minor memleak in Buildsystem: parsing 2024-03-11 09:31:30 +02:00
Florian Festi 3ad98187cc Use basename (3) for the %basename macro 2024-03-07 12:39:19 +01:00
Florian Festi 9571e3d9a2 Use dirname (3) for %dirname
This changes the behaviour of %dirname to something sane. No longer
return the argument unchanged if there is no / found. Also handle
several cornercases properly.

Resolves: #2928
2024-03-07 12:39:19 +01:00
Panu Matilainen 8eac330426 Remove perl dependency generators from the repo
These are far better maintained by the Perl community, in a repository
of their own:

	https://github.com/rpm-software-management/perl-rpm-packaging

Fixes: #2873
2024-03-07 11:47:13 +02:00
Florian Festi 1296ea93f8 Don't allow build directives in generated specs
Many things need to be known before the build can be started. Make
declaring these sections or directives an error when encountered parsing
the generated Spec parts.

Resolves: #2693
2024-03-07 11:45:30 +02:00
Florian Festi cbf66768b0 Add parseStages enum
As we now have three different sources of spec content we need a proper
enum to tell them apart and get rid of the seconday bool parameter.

No functional change but is needed for the next patch
2024-03-07 11:45:30 +02:00
Alexander Kanavin 26a1ccf281 CMakeLists.txt: eliminate floating dependencies
Prior to this, the respective build options would get enabled depending
on whether or not these components were found on the build system.

I believe it's better to make them strict (add REQUIRED parameter),
so that rpm builds are always deterministic, subject to cmake options.

Resolves: https://github.com/rpm-software-management/rpm/issues/2855
2024-03-06 10:27:20 +01:00
Panu Matilainen f016ab70a4 Add a blurb about favoring env variables over macros in build scripts 2024-03-04 14:25:15 +02:00
Panu Matilainen b49437c7fc Oops, RPM_SPECPARTS_DIR was missing in our env variables table
Should've been in commit 78d105db0a
2024-03-04 14:20:23 +02:00
Jan Engelhardt 961d1d0a2d build: reword "%changelog is missing"
Despite openSUSE packages having a %changelog section at all times,
rpm throws this error.

Turns out it's just terribly worded. Fix that.
2024-03-04 09:44:29 +02:00
Panu Matilainen 6ce6c4fea6 Expose build time to package build scriptlets via $RPM_BUILD_TIME
This is useful for consistently setting timestamps within build
scriptlets, in particular when doing reproducable builds.
2024-03-04 09:42:43 +02:00
Panu Matilainen 78d105db0a Document the rpm-specific environment variables in build scripts 2024-03-04 09:42:43 +02:00
Zbigniew Jędrzejewski-Szmek 59ed1565b2 Set git commit dates based on $SOURCE_DATE_EPOCH or $RPM_BUILD_TIME
(https://github.com/rpm-software-management/rpm/pull/2933 is required
for $RPM_BUILD_TIME.)

When %autosetup -S git is used, a bunch of git commits are created. Without an
override, their metadata will include the current time. Many projects include
the git hash of HEAD in the build information, which means that the build result
is not reproducible. Since we're creating a scratch repo ourselves, this hash
doesn't have any meaning outside of the build. If $SOURCE_DATE_EPOCH is set, use
that as the commit timestamp instead. If $SOURCE_DATE_EPOCH is _not_ set, fall
back to $RPM_BUILD_TIME, which should always be set.

For projects which somehow make use of the git commit information, this fixes
an irreproducibility. For projects which don't care about the git hash, this
should make no difference.

Fixes https://pagure.io/fedora-reproducible-builds/project/issue/9.
2024-03-04 09:39:27 +02:00
Panu Matilainen ebece0fb63 Fix invalid syntax in two Lua examples
Fixes: #2929
2024-02-28 14:04:40 +02:00
Florian Festi 1dc7e76fa5 Add --list and --delete to rpmkeys
This is a  bit of a hack as it manipulates the parsed cli parameters to
to the "right thing" and then calls rpmcliQuery and rpmErase.
2024-02-28 12:12:57 +02:00
Florian Festi 660a502f94 Don't advertise rpm -qa gpg-pubkey* in man page 2024-02-28 12:12:57 +02:00
Panu Matilainen 233ddeb188 Drop a leftover sqlite pragma case_sensitive_like
Sqlite upstream has deprecated case_sensitive_like, but we no longer
use SQL LIKE since c9380471ad so we
can just drop it.

Suggested-by: Michael Schroeder <mls@suse.de>

Fixes: #2925
2024-02-27 10:47:25 +02:00
Panu Matilainen 217e217d92 Drop misleading statement about rpm2archive vs rpm2cpio
rpm2archive does use somewhat more librpm functionality than rpm2cpio
does, but both link to librpm which has to be there and functional
for either of them to work.
2024-02-27 09:21:01 +02:00
Panu Matilainen 1825dbf824 Fix a memleak on invalid command line options
The OS will clean it up yes, but in the meanwhile ASAN (when enabled)
blew up on your face and scared you silly. Use the opportunity to add a
test for a test on invalid option.
2024-02-21 16:07:05 +02:00
Panu Matilainen 126b7ab7af Don't install an effectively internal README
This documentation is only meaningful in relation to the codebase
and end users are not the target audience.

Fixes: #2811
2024-02-21 13:27:21 +02:00
Florian Festi 4276386310 Ignore %config flag where not supported
%config is only allowed for regular files and links. While rpmbuild won't
produce package with other files with %config other tools might. Handle
these cases gracefully by ignoring the %config flag.

Resolves: #2890
2024-02-21 12:26:01 +01:00
Panu Matilainen b2638067fc Document %missingok and %artifact in verify output and the manual
Fixes: #2833
Fixes: https://bugzilla.redhat.com/show_bug.cgi?id=2256014
2024-02-21 12:31:26 +02:00
Panu Matilainen 5bb53af74c Update the po submodule to pull in the tools/ path change 2024-02-21 08:43:05 +02:00
Panu Matilainen 984448aa0a Add a new test group for package format matters
Using rpmdump output for comparison lets us inspect the file format
aspects without drowning ourselves in the details of tag contents
in the way --xml/--json output does. It should also be useful to
guard against accidental changes, deity knows we could've used
this before.

As rpmdump output is rather verbose, putting the output to a separate
file to keep the .at file manageable.
2024-02-19 14:21:00 +02:00
Panu Matilainen d87544ed76 Fix potential unaligned access to region trailer in rpmdump
Compared to header.c, rpmdump is obviously taking all manner of
shortcuts. The address sanitizer helpfully points out why the former
has the "mysterious" memcpy() on the trailer data.
2024-02-19 14:21:00 +02:00
Panu Matilainen 9102a8f931 Split our reproducability tests to further helpers to allow reuse
We'll need this in the next steps for producing packages with the
same exact set of parameters except for the produced package version.
2024-02-19 14:21:00 +02:00
Panu Matilainen 348d7c7b8d Generate rpmtests.at automatically to avoid redundant book-keeping
We have the list of tests in cmake, we can just as well generate the
master rpmtests.at file from there.

As the order of tests now depends on the list in tests/CMakeLists.txt,
update it to match the former order in rpmtests.at. As arbitrary as
that order is, people seem to get attached to certain test numbers. Er.
2024-02-19 13:57:03 +02:00
Panu Matilainen 3db12291fa Implement --json query format
The existing --xml output is extremely useful when inspecting oddities,
but the format is such an eyesore. JSON is much saner to look at.
2024-02-19 11:47:54 +02:00
Panu Matilainen 3df1dd3a35 Refactor tag name formatting to a helper function
No functional changes, we'll need this in the next commit(s).
2024-02-19 11:47:54 +02:00
Panu Matilainen cefb0a182a Generalize xml header formatting to support other formats too
Refactor the xml specific output parts into generic format and tag
level header and footer function pointers. No functional changes.
2024-02-19 11:47:54 +02:00
Panu Matilainen b1c59924f7 Refactor header format string append to a helper function
It feels like a decade since I've last been here, git disagrees.
How in the deity we still have these manual string length calculations
and stuff in this day and age there ... ick.
2024-02-19 11:47:54 +02:00
Vít Ondruch c167ef8bda Add support for spec local file attributes and generators
Allow declaring file attributes from the spec via %_local_file_attrs
macro. This allows enabling file attributes and their dependency
generators even if they are only shipped in the package itself and are
not yet installed.

The names need to be separated by colons (:).

Co-authored-by: Florian Festi <ffesti@redhat.com>
Resolves: #782
2024-02-15 09:00:59 +01:00
Panu Matilainen d3b7b0e328 Refactor to split file attribute discovery and initialization
No functional changes, will be useful for the next commit.

Co-authored-by: Florian Festi <ffesti@redhat.com>
2024-02-15 09:00:59 +01:00
Panu Matilainen 5ece87a250 Let eBPF ELF files be packaged in noarch packages
eBPF ELF represents a virtual machine where our file colors make no
sense at all. Filter out the color from these files to avoid a
"Arch dependent binaries in noarch package" error from them in noarch
packages.

We don't want to pull in clang to the check images just because of
this, so add a pre-built binary for the check and a simple way to
reproduce from the test-spec.

Fixes: #2875
2024-02-14 12:43:53 +01:00
Panu Matilainen 41974f46f9 Drop a dead assignment, the calculated value is never used
This was erroneously added in fb13f7fd9e.

Fixes: #2904
2024-02-14 10:49:01 +02:00
Panu Matilainen 56dab4c5e8 Revert "Use Ninja-compatible syntax for passing TESTOPTS"
Urks, seems I mistested this, it breaks our normal usages.

This reverts commit 34cb5ee922.
2024-02-14 10:48:39 +02:00
Florian Festi 44afd5b49c Adjust User/Group handling Documentation
We now use our own script (sysuser.sh) instead of systemd's
systemd-sysusers.

Resolves: #2857
2024-02-14 10:36:14 +02:00
Panu Matilainen 34cb5ee922 Use Ninja-compatible syntax for passing TESTOPTS
Ninja doesn't support passing environment as command line arguments
like make does, access TESTOPTS through environment instead of the
make syntax to make it work for both generators.
2024-02-13 10:21:36 +02:00
Panu Matilainen 81e500a7e3 Drop erroneous BYPRODUCTS uses from the cmake files
BYPRODUCTS is only relevant for Ninja generator which we officially
don't even support, but on which these usages cause Ninja to error out
with "phony target names itself as an input" messages.

I don't remember why exactly I put these BYPRODUCTS in there, but I know
it was NOT to support Ninja explicitly. Probably it seemed somehow
relevant to this cmake newbie and since it didn't harm anything ... on
the make generator. Taking them out makes Ninja happy except for the
test-suite. The make generator is still the only officially supported
one though.

Reported-by: Timothy Brackett <brackett.tc@gmail.com>
2024-02-13 09:48:29 +02:00
Panu Matilainen e5d7a823c9 Run build scriptlets with closed stdin to enforce unattended builds
Even max-rpm philosophy section points out that rpm builds are
unattended, but then we do nothing at all to prevent it? I first though
maybe this regressed when we switched the build scripts to use rpmfcExec()
a few years ago, but there wasn't anything before that either. Weird.
2024-02-13 09:48:03 +02:00