Commit Graph

664 Commits

Author SHA1 Message Date
Panu Matilainen ff3fb499e8 Fix an embarrasing refactoring error
Commit 89bddb2e1d managed to completely
mess up the simple return condition, thanks to Michael Schroeder for
pointing it out.
2016-10-18 15:29:58 +03:00
Panu Matilainen 89bddb2e1d Refactor matchNetsharedpath() to return simple yes/no answers
The calling code doesn't care about the actual matching path,
it just wants to know whether to skip it or not. No intentional
behavior changes here.
2016-10-11 15:41:23 +03:00
Panu Matilainen 7d76713adb Do not permit excluding %license files via install policies (RhBug:1333509)
In the old days licenses were typically packaged with "%doc COPYING"
which when installed with --excludedocs would in many cases violate
the license. Using "%license COPYING" avoids the most common pitfall
but %license supports absolute paths too in which case those files
can have other special attributes attached too. Such as documentation
or language specificness, which must not cause exclusion for licenses.
And all sorts of funny corner cases...

On net shared paths we could not install anything anyway. Wrong
colored files would conflict. The common theme between these is that
the file is expected to be there via some other means, which makes
it ok to skip them. This covers --excludedocs, install langs etc,
ie the most obvious cases. Not covered here is skipping due
--excludepath which should not be allowed either (if a path is
inaccessible you can always relocate instead), leave a FIXME
reminder as it requires a bit more work whereas this is trival
to backport.
2016-10-11 11:23:56 +03:00
Peter Eisentraut 159351d7f3 Add missing header files
They are generating warnings.
2016-02-11 11:06:26 +01:00
Michal Domonkos 448db68ceb Add RPMCALLBACK_ELEM_PROGRESS callback type
Currently, there's no callback type that would be issued per each
transaction element.  RPMCALLBACK_TRANS_PROGRESS is only issued during
the prepare phase but not when packages are actually installed or
erased.  Likewise, RPMCALLBACK_INST_ST* and RPMCALLBACK_UNINST_ST* won't
be issued if an install or erase operation is skipped for some reason (a
script or package upgrade failure).

Having such a callback would allow the Python API consumers to always
know upfront which element is about to be processed, before any other
callbacks are issued.  This is important since not every callback type
carries enough data about the subject package; while the INST types
provide the user object passed to a former addInstall call, the UNINST
types only provide the package name (which may not be unique within the
transaction set).

This commit adds such a callback.
2016-01-28 17:03:54 +01:00
Lubos Kardos a0f2d94c3c Add possibility to disable file triggers.
Now options --notriggers, --notriggerin, --notriggerun, --notriggerpostun
disable also file triggers and not only normal trigges. Transaction file
triggers can be also disabled with --nopretrans and --nopostrans options.

Before this patch file triggers weren't disabled when option --test was
specified. That caused unwanted multiple execution of file triggers
in dnf because dnf executes transaction with flag test before executing
transaction for real (rhbz:1282115).
2015-11-23 16:43:39 +01:00
Lubos Kardos 8100d663c1 Add priorities between file triggers and the other scriptlets.
File triggers defined with priority greater than or equal to 100000
will be executed before standard scriptlests. The other file triggers
will be executed after standard scriptlets.
2015-07-23 14:12:47 +02:00
Lubos Kardos 861e92fd0a File triggers moved to own file 2015-07-23 11:03:02 +02:00
Lubos Kardos ee72c41d8b Fix off-by-one error (rhbz:#1206750)
- Caused by commit b598ce37d7
2015-03-30 09:31:15 +02:00
Lubos Kardos b598ce37d7 Skip directory if contains subdirectory that contains only skipped files.
Previously directory was skipped from installation if it contained only
skipped files. But it wasn't skipped if it contained some subdirectory.
Now if subdirectory contains also only skipped files then subdirectory
and also parent directory are skipped. It is achieved by solving
subdirectories at first and then solving parent directories.
(rhbz#1192625)
2015-03-20 10:06:37 +01: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
Lubos Kardos fbdf2995c5 Get rid of warnings about maybe uninitialized variables.
These warnings were caused by my recent file trigger commits. These
warnings are showed only with compiler option "-O2" and I used "-O0"
that's why I didn't notice them at first.
2015-02-16 14:27:18 +01:00
Lubos Kardos 30a5603159 Add support for %transfiletriggerun. 2015-02-05 08:08:12 +01:00
Lubos Kardos ec78eea7fe Add support for executing file triggers.
Supported file triggers:
%filetriggerin
%filetriggerun
%filetriggerpostun
%transfiletriggerin
%transfiletriggerun
2015-02-05 08:08:12 +01:00
Lubos Kardos b04c4f559b Add hash installedPackages to transaction members structure.
- After transaction this hash contains all packages installed in
  transaction. This hash can be used as argument of rpmdbFilterIterator()
  to get all packages installed in transaction from rpmdb.

- Rename removedHash to packageHash.
2015-02-05 08:08:12 +01:00
Lubos Kardos 2f31395dcd Fix color skipping of multiple files with the same content.
- If we process some file and we find another file with the same path
  and the same content and this other file is skipped for color then
  the currently being processed file has to be skipped for color too.
  (RhBug:1170124)
2014-12-17 16:53:42 +01:00
Panu Matilainen 454285b3a2 Add disabler flag + --noplugins cli switch for plugins
- Always knew we'd need a plugin disabler flag sooner than later but
  didn't realize enabled plugins would fail basically the entire
  test-suite :)
- Enable --noplugins for entire test-suite for now, but eventually
  we'll need to come up with ways to test plugins as well
2014-06-24 15:14:35 +03:00
Panu Matilainen d8ebc90e64 Initialize plugins based on DSO discovery
- %__transaction_plugins style configuration is problematic for plugins
  because we want plugins to be, well, pluggable. As in drop-in to
  enable, which is not achievable with a single macro entry. Look up
  all DSO's from the plugin dir and enable if a matching
  %__transaction_foo macro is defined.
- This isn't optimal but it'll buy us the drop-in capability, which
  is what matters most right now. We'll want to have forcability as
  well later on (ie it should be possible to require given plugins
  to be present)
2014-06-24 14:46:37 +03:00
Panu Matilainen 713914bde1 Drop the experimental collection support
- The basic concept is not without merit but what was implemented here
  has been stuck in experimental state in middle of two sorta conflicting
  goals for four years now, and world has moved onward in the meanwhile.
  The sepolicy part is better handled in the new selinux plugin, and other
  action business belongs to packages (in the form of some trigger-like
  scripts or such) rather than rpm plugins.
- Deleted here, but the sepolicy plugin functionality still needs
  merging into the new selinux plugin...
- RPMTAG_COLLECTIONS left in place but tagged unimplemented as per policy
  to never actually remove tags
2014-06-17 16:27:24 +03:00
Panu Matilainen f311fb65ee Reset file actions between rpmtsRun() calls (RhBug:1076552)
- When the world changes underneath us (eg by %pretrans hackery)
  between test-transaction and actual transaction, in some cases
  the file action does not get recomputed if already set.
  Always reset file actions to FA_UNKNOWN before disposition
  calculations to ensure have a clean starting point.
2014-03-21 12:44:03 +02:00
Panu Matilainen 4d2ee13a6e Use the proper file action for .rpmsave on erasures. Doh.
- We have FA_SAVE which results in .rpmsave suffix so use it, instead
  of mapping FA_BACKUP to .rpmorig or .rpmsave depending on whether
  we're installing or erasing. Doh.
- Goal is no longer needed by fsmMapPath()
2014-03-13 08:47:23 +02:00
Panu Matilainen fd40d58efa Legalize proper reinstall within transaction
- Account for packages removed in transaction when checking whether
  package is already installed. This permits install + erasure of the
  same package within a single transaction, aka reinstall, with
  changing file policies (excludedocs, installangs etc) properly
  taken into account. Related to RhBug:966715.
- This differs from --replacepkgs which is just a strange hack really
  but one that's difficult to change because of how its presented
  in the API. --replacepkgs behavior does not change here, and a proper
  reinstall is NOT possible when replacepkg problem filter is active.
- Testing this is not possible with rpm cli :(
2014-03-04 11:14:37 +02:00
Panu Matilainen 326f1d7953 Turn rpmteSetFI() into clean-only function
- Nothing outside rpmte.c should be able to muck around with the
  file info set associated with the ts element. Except to free
  memory, which is the only thing rpmteSetFI() is now being used for.
2013-12-02 15:17:01 +02:00
Panu Matilainen 3a858ad5b0 Eliminate rpmteFI() use from rpmFindBaseNamesInDB()
- Use local iterator on rpmteFiles() instead
2013-11-11 12:19:24 +02:00
Panu Matilainen d093a58f34 Eliminate rpmteFI() uses from transaction skip policy calculations
- Grab files and file states from the main loop and pass as arguments
  to skipInstallFiles() and skipEraseFiles(), neither actually
  needs the transaction element otherwise.
- Use local iterators in both skip*Files(), not that it actually
  matters here other than eliminating rpmteFI() uses
2013-11-11 12:06:28 +02:00
Panu Matilainen f9f93714c5 Switch fingerprinting main loop from rpmfi to rpmfiles
- The internals already use rpmfiles random access anyway, rpmfi
  only gets in the way there
2013-11-11 11:55:16 +02:00
Panu Matilainen b1c31b9632 Switch countFiles() from rpmfi to rpmfiles
- Need to do more work to get the same silly number, this particular
  case doesn't really look like progress :)
2013-11-11 11:20:49 +02:00
Panu Matilainen 4140e6562d Make rpmteFiles() return refcounted rpmfiles, fixup callers 2013-11-08 13:50:20 +02:00
Panu Matilainen afb89d072d Only fetch otherFi when it'll actually be needed
- Shouldn't change anything as is, just rearranging this to allow
  refcount on rpmteFiles() return
2013-11-08 13:04:21 +02:00
Panu Matilainen 0a9c199bc2 Bunch of forgotten rpmfi -> rpmfiles (internal) function renames 2013-11-08 11:03:33 +02:00
Panu Matilainen bb7ad2f1f1 Switch checkInstalledFiles() from rpmfi to rpmfiles
- All the called functions expect rpmfiles anyway so might as well
  grab that from the start. We could probably do some of this with
  iterators now but as everything here is done with the random-access
  functions, switching would take quite a bit of work...
2013-11-07 16:29:25 +02:00
Panu Matilainen d9c0b07adb Mass-rename all rpmfiFooIndex() functions to rpmfilesFoo()
- These all operate on rpmfiles, not rpmfi, now so make the point
  clearer. All internal stuff so we're free to mess around.
- No functional changes, only a straightforward perl-assisted rename...
2013-11-07 15:58:10 +02:00
Panu Matilainen c0cb2d86f9 Chainsaw rpmfi iteration apart from the actual file set
- The self-iterator in rpmfi prevents all sorts of sane uses of
  file set iteration. Split the actual data into a separate data
  type, changing the internal random-access functions to use the
  new rpmfiles datatype directly and update internal callers minimally.
  This should be entirely transparent to public API consumers who still
  only see the braindamaged self-iterating version.
- Internal consumers dont directly benefit (yet), this is just an
  early step on the road to rpmfi sanity. Much of the API and variables
  will need renaming etc but avoiding that here to keep the changes
  to minimum, this is a rather huge commit as it is.
2013-11-07 14:27:26 +02:00
Panu Matilainen 1ae157a017 Remove pointless rpmdbSync() function
- The DB backend is supposed to take care of syncing when necessary,
  syncing all indexes "just in case" whether they were written to
  doesn't make a whole lot of sense.
2013-04-19 18:43:49 +03:00
Panu Matilainen 23e82afcbc Add scriptlet-specific disablers for %pretrans and %posttrans
- Previously %pretrans and %posttrans were tied to --nopre and --nopost
  disablers (since commit 0b2d7775c5)
  because back then, there was no room new disablers in rpmtransFlags
  bitfield. This is no longer the case as of rpm >= 4.9.x where
  a bunch of obsolete flags were axed, so we can now add specific
  --nopretrans and --noposttrans switches + corresponding flags.
- This is obviously a behavior change as --nopre and --nopost no
  longer affect %pretrans and %posttrans, but --noscripts behavior
  remains the same.
2013-04-10 11:40:13 +03:00
Panu Matilainen 51b306686c Initialize plugins much earlier
- Lazily initialize plugins when adding install or erase elements
  to the transaction already. Since this ensures the setup will
  always be performed, there's no need to do this from rpmtsRun()
  anymore, empty transaction would not get that far anyway.
- This will allow adding hooks to the places where package header
  is still available (which is required for various things) and
  in general, before transaction is actually executed.
- The downside here is that adding or removing packages to a transaction
  can now fail due to plugin initialization failure where its not
  easily distinguishable from other errors, but then they can also
  fail due to rpmdb open failure which kinda similar "shouldn't be
  here" issue. The alternative would be initializing the plugins
  in rpmtsCreate() but as that's not actually permitted to fail at
  all, its not an option really.
2013-04-03 16:53:12 +03:00
Panu Matilainen d497ca6d46 Use rpmtsPlugins() instead of direct struct access everywhere 2013-04-03 14:29:25 +03:00
Panu Matilainen 34f8836aa9 Missing <inttypes.h> include, hysterically masked by "leaking" BDB includes 2013-03-25 09:57:36 +02:00
Panu Matilainen b5e3e1efee Eliminate built-in selinux support. RIP.
- We hereby unceremoniously declare that from now on, SELinux and
  other similar mechanisms are to live in plugins, rpm doesn't need
  to know about every possible security etc mechanism there might be.
  Its a big commit but as its really just removals...
- We need to disable sepolicy collection plugin for now as it relies on
  built-in support for selinux, this not only makes no sense but
  wont work now that there is no built-in support. The sepolicy
  plugin needs to be merged into the selinux base plugin now.
- Another "breakage" is that --rebuilddb no longer relabels the database,
  this needs plugins to called in a place where they currently cannot
  be called. This needs to be resolved before next actual release.
2013-03-21 13:56:33 +02:00
Panu Matilainen 159485f4e7 Introduce transaction begin/end API on top of rpmlock
- For now this doesn't do anything particularly interesting, it
  just replaces the transaction lock handle we use internally.
  We want to export this interface but that needs further changes.
2013-03-11 12:46:30 +02:00
Ville Skyttä 8002b3f985 Spelling fixes.
Signed-off-by: Panu Matilainen <pmatilai@redhat.com>
2013-02-19 21:35:40 +02:00
Panu Matilainen 147a26c5f6 Dont skip shared file/dir create if the other one is a ghost
- Explicitly test for shared file/dir being ghost when deciding whether
  to skip create: we must never skip the creation of a real file/dir
  because of a ghost as the ghosts do not get created.
- This fixes the shared ghost testcase, ie the thing that commit
  a712252392 was supposed to fix,
  without side-effects that I can see.
2013-01-30 14:07:33 +02:00
Panu Matilainen 471b74bf6e Revert the severely broken FA_SKIP on %ghost "fix"
- Reverts the bad half of commit a712252392eca75443ca45c10a72873cabec7963:
  treating files that wont be installed as skipped seems logical enough,
  but rpm disagrees... making %ghosts FA_SKIP on install causes
  upgrades on %ghost %config files to miss the necessary FA_SKIP getting
  set on the erase half via handleInstInstalledFile() and
  rpmfiDecideFate(), causing %ghost %config files to be nuked. Which isn't
  very nice when your /var/lib/rpm/ contents are packaged as
  %ghost %config...
- This fixes the %ghost %config testcase but breaks the shared %ghost
  case in turn.
2013-01-30 14:01:59 +02:00
Panu Matilainen a712252392 Be more careful about skipping shared file/directory creation
- Only skip shared file/dir creation if its actually being created
  by another package. Previously we could've decided to skip an entry
  where the other file was also being skipped for some other reason.
- Ensure %ghost entries always have FA_SKIP on install, previously
  they often were FA_CREATE which makes no sense for %ghost. We dont
  encounter %ghosts at all during install in the FSM as they dont
  exist in the payload, but the file disposition calculations need
  to take them into account now that we're avoiding redundant creates.
- Fixes a regression from commit f7f5f88f9f
  which unearthed the %ghost FA_CREATE issue, reported here:
  http://lists.fedoraproject.org/pipermail/buildsys/2013-January/004047.html
2013-01-28 12:50:39 +02:00
Panu Matilainen d73535e1a9 Handle transaction global pool allocation centrally in rpmtsPool()
- Previously the pool would only get allocated on successfull addition
  of install or erasure elements, causing assert() failures on
  operations on empty transaction set, which should be just a no-op,
  not an error.
- Make rpmtsPool() create the pool if it doesn't exist, update relevant
  users to call rpmtsPool() instead of directly accessing tsmem->pool,
  this avoids having to worry about pool existence in all the various cases.
- Also fix up the pool-related comment on rpmtsEmpty(): pools does not
  and can not support emptying as it could break references to its
  contents. Per-string refcount would be needed for emptying support.
2012-12-19 12:32:52 +02:00
Elena Reshetova 19ece18f1a Making pre/post tsm/psm hooks more consistent.
-All post hooks take an additional rc argument that indicates general return code from operation.
-All post hooks are always called if correspoding pre hook has been called.
-The return value from post hooks is curently ignored

Signed-off-by: Panu Matilainen <pmatilai@redhat.com>
2012-12-05 15:58:49 +02:00
Panu Matilainen b1d3f21a54 Account for temporary disk-space requirement on forced replace too
- Similar to commit 85df102165, but
  for forced file replacements.
2012-11-14 12:25:43 +02:00
Panu Matilainen f8da4f6136 Remove ancient, no longer relevant comment
- Since commit f7f5f88f9f, only the first
  instance of shared files is created, the rest are FA_SKIP which
  consume no disk space and are not counted either.
2012-11-14 10:57:19 +02:00
Panu Matilainen 85df102165 Account for temporary disk-space requirements on updates (ticket #175)
- When updating packages, we first create them with a temporary names
  and only after all files from payload have been created this way,
  the files are renamed to the final target. This means that performing
  an update temporarily requires roughly twice the disk space (and inodes)
  compared to the final result on per-package level. Which matters
  when space is tight, such as presumably in RhBug:872314.
- Simulate what happens on upgrades by adding block and inode delta
  to the equation: installing a file always consumes an inode and
  the specified amount of disk space. But when replacing files,
  reduce the size-delta from disk consumption *after* checking for
  problems in a given DSI.
- Also fixes inode accounting which has been broken for forever (since
  commit a9a1fd866c more exactly)
2012-11-14 10:31:15 +02:00
Panu Matilainen 1986eb6242 Remove unnecessary casts 2012-11-09 12:18:13 +02:00