Commit Graph

326 Commits

Author SHA1 Message Date
Panu Matilainen a0e24f2caf Reset global macro state after each spec query/parse
Parsing a spec, even unsuccessfully, will affect the global macro
state in any number of ways that may affect the following operations
in unpredictable ways. Lacking any saner way to do this, reset the
entire global macro state after each spec parse in rpmspec and spec
query code (rpmbuild already does this) while maintaining possible
cli-specified target and rcfile.
2020-02-12 10:23:23 +01:00
Panu Matilainen 9fe75561f9 Replace uses of localtime() with the re-entrant variant
LGTM flags localtime() as a "dangerous" function, which seems a bit
over the top to me, but as we're flirting with threads, it certainly
is not thread-safe.
2019-10-31 11:59:20 +01:00
Panu Matilainen 4eda663a5f Fix --querybynumber on non-existent record, add test
RPMDBI_PACKAGES differs from the indexes in how record searches behave,
indexes return NULL for non-existent values but with RPMDBI_PACKAGES
(and the pseudo index LABEL) we always get an iterator which we need to
walk to determine whether there's data or not. Use the newly introduced
helper to get the query return right.

One could argue that this should be done in the database code, but then
the behavior is kinda consistent other iteration over RPMDBI_PACKAGES:
you don't know how many, if any, matches there are until you walk it.
2019-10-28 15:28:34 +02:00
Panu Matilainen 3754abffa1 Refactor query match counting to a helper function
No functional changes here, needed for the next commit.
2019-10-28 15:28:34 +02:00
Pavlina Moravcova Varekova df55e76c66 Use function rpmFileHasSuffix instead of manual calculation in query.c 2019-03-18 11:19:48 +02:00
Pavlina Moravcova Varekova 8dd8e37acc Show list of files only once when use rpm -ql and multiple rpm files 2019-03-18 11:19:48 +02:00
Pavlina Moravcova Varekova ce11f04ed5 Correct rpm -ql exit value when optional -p is omitted (RhBug:1680610) 2019-03-18 11:19:48 +02:00
Panu Matilainen d5b66a81b1 Ensure space between user and group in verbose file query output (#544)
With usernames >= 8 characters long, the username and groupname are
printed together creating an unintelligible mess. Ensure space between
user and group.

What a sorry little bug, and easily 15+ years old.
2018-10-01 18:03:30 +03:00
Panu Matilainen a83288b0ce Add support for --whatconflicts for good measure
Seems bizarre to not have this when all other dependency types
are covered so...
2018-06-12 14:06:55 +03:00
Thierry Vignaud 88b207a373 Add support for --whatobsoletes
Mirroring the other --what* options, it's useful when debugging some
upgrade issues
2018-06-12 13:54:38 +03:00
Panu Matilainen 80f8d63760 Split cli verification flags out of qva_flags
These are common in all cli operation, hiding them in "query flags" under
yet another (or actually two, QUERY_DIGEST / VERIFY_DIGEST etc) different
names and then translating back to internal vsflags everywhere doesn't
make anybody's life easier. No functional changes from cli point of view,
any theoretical API users will need changes of course.
2017-11-14 11:12:04 +02:00
Panu Matilainen 0636ce28aa Split inclusion-filtering into a separate bitfield in qva
This makes the whole thing simpler and conceptually clearer as these
are not really different query targets, only filters by inclusion.
No functional changes intended from rpm cli perspective, API and
ABI are of course broken here.
2017-11-10 12:29:46 +02:00
Panu Matilainen 605891908e Rename qva_flags to a more descriptive qva_excattr
No functional changes, just an API break in the practically unused
cli-department. Of course wouldn't be worth the breaking unless there
was a benefit, which will come in later commits.
2017-11-10 10:53:11 +02:00
Panu Matilainen 6f1e75ddd2 Add support for new virtual file attribute "%artifact"
This can be used to differentiate files that are not natural parts of
packages but created as by-products of our processing so they're easy
to filter out of queries.

Possible candidates include build-ids, byte compiled files etc, but this
nothing is automatically marked as artifact in this commit.
2017-11-08 11:02:10 +02:00
Panu Matilainen 95f4e6c6d6 Eliminate now unnecessary rpmtdFreeData() calls 2017-05-26 12:40:36 +03: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 6bada81529 Make filter query/verify by file attributes generic
We only have a disabler for %ghost files ATM but that doesn't mean
the actual code can't be generic, the logic is actually much clearer
this way (especially compared to the to-negate-or-not-to-negate
fun on verify side)

One might envision a generic way to set filters via a cli argument to
go with this, eg --noattr=cd to skip documentation and configs,
or --noattr=g as an alias to --noghost.
2016-11-17 10:50:18 +02:00
Panu Matilainen 1d32a88181 Revert "Add macro _vsflags_query_rpmdb"
This is too flimsy a mechanism for such a critical item as signature
checking: with the innocent- and unrelated looking commit
e3e5db7f39 in place,
'rpm -q foo.rpm' runs with NO signature checking whereas 'rpm -qp foo.rpm'
does signature check. Not sane behavior.

Also the commit is buggy to begin with, qva->qva_source is not a bitfield
so most queries would run with signature checking enabled still.
Revisit some day in a different form, maybe.

This reverts commit b30fca9eed.
2016-10-20 10:31:37 +03:00
Florian Festi e3e5db7f39 Try arguments of rpm -q as file names (-p)
if no match is found in the rpm db and they end with .rpm
Resolves: trac #28
2016-04-05 14:50:56 +02:00
Lubos Kardos 5490887c3a Add option the select option --builtrpms to rpmspec(rhbz:961833)
When --builtrpms is used then rpmspec operates only on the binary
package headers of packages which would be built from spec. That means
ignoring package headers of packages that won't be built from spec
i. e. ignoring package headers of packages without file section.
2016-03-09 14:51:27 +01:00
Florian Festi 93a2f6ae92 Add --whatrecommends, --whatsuggests, --whatsupplements, --whatenhances
query parameters.
2015-06-01 09:33:00 +02:00
Lubos Kardos b30fca9eed Add macro _vsflags_query_rpmdb
If it is defined then it is used for queries when "-p" is not set on
commandline. If it is not defined then macro _vsflags_query is used.
For queries with "-p" on commadline macro _vsflags_query is always used.
Macro _vsflags_query_rpmdb is set to 0xf0f00 (no checking) by default.
(rhbz:#438625)
2015-03-20 17:03:38 +01:00
Panu Matilainen f52b2821c8 Make "now" non-static, there's no need for it to be that way
- This makes "now" be "now" on "package query started" than
  "some arbitrary point in process lifetime when", which could
  in theory be arbitrarily long in the past. Which should be
  a sane thing... and also avoids having to do pthread tricks
  for such a silly and cheap-to-call thing.
2013-02-19 17:59:40 +02:00
Panu Matilainen 4b19c17f53 Add cli-switch to query for license files 2012-11-08 10:28:01 +02:00
Panu Matilainen 32a4e283a6 Recognize relative paths as such in --whatprovides query 2012-07-03 08:51:09 +03:00
Panu Matilainen 9ad57bda4a Use RPMDBI_INSTFILENAMES on file queries as well
- This changes query behavior quite a bit as files with non-installed
  status are no longer returned as matches. The rationale is that
  it makes figuring out dependency issues with the "new" behavior
  more obvious (but perhaps we should have a switch to enable
  former behavior). Besides not satisfying dependencies, files with
  non-installed status are not really owned by the package, as they
  would not be removed on package removal.
2011-08-29 16:19:32 +03:00
Panu Matilainen c295b772f3 Remove dead NULL-assignment before reassign 2011-05-31 12:35:18 +03:00
Panu Matilainen 5006b8fbce Remove superfluous localtime() call
- The tm pointer is reset to localtime(&when) before accessed,
  this is nothing but a dead call and assignment
2011-05-31 12:27:58 +03:00
Panu Matilainen 31fabc4d03 Remove bogus condition on provide checking in query
- RPMQV_WHATPROVIDES only falls through to RPMQV_PATH on absolute
  paths, so the only place checking for provides_checked value would
  never be reached in the case it was set.
- Add a comment about the fallthrough case
2011-05-31 08:41:18 +03:00
Panu Matilainen f67c47b856 Eliminate bunch of dead assignments on ts vsflags
- The common pattern here is grabbing current flags to a local
  variable, modifying them for an operation and then restoring,
  which is fine... but we dont care about the previous flags
  when we're restoring them.
2011-05-30 15:50:29 +03:00
Panu Matilainen b1597da353 Eliminate dead NULL-assignments at scope-end in librpm, part VI
- Remove NULL-assignments of local variables at the end of scope
  in "cli-level" code
2011-05-29 11:50:54 +03:00
Panu Matilainen 3baf0da79f Remove unused nowtm variable 2011-03-04 12:32:49 +02:00
Panu Matilainen 41e311c91d Meh, one missed rpmTag -> rpmTagVal change in query
- While the initial assignment is to true rpmTag, rpmTagGetValue()
  returns rpmTagVal, not rpmTag.
2010-10-22 12:35:56 +03:00
Panu Matilainen 0715b04664 Change all internal uses of rpmtsInitIterator() to use DBI tags 2010-10-22 11:49:52 +03:00
Panu Matilainen 327b9a3818 Switch lone rpmTag use in query to rpmTagVal 2010-10-22 11:43:10 +03:00
Panu Matilainen 534d0f77be Eliminate useless --fileid query selector
- Finding out which package provides a file with a given digest
  is just .. useless functionality. Being next to useless is one
  thing, but we pay a high price for this particular uselessness:
  the index needed for this is one of the biggest and most expensive
  indexes we have.
2010-10-22 08:58:06 +03:00
Panu Matilainen 190b58746c Add support for querying source rpm from spec too
- Handle source rpm query as a new query source type RPMQV_SPECSRPM,
  rename the binary query to RPMQV_SPECRPMS, with RPMQV_SPECFILE
  as a backwards compatibility alias to RPMQV_SPECRPMS.
2010-10-12 14:41:35 +03:00
Panu Matilainen 59b275ddc7 Further streamline rpmcliArgIter() and friends
- Turn applyFilters() into match iterator initializer which optionally
  applies filters if present
- Handle NULL iterator error codes centrally in rpmcliShowMatches()
2010-10-04 14:31:55 +03:00
Panu Matilainen be488096e0 Use the new tag type/return type getters everywhere
- Instead of masking and bitfiddling all over the place, use the
  new getters to get the exact (enum) type directly. rpmTagGetType()
  is now unused within rpm but leaving around for backwards compatibility
2010-09-21 12:40:33 +03:00
Panu Matilainen 1607bc3908 Turn rpmQueryVerify() into query iterator initializer
- Eliminates quite a bunch of redundant error code return hoop-jumping
  and makes the iterator init + frees nicely paired all together
  inside rpmcliArgIter().
2010-09-08 07:51:08 +03:00
Panu Matilainen 33d79b470e Lift the remaining oddball case out of rpmQueryVerify()
- specfile queries are handled differently from everything else,
  handle the special case in rpmcliArgIter()
2010-09-08 07:51:02 +03:00
Panu Matilainen d2eb366a90 Eliminate qva_mi and qva_gi from rpmQVKArguments
- These are internal only stuff and have no business being exported
  in the API. Pass the iterators around in, duh, arguments as needed.
2010-09-08 07:50:50 +03:00
Panu Matilainen 50d70b056e Eliminate some dozen redundant rpmcliShowMatches() calls
- Simply call it once at the end, its common for all the cases
2010-09-08 07:50:40 +03:00
Panu Matilainen 03bc9f0f32 Cut some extra twists from the query maze
- RPMQV_ALL and RPMQV_RPM do nothing but call rpmcli/giShowMatches()
  in rpmQueryVerify(), call them directly from rpmcliArgIter() instead
- Make iterator allocation + deallocation symmetric: both
  rpmcliArgIter() and rpmQueryVerify() now free what they alloced,
  rpmfooShowMatches() is a weird place for freeing
2010-09-08 07:50:31 +03:00
Panu Matilainen 029615e1f6 Eliminate rpmQueryVerify() from librpm API
- This is an inconsistent oddball interface which only works for
  limited query types, "cli" level API users are better off calling
  rpmcliQuery() / rpmcliArgIter() instead
2010-09-08 07:50:23 +03:00
Panu Matilainen b71818080b Urk, mixed up in branches and wrong stuff getting pushed. Revert.
- This reverts commits 9ac127c352 and
  7abc26e300
2010-09-08 07:48:04 +03:00
Panu Matilainen 7abc26e300 Beat a little bit of sense into rpmQueryVerify()
- Single point of exit, assume failure
- Replace about a dozen rpmcliShowMatches() calls with one at the
  bottom.
2010-09-07 21:32:17 +03:00
Panu Matilainen 9ac127c352 Mark ts argument unused in bunch of query APIs
- The ts argument used to be necessary and used for rpmfiNew() and spec
  query but not any more...
2010-09-07 21:13:34 +03:00
Panu Matilainen 339f31face Eliminate rpmcliShowMatches() from librpm API
- This is really just an internal helper which only even works with
  limited set of queries.
2010-09-07 20:44:59 +03:00
Panu Matilainen a68bcb383e Use the common rpmcliQueryFlags for signature verify options in rpm cli too
- Technically this changes the rpmcliQuery() and rpmcliVerify() API
  in the sense that we no longer honor the qva->qva_flags for the
  --nosignature and others, but we assume anybody using these (as if
  anybody was using the "cli" API) uses rpmcliInit() which takes
  care of these common bits... shrug.
- Ditch ancient and hidden --nopgp --nogpg switches along with the
  dishwater which are simply alias to --nosignature.
- Eliminate now unused qva_flags from rpmInstallArguments (along with
  a double vsflags goo from rpmgraph)
2010-09-03 10:50:37 +03:00