Commit Graph

58 Commits

Author SHA1 Message Date
Panu Matilainen 2cf26bdd2f Fix memleak in commit dd4f2c68a0 2022-03-03 12:19:50 +02:00
Panu Matilainen dd4f2c68a0 Handle missing RPMTAG_ARCH in RPMTAG_ARCHSUFFIX
RPMTAG_ARCHSUFFIX from commit e6a6399cb4
assumes all headers have RPMTAG_ARCH, but a notable exception is gpg-pubkey
headers in rpmdb, causing segfaults on `rpm -qa` on normal systems.

Special case conditionals in queryformats get ugly and error-prone real
fast, which is why we have all the NEVRA formatter extensions. Avoid
adding yet more of those tags by handling the dot formatting in
ARCHSUFFIX instead - the "suffix" in the name seems to imply this
anyway.

Also add tests to cover the common -qa cases.
2022-03-02 14:22:39 +01:00
Florian Festi e6a6399cb4 Add ARCHSUFFIX extension tag
The new tag returns src/nosrc instead of the build architecture of
(no)source packages.
2022-02-21 16:12:01 +02:00
Panu Matilainen 0b75075a8d Shut up bogus Doxygen warnings about undocumented parameters
As of Doxygen >= 1.8.20 it started complaining about anything marked
as @retval being undocumented. As this is widely used in rpm...
Mass-replace all @retval uses with @param[out] to silence. Some of
these are actually in/out parameters but combing through all of them
is a bit too much...

Also escape <CR><LF> in rpmpgp.h to shut up yet another new warning.
2020-10-28 10:40:41 +02:00
Florian Festi b4f0e7ef18 Make sure getNEVRA always sets td.data
Fixes segfault when reading tampered package without any of the NEVRA tags.
2016-04-26 10:05:35 +02:00
Florian Festi a2826033be Fix doc strings and though doxygen warnings 2015-09-01 10:48:08 +02:00
Lubos Kardos d27f0167aa Get rid of warnigs caused by d18fdd7f89 2015-08-31 16:10:49 +02:00
Lubos Kardos d18fdd7f89 Add --filetriggers option to show info about file triggers. 2015-08-06 15:16:30 +02:00
Florian Festi 284a771504 Fix doc strings 2015-04-24 09:55:42 +02:00
Florian Festi b151b5297b Fix doxygen warnings
Make shure parameter descriptions in doc strings match the functions
2015-02-17 15:31:22 +01:00
Michael Schroeder 66a46b0e8d Support old SuSE style weak dependencies in --recommands, --suggests, --supplements and --enhances
and the underlaying extension tags (RPMTAG_RECOMMENDNEVRS, ...)
2014-02-26 11:36:41 +01:00
Florian Festi 4360e7e131 Add RPMTAG_RECOMMENDNEVRS, RPMTAG_SUGGESTNEVRS, RPMTAG_SUPPLEMENTNEVRS and RPMTAG_ENHANCENEVRS extension tags 2014-02-19 12:11:27 +01:00
Panu Matilainen 97e72eaaea Test for file data tag sanity in fnTag() extensions
- Basename and dirindex counts must be equal, dirnames count must be
  larger than zero and no larger than number of basenames. Check
  that directory indexes are within range. Additionally file states
  array size, if used, must equal to the genaral file count.
2012-02-21 16:24:18 +02:00
Panu Matilainen e3fdb8a45a Fix crash on INSTFILENAMES extension on non-installed package
- Packages with no RPMTAG_FILESTATES cannot have installed files
  from our POV, just exit early in that case.
- Rerrange the exit path a bit and only call rpmtdFreeData() on
  file states if the corresponding headerGet() call was actually
  made. Wont make any difference yet, but once we have other jumps
  to exit it will.
2012-02-21 15:59:34 +02:00
Panu Matilainen fced9ab012 Sanitize filename tag extension handling
- Rename rpmfiBuildFNames() to fnTag() and push all the td manipulation
  there, making all the various different fn-related tags differ by
  just the arguments to fnTag() and allowing central error etc
  handling. No functional changes (yet) though.
2012-02-21 14:42:20 +02:00
Panu Matilainen f258e6089a Add tag extension to calculate hardlink count for files 2012-02-08 15:40:02 +02:00
Panu Matilainen 628ad2fae2 Add four new extension tags for pretty-formatting dependencies
- The current method that --requires and friends use is kinda
  cumbersome and outputs extra whitespace for dependencies which
  dont have flags+version attached. Adding extensions for this
  is likely to be easier than teaching query formatting to
  permit conditionalizing on current value instead of just tag existence.
2011-09-06 15:58:35 +03:00
Panu Matilainen 3a309d8f1b Add RPMTAG_INSTFILENAMES tag extension for state-aware file lists
- For a more consistent experience wrt all the state-awareness stuff,
  this needs to be easily querifiable too.
- Also makes the tagnames kludgery from commit
  cac8c38960 unnecessary
2011-09-01 12:11:13 +03:00
Panu Matilainen 01b9b40481 Try to generate fileclass in the tag ext at runtime if missing from header
- For non-regular files we can easily generate this information based
  on file mode + in case of symlinks, the link target is available
  in the header elsewhere. This also means --fileclass will return
  at least partial data for packages built with the external depgen.
- Clean up fileclassTag() a bit while at it, removing redundant fluff.
- Arguably this "magic" should be done inside rpmfiFClass() instead, but
  that'd require changing the API to return malloced data.
2011-06-16 12:41:44 +03:00
Panu Matilainen 738d05bb1b Eliminate dead NULL-assignments at scope-end in librpm, part I
- Remove NULL-assignments of local variables at the end of scope
  in header + tag- and format-extension code. While this
  NULL-on-free idiom of rpm codebase is harmless as such, these
  unnecessary NULL-assignments have the effect of hiding real problems
  in the amount of noise they generate on code analysis.
- While the changes are supposedly trivial, doing this in smaller parts
  to make bisecting easier in case a some regression slips through.
2011-05-28 22:24:20 +03:00
Panu Matilainen 8c925108fb Eliminate dead RPMTAG_INSTALLPREFIX tag extension
- This hasn't been functional since rpm 4.6 at least: the tag is marked
  internal so it's not recognized as a valid query tag, and there's
  no point supporting this anyway, it was already deprecated backwards
  compatibility hack in rpm 2.x in 1998 era.
2010-11-29 12:28:47 +02:00
Panu Matilainen dc2ee980bc Remove RPMTAG_FILESTATUS tag extension
- This is a bad "API" for verification, it can't be controlled and
  causes heavy IO where one would not expect it. Getting rid of it now
  before anybody starts relying on it...
- Leaving :fstatus format extension alone however, it's at least harmless
  and produces a more predictable output than :vflags extension so it
  might be actually useful in scripts.
2010-11-15 11:12:50 +02:00
Panu Matilainen 757d0b443b Switch header APIs to use rpmTagVal instead of rpmTag
- The header getters are used for both signature header and the "normal"
  header, and even beyond that there's no requirement for a tag in
  the header to be part of rpmTag enum. The headerPutFoo() variants
  technically do require the tag to be found in the tag table (ie be
  an rpmTag) but they still operate on the integer value, they dont
  require it to be a "true" enum.
- Inside tagexts.c there are a few "true" enum uses in the
  internal helper functions, leave them be.
- While this technically changes some the most commonly used API's,
  this wont affect callers really: if the callers were using an enum
  before, enum can always be cast naturally to an integer. The other
  way around was the problematic part (ie the braindamage we're fixing
  here now...)
2010-10-22 09:59:56 +03:00
Panu Matilainen 2508fedea0 Default to the common case wrt dir name/index tags, not relocation
- Avoids an unnecessary extra initialization in the common case, and
  also avoids int/enum mismatch from initializing to 0.
2010-09-21 16:35:10 +03:00
Panu Matilainen e639f57d43 Move rpmHeaderTagFunc() a bit to avoid unnecessary forward declaration 2010-09-21 12:49:46 +03:00
Panu Matilainen b0d62148a9 Use proper types for tag and format extension functions
- Stuff the tag prototypes into misc.h in lack of better place
- Actually use the headerTagFooFunction prototypes instead of void *
2010-09-21 12:23:18 +03:00
Panu Matilainen 2fb15a5443 Stop abusing enum typedefs for bitfield types
- Enums are fine for defining the bitfield flags, but the bitfield
  itself is not an enumeration. Add a separate typedef on "rpmFlags"
  type (presenting a bitfield of flags) for all of these. Compilers
  hardly care, but the typedefs give a nice visual clue for
  us humans using these flags far away from ho^H^H definitions.
2010-09-21 11:10:14 +03:00
Panu Matilainen 00f1a6e0b1 Add header extension tag RPMTAG_FILESTATUS for file verification
- Permits basic file verification with just a headerGet(), with some
  caveats: there's no way to control which attributes get verified,
  and there's no filtering of mtime differences of shared files. Those
  aside, rpm -q --qf "[%{filestates:vflags} %{filenames}\n] <args>" now
  performs the same as "rpm -V --nodeps --noscripts <args>"
2010-05-28 12:21:34 +03:00
Florian Festi 51c96db046 Kill RPMTAG_FSNAMES and RPMTAG_FSSIZES and everything implementing them 2010-02-03 16:27:00 +01:00
Panu Matilainen 78335417a0 Sanitize i18nTag() when NLS disabled
- if NLS is disabled, the whole thing becomes just a plain old headerGet()
2010-01-05 14:14:23 +02:00
Panu Matilainen 1567738fed Always return malloced data from i18n extensions for consistency 2009-12-07 09:12:44 +02:00
Panu Matilainen d0eaa7c048 Add RPMTAG_EPOCHNUM tag extension
- return RPMTAG_EPOCH but convert non-existent epoch to 0, as rpm internals
  treat it
2009-11-20 10:32:47 +02:00
Panu Matilainen df61816c75 Add RPMTAG_VERBOSE extension
- hack to permit different query formatting based on rpm's verbosity level
2009-10-12 11:02:56 +03:00
Panu Matilainen d846e6b0f8 Don't add dependency type into file requires and provides (RhBug:523282)
- unintended change in commit 3d8656f040
2009-09-15 08:45:14 +03:00
Panu Matilainen 3661e1d525 Add header color tag extension, ie headerGetColor()
- use common numeric tag generation helper for header color
  and dbinstance tags
2009-09-02 13:57:54 +03:00
Panu Matilainen b5bc388ee3 Eliminate uses of headerNVR() and friends in librpm (and python) code 2009-09-02 12:06:34 +03:00
Panu Matilainen a5a9208b69 Add tag extensions for common name-[epoch:]version-release[.arch] combos
- RPMTAG_NVRA same as rpm5.org, others are new tags
2009-09-02 10:49:00 +03:00
Panu Matilainen 0fd95da2e7 Add dbinstance tag extension (port from rpm5.org) 2009-09-01 15:08:58 +03:00
Panu Matilainen e18aedbf97 Pass headerGet flags to extensions too (unused for now) 2009-07-03 14:21:01 +03:00
Panu Matilainen e232344a49 Pay more attention to tag extension return codes
- behave like headerGet() does and return failure if there's no data
  to return
- some cases where we used to return nothing previously now return (none)
  in query, but the former behavior was inconsistent between tags
- not sure if (none) is really wanted for a return of no value always,
  but at least it's consistent now
2008-12-04 21:55:52 +02:00
Panu Matilainen 1f61d628fd Fix triggerconds return when no data is there (rhbz#474550) 2008-12-04 21:40:36 +02:00
Panu Matilainen f01ed5459d Convert in-tree users of rpmfiNew() to use flag names
- easier to grep for than scareMem, preparing for further flags
2008-10-30 13:47:40 +02:00
Panu Matilainen 9879f8440d Make fssizes tag extension 64bit
- type changing doesn't matter much as this is just runtime generated data,
  not from headers
- also gets rid of the remaining old hge() use in tagexts
2008-06-12 17:09:35 +03:00
Panu Matilainen 4c6f6d88b8 Add more 64bit size tags + tag extensions for converting from old values 2008-06-12 15:05:43 +03:00
Panu Matilainen 3c5a8a7046 Move 32 to 64 bit tag conversion to helper function 2008-06-12 15:01:58 +03:00
Panu Matilainen 5f361fe6a1 Use HEADERGET_ALLOC instead of manual copy in longfilesizesTag() 2008-06-12 14:16:28 +03:00
Panu Matilainen 6c4772537d Add new tag extension to retrieve filesizes as 64bit types
- convert old 32bit sizes to 64bit if large sizes aren't present in header
- if large sizes are present, we malloc + copy the result to have consistent
  behavior for rpmfi
2008-06-10 18:11:32 +03:00
Panu Matilainen 9130995df6 Minimally convert rpmfiBuildFNames() to new headerGet() 2008-06-10 16:50:18 +03:00
Panu Matilainen b0885bd0f2 Callers are now well known, require non-NULL arguments 2008-06-10 16:50:18 +03:00
Panu Matilainen 6b3e0cc97b Eliminate rpmfiBuildFNames() from the API
- headerGet() with extensions enabled provides a nicer interface to
  the data, no need to expose it
2008-06-10 14:36:12 +03:00