Commit Graph

172 Commits

Author SHA1 Message Date
Panu Matilainen a48b11edbd Make rpmdsMerge() return something meaningful
- The API documentation was always incorrect and meaningless, as
  rpmdsMerge() can merge any number of entries so there's no single
  index to return. Instead return the number of merged entries
  and adjust the docs to match the new behavior.
- This is of course an incompatible API change in a strict sense,
  but then since the documentation was always wrong to begin with
  anybody looking at rpmdsMerge() return is relying on undocumented
  behavior really. The compatible way to use this is to check
  for < 0 for errors and assume success otherwise.
2013-04-15 18:13:46 +03:00
Panu Matilainen 83844d55cd Fix ages old bug in rpmdsFind() wrt flags
- EVRs are pointers which in theory could be NULL so checking them
  is appropriate, but 0 is a perfectly legal value for flags and
  the bogus "NULL check" causes it to get things wrong if either or both
  flags are RPMSENSE_ANY
2013-04-15 17:35:18 +03:00
Panu Matilainen db80e6ed5a Guard against NULL ds in the rpmds indexed getters
- NULL dependency sets are all over the place as NULL ds means
  "no dependencies of this kind", whereas for eg rpmfi NULL is an
  error.
2012-10-05 10:09:50 +03:00
Panu Matilainen f4758b1920 Export the indexed rpmds accessors internally
- Add an internal header for rpmds too to allow adding interfaces we
  dont necessarily want to export in the public API, make the indexed
  accessors available internally.
2012-10-05 10:07:52 +03:00
Panu Matilainen 62ddd3149f Add indexed access variants for rpmdsColor() and rpmdsCompare()
- Various places in rpm need random access to the dependency sets,
  save and restore on somebody elses "iterator index" just doesn't
  cut it. This is merely preliminaries for further changes.
2012-10-05 10:07:14 +03:00
Panu Matilainen ad3f256be3 Take advantage of rpmstrPoolStreq() in rpmdsCompare()
- This gives quite a speedup for dependency checking as within
  transaction, all the dependency sets come from the same pool
  and making this just an integer comparison.
2012-09-21 15:49:11 +03:00
Panu Matilainen 17d3db4e3a Unify the three rpmdsFooMatchesDep() functions into one
- These all do more or less the same thing, easily handled with a common
  function that takes a couple of more extra parameters. The old variants
  become just wrappers to call the pool-aware rpmdsMatches() with suitable
  arguments.
2012-09-13 13:03:38 +03:00
Panu Matilainen d12fe7841e Add pool-aware version of rpmdsRpmlib() 2012-09-13 11:54:54 +03:00
Panu Matilainen 9816b07560 Add pool-aware versions of rpmdsThis() and rpmdsSingle()
- Pooh ... I mean pool ... bah. The previous  versions become simple
  wrappers to the pool-aware ones, using a private pool always.
  rpmdsCurrent() doesn't need pool-variant as its inherits its pool
  from the parent.
2012-09-13 11:01:09 +03:00
Panu Matilainen f3f4c74748 Simplify single ds creation
- Eliminate the pre-created pool wtf'ery (what was I thinking?), just
  create a ds with zero id's and fill them up once we have the ds.
2012-09-13 10:39:28 +03:00
Panu Matilainen 0654685493 Allow keeping hash table around on pool freeze, adjust callers
- Pool id -> string always works with a frozen pool, but in some cases
  we'll need to go the other way, allow caller to specify whether
  string -> id lookups should be possible on frozen pool.
- On glibc, realloc() to smaller size doesn't move the data but on
  other platforms (including valgrind) it can and does move, which
  would require a full rehash. For now, just leave all the data
  alone unless we're also freeing the hash, the memory savings
  isn't much for a global pool (which is where this matters)
2012-09-12 19:17:20 +03:00
Panu Matilainen 86dbb88448 Add getters for rpmds dependency name and EVR pool ids 2012-09-12 19:13:02 +03:00
Panu Matilainen 00b6d69a7a Add getter methods for rpmds and rpmfi string pool handle 2012-09-12 12:53:56 +03:00
Panu Matilainen 8a1f9c13fd Oops, only private pool should be frozen on ds create 2012-09-11 14:40:01 +03:00
Panu Matilainen 0d17da2615 Add an alternative rpmds constructor to allow shared pool usage
- rpmdsNewPool() allows specifying shared/private pool, and rpmdsNew()
  is now just a wrapper to always call it with NULL (ie private) pool.
2012-09-11 13:53:24 +03:00
Panu Matilainen 2d62f297bc Freeze the rpmlib dependency set pool on successful return
- ...to avoid wasting memory on the relatively static data. We could
  handle the rpmlib ds singleton behavior here too but it would change
  semantics. Ponder about it later...
- Would be nicer to have rpmdsMerge() freeze on return, but that
  gets called in loops so we'd be doing a whole lot of huffing and
  puffing recreating the pools on each entry.
2012-09-11 13:43:09 +03:00
Panu Matilainen f5be054332 Further split single ds creation into two, sigh
- Allow rpmdsCurrent() to share the pool and id's of its "parent" ds
  instead of having to repeatedly create and tear down entire pools
  just for a couple of strings. Used by python bindings for rpmds
  iteration so we'll want to be reasonably efficient.
- For now, rpmdsSingle() and rpmdsThis() always get a private pool,
  wasteful as it might be, but at least now we can freeze them.
2012-09-11 13:41:16 +03:00
Panu Matilainen cee404ff37 Unify the common parts of rpmds creation into a helper function
- No functional changes, just sanity-refactoring
2012-09-11 11:54:23 +03:00
Panu Matilainen b89a836829 Eliminate assert()'s from rpmdsMerge()
- These "can't happen" cases where EVR/Flags in source ds are missing
  are just as easy to handle as is dying, handling is saner...
2012-09-11 11:19:23 +03:00
Panu Matilainen c5b6ad0464 Eliminate assert()'s from rpmdsDup()
- The "can't happen" case where EVR/Flags are not present is just as
  easily handled as dying.
2012-09-11 11:00:24 +03:00
Panu Matilainen 71c72058d2 Switch dependency sets to use string pool storage for names and evrs
- Always push dependency names and versions into string pool (private
  for now). This is terribly wasteful for single ds items, even more
  so for rpmdsCurrent() but to keep the initial switch-over changes
  to minimum we'll deal with those later.
- While we freeze the pool for ds data from headers, single ds items
  are on purpose not frozen for now, due to interactions with
  rpmdsCurrent() and rpmds merging.
- Eliminate no longer needed rpmdsDupArgv(), we're now just copying
  a bunch of integers around. Sanitize rpmdsMerge() now that we can:
  realloc and shift the data instead of recreating all of N, EVR
  and Flags.
2012-09-11 10:54:40 +03:00
Panu Matilainen 9929a34aaf Eliminate direct rpmds name (and flags) access on rpmdsNew() 2012-09-11 08:09:16 +03:00
Panu Matilainen c5276f3b3d Clean up rpmdsSearch() a bit
- Eliminate numerous repeated direct accesses to [o]ds N, EVR and Flags,
  instead use getter functions and local variable for ods name which
  does not change.
2012-09-11 08:09:12 +03:00
Panu Matilainen 42f6abba48 Add internal indexed variants of rpmds N, EVR and Flags getters
- We'll need these to eliminate the remaining direct accesses to
  N, EVR (and Flags) on random access patterns such as rpmdsSearch().
2012-09-11 08:09:07 +03:00
Panu Matilainen a596ae47a3 Clean up rpmdsFind() a bit
- Eliminate numerous repeated direct accesses to [o]ds N, EVR and Flags,
  instead grab them into local variables through getter functions as
  needed: on entry for ods which doesn't change, for ds in the loop
  as we're changing ds->i here.
2012-09-11 08:08:59 +03:00
Panu Matilainen d2f51ded49 Split rpmds EVR comparison into function of its own
- The EVR comparison is a distinct operation of its own: rpmdsCompare()
  looks at the other properties, EVR comparison is done if needed.
  Doesn't affect speed or functionality, but cuts down on the
  big number of local variables and has the nice side-effect of
  making the xstrdup() allocations local within rpmdsCompareEVR()
2012-09-11 08:08:54 +03:00
Panu Matilainen 03b6fcb1a1 Use getter functions for name, evr and flags in rpmdsCurrent() 2012-09-11 08:08:46 +03:00
Panu Matilainen 9d0e0fcc23 Clean up rpmdsCompare() a bit
- Eliminate numerous repeated direct accesses to ds N, EVR and Flags,
  instead grab them into local variables through getter functions
  as they are needed. Besides making it easier on the eyes, makes the
  function safe(r) wrt illegal iterator values etc.
2012-09-11 08:08:39 +03:00
Panu Matilainen 25bef90870 Clean up rpmdsNewDNEVR() a bit
- Eliminate numerous repeated direct accesses to ds N, EVR and Flags,
  instead grab them into local variables at entry. This also makes
  the function safe illegal iterator values (ie calling when iteration
  not started), previously the bounds were not checked.
2012-09-11 08:08:34 +03:00
Michael Schroeder db28221a4a Add support for dpkg-style sorting of tilde in version/release
- This allows much nicer handling some common scenarios such as
  upstream pre-releases where the pre-release version would normally
  appear newer than final release, eg 1.0-rc1 vs 1.0. Previously this
  required mapping the pre-release tag into the release tag to achieve
  desired sorting, with tild this becomes simply 1.0~rc1 < 1.0.
- Add a rpmlib() tracking dependency to prevent older rpm versions
  from getting confused with packages relying on the new behavior.

Signed-off-by: Panu Matilainen <pmatilai@redhat.com>
2012-04-23 11:04:02 +03:00
Panu Matilainen cab09c6c36 Remember ds color (if set) through rpmdsCurrent()
- Currently only dependency sets coming from transaction elements
  get colored, only bother allocating memory for non-zero color.
2011-08-31 11:09:03 +03:00
Panu Matilainen d26080fa88 Eliminate dead NULL-assignments at scope-end in librpm, part IV
- Remove NULL-assignments of local variables at the end of scope
  in the higher level package-related "objects": rpmds, rpmfi, rpmte
2011-05-28 22:28:53 +03:00
Florian Festi d8b1d68ae5 Remove rpm v3 code
These cases are check for in rpmdsCompare() anyway. No need to "optimize" for a long dead rpm release.
2011-03-31 10:56:43 +02:00
Florian Festi b1a4b57315 Add rpmdsMatchesDep() as alternative to rpmdsAnyMatchesDep() to make use of the tag number (index) we get from the rpmdb on queries 2011-03-31 10:56:43 +02:00
Panu Matilainen ddc47f4cfe Return error codes from rpmdsRpmlib()
- It can fail with eg NULL dsp passed, might as well return something
  which also silences gcc
2011-03-04 13:08:17 +02:00
Michael Schroeder 82347dc881 Fix corner-case behavior on dependency matching when release not present
- The idea behind the patch is that a missing release is handled
  as "all/any release". Nothing changes for "foo < 1.2" or
  "foo > 1.2", it still just compares the version. But "foo = 1.2"
  means "everything with version 1.2". Thus, any match against
  a package with version "1.2" a any non-empty release must
  return true.
- Update test-suite expectations to the new behavior.

Signed-off-by: Panu Matilainen <pmatilai@redhat.com>
2011-02-15 14:55:55 +02:00
Panu Matilainen 5c43095e1d Implement transaction ordering hinting
- Add support for new "OrderWithRequires: foo" spec syntax
  which has "if and only if foo is present in transaction, order
  the transaction as if this package required foo" semantics.
  While it looks, and in some ways is, a soft dependency, this
  is not the same as recommends/suggests etc: those have unknown
  depsolver policy dependent semantics attached to them, whereas
  ordering hints have a clear definition and is only relevant for rpm
  itself, depsolvers should not even look at the data.
- This allows packages to express correct ordering for optional
  functionality, such as

      %post
      if [ -x %{_bindir}/register-component ]; then
          %{_bindir}/register-component %{name}
      fi

  If the package containing %{_bindir}/register-component is included
  in the same transaction, it makes sense to have it installed before the
  package(s) that use it. But as it is fully optional, Requires would
  not be appropriate. Using OrderWithRequires allows this to be expressed
  without dragging in extraneous dependencies for optional functionality.
2010-12-13 12:26:06 +02:00
Panu Matilainen 53e3ca23ea Const-correctness: rpmdsRpmlib() doesn't (and must not) modify tblp 2010-11-05 10:18:41 +02:00
Panu Matilainen 73c079735a Switch rpmds API and internals to use rpmTagVal instead of rpmTag
- None of these require passing "true enum", the value is what counts.
  In general, enums as function argument types are just a royal PITA
  from C++, avoid when not strictly necessary.
2010-10-22 11:27:01 +03:00
Panu Matilainen 5eda185109 Use RPMTAG_NOT_FOUND instead of for "invalid tag" value 2010-09-21 13:11:56 +03:00
Panu Matilainen 92c12d1a8e Eliminate all fooUnlink() functions out of the API
- These are internal helpers only, all refcount users need to use
  fooFree() or similar for correct operation. Add fwd declarations
  where necessary to avoid moving code around unnecessarily.
- We could add these back later as aliases to fooFree() but for now,
  just get them out of the way.
2010-09-13 13:08:33 +03:00
Panu Matilainen 85437f43ab Use rpmdsThis() instead of doing the same manually 2010-06-28 16:02:14 +03:00
Panu Matilainen 2aac5c68ad Lazy allocation of rpmds color array
- only requires and provides in transaction elements get colored,
  dont allocate unused memory
2010-03-29 16:07:28 +03:00
Panu Matilainen 593902eee6 Remove unused dependency set file reference count
- this has never been used for anything at all, there are better things
  to use our memory for than unused arrays
2010-03-29 15:03:14 +03:00
Panu Matilainen e18d9e6826 Remove unused and non-sensible depedency set build-time
- Buildtime was never part of rpm version comparison nor should it be,
  on rpm level the only sensible differentiator between two identical
  dependencies is the dependency color if any. Other than that, random()
  just as "appropriate" as build time.
2010-03-29 14:53:10 +03:00
Panu Matilainen b88d5d3aaf Add public rpmdsCurrent() function for creating a single ds from iteration
- Permits extracting single dependencies from a set with instance
  number inherited without exposing rpmdsSetInstance() kind of thing
- Also faster than calling rpmdsSingle(rpmdsTagN(ds), rpmdsN(ds)....)
  where each call re-re-re-re-validates the indexes
2010-03-26 17:11:12 +02:00
Panu Matilainen 971348fd46 Split single ds generation into helper function, clean up a bit
- allows nicer handling of ds instance without special cases
2010-03-26 17:11:12 +02:00
Panu Matilainen eaff094c57 Record header instance in dependency sets + add API for retrieving 2010-03-26 14:56:14 +02:00
Panu Matilainen 19498b426f Lose the useless rpmds refcounting debug junk + switches
- get the debug messages out of API, this is what should've been in commit
  dbdbe8010c
2010-03-22 13:04:26 +02:00
Panu Matilainen e696b409fe Record problems into the transaction elements causing them
- Any problem found in transaction processing is caused, or at least
  triggered by, some transaction element. Having the problems in
  elements lets API users easily determine which package caused which
  problem instead of having to parse problem strings in vain.
- No problem set stored in transaction set itself now, rpmtsProblems() API p
  reserved by making it collect problems from our transaction elements
  into a new set. The problem set fiddling in rpmtsRun() wrt %pretrans
  and all is a bit crazy - always was, now its just more visible...
- Make rpmtsCheck() pass the associated transaction elements into
  the lower level functions. rpmdsProblem() removed from API, it's
  not particularly useful outside rpmtsCheck() internals.
- rpmts struct is now opaque within depends.c except for solve callback
- This breaks --badreloc, need to figure out something saner for the
  problem filtering
2010-03-12 19:46:06 +02:00