Commit Graph

15956 Commits

Author SHA1 Message Date
Panu Matilainen cad5affacd Add shorthand macros for some conventient Lua string operations
Despite all the Lua magic we already do, it's annoyingly often the case
that shelling out is easier (or at least shorter) than doing the same in
Lua (substrings, length etc)

Add shorthand macros %gsub, %len, %lower, %rep, %reverse, %sub and
%upper which simply wrap the corresponding Lua string.* functions for
convenience.
2022-09-15 10:32:08 +03:00
Panu Matilainen f78be76a00 Fix a memory leak in the new directory dance in ensureDir()
This would leak the path whenever we already had the directory open.
Which happens a lot. Oops.
2022-09-14 13:13:24 +03:00
Shreenidhi Shedi ae2e75a129 Fix a race condition in brp-strip
brp-strip script runs strip command on deliverables paralley and if
deliverables are hard linked inside buildroot, it will create
contention.

One good example for such package is git.
https://github.com/vmware/photon/blob/master/SPECS/git/git.spec

```
Sample output:
$ rpm -ql git | grep libexec | xargs ls -li
668153 -rwxr-xr-x  137 root root 3401056 Aug  2 08:30 /usr/libexec/git-core/git
668153 -rwxr-xr-x  137 root root 3401056 Aug  2 08:30 /usr/libexec/git-core/git-add
787238 -rwxr-xr-x    1 root root   47770 Aug  2 08:30 /usr/libexec/git-core/git-add--interactive
668153 -rwxr-xr-x  137 root root 3401056 Aug  2 08:30 /usr/libexec/git-core/git-am
```

To overcome this, we run strip twice once for all files with no
hardlinks, this is a parallel job, meaning multiple binaries will be
stripped in parallel.

And once for files with hardlinks, in this case we disable parallel
processing and strip binaries in sequential order.

RH bug link:
https://bugzilla.redhat.com/show_bug.cgi?id=1959049

Co-authored-by: Dweep Advani <dadvani@vmware.com>
Signed-off-by: Shreenidhi Shedi <sshedi@vmware.com>
2022-09-13 13:46:08 +03:00
Panu Matilainen 2c63113c8e Add the new binary test-key to tarballs to unbreak dist-check
Should've been in commit 2bc745f2fd
2022-09-13 13:44:56 +03:00
Panu Matilainen 3848c97cb2 Fix %posttrans argument on upgrade
Packages need to be able to differentiate between install and upgrade
scenarios, seems commit ab069ec876 with
half the lights out...

As %posttrans happens after all the excitement, with the erasure elements
already executed, so the installed package count cannot be used to
differentiate between install and upgrade. So we need to find it out the
hard way: see if there's an erasure element that depends on this
package.
2022-09-13 12:57:22 +03:00
Panu Matilainen af08077fb4 Fix possible descriptor leak in fsmOpenat()
For the very unlikely case when openat() succeeded but fstatat()
doesn't, the directory descriptor may be leaved opened. Rearrange
the code a bit to ensure it'll always get closed when appropriate.

Suggested-by: Pavel Kopylov <pkopylov@cloudlinux.com>
Suggested-by: Dmitry Antipov <dantipov@cloudlinux.com>
2022-09-13 10:26:05 +03:00
Radovan Sroka 534fd1f0c8 fapolicyd: Make write() nonblocking
- switch to read only and non blocking mode for pipe
- add 1 minute loop to wait for pipe to reappear

Sometimes during the system update/upgrade fapolicyd
get restarted e.g. when systemd gets updated.
That can lead to the situation where fapolicyd pipe
has been removed and created again.
In such cases rpm-plugin-fapolicyd gets stuck on
write() to the pipe which does not exist anymore.
After switching to non blocking file descriptor
we can try to reopen the pipe if there is an error
from write(). Assuming that a new pipe should appear
when fapolicyd daemon starts again.
If not then after 1 minute of waiting we expect
fapolicyd daemon to be not active and we let the
transaction continue.

Signed-off-by: Radovan Sroka <rsroka@redhat.com>
2022-09-13 10:12:48 +03:00
Neal H. Walfield 2bc745f2fd Add pgpPubkeyFingerprint for Sequoia.
Also add a unit test to exercise pgpPubkeyFingerprint.
2022-09-06 15:48:47 +03:00
Panu Matilainen dc9e816979 Make pgpPubkeyFingerprint() do something meaningful again
Commit 4bbeec134a "fixed" an old
terminology confusion about keyid vs fingerprint, but in the process
broke pgpPubkeyFingerprint() for any external callers, as it now only
feeds on decoded packets whereas before it did the decoding by itself.
Add the decoding step back to the public function to make it usable outside
rpmpgp_internal.c again, retrieving a fingerprint seems like an useful
(public) API to have.

This is kind of a regression fix in that prior to commit
4bbeec134a pgpPubkeyFingerprint() returned
meaningful data to the outside caller and afterwards it didn't, however
that commit broke the API anyhow so it's kinda complicated.
Maybe we should just call it a bugfix and be done with it.

Related to #1549
2022-09-06 15:48:47 +03:00
Panu Matilainen 19d73f6788 Fix buffer overrun from commit 4420c78beb
The newly handled ^ needs to be accounted for when allocating memory.
Found when testing #1936, goes to show what a useful thing that is.
2022-09-06 13:18:33 +03:00
Panu Matilainen 0f0fa49170 Update rpm-sequoia URL as per #2164 2022-08-31 12:07:43 +03:00
Alexander Kanavin 73847f8179 configure.ac: add linux-gnux32 variant to triplet handling
1cdb72ae48
introduced a change where triplets that rpm doesn't know about
are rejected, which in turn causes a regression for users like
Yocto that explicitly use them.

In particular, x32 is a 64 bit x86 ABI with 32 bit pointers and
is supported via settings in custom /etc/rpmrc:

arch_compat: qemux86_64: all any noarch x86_64_x32 qemux86_64
2022-08-30 10:48:27 +03:00
Vyacheslav Potoropin cf3150509e Fix rpm lua rpm_vercmp error message if second argument is broken 2022-08-29 14:36:26 +03:00
V I 9884a89838 Translated using Weblate (Russian)
Currently translated at 53.4% (486 of 910 strings)

Translation: rpm/master
Translate-URL: https://translate.fedoraproject.org/projects/rpm/master/ru/
2022-08-25 11:46:00 +03:00
Ettore Atalan 7273d330d4 Translated using Weblate (German)
Currently translated at 91.9% (837 of 910 strings)

Translation: rpm/master
Translate-URL: https://translate.fedoraproject.org/projects/rpm/master/de/

Translated using Weblate (German)

Currently translated at 87.4% (796 of 910 strings)

Translation: rpm/master
Translate-URL: https://translate.fedoraproject.org/projects/rpm/master/de/
2022-08-25 11:46:00 +03:00
Temuri Doghonadze 403f9a68f2 Translated using Weblate (Georgian)
Currently translated at 29.1% (265 of 910 strings)

Translation: rpm/master
Translate-URL: https://translate.fedoraproject.org/projects/rpm/master/ka/
2022-08-25 11:46:00 +03:00
Thierry Vignaud 7da7e4c663 Translated using Weblate (Breton)
Currently translated at 19.8% (181 of 910 strings)

Translation: rpm/master
Translate-URL: https://translate.fedoraproject.org/projects/rpm/master/br/
2022-08-25 11:46:00 +03:00
김인수 99edd1c28b Translated using Weblate (Korean)
Currently translated at 100.0% (910 of 910 strings)

Translation: rpm/master
Translate-URL: https://translate.fedoraproject.org/projects/rpm/master/ko/

Translated using Weblate (Korean)

Currently translated at 100.0% (910 of 910 strings)

Translation: rpm/master
Translate-URL: https://translate.fedoraproject.org/projects/rpm/master/ko/

Translated using Weblate (Korean)

Currently translated at 100.0% (910 of 910 strings)

Translation: rpm/master
Translate-URL: https://translate.fedoraproject.org/projects/rpm/master/ko/

Translated using Weblate (Korean)

Currently translated at 100.0% (910 of 910 strings)

Translation: rpm/master
Translate-URL: https://translate.fedoraproject.org/projects/rpm/master/ko/
2022-08-25 11:46:00 +03:00
Neal H. Walfield f439f246b5 Change tests that import partially valid keys to use --quiet
When `rpmkey --import` is given a partially valid key, it may emit
warnings, which are backend dependent.  This is currently the case
with the Sequoia, but not the internal OpenPGP parser.

The lints make the tests more fragile.  Moreover, the tests aren't
checking the warnings, but other behavior.  Suppress the warnings by
passing `--quiet` to `rpmkeys`.

Fixes #2071.
2022-08-25 11:36:19 +03:00
Panu Matilainen 866a235441 Allow suppressing key import lint warnings
Hack to allow suppressing key import lint warning messages. Emitting
warning messages depending on verbosity level is ugly but for the case
at hand (different output between PGP backends on CI) it's probably the
lesser evil here.

Initial patch by Neal H. Walfield.
2022-08-25 11:35:39 +03:00
Neal H. Walfield afe10be2d4 Fix expected test output when using Sequoia.
An OpenPGP subkey shouldn't be checked for validity when imported, but
when it is used, e.g., when checking a signature's validity.  This is
because a key's validity partially depends on the current time.

The internal OpenPGP implementation checks for validity when the key
is imported; other implementations should not do this.  This means
that the output of two tests (268, 'rpmkeys --import rsa (rpmdb)' and
273, 'rpmkeys --import invalid keys') have different output depending
on whether the internal OpenPGP implementation is used or the Sequoia
backend is used.

Use AT_CHECK_UNQUOTED instead of AT_CHECK, and the selected backend to
customize the expected output.

Fixes #2062.
2022-08-25 11:16:37 +03:00
Panu Matilainen 21c34bdd61 Fix missing newline in debuginfo-related warning
Should've been in bbfe1f86b2
2022-08-25 08:34:56 +03:00
Panu Matilainen 8ee98091b7 Clarify %bcond, %bcond_with and %bcond_without documentation, take XVII
The key to understanding `%bcond_with` and `%bcond_without` is that these
options *create command line switches* and unless the user thinks in those
exact terms, there's little hope of understanding them. Further, take
care to differentiate between option creation, enablement and defaults
in terminology and document `%bcond` version availability.

Fixes: #2150
2022-08-19 10:49:48 +03:00
Michal Domonkos 1f5ae2a6dd Fix upstream branch setting in "%autosetup -S git"
If the repo is already initialized when calling this macro and it's
using a different branch name than "master" (see #2121) or the global
git option init.defaultBranch is set differently (see #2120), the macro
will fail at:

    %{__git} branch --set-upstream-to=master

Instead of being overly clever, just track the original (start-point)
branch by using --track when branching (see git-branch(1) for details).

For brevity, combine this and branch creation into a single checkout
command.

This fixes commit 3a6b1d8fbf.

Thanks Panu for the clarification and suggestion in #854!
2022-08-18 15:39:16 +02:00
Michal Domonkos db961352d3 Revert "Use explicit default branch in %autosetup -S git"
We will fix this in a better way in the subsequent commit.

This reverts commit 8b9da98e4c.
2022-08-18 15:39:16 +02:00
Michal Domonkos f183ad4d9b Refactor rpmGlob()
No functional change, just shuffle some lines around for better
readability.
2022-08-18 12:33:00 +03:00
Michal Domonkos 493dd91bc1 Return GLOB_NOMATCH on missing dirs from rpmGlob()
As per GNU glob(3), GLOB_ONLYDIR does not guarantee the matches are in
fact directories, that's why we check them with lstat(2).

That may lead to the match list being empty even after a successful
glob() run (rc == 0), so for consistency, return GLOB_NOMATCH in that
case, just like we would for a missing file.

No functional change since we don't check for the exact return code in
the callers, only whether it's positive or not.
2022-08-18 12:33:00 +03:00
Michal Domonkos ecc140c42f Return arg count 0 from rpmGlob()
Do set *argcPtr even if the actual count is 0, rather than leaving it
unchanged and thus possibly undefined in the caller.  This is also
consistent with how glob(3) works.
2022-08-18 12:33:00 +03:00
Michal Domonkos 06a1acdf85 Refer to glob(7) for metachar listing in spec.md
Rather than listing all the rules, just refer the reader to the man
page.  Although brace expansion isn't part of the standard rules, we
still support it through glob(3) with GLOB_BRACE, so make a note.
2022-08-18 12:33:00 +03:00
Michal Domonkos 1cd7f1ab1e Don't try to expand URLs in rpmGlob()
By definition, glob(3) matches pathnames on the file system, so no
pattern starting with a URL protocol (e.g. http:// or file://) will ever
produce any meaningful results when passed to it, it will just fail with
GLOB_NOMATCH.

This wasn't always the case, we used to call a custom Glob() function
here in the past, which knew how to handle URLs, but that was axed in
commit 9cbf0349b8 some 15 years ago.

To this day, however, we somewhat continue the legacy by letting
URL_IS_PATH (file://) patterns pass through glob(3) if they contain
magic chars, with the only possible outcome of failing afterwards.  Drop
this special case and simply consider any known URL pattern as non-local
(int local = 0) and return it immediately.  Also remove the no-op URL
code while at it.
2022-08-18 12:33:00 +03:00
Michal Domonkos ce6247e9e3 Append to arglist in rpmGlob()
Instead of constructing a new list from scratch and returning that, just
extend the passed list.  This makes it easier to use this function
incrementally when expanding multiple patterns in a loop, such as during
package manifest parsing which we adapt here right away.

Preserve the ability to pass NULL as argvPtr and still get a match count
via argcPtr, by keeping the local argv around for that case.

No functional change.
2022-08-18 12:33:00 +03:00
Michal Domonkos 9ddb2508c8 Fix non-glob fallthrough in rpmGlob()
Now that we directly use GLOB_NOMAGIC to implement a fallthrough for
non-glob patterns since commit 9e541c6a7d,
we may ironically end up subjecting such patterns to the lstat(2) check
at the end if they're directories, and thus possibly not return them.

While the actual impact on our codebase seems to be minimal, mostly in
terms of pushing the point of failure elsewhere and possibly printing a
different error message, for the sake of consistency with the idea of
GLOB_NOMAGIC, fix this by bringing back the short-circuit check.

While at it, make it a bit simpler than the original rpmIsGlob() by
leaving out the well-formedness check (i.e. if a bracket/brace has a
closing counterpart) as that's not what GLOB_NOMAGIC does either.
Remove the now unused next_brace_sub() as part of that.
2022-08-17 10:58:20 +03:00
Panu Matilainen a7c3886b35 Mop up leftovers from rpmteFI()
This should've been in commit 6fcdaefef5
2022-08-10 13:36:57 +03:00
Florian Festi 8f922eb38a rpm2cpio.sh: only read needed bytes of file magic
As we look at the first 4 bytes anyway there is no reason to read more.
Reading more also hits a bug in bash on aarch64 (rhbz#2115206).
2022-08-10 12:04:03 +02:00
Florian Festi 951f25bc84 Quote %sources and %patches for shell
Add testcase with special characters

Resolves: #1445
2022-08-02 12:55:35 +02:00
Florian Festi a3eac98460 Testcases: Queries to rpmdb including ^~+
Related: #2070
2022-07-21 16:47:19 +02:00
김인수 f5118bba73 Translated using Weblate (Korean)
Currently translated at 100.0% (910 of 910 strings)

Translation: rpm/master
Translate-URL: https://translate.fedoraproject.org/projects/rpm/master/ko/
2022-07-18 14:28:13 +02:00
Temuri Doghonadze ea537168d8 Translated using Weblate (Georgian)
Currently translated at 9.0% (82 of 910 strings)

Translation: rpm/master
Translate-URL: https://translate.fedoraproject.org/projects/rpm/master/ka/
2022-07-18 14:28:13 +02:00
Florian Festi 2b5b271b0e Add support for --oldpackage to --freshen
This allows to downgrade packages just as with --upgrade but limited to
already installed packages.

Also add basic tests for --freshen

Resolves: #652
2022-07-14 16:02:01 +02:00
Florian Festi 9ed9d3fce3 Add SourceLicense tag to spec syntax
to set a separate license to the source RPM. This can be useful if the
sources have code under additional licenses that do not end up in the
binary packeges.

Resolves: #2079
2022-07-14 15:04:02 +02:00
Florian Festi 85d92cab05 rpm2cpio.sh: Improve error message
for unknown payload compression format. At this point it is unlikely
this isn't an RPM file as we detected the headers but much more likely
the package is using a newer compression format.
2022-07-13 16:54:49 +02:00
Florian Festi f3b263610b rpm2cpio.sh: Deal with null byte in lzma magic
As the shell can't deal with null bytes only read two bytes and check
for proper match. This way we can match for the null byte even if it is
not part of the string.

This also silents the warning from the shell that there is a null byte
being ignored in the magic string for lzma.
2022-07-13 16:54:49 +02:00
Florian Festi d499887c92 rpm2cpio.sh: strip null bytes with tr
to avoid warnings
2022-07-13 16:54:49 +02:00
Florian Festi a18a11924a rpm2cpio.sh: Don't drop newlines from header sizes
This script converts binary header sizes to decimal numbers. Shell is
not that well suited for this task as it drops newlines at the end of
command substitutions. Add a . character at the end and strip it right
after that to avoid this problem.

Resolves: rhbz#1983015
2022-07-13 16:54:49 +02:00
Florian Festi ba31a14191 rpm2cpio.sh: Check for header magic
This make is much less likely to mistake a file as an RPM and will catch
errors in header size calculation.
2022-07-13 16:54:49 +02:00
yangchenguang 4420c78beb
Fix query arguments with ^ not working
when querying packages in the RPM database.

Rersolves: #2104
2022-07-13 10:52:07 +02:00
Florian Festi aa701a8f48 Exclude *.src.rpm from check-buildroot
With the SRPMs now containing the expanded spec file they are bound to
have the build root included in the header. Turns out some people
package SRPMs to rebuild them locally e.g. against the local kernel.

Resolves: rhbz#2104150
2022-07-11 14:50:48 +02:00
Michal Domonkos 8b9da98e4c Use explicit default branch in %autosetup -S git
Commit 3a6b1d8fbf assumed "master" as the
default git branch to track, however the name can be changed globally,
so make it explicit.

Given the choice now, go with "main" as the general trend, e.g:
https://fedoraproject.org/wiki/Changes/GitRepos-master-to-main
2022-07-11 14:09:45 +02:00
Panu Matilainen 8c3fb5eb01 Add an experimental CMake build system
This is an incomplete release-early version, NOT intended or
suitable for production use. It is intended to replace the autotools
based buildsystem in rpm 4.20, until then it'll be developed alongside
it. This causes some extra complications of course, but then we avoid
a huge flag-day, and that matters more.

To those wondering why cmake and not ${myfavorite}: the community around
us effectively made that choice for us. We've made a lot of noise about
bootstrap dependencies. When libsolv, dnf and all the related stack is
powered by cmake build, it'd be just foolish to go with anything else.
This way people working on the rpm stack have only one build system to
learn, there's peer support available nearby and bootstrap dependencies
are reduced, not increased. It also doesn't hurt that cmake is actually
and actively maintained.
2022-06-28 16:33:33 +03:00
Bernhard Rosenkränzer 5f8ac6d1ad Fix unterminated macros in rpmuncompress
Fix unterminated macros being called when rpmuncompress
tries to expand an lrzip, 7zip or zstd compressed file
2022-06-27 08:47:36 +03:00