Commit Graph

12565 Commits

Author SHA1 Message Date
Panu Matilainen f720f23588 Add basic python bindings for rpm string pool
- Python users are unlikely to have much use for this thing as such,
  python has plenty enough native datatypes to not bother with rpm
  specialties. The primary reason for adding it is to allow utilizing
  a shared string pool for various rpm objects from python side as
  well. That'd only require being able to pass the pointer around
  for which we wouldn't need a full-blown object, but otoh creating
  test-suitet cases in python is nicer than in C so having at least
  the base methods available wont hurt...
2013-12-13 15:35:20 +02:00
Panu Matilainen d26511005f Clarify + document rpmfiles directory vs file index
- Rename the file index argument for rpmfnDI(), rpmfilesDI() and
  rpmfilesODI() to ix for consistency with other file index arguments
- Document rpmfilesDI() and rpmfilesODI() and its usage with rpmfilesDN()
  and rpmfilesODN()
2013-12-12 11:21:02 +02:00
Panu Matilainen 6c165f507d Document rpmfiles API, tweak rpmfi docs a bit to differentiate
- rpmfiles API is mostly a copy-paste of rpmfi with index argument
  added
- clarify rpmfi.h docs to speak about "file info set iterator",
  rpmfiles.h is the "file info set" thing now
2013-12-11 17:21:37 +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
Panu Matilainen 05eeece43a Move file related defines and typedefs to a new public rpmfiles.h header
- Preparation for making the indexed rpmfiles API public, API users
  are not affected as rpmfiles.h is included from rpmfi.h now. rpmfi.h
  is for the iterator part only.
2013-12-11 16:00:34 +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 f2d5e7ecd7 Clarify a couple of comments 2013-12-02 13:13:00 +02:00
Panu Matilainen 25406a133f Track chunk usage in the pool struct directly
- This simplifies things a bit as we dont need to worry about the
  id storage and the starting location of the next string in advance.
- Also make it clearer the string is copied into the current chunk,
  to which pool->offs only points to. Make pool->offs const to
  enforce the strings are never written through it.
2013-12-02 12:47:23 +02:00
Panu Matilainen 938b86b8bd Clarify pool chunk allocation
- Assign newly alloc'ed chunks to pool->chunks, pool->offs just
  contains pointers into the chunks. This doesn't change actual
  behavior at all, just (IMO) clarifies the code a bit.
2013-12-02 12:29:21 +02:00
Panu Matilainen c24930219a Fix a harmless off-by-one in rpmstrPoolPu()
- ssize already has the trailing \0 accounted for
2013-12-02 10:54:18 +02:00
Panu Matilainen cfe99e08ad Drop the end-of-chunk dummy entries from string pool
- As pointed out by Michael Schroeder in
  http://lists.rpm.org/pipermail/rpm-maint/2013-September/003605.html,
  the dummy entries used for optimizing rpmstrPoolStrlen() are
  problematic in number of ways:
  - Walking the id's in a pool is unreliable, and rehashing can cause
    bogus empty strings to be added to a pool where they otherwise
    do not exist
  - rpmstrPoolNumStr() is not accurate when more than one chunk is in use
- Unfortunately this means giving up the rpmstrPoolStrlen() optimization,
  for now at least.
2013-12-02 10:45:33 +02:00
Panu Matilainen 43745e88e5 Use a common string pool for rpmds'es within file classifier
- Avoid pool setup + teardown for each and every dependency we create,
  and string copy between pools on subsequent rpmdsMerge(). Probably
  wont make much of a difference in practise since the number of
  dependencies per package isn't *that* big, but wont hurt either
  (and who knows what kind of texlive-monsters we get thrown at...)
2013-11-29 16:24:35 +02:00
Michael Schroeder 41a01d2563 Fix off-by-one in rpmstrPoolRehash()
- pool->offs_size is the last used id, thus it should be "<=" instead of "<"

Signed-off-by: Panu Matilainen <pmatilai@redhat.com>
2013-11-29 10:42:36 +02:00
Panu Matilainen c732f01598 Eliminate unused arguments to fsmMkdirs() and fsmCommit()
- Both cases are simply leftovers gone unnoticed when refactoring
2013-11-28 10:15:41 +02:00
Panu Matilainen 4c3ac96f54 Fix a truly bogus ancient comment
- The comment about ghosts on build may (or may not) have been accurate
  at some point in history but that hasn't been the case in a very, very
  long time...
2013-11-27 11:26:44 +02:00
Panu Matilainen b839d970ea Consolidate bunch of common initialization tasks into fsmNew() 2013-11-27 11:01:02 +02:00
Panu Matilainen 04b81d8d08 Avoid redundant rpmteGetFileStates() calls
- We already have the file states in fsm->fs, use that...
2013-11-27 10:55:37 +02:00
Panu Matilainen 4f29d4952f Dont collect hardlinks on file-pre hook failure
- Encountering hardlinks can affect fsm->postpone value which we
  must not modify if it was already set due to file-pre hook failure,
  and we can't just break out of the loop on failure as file-post
  hook must be called symmetrically, ie even in case of failure.
2013-11-27 10:47:36 +02:00
Panu Matilainen 8f73ddd81f Fix memory leak on packages with no files
- Leak introduced in commit 9bf578376d
  due to change in init sequence, rpmfnInit() needs to be passed a pool
  so we need to ensure one exists before calling it. Previously
  pool was allocated/referenced lazily only on packages with files, and
  rpmfilesFree() assumed that behavior.
2013-11-26 11:29:23 +02:00
Panu Matilainen d39c96c0c1 Make pkg->cpioList rpmfiles instead of rpmfi
so rpmPackageFilesArchive() has only one rpmfi object.
2013-11-25 13:44:33 +01:00
Florian Festi 884b25462b Inline writeFile into rpmPackageFilesArchive 2013-11-25 13:44:33 +01:00
Florian Festi d387ac2cdc Handle all but non empty regular files within the archive write iterator 2013-11-25 13:44:33 +01: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
Florian Festi 3f16fe60db Allow rpmfiNext to return values < -1 as error codes 2013-11-25 12:27:00 +01:00
Florian Festi a103e87c49 Prepare CPIOERR_* for being used and returned from rpmfiNext
* Make CPIOERR_* negative
 * Make CPIO_CHECK_ERRNO a value instead of a bit
 * Make CPIOERR_HDR_TRAILER -1 as this is end of iterator
 * Rename CPIOERR_MISSING_HARDLINK to CPIOERR_MISSING_FILE for clarity
2013-11-25 12:26:01 +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 b2cf1471bb Further sanity check for EVR validity on build
- Check for multiple ':' and '-'  separators (eg foo >= 1-1-1)
  which is not valid. Based on James Antill's patch on rpm-maint
  (http://lists.rpm.org/pipermail/rpm-maint/2013-November/003640.html)
  but modified to avoid bogus spec line numbers on invalid
  autogenerated dependencies.
2013-11-20 15:45:13 +02:00
Panu Matilainen 48563caa6a Make error message in parseRCPOT() alloced
- rasprintf() is of course an overkill for the simple constant strings
  currently here but making it allocated gives us room to be more
  detailed. No visible changes here though.
2013-11-20 15:39:06 +02:00
Panu Matilainen 1c1affa1aa Eliminate bsearch high and low elements from rpmds struct
- The low element is never used for anything, the high element
  has been used to communicate insertion point from rpmdsFind()
  to rpmdsMerge(). Which only needs an additional return value
  from find, arrange this with internal helper and axe the
  stupid struct members.
2013-11-20 09:58:29 +02:00
Panu Matilainen c6a1d4654f Reduce ds->u and ds->l references to minimum
- rpmdsMerge() relies on bsearch high element from rpmdsFind(),
  hysterically preserving the bsearch helper variables in the struct.
  Reduce the number of references to make next step more obvious,
  no functional changes.
2013-11-20 09:56:27 +02:00
Panu Matilainen 73a348c3ca Source packages still dont have payload prefix
- This probably counts as pedantry, but src.rpm payloads are still
  without dot-prefix so avoid adding an unnecessary rpmlib() dependency
  on them.
2013-11-19 10:32:31 +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 e0dd56a156 Consolidate failedFile handling into writeFile() 2013-11-19 06:41:56 +02:00
Panu Matilainen 36773ba7e3 Only prepend dots for absolute paths on archive creation
- Notably src.rpm paths are relative, adding dots breaks stuff.
  Not that this code gets currently used at all...
2013-11-19 05:49:07 +02:00
Jan Silhan 62bdcc0a32 Python 3 compatibility fixes
- Use open() instead of calling file constructor
- Borrow python-six trick of dealing with difference in string types

Signed-off-by: Panu Matilainen <pmatilai@redhat.com>
2013-11-18 10:13:08 +02:00
Panu Matilainen 003451abb0 Oops, forgotten rpmfiODN() and rpmfiOBN() implementation...
- Should've been in commit 4ab11d140b, doh!
2013-11-15 14:37:00 +02:00
Panu Matilainen f061101939 rpmtsClean() doesn't actually remove the elements, rpmtsEmpty() does...
- Makes me wonder how has this actually worked at all. Oh well.
2013-11-15 13:29:15 +02:00
Panu Matilainen fd70ef48a6 ...and use saveOrig() for src.rpm relocations too 2013-11-15 13:16:06 +02:00
Panu Matilainen c7314f321d Save relocated paths to header on the spot
- Passing all the td's to saveRelocs() doesn't make much sense,
  do it on the spot. Now that saveRelocs() simply saves the original
  paths, rename accordingly...
2013-11-15 13:12:28 +02:00
Panu Matilainen af3869a9e4 And finally move the rest of the relocation stuff out of rpmte
- Except for function name change (as it is no longer static),
  no code changes, just shoveling ... stuff ... around.
2013-11-15 13:00:13 +02:00
Panu Matilainen d265f8379d Refactor buildRelocs() to eliminate rpmte dependency
- Same s*** but different day, err, way of returning the data - via
  retvals instead of mucking about in rpmte struct.
2013-11-15 12:55:27 +02:00
Panu Matilainen 071f5e91eb Consolidate the relocation goo into a source of its own
- This stuff doesn't belong in rpmfi, rpmte, psm or anywhere else either.
  Invent a new dark hole to shove it into...
- No functional changes as such, just shuffling things around.
2013-11-15 12:33:38 +02:00
Panu Matilainen 5b757ec381 Handle src.rpm install-time relocation similarly to binaries
- Just to make rpmInstallSourcePackage() that little bit less ugly
  special case, shouldn't change any actual functionality
2013-11-15 11:46:17 +02:00
Panu Matilainen 254248b14c Use file count from file states which is just as well here...
- Doesn't change anything now but avoids another use of rpmfi
  which is shortly going away
2013-11-15 11:22:36 +02:00
Panu Matilainen 3ad781ffbd Refactor src.rpm file relocation into a separate function, comment
- No functional changes here, but we'll need this for the next steps
2013-11-15 11:02:58 +02:00
Panu Matilainen bf0046e4ed Refactor searching for spec in header to a helper function
- Only makes things slightly harder but we'll need this later
- This requires retrieving filenames twice, but this is hardly
  a performance-critical place...
2013-11-15 10:51:10 +02:00
Panu Matilainen 556527e976 Only return cookie and spec file from src.rpm install on success
- Returning malloced memory through retvals on failure (when its
  not an error message etc) seems questionable. Also paving way
  for next steps...
2013-11-15 10:17:10 +02:00
Panu Matilainen 79e629fe9d Undefine src.rpm install-time macros as well
- Doesn't make much of a difference for the average 'rpm -i foo.src.rpm'
  but such side-effects are ugly for possible other API users.
2013-11-15 09:47:08 +02:00