Commit Graph

561 Commits

Author SHA1 Message Date
Panu Matilainen 7c036b9ca3 Eliminate dead NULL-assignments at scope-end in librpm, part V
- Remove NULL-assignments of local variables at the end of scope
  in transaction and database code
2011-05-29 11:49:46 +03:00
Panu Matilainen 75a0d6dcf4 Colored conflict resolution part II
- Same as commit 7bbc9b073d but
  within the to-be-installed set
2011-05-26 14:16:14 +03:00
Panu Matilainen 7bbc9b073d Both files must be colored for multilib conflict resolution (RhBug:705115)
- File conflicts should only be resolved to preferred color when
  both files are colored. Prior to this we would happily overwrite
  scripts with a clearly conflicting ELF binary.
2011-05-26 11:40:55 +03:00
Panu Matilainen e040a126a0 Disable all scriptlets and collections centrally on --test and --justdb
- These are already taken care of in other places but they're littered
  a little bit of here and there, eg in case of collections these
  modes are only skipped deep down in the plugin code. This should
  make the intended behavior more obvious upfront.
2011-05-25 14:52:39 +03:00
Panu Matilainen 4f3aa73270 Empty transaction is not an error (RhBug:699929)
- Empty transaction just means we have nothing at all to do,
  but it's not an actual error.
2011-05-18 08:28:07 +03:00
Panu Matilainen b45622b5b9 Eliminate another set-but-unused xx warning
- There's no meaningful way to return error from rpmdbExtendIterator()
  in rpmFindBaseNamesInDB() so dont bother collecting the result.
  At least there'll be rpmlog spew on errors so it wouldn't be
  silently failing.
2011-04-19 10:02:23 +03:00
Panu Matilainen 805f7fd5af Move string hash function to librpmio and rename for namespacing
- There are places in rpmio and build that would benefit from hashing, but
  hashFunctionString() being internal to librpm has prevented that. Rename
  to rstrhash() to resemble the other foo in rpmstring.h for
  minimal namespacing as its now public function and update callers.
- Also mark the function as "pure" - it only looks at its arguments.
  This is one of the busiest functions in entire rpm so any optimization
  no matter how minor is well worth it.
- Hereby awarding hashFunctionString() with the grand prize for
  the Most Moved Around Function in rpm ;)
2011-03-10 10:17:39 +02:00
Panu Matilainen 3632294483 Remove pointless return code from handleInstInstalledFiles()
- There are no errors to return here... so it might as well be void
2011-03-04 13:46:06 +02:00
Panu Matilainen fbdfe8e5bf Add an error message + comments on open(".") behavior (RhBug:672576)
- Bail out early and complain if current directory can't be open()'ed,
  as we'll need it for reliable cwd restoration after running Lua
  scripts.
- Technically we'd only need open(".") succeeding for chroot operations
  and running Lua-scripts, but there's no easy way to determine whether
  a transaction will run Lua-scripts. They could be in-db triggers
  which will only be evaluated in the middle of transaction, better
  to fail early for consistent behavior.
2011-01-28 13:19:53 +02:00
Panu Matilainen bd96c179b7 Plug potential division by zero in the rpmdb size calculation (RhBug:671056)
- This smells like treating the symptom instead of the disease, add
  a reminder comment to figure out what's going on here...
2011-01-21 14:02:28 +02:00
Panu Matilainen b270b38a70 Only force default umask during transaction (RhBug:494440)
- For rpm itself forging global umask on init is kinda convenient, but can
  be troublesome for API users. This is especially bad in python bindings
  where just importing the rpm module silently changes process umask with
  no good reason.
- Instead of global setting on init, only change the umask to 022 default
  for the duration of rpmtsRun() where it's necessary for consistent
  transaction results on implicitly created directories and files created
  by scriptlets. This way we dont affect callers and provide better
  "protection" for ourselves too - we don't know if API users change
  umask again behind our back if we just set it on initialization.
- To make matters more fun, Lua scripts can change our umask. Save
  and restore umask when running Lua scriptlets.
2010-11-18 12:50:55 +02:00
Panu Matilainen 4287e2e6df Always exit rpmtsRun() via rpmtsFinish()
- Fixes a memory leak from rpmtsSELabelInit()
- Ensures we get out of chroot() on the way out
2010-11-17 16:27:10 +02:00
Panu Matilainen 0f9cef69c0 Eliminate unused strlen() calls 'n stuff from skipInstallFiles()
- These were used by the netsharedpath calculations which used
  to be inline here, but that's now in a function of their own. Also
  move the temporary variables to the scope where they're actually used.
2010-11-04 14:44:25 +02:00
Panu Matilainen bed4ada5c1 Remove nicely misleading #ifndef NOTYET case from skipInstallFiles()
- No point "documenting" with reverse ifdef's what somebody was
  considering to implement eight years ago, as it is directory and
  file iterations can't be mixed as they both mess with fi->j.
- Also eliminate pointless "can't happen" check - this never gets
  called with NULL fi in an element (which is already a cant happen)
2010-11-04 14:42:34 +02:00
Panu Matilainen a40598b228 Separate match iterator allocation vs initialization
- There's exactly one spot within rpm which needs the former behavior
  of rpmdbInitIterator() on a secondary index with keyp of NULL:
  rpmFindBaseNamesInDB(): it wants an empty iterator on RPMDBI_BASENAMES,
  which is then extended as it progresses. Starting with commit
  c70e076e08, rpmdbInitIterator()
  however returns the actual index in that case, which is not
  optimal for rpmFindBaseNamesInDB(). Handle the basenames in db
  as the special case it is, and have it explicitly create an
  empty iterator with the new call.
2010-10-26 09:54:55 +03:00
Panu Matilainen ea951fca34 Eliminate pgpHashAlgo uses in librpm side
- In all these cases the value comes from a non-enum source so
  just use an int instead
2010-10-22 13:06:36 +03:00
Panu Matilainen 0715b04664 Change all internal uses of rpmtsInitIterator() to use DBI tags 2010-10-22 11:49:52 +03:00
Steve Lawrence 34b5d67c2d Use selabel interfaces instead of matchpathcon
This replaces the old matchpathcon interfaces with the new selabel
interfaces for relabeling files, storing an selabel handle in the
transaction set.

With this change, also comes an added distinction between --nocontexts
being specified and a failure to read the load file contexts.
Previously, there was no distinction, and both cases used the
RPMTRANS_FLAG_NOCONTEXTS flag.

However, with the new policy plugin, it is necessary to make such a
distinction. This is because matchpathcon_init (now selabel interfaces)
can fail at the beginning of the transaction, but succeed later after
new policy is installed. Because of this, we may need to enable/disable
RPMTRANS_FLAG_NOCONTEXTS multiple times. However, because this flag
could also mean --nocontexts, we cannot do that. By storing the selabel
handle in the rpmts, we can easily keep track if the handle has been
successfully created, rather than overloading RPMTRANS_FLAG_NOCONTEXTS
with two meanings.
2010-09-01 09:30:51 +03:00
Steve Lawrence 883f13c8b7 Update the plugin architecture to allow for remembering state
This moves most of the plugin logic to a new rpmplugins file with a
struct and functions for managing plugins, allowing for plugins to carry
state. This also adds init and cleanup hooks for plugins to initialize
and cleanup their state, and a new 'open te' hook allowing plugins to
read and save information from transaction elements.

This also generalizes the plugin architecture a bit so it isn't so
specific to collections.
2010-09-01 09:04:05 +03:00
Panu Matilainen d3bebf2656 Lose the now unnecessary rpmtsSELinuxEnabled() function
- it never was anything more than a cached value of is_selinux_enabled()
  and caching this fairly expensive result is no longer needed as
  scriptlet execution wrt selinux contexts is now conditionalized on
  RPMTRANS_FLAG_NOCONTEXTS instead
2010-08-13 17:24:12 +03:00
Steve Lawrence 85d89bafdc Determine when to perform Collection actions
There are three times during a transaction when Collection actions can be
performed:

1) After the last time a member of a collection is either installed or removed
2) After the last time a member of a collection is installed only
3) Before the first time a member of a collection is removed only

This patch adds three lists to the rpmte structure to mark which transaction
elements fall into each of these groups, and the collections that caused that.
A new function is added to the TSM to scan through all the transaction elements
and update these lists. When a collection is added to one of these lists, it
signifies that when that transaction element is installed, the appropriate
action should be performed for that collection.
2010-06-22 11:12:43 +03:00
Panu Matilainen 33197fd4b1 Dont bother with selinux contexts in test transactions
- initializing contexts isn't exactly cheap, and test transactions
  have no use for them
2010-06-11 08:20:32 +03:00
Panu Matilainen 099a45a5b9 Nuke leftover variable from the chroot workout 2010-05-31 18:00:33 +03:00
Panu Matilainen f2bfa2edfc Use the new chroot API everywhere, eliminate old related goo 2010-05-31 14:11:12 +03:00
Panu Matilainen 5c6795bf43 Handle test-transaction centrally on entry to psm
- psm in test-mode is a no-op anyway, so dont bother at all with it
- also removes the need to check for test mode on pre/posttrans scripts,
  these are now fully covered by psm too
2010-05-26 13:25:39 +03:00
Panu Matilainen 0e04c09d48 Move the lone hashFunctionString() into misc.[ch], eliminate rpmhash.[ch]
- Besides there not being much point in having a separate source + header
  for a small single function, this fixes build on case-insensitive
  systems such as Mac OS X.
2010-05-21 15:36:03 +03:00
Panu Matilainen f051801373 Convert rpmte internals to use the transaction pointer from element itself 2010-05-07 14:31:25 +03:00
Florian Festi 70e9b035ff Convert tsmem->removedPackages to a hash table and remove rpmdbPruneIterator from the API 2010-05-06 16:07:56 +02:00
Panu Matilainen 1f625e69e9 Further generalize the rpmlock interface
- Move transaction lock path handling into rpmts.c, export new low
  level rpmlockAcquire() function to actually grab a lock
- Rename rpmtsFreeLock() to rpmlockFree() and return NULL in the
  general rpm style
2010-04-22 11:01:27 +03:00
Panu Matilainen 35c563af8c Make rpmlock type visible inside rpm, use instead of void* 2010-04-22 10:37:51 +03:00
Rakesh Pandit 8cc740c43f Eliminate unused "known problems" based filtering from rpmtsRun()
- This mechanism has never been used by anything at all, which suggests
  its not a particularly useful feature
- Removing unused rpmpsTrim() from rpmps
- Marking okProbs parameter of rpmtsRun() function as unused to avoid
  unnecessary breakage
2010-04-21 12:03:09 +03:00
Panu Matilainen 2275a2ef89 Hide rpmte open/close/error etc logic inside rpmteProcess()
- make a bunch of helper functions static now that they're not needed
  elsewhere, rpmte is slowly becoming self-aware ;)
2010-03-29 18:40:29 +03:00
Panu Matilainen 7289fadea3 Move the little thats left of psm.h into rpmte_internal.h
- no functional changes, just shuffling declares around
2010-03-29 18:40:29 +03:00
Panu Matilainen 94f94398dc Oops, diskspace problem messed up from the argument shuffle
- fixes regression from commit 12392d93e2
2010-03-26 15:29:19 +02:00
Panu Matilainen 0f93affa16 Record originating header instance to all problems where relevant
- currently unused but allows tracking things like file conflicts
  back to the originating header directly from the problem set
2010-03-26 15:22:13 +02:00
Panu Matilainen 12392d93e2 Sanitize rpmteAddProblem() arguments
- lump fn/dn into one, in no case both are needed
- move altNEVR earlier to lump the generic attribute foo last
2010-03-26 10:27:39 +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
Panu Matilainen ffd5d96817 Split transaction member information out of rpmts to separate struct
- add internal rpmtsMembers() function to get the member structures
- the main rpmts struct is now opaque within order.c, and much closer
  to being so for depends.c and transaction.c too
- no functional changes
2010-03-12 10:20:25 +02:00
Panu Matilainen df9cdb1321 Turn PSM into a complete blackbox
- The psm structures aren't stored or passed around by any users,
  so there's no need for them to separately allocate and free the
  struct, bury this all inside rpmpsmRun() which takes care of
  initialization, actual actions and freeing.
- There's also no need for refcounting now as allocations are completely
  contained within the rpmpsmRun() blackbox. Lose psm-debug foo which
  was only used for refcount debugging.
- No functional changes
2010-03-12 09:04:29 +02:00
Panu Matilainen 81ad49ceec Minor rpmtsCheckDSIProblems() cleanup 2010-02-26 13:45:47 +02:00
Panu Matilainen e5a32d7701 Lose some unnecessary includes 2010-02-26 09:36:42 +02:00
Panu Matilainen 3a240cc1d6 Hide install/erase statistics collection inside psm 2010-02-26 09:17:03 +02:00
Panu Matilainen 22df735b5a Lose fluff from ensureOlder()
- p and h can't possibly be NULL in the place this gets called
- the single caller doesn't care about return value
2010-02-25 21:50:20 +02:00
Panu Matilainen 04d07f836b Lose another pointless NULL-check on rpmfi iteration + an unused variable 2010-02-25 21:35:56 +02:00
Panu Matilainen 31de39c934 Lose some completely pointless "can't happen" checks
- rpmfiFC() returns 0 if called with NULL, which is ok in these cases
- rpmfiInit() and rpmfiNext() behave correctly when passed NULL, no need
  check separately
- "dn" is already referenced before checking for NULL... it really
  cannot happen ;)
2010-02-25 20:52:35 +02:00
Panu Matilainen 91b3bc198a Tidy up checkProblems() a bit, no functional changes
- avoid a million redundant calls to rpmtsFilterFlags()
- turn osOkay() and archOkay() into macros, they're suitably dumb for that
2010-02-25 20:42:55 +02:00
Panu Matilainen cd3d8082e1 Implement pretrans, posttrans and verifyscript as psm goals
- Loose rpmpsmScriptStage() hack and bury the psm details inside
  the psm implementation
- Map the script-only goal enums to the corresponding script tag
  to avoid having to re-re-re-map stuff unnecessarily
- pretrans and posttrans should really be handled as a part of PKG_INSTALL
  process, but as these stages are disconnected from the main install
  part we can't remember the state in the psm - it would need to be
  stashed into transaction elements in the meanwhile
2010-02-25 14:22:34 +02:00
Panu Matilainen 384f777705 Separate PSM goals from individual stages
- no functional changes - supposedly
- nothing outside the PSM should need to know anything about its
  internals, the general goals need to be sufficient (not the case yet)
- define goals to match rpmteType so there's no need to re-re-re-map
  the operations
- loose the big unused individual stage string switch
2010-02-25 13:55:24 +02:00
Panu Matilainen 1b78ed281b Improve failed transaction element behavior + logging
- handle failed element in rpmteOpen() already, avoiding need to check
  everywhere else
- elements cancelled due to parent failure can further cancel their
  dependent elements
- all failed, including skipped, elements are now logged
2010-02-25 12:38:22 +02:00
Panu Matilainen 924234e8b6 Lose now unnecessary progTag from psm
- our scriptlet thingie knows which progtag to use for a given script tag
  already, no need to baby-feed the psm
2010-02-25 11:05:02 +02:00