Commit Graph

13605 Commits

Author SHA1 Message Date
Panu Matilainen bd942d5fee Raise actual error on unknown option to parametric macro 2017-01-19 14:18:29 +02:00
Panu Matilainen 02dea59e3a Flag real errors from macro define and undefine errors
This WILL cause behavior changes in cases where there have been
illegal macro names etc which have previously been more or less
ignored with an logged error, but now they will actually abort.
2017-01-19 14:15:38 +02:00
Panu Matilainen 8f86427d8a Pass macro buf, not context, to doUndefine()
No functional changes, just for symmetry with doDefine()
2017-01-19 14:13:15 +02:00
Panu Matilainen 7d1ceefe9e Store errors during macro expansion centrally
With direct rc assignments there's a risk that a previously
flagged error is overwritten by a success, only flagging errors
specifically avoids that. It also makes things simpler in some ways.

This probably changes *some* behavior wrt errors, in that errors
might actually get counted as such.
2017-01-19 14:08:28 +02:00
Panu Matilainen b298e93686 Arrange single point of exit in expandMacro() 2017-01-19 13:41:42 +02:00
Panu Matilainen 1b4744e1c6 Refactor %{lua:...} macro execution to a helper function
expandMacro() is big enough without this kind of easily separable
material...
2017-01-19 12:09:10 +02:00
Panu Matilainen e3e99e929a Reindent expandMacro() to common rpm style
This huge and scary looking diff is strictly whitespace-only change.
2017-01-19 11:28:40 +02:00
Panu Matilainen 34c4609df3 Add a "gendiff" backend for %autosetup
This is just plain patch, but generates backups suffixed by patch
ordinal (NOT patch number) for the benefit of gendiff. Hence the name.

Thanks to Per Øyvind Karlsen and Neal Gompa for inspiration, input
and patch suggestions in PR#109 and PR#110.
2017-01-18 16:07:25 +02:00
Panu Matilainen 1d7b45e484 Pass patch path and ordinal as 1st and 2nd arguments to %autopatch backends
The quilt backend has been using %1 but that only worked due to flaws
in the macro engine: automatic macros are not cleared for
inner callers, they can only be overridden. This makes the the
scm backend %1 argument real to begin with, and adds another one:
the patch ordinal might be useful for some purposes.

It's tempting to use %1 and %2 from %apply_patch - we're only passing
them along unchanged, right? Well, it's just that rpm does not expand
arguments of parametric functions, so those %1 and %2 would refer
to themselves within the called macro. Gotta love it...
2017-01-18 16:01:20 +02:00
Panu Matilainen 1949aaa0bb Remove the now unnecessary archive size estimation
Commit e51644e0ee eliminates the need
to estimate the size.
2017-01-13 11:04:48 +02:00
Panu Matilainen e51644e0ee Make the signature header size constant between 32- and 64-bit tags
Since commit 68bddc353a we're initially
creating the signature header with estimated values, and if you're
unlucky enough to have the estimated and actual size on the different
sides of UINT32_MAX boundary, the resulting package will have the main
header off by eight bytes, making it unreadable by rpm (RhBug:1405570)

Always reserve a little bit of space in the signature header so we
we can maintain the overall size constant regardless of whether 32- or
64-bit tags were used by using a smaller "padding" with 64bit tags.
2017-01-13 11:02:42 +02:00
Panu Matilainen d1c988b2a8 Unbreak headerCopyLoad() (manifesting as segfault on signing)
Commit 6d2124ae90 broke headerCopyLoad()
which doesn't supply the size ... because it doesn't know it. Handle
zero bsize in headerImport() by parsing the supplied blob early and then
do it again on the copied data. This also depends on commit
7c6b9d057c.
2017-01-11 11:40:01 +02:00
Panu Matilainen 7c6b9d057c Eliminate redundant "uc" field from hdr blob struct
The ondisk-size is already there in pvlen so this is completely
redundant. The uc argument is only used for verifying whether
caller expectation of the size matches, and that is made again
optional here as well.
2017-01-11 11:26:21 +02:00
Panu Matilainen 1ce844ab26 Only process regular files when generating build-ids
Versioned shared libraries typically have several symlinks pointing
to them directly and indirectly. When %_build_id_links is set to compat or
separate this causes bogus warnings about duplicate build-ids.

It looks commit bbfe1f86b2 intends to skip
symlinks since it filters on S_ISREG(), but since uses fstat()
on already open()'ed file it ends up stat()'ing the symlink target.
Flip stat() + open() around and use lstat() instead to fix it.
2017-01-05 15:54:39 +02:00
Ville Skyttä 40ef88d945 find-lang.sh: Add --with-kde KF5 support 2017-01-04 12:03:16 +02:00
Igor Gnatenko 669fc07da5 rpmsign: eliminate unused leftover variable
Signed-off-by: Igor Gnatenko <i.gnatenko.brain@gmail.com>
2017-01-04 11:28:15 +02:00
Mark Wielaard 53eaf59ab6 Link testing/usr/bin to testing/bin.
Some tests running under fakechroot started failing because scripts tried
to execute /usr/bin/rm but inside the testing chroot /usr/bin and /bin
aren't linked. Just symlink testing/usr/bin to testing/bin to simulate
a unified /usr setup.

Signed-off-by: Mark Wielaard <mjw@redhat.com>
2017-01-03 12:36:12 +02:00
Panu Matilainen ff43d03d1f Static signal-related variables need to be thread local 2016-12-16 09:51:12 +02:00
Panu Matilainen bbdf819392 Literally blocking *all* signals is a bit too much
Programming errors like SIGSEGV and SIGBUS need to get through no
matter what and blocking them is undefined behavior anyway.
The odd man out in this list is SIGTSTP which is just otherwise useful
and not harmful since the process can be continued afterwards.
2016-12-15 15:15:33 +02:00
Panu Matilainen 120229d73a Replace sigprocmask() uses with pthread_sigmask()
We're not exactly thread-safe anywhere but lets at least use the variant
whose behavior is not decidedly undefined in a threaded environment.
2016-12-15 15:05:08 +02:00
Panu Matilainen c5f82d3f62 Block signals during RPMTXN_WRITE transactions
This includes (but not limited to) rpmtsRun() during which the accidental
ctrl-c no longer aborts the whole dang thing. This could've of course
been done without all the other recent signal infra too, but now that it's
all neatly (yeah, right...) wrapped inside rpmsq instead of being littered
all over town its nicer to do.
2016-12-15 14:21:48 +02:00
Panu Matilainen 12ea4ed2bd Call rpmsqBlock() directly from rpmdb code to remove unused cruft
This could've been done in commit 45d63715039d19fc2bd4be14229d37561fe0bd16
already of course but should there be regressions (my oh my!) this makes
it easier to bisect.
2016-12-15 14:14:39 +02:00
Panu Matilainen 20f54a28ca Add an shortcut API for blocking/unblocking signals
For rpm's purposes blocking all signals and restoring to previous
status is the only necessary operation, make this part of the
official API to make it available everywhere and replace rpmdb
internal signal handling code with it.

Noteworthy points:
- The block/unblock operation is reference counted so these can be
  nested to arbitrary level without messing up things, much like
  the internal chroot API.
- The rpmdb code used to remove rpmsq signals from the blocked mask, but
  blocked should really mean blocked, really. The pending signals will be
  delivered when unblocked and there's no need for us to mess with it.
- Unlike the rpmdb variant, we now Run rpmsqPoll() *after* unblocking
  the signals. This actually matters now because rpmsqPoll() honors blocked
  signals since commit 07620f4ae7.
2016-12-15 14:12:33 +02:00
Panu Matilainen 4edaafc26f Remember the first signal to arrive, not last
This is more in line with how "normal" signals behave - if a signal
of the same type is already pending then the subsequent signals of
that type are dropped.
2016-12-15 12:40:31 +02:00
Panu Matilainen 07620f4ae7 Honor blocked signals during rpmsqPoll() too
Queued signals might get processed much much later than they arrive,
and almost anything can happen in the meanwhile. Such as program
blocking signals before entering a critical piece of code, which
routinely calls rpmsqPoll() underneath since the code is not always
critical. Such as rpmdb iterator init/free - sometimes they're
called during harmless read-only query, at other times they're in
middle of transaction...
2016-12-15 12:16:41 +02:00
Panu Matilainen b275b94061 Make signal queue on/off a global atomic state
We always want the signal queue either enabled for the certain set
of signals or completely disabled, make the API reflect that and
make the switch "atomic", ie signal delivery is disabled while
changing state.

Perhaps more importantly, this allows changing signal handlers "offline",
so an application can set its own signal handler for, say, SIGINT
*in case* the signal queue is activated.
2016-12-15 10:59:02 +02:00
Panu Matilainen 3ecd11318e Rename static handler function to make (name)space available 2016-12-15 10:59:02 +02:00
Panu Matilainen ff6b9c56d3 Refactor finding a signal in the table to a helper function 2016-12-15 10:59:02 +02:00
Panu Matilainen 19d7597f42 Return the return code of rpmsqPoll() to python too 2016-12-14 19:03:49 +02:00
Panu Matilainen b728665bc8 Replace rpmdbCheckSignals() with rpmsqPoll() everywhere, eliminate from API
rpmdbCheckSignals() is a public function and it'd be trivial to keep
it but there are no known callers and its such a hysterical name that
lets just get rid of it while we're breaking the ABI anyway...
2016-12-14 18:57:58 +02:00
Panu Matilainen ab676d6300 Lets do something silly with the newly gained signal info argument
(sorry, found the temptation to say greetings to Lemmy overwhelming)
2016-12-14 18:08:39 +02:00
Panu Matilainen 524a29051e Support the info argument from rpmsqPoll() handlers
Copy the info contents on signal arrival, pass on to handlers during
poll round. There are some pointers in siginfo_t whose validity might
be questionable at the time we get it, but then those pointers like
address of segfault aren't exactly something to go poking at anyway.
2016-12-14 17:51:14 +02:00
Panu Matilainen 8c6c2a199d Make the signal queue actually customizable and useful
The original rpmsq API is somehow backwards and upside down: it allows
overriding the handler when enabling the queue, but if the queue is
to be enabled for a signal, then the only possible handler for
it is the action that stores the signal in the queue. If you wanted
to have some other kind of behavior you wouldn't want to enable the
queue for that signal to begin with!

What applications need is the ability to override what happens at
signal poll, not arrival time - arrival time is at odds with the
whole queue notion. So introduce a poll function which runs the
handlers for caught signals, clearing them on the way. Add to that
the notion of default handler which is called if no custom handler
is set. Now this can be trivially used to replace the signal foobar
inside rpmdb and suddenly applications can replace the standard behavior
with a simple

    void my_sigint_handler(....)
    {
        /* do foo */
    }

    rpmsqEnable(SIGINT, my_sigint_handler);

...and the custom hander will be called when a SIGINT has arrived
and the next signal polling round from rpmdb internals or whever
occurs.

rpmsqAction() is removed from the API/ABI here, but it's not as if
it ever was useful to anybody anyway.
2016-12-14 17:34:02 +02:00
Panu Matilainen f60131dae0 Drop support for systems without SA_SIGINFO
Life's too short to keep worrying about ancient junk forever.
Even Hurd has this now, can you imagine? (Hurd was the reason
this was special-cased back in 2008)
2016-12-14 15:32:21 +02:00
Panu Matilainen afbb9713ce Simplify rpmsq activate signals tracking
There's little better way of tracking set of signals than a sigset_t
with its associated APIs. For one, this way we dont for example need to
loop through the table to see if a signal is active or not.

Note that This drops the "fancy" reference counting: calling rpmsqEnable()
with different handlers would increase the refcount but not actually change
the behavior, so the refcount means exactly what? The refcounting also
hasn't been used by rpm at all/in a long time, because whether its
active or not is tracked by the rpmdb code which is the only place
really knowing if its needed or not.
2016-12-14 13:09:39 +02:00
Panu Matilainen 4639f4b2ba Use abs() when abs() is called for 2016-12-14 12:51:14 +02:00
Panu Matilainen ecc9c61e4b Remove useless signal table defines 2016-12-13 12:02:19 +02:00
Panu Matilainen 8cc3342cff Clean up rpmdb leftovers from an atexit() handler.
There's a standard C mechanism for cleaning up cruft at exit and
it's known as atexit handler. atexit() handlers do not get called
when exiting due to signal, but we're trapping the signals and calling
exit() voluntarily in that case so... for fsck's sake Sherlock.

This removes rpmdbCheckTerminate() from the API, the semantics
change incompatibly here and it makes even less sense after this.
It's a good time for this change since we're removing all sorts of
other goo out from the API as well.

Also rip out the previous workarounds from python side, RIP.
2016-12-13 11:19:03 +02:00
Panu Matilainen 9b9e998c9a Fix recent rpmdb handles cleanup-on signal regression
Commit 4c6e51e2c0 seems perfectly
sensible but managed to break rpmdb handles cleanup on signals,
ie the sole reason this mess of a code exists to begin with.

The reason that change did not work for rpm is it expects the surroundings
being sane when that's not the case: rpmdbCheckTerminate() removes
the entries from the handle lists before calling the destructor
functions, which would do the very same thing if you only let them. Not
mucking with the lists from left and right simultaneously makes things
work, what a shock.
2016-12-13 09:18:46 +02:00
Panu Matilainen 1200b98efd Revert "rpmdb.c: (rpmdbCheckTerminate) return non-zero on subsequent runs"
The change seems logical enough, but that doesn't work when the surrounding
code is not. rpmdbCheckTerminate() is an idiotic API by yours truly
which must return non-zero exactly once because that's the signal
for the *caller* to call exit() (did I already say idiotic?)
Anyway, if it repeatedly returns non-zero rpm will exit() more than
once which at least glibc seems to take as "so lets exit already shall we?"

This reverts commit e5d3b9f682.
2016-12-13 08:55:33 +02:00
Mark Wielaard 3d4db6f99f Define AM_CFLAGS inside the Makefile.am files themselves.
Trying to include AM_CFLAGS through a configure generated rpm.am file
doesn't really work because at the time automake runs configure doesn't
exist yet to process rpm.am.in. Just define the AM_CFLAGS substitution
inside the Makefile.am files themselves.

Rename rpm.am.in back to rpm.am.

Signed-off-by: Mark Wielaard <mjw@redhat.com>
2016-12-09 11:35:38 +02:00
Panu Matilainen 4e6583fe23 Refactor package component sizes debug printing out of rpmReadSignature()
The big block in rpmReadSignature() was only used for RPMLOG_DEBUG
level printing, obfuscating a rather important function needlessly.
Move all the data retrieval into printSize() and eliminate the
rather pointless return code based on fstat() success.
2016-12-09 11:12:36 +02:00
Mark Wielaard 245b5a3b4b Eliminate unnecessary dependency on bfd.h from sepdebugcrcfix
I think the reliance on bfd.h was a mistake. The code was lifted from
bfd, but should be totally independent (it just calculates a CRC).
Fix the type to be a normal size_t and include sys/stat.h (which was
included through bfd.h) to get the definitions of stat and chmod.
2016-12-09 10:31:23 +02:00
Panu Matilainen e825e071bb Simplify intGetTdEntry()
Ultimately there are exactly two possibilities here and we certainly
don't need a switch-case to handle it.

Thanks to Thierry Vignaud for pointing this out.
2016-12-09 09:24:18 +02:00
Panu Matilainen fdb520cfec Eliminate a mindless switch-case in rpmInstallLoadMacros()
The switch-case is a leftover from times where different formats
sort of needed special handling in here, but RPM_NULL_TYPE is just
hysterical, headerGet() will never return such a data type. So
the whole thing is just moot.

Thanks to Thierry Vignaud for pointing this out.
2016-12-09 09:20:10 +02:00
Panu Matilainen e81aba9c68 Oops, python Makefile wasn't including rpm.am 2016-12-08 15:27:02 +02:00
Florian Festi bbb8f91817 Actually use supplements and enhances... 2016-12-08 13:23:33 +01:00
Florian Festi 8bec06c1f2 Remove unneccesary if clauses 2016-12-08 13:19:13 +01:00
Florian Festi decd7e619e Order by weak and reverse dependencies also
Add reversed param to add(Single)Relation() for Supplements and Enhances

Also fix generation of reversed relations. As we generate all relations for
one package (p) at once they are all the latest on the other packages. So we
don't have to search through the list of relations there. But in the current
package the relation might have been added before others.

So we can check in package q if the relation is already there - using the
proper list depending on the direction. So we can't reverse by just switching
p and q before doing that.
2016-12-08 13:13:56 +01:00
Florian Festi 61992a4b65 Remove code leftover from collections 2016-12-08 12:20:26 +01:00