Commit Graph

114 Commits

Author SHA1 Message Date
Panu Matilainen 1850366248 Eliminate the ancient, useless fingerPrint_s -> fingerPrint typedef
This is unlike all the other typedefs in rpm and only makes things
harder to follow. Luckily this is an internal-only thing.
2024-06-26 10:42:08 +02:00
Panu Matilainen 18f7e53951 Remove C++ guards from internal headers
While these were necessary to get things going, they are only
counterproductive now: we want to be able to freely use C++ features
inside rpm.
2024-05-06 12:08:29 +03:00
Panu Matilainen 1c98b67911 Drop top-level source for our global include directories
Having everything accessible to everything encourages fast and loose
includes from places one shouldn't be using, and makes it easy for
those cases to hide in plain sight as well. There were reasons for
the top-level include back in 2007 but our codebase is a rather
different beast these days. Limiting access through per-target
include directories on everything nicely highlights the exceptions
and makes the whole more controllable and manageable.

This change looks huge, but it's just due to stripping no longer valid
prefixes from all the gazillion internal includes. No rpm-side
functionality is affected, this is just source-level hygiene operation.
2023-09-13 13:34:17 +03:00
Panu Matilainen fb13f7fd9e Add optional callback on directory changes during rpmfi iteration
Internal only for now in case we need to fiddle with the API some more,
but no reason this couldn't be made public later.
2022-02-16 10:57:18 +02:00
Pavlina Moravcova Varekova 29c48e14de Add mode for updating with minimal writing (RhBug:783480)
How does the number of writes change?
I compared number of writes with and without minimal writing
for upgrade from RHEL 7.0 to RHEL 7.1, from RHEL 7.1 to RHEL 7.2, ...
In more details, the size of memory used for writing regular files.

The following table contains in the second column percentages of files
which can be only touched from all installed files. In the third column,
there are percentages of sum of their sizes.

                       |       Touched        |        Touched
                       |    Updated files     |     Updated bytes
------------------------------------------------------------------------
RHEL 7.0 -> RHEL 7.1   |         63 %         |          66 %
RHEL 7.1 -> RHEL 7.2   |         53 %         |          43 %
RHEL 7.2 -> RHEL 7.3   |         60 %         |          42 %
------------------------------------------------------------------------
F24 -> F25             |         63 %         |          40 %
F25-> Fraw             |         49 %         |          28 %

Does the speed change?
The update speed for classical disks or SSD almost does not change.

How it works?
If there is a file in the new package, which has the equal digest
as the corresponding file in the old package and the same file on
the disk (thus the contents are expected to be equal), rpm will not
install the whole file, but rather only upgrade the file's meta data.
In other cases, it will install the whole file.
2017-04-21 13:50:50 +03:00
Lubos Kardos c53158a6f6 Add rpmfilesFindPrefix() to find files with given prefix. 2015-02-05 08:08:12 +01:00
Florian Festi 78dcf9d0cb Move archive handling functions into rpmarchive.h 2014-01-31 09:49:43 +02:00
Panu Matilainen c61c2e00f7 Make the relevant rpmfiles accessor functions public
- All the public rpmfiFoo() accessors have an indexed rpmfilesFoo()
  counterpart, make the rpmfiles-versions public too.
- The noteworty exceptions are rpmfiDecideFate() and rpmfiConfigConflict()
  which shouldn't have been public in the first place, and are to be
  removed from the API in the next API break. So we're not adding
  new rpmfiles-counterparts for functions that are to be removed
  from the (public) API. Actually document the issue by deprecating
  both rpmfi-functions.
- The iterator types need to be in rpmfiles.h as the iterator
  constructor is there (otherwise there'd be a cyclic include
  between rpmfiles.h and rpmfi.h, which wont do...)
2013-12-11 16:47:35 +02:00
Florian Festi 2caf1593a6 Create true file iterator for writing the archive content.
* Write headers while iterating over the files
 * Handle hard links within the Iterator
 * Remove rpmfiAttachArchive()
 * Remove rpmfiArchiveWriteHeader() from the API
2013-11-25 13:44:21 +01:00
Florian Festi 4e142e9085 Create true file iterator for reading the archive content.
* remove rpmfiArchiveNext and let rpmfiNext handle getting to the next file
2013-11-25 12:36:45 +01:00
Panu Matilainen 8b06737db1 ...but require an exact 1 for nodigest in rpmfiArchiveReadToFile()
- This way we can change the argument into a flag bitfield later
  on without it being an API change.
2013-11-21 14:48:01 +02:00
Panu Matilainen 5a928ec372 Use a plain old int for rpmfiArchiveReadToFile() nodigest argument
- There's no benefit to using char here, and int is what is generally
  used for such (flag-type) arguments.
- As it happens char doesn't even work here as the nodigest argument
  passed from fsm is not a simple 0/1 value but result of
  (rpmtsFlags(ts) & RPMTRANS_FLAG_NOFILEDIGEST), which when crammed
  into a char actually turns into a zero... so this unbreaks
  --nofiledigest
2013-11-21 14:37:51 +02:00
Panu Matilainen 0c2a5d5868 Sanitize archive creation
- Get rid of the crazy tag-tango around rpmfi in genCpioListAndHeader():
  pkg->cpioList is an rpmfi with the actual in-package paths, and
  on-disk package paths are passed around as a separate array. This
  simplifies and sanitizes things a lot... and also finally gets rid
  of fi->apath entirely.
- Dependency generation wants on-disk paths, but it can generate those
  by prepending buildroot, which actually makes it more obvious what's
  going on.
- This also kills %{_noPayloadPrefix} ancient-history compatibility flag.
  We could honor it in rpmfiArchiveWriteHeader() if we cared but we're
  talking about rpm < 3.0.5 compatibility here ... so we dont.
2013-11-19 10:20:53 +02:00
Panu Matilainen 4ab11d140b Add a bit of API for accessing the original paths
- Especially rpmfiOFN() and its underlying buffer is more than a bit
  dubious, but can't really help it as people are going to expect
  it behaving identically to rpmfiFN(). And they can't share the
  same buffer as somebody is going to be tempted to do eg
      if (strcmp(rpmfiFN(fi), rpmfiOFN(fi)))
          /* file has been relocated */
- Based on ffesti's original work on the subject
2013-11-13 17:29:06 +02:00
Panu Matilainen 19577025c2 Implement selectable iterator mode for rpmfi
- Forward (the default) and (a new) backwards iteration modes for now
- Internal iterator function just returns the next iteration index,
  bounds checking and actual advancing in rpmfiNext() to avoid having
  to duplicate that code in every single iterator function.
2013-11-08 12:04:30 +02:00
Panu Matilainen 0a9c199bc2 Bunch of forgotten rpmfi -> rpmfiles (internal) function renames 2013-11-08 11:03:33 +02:00
Panu Matilainen 4640e833da Add (and use) rpmfiles counterpart for rpmfiFindFN() 2013-11-08 10:18:06 +02:00
Panu Matilainen dbc2ed980a Add (and use) rpmfiles counterpart for rpmfiColor() 2013-11-08 09:43:22 +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 dba7e99403 Make rpmfiles constructor, destructor and refcount internally accessible 2013-11-07 15:27:58 +02:00
Panu Matilainen 520c7266c8 rpmfi has no associated pool, the file set has
- should've been in previous commit really but since there's just
  one user... meh
2013-11-07 15:25:11 +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 ffda2460cd Make rpmfi struct opaque outside rpmfi.c
- Now that its possible (no matter how feebly), this makes changing
  rpmfi internals a bit easier
2013-11-07 14:10:43 +02:00
Panu Matilainen 9550e13978 Add & use temporary internal API to eliminate direct access to fi->apath
- Doesn't make the apath thingie any less ugly, but allows us to
  make rpmfi entirely opaque.
2013-11-07 14:10:01 +02:00
Panu Matilainen 760abcf0b4 Buffer on archive write is not touched, make it const 2013-11-04 16:27:13 +02:00
Florian Festi 8b6de4ded9 Add payload handling to rpmfi 2013-11-04 13:21:02 +01:00
Florian Festi 85f42455eb Implement rpmfiFLinks and reimplement rpmfiFNlink
using header data. This will replace the hard link handling in the fsm.
2013-10-29 15:03:45 +01:00
Florian Festi 6e6e4e95f8 Add support for 64bit sizes to rpmfi[SG]etFReplacedSizeIndex 2013-06-18 09:37:23 +02:00
Florian Festi f5d3a4b8a4 Load LONGFILESIZES into rpmfi if present 2013-06-18 09:37:23 +02:00
Panu Matilainen 5e89283259 Export the pool-aware rpmfi constructor
- Similar as commit 541234b02e for rpmds,
  but speed is less of an issue with the complex rpmfi's than single
  rpmds'es where private pool construct+teardown can be very expensive.
  With rpmfi's the bigger gain from shared pools is memory savings,
  permit taking advantage of this outside librpm internals.
2013-06-07 11:38:07 +03:00
Panu Matilainen 3ff6fdd688 Hide the strpool-related rpmts/rpmfi/rpmds interfaces out of sight for now
- In the package/transaction related things the strpool is more of
  an internal implementation detail than an end-goal in itself, move
  string pool related interfaces of rpmts, rpmfi and rpmds to
  internal-only APIs for now. The kind interfaces we'll want to eventually
  export a) dont exist yet and b) are likely to be something very different.
- The string pool itself remains exported however, its a handy data
  structure for all sorts of things and both librpm and librpmbuild
  heavily use it already.
2012-11-01 09:59:57 +02:00
Panu Matilainen 3d65369920 Make fingerprint struct opaque outside fprint.c
- rpmfi cannot know anything about the storage, so rpmfiFpxIndex()
  cannot be... change it to rpmfiFps() which only returns the pointer
  we got from fpLookupList()
- Change fpCacheGetByFp() to assume it gets passed an array of fps,
  and take an additional index argument. Return the fingerprint
  pointer on success, NULL on not found to allow further operations
  on the fp without knowing its internals.
2012-09-14 13:41:41 +03:00
Panu Matilainen bfde7c4d0a Add getters for rpmfi base- and directory name pool id's 2012-09-12 19:12:56 +03:00
Panu Matilainen 7dc5ca2da1 Switch file info set base- and dirnames storage to string pool
- Always push base and dir names into file info sets string pool,
  whether private or shared. For basenames, this can save significant
  space even in a private pool, for dirnames private pool is moot
  as the names are already unique, shared pool is quite another story.
- Adjust fpLookupList() to take a pool and id's as arguments.
- This introduces a fair amount of overhead, so things will be somewhat
  slower until the transition to pool id's is (more) complete. Sometimes
  things have to get worse before they get better... Other than that,
  this should be entirely invisible to callers.
2012-09-08 11:25:16 +03:00
Panu Matilainen bd33a6656c Axe the no longer needed rpmfi string "cache" stuff 2012-09-07 13:34:56 +03:00
Panu Matilainen 90e3792232 Use string pool for file set symlinks
- Removes the last use of our former simple, stupid and slow caches
- For now, use a per-fi pool for this just like the previous caching
  did. Memory use is slightly increased but its faster than before,
  to reap the full benefits (memory and otherwise) we'll want a
  per-transaction pool for these, to be added later.
2012-09-07 13:34:50 +03:00
Panu Matilainen 8909eed1a8 Replace user- and groupname + file lang caches with a global stringpool
- With the string pool we dont have to worry about overflowing the
  indexes so we can lump all this relatively static data into one pool.
  Because rpmsid's are larger than the previous cache indexes, we'll
  loose some of the memory savings, but then the pool is faster on
  insertion, and we'll only need one of them so...
- The misc. pool is never freed, flushed or frozen so it'll "waste" memory
  throughout the lifetime of a process (similarly to the previous caches)
  but its not huge so .. ignoring that for now.
2012-09-07 13:34:42 +03:00
Panu Matilainen 4606460e54 Dont bother with file capability "cache"
- Very few packages have RPMTAG_FILECAPS at all, and the memory saving
  for those that do is so marginal it hardly matters at all. At least
  for now, dont bother.
2012-09-07 13:34:37 +03:00
Panu Matilainen 87e7e88f90 Change rpmfi replaced size functions to take index
- Further preliminaries to handle file conflicts within a package.
- These are internal-only interfaces so we can just change without
  bothering with compat wrappers.
2012-04-12 17:39:57 +03:00
Panu Matilainen 3f996a588a Add rpmfiFooIndex() variants for the conflict handling methods
- Preliminaries for handling file conflicts within a package:
  Using rpmfi's self-iterator limits access to the file info to
  one caller at a time, in order to self-file conflicts we'll need
  to be able to access the same rpmfi at different indexes simultaneously.
- As these are public API's, add compat wrappers for the self-iterator
  use (although AFAIK nothing except rpm itself uses these)
2012-04-12 17:39:32 +03:00
Panu Matilainen 11116a6786 Make rpmfiFNIndex() safe for callers on different indexes
- Previously this would return a pointer to an internal per-rpmfi buffer
  whose contents get silently overwritten on each call to rpmfiFNIndex(),
  making it unsafe for unsafe for random access for more than one
  active caller (such code does not currently exist in rpm though)
- Make rpmfiFNIndex() always return freshly allocated memory, and adjust
  the rpmfiFN() iteration wrapper to free and realloc the internal
  "buffer" on each call. It's a wee bit slower than before but it's
  not called *that* much, and if needed there are ways to optimize it.
2012-04-12 15:29:18 +03:00
Panu Matilainen b9c96a9fa9 Remove unused scareFlags member from rpmfi struct
- This is just a leftover from rpm < 4.7.x days
2012-04-04 17:30:04 +03:00
Panu Matilainen aee64fbc46 Turn FSM into a blackbox, much like PSM is
- Similar in spirit to PSM blackbox treatment in
  commit df9cdb1321, except that
  technically fsm guts are still wide-open in fsm.h due to cpio
  "needing" them (yuck).
- Allows getting rid of dumb a**-backwards things like rpmfiFSM()
  which is just not needed, fsm is a relatively short-lived entity
  inside psm and build, nobody else needs to bother with it except
  for the returned results.
- Figure out the cpio map flags in fsmSetup() where it logically belongs,
  we have all the necessary info available there.
- Get rid of newFSM() and freeFSM(), we can just as well place the
  fsm on stack, merge the necessary cleanup bits from freeFSM()
  into fsmTeardown()
- Supposedly no functional changes, knock wood.
2012-01-11 15:41:22 +02:00
Panu Matilainen 1dc09307d8 Eliminate archiveSize member from rpmfi
- rpmfi itself doesn't need it for anything, its only really used
  for progress reporting during install. Grab the size into psm
  total directly, this is already passed down to fsm.
- Removes one of the last remaining rpmfi opacity violations, just
  fi->apath to go...
2012-01-11 12:17:31 +02: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 8b7ff12b4e Add "c++ protection" to (hopefully) all of our internal headers 2010-09-21 15:21:12 +03:00
Panu Matilainen 45e2d4e1d0 Rip out more rpm 2.x era relocation leftovers
- we can't even read packages from that timeframe, much less relocate them
2010-03-01 16:13:52 +02:00
Panu Matilainen 33685ef74e Kill off last remaining uses of _constfree()
- practially all the data in rpmfi needs to be treated as const, these
  are just a funky special case which point to header memory for the
  couple of cases where KEEPHEADER is still used
2009-12-22 14:36:35 +02:00
Panu Matilainen 569adfa17c Tidy up rpmfi struct definition a bit 2009-03-27 16:15:00 +02:00
Panu Matilainen 74a4f639e2 Lose unused/useless Type and tagN fields from rpmfi struct 2009-03-27 16:12:25 +02:00