platform/upstream/rpm.git
12 years agoPass tsflags to rpmal and remember them
Panu Matilainen [Thu, 1 Sep 2011 10:19:18 +0000 (13:19 +0300)]
Pass tsflags to rpmal and remember them

- No functional changes here, but we'll need to know some of these
  bits for accurately calculating various dependency bits later on.

12 years agoSource formatting cosmetics: function blocks start on the next line
Panu Matilainen [Thu, 1 Sep 2011 09:55:30 +0000 (12:55 +0300)]
Source formatting cosmetics: function blocks start on the next line

12 years agoOnly consider installed files when looking at removed dependencies
Panu Matilainen [Thu, 1 Sep 2011 09:39:06 +0000 (12:39 +0300)]
Only consider installed files when looking at removed dependencies

- Non-installed files cannot very well have dependencies, this
  eliminates some bogosities from those cases.

12 years agoAdd RPMTAG_INSTFILENAMES tag extension for state-aware file lists
Panu Matilainen [Thu, 1 Sep 2011 09:11:13 +0000 (12:11 +0300)]
Add RPMTAG_INSTFILENAMES tag extension for state-aware file lists

- For a more consistent experience wrt all the state-awareness stuff,
  this needs to be easily querifiable too.
- Also makes the tagnames kludgery from commit
  cac8c389607d7a5735b2905035fdfe4404670d06 unnecessary

12 years agoAdd + use helper macro for testing for installed file state
Panu Matilainen [Thu, 1 Sep 2011 09:07:30 +0000 (12:07 +0300)]
Add + use helper macro for testing for installed file state

12 years agoOops, missing include for rpmFreeMacros() in python module
Panu Matilainen [Thu, 1 Sep 2011 08:20:54 +0000 (11:20 +0300)]
Oops, missing include for rpmFreeMacros() in python module

- This should've been in commit f07ab5c1afa9b0b7105082a8617ec6a7657fc27e

12 years agoAvoid SystemError on inserting an empty list insert to header from python
Panu Matilainen [Thu, 1 Sep 2011 06:40:52 +0000 (09:40 +0300)]
Avoid SystemError on inserting an empty list insert to header from python

12 years agoAdd method to reset + reload rpm configuration to python bindings
Panu Matilainen [Thu, 1 Sep 2011 05:31:04 +0000 (08:31 +0300)]
Add method to reset + reload rpm configuration to python bindings

12 years agoRemember ds color (if set) through rpmdsCurrent()
Panu Matilainen [Wed, 31 Aug 2011 08:09:03 +0000 (11:09 +0300)]
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.

12 years agoOops, forgot to add the instfilenames pseudo index to tag lookup code
Panu Matilainen [Wed, 31 Aug 2011 08:07:32 +0000 (11:07 +0300)]
Oops, forgot to add the instfilenames pseudo index to tag lookup code

- DBI tags dont really belong there to begin with but changing this
  would be more painful than its worth...

12 years agoUse RPMDBI_INSTFILENAMES on file queries as well
Panu Matilainen [Mon, 29 Aug 2011 13:19:32 +0000 (16:19 +0300)]
Use RPMDBI_INSTFILENAMES on file queries as well

- This changes query behavior quite a bit as files with non-installed
  status are no longer returned as matches. The rationale is that
  it makes figuring out dependency issues with the "new" behavior
  more obvious (but perhaps we should have a switch to enable
  former behavior). Besides not satisfying dependencies, files with
  non-installed status are not really owned by the package, as they
  would not be removed on package removal.

12 years agoTake advantage on RPMDBI_INSTFILENAMES in rpmdbProvides()
Panu Matilainen [Mon, 29 Aug 2011 12:49:08 +0000 (15:49 +0300)]
Take advantage on RPMDBI_INSTFILENAMES in rpmdbProvides()

- No functional changes, we did the same thing "manually" here already.
  Only now the data is more conveniently available through API to
  other callers who might care (yum & friends)

12 years agoAdd a new pseudo index for actually installed files
Panu Matilainen [Mon, 29 Aug 2011 12:43:15 +0000 (15:43 +0300)]
Add a new pseudo index for actually installed files

- RPMDBI_BASENAMES (ugh) returns all headers with matching filenames,
  whether the files are actually installed or not, which can be
  rather misleading when dealing with file dependencies. The new
  RPMDBI_INSTFILENAMES only returns headers with matching filenames
  whose state indicates they are actually present on the system.

12 years agoGeneralize pseudo tag handling in rpmdbInitIterator()
Panu Matilainen [Mon, 29 Aug 2011 12:23:02 +0000 (15:23 +0300)]
Generalize pseudo tag handling in rpmdbInitIterator()

- No functional changes, just makes the case where a pseudo index
  uses a differently numbered underlying physical db index more generic.

12 years agoUse correct file state for colored file replacements
Panu Matilainen [Mon, 29 Aug 2011 11:04:28 +0000 (14:04 +0300)]
Use correct file state for colored file replacements

- On colored file conflict resolution, the non-preferred colored
  file state would depend on installation order: if non-preferred
  arch is installed first, and the preferred arch in another
  transaction, the non-preferred color would get marked "replaced"
  indicating a forced install when none was used. This fixes
  the file state in such cases to "wrong color" to be consistent
  of the other installation scenarios.

12 years agoAdd test for ts.clear() as a side-effect of add to ts test
Panu Matilainen [Thu, 25 Aug 2011 09:29:48 +0000 (12:29 +0300)]
Add test for ts.clear() as a side-effect of add to ts test

12 years agoExport rpmtsEmpty() to python as ts.clear()
Panu Matilainen [Thu, 25 Aug 2011 09:02:48 +0000 (12:02 +0300)]
Export rpmtsEmpty() to python as ts.clear()

- Why the heck hasn't this been exported before, duh?
- Method name clear() chosen as this appears to be emerging as a
  standard of sorts for this kind of operation: dictionaries and
  sets have it and list will get it in some python 3.x version.
  Additionally foo.empty() could easily be mistaken for "test whether
  container foo is empty or not" (especially those with c++ background...)

12 years agoRemove support for ancient bzip2 library versions
Panu Matilainen [Fri, 19 Aug 2011 07:19:58 +0000 (10:19 +0300)]
Remove support for ancient bzip2 library versions

- bzip2 1.0 is over ten years old by now, anybody still using versions
  older than that get what they deserve...

12 years agoRemove unused FDFOO macros
Panu Matilainen [Fri, 19 Aug 2011 07:00:32 +0000 (10:00 +0300)]
Remove unused FDFOO macros

12 years agoHandle query format field width centrally in formatValue()
Panu Matilainen [Wed, 17 Aug 2011 07:59:49 +0000 (10:59 +0300)]
Handle query format field width centrally in formatValue()

- Eliminate the quirky formatPrefix buffer argument to formatter functions,
  deal with the width at formatValue() if specified.
- This not only simplifies things a great deal, removes a nasty
  unbounded buffer writing from formatter functions and speeds things
  up somewhat by removing extra rasprintf()'s in many cases, it also
  gives us width formatting of everything including "error messages"
  like "(none)" and "(not a number)" which previously got dumped without
  any formatting.
- The cost of this is the loss of zero padding support for numeric
  data but that's hardly a big deal.

12 years agoTake length of format width specifier into account for format string buffer
Panu Matilainen [Wed, 17 Aug 2011 06:03:44 +0000 (09:03 +0300)]
Take length of format width specifier into account for format string buffer

- Prevents buffer overflow in case of ridiculous field width specifiers
  like --qf "%100000000000000000000000000{name}". There's another similar
  static-sized buffer in rpmtdFormat() but there we're not dealing
  with user-speficied format strings so its okay even if ugly.
- The format string handling wants a bigger overhaul but this makes
  for a nice little backportable patch for starters.

12 years agoValidate query format field width specifier is sane
Panu Matilainen [Wed, 17 Aug 2011 05:17:13 +0000 (08:17 +0300)]
Validate query format field width specifier is sane

- Only allow [[-]<number>] in the format field, users have no business
  telling which format conversion sprintf() should use for tag data.
  Fixes embarrassing segfaults from things like %s{size} which rpm
  has merrily passed on to sprintf() as-is.

12 years agoStrip trailing slash from paths at addFile()
Panu Matilainen [Tue, 2 Aug 2011 09:39:51 +0000 (12:39 +0300)]
Strip trailing slash from paths at addFile()

- Fixes regression from commit 23167c3ea459405c98d8e759993efb6d9b1ea7f3
  which causes all %dir entries to have a trailing slash, breaking
  at least dependencies on such directories and probably something
  else as well.

12 years agopgpVerifySig() check of NULL hash is the wrong way around
Panu Matilainen [Tue, 2 Aug 2011 09:22:52 +0000 (12:22 +0300)]
pgpVerifySig() check of NULL hash is the wrong way around

- NULL hash is pretty much a can't happen-case here but lets be
  sane if it happens afterall - NULL hash would be an error and
  we dont want to process the rest if that happened.

12 years agoRestore %defattr() behavior on special %doc
Michael Schroeder [Tue, 2 Aug 2011 09:20:35 +0000 (12:20 +0300)]
Restore %defattr() behavior on special %doc

- With the change in the defattr handling (commit 09efbe96), you also
  need to save the current defattr setting when processing %doc.
  Otherwise doc files will just get the value from the latest defattr line.

12 years agoFix misleading error message when gpg key is expired (RhBug:672727)
Jindrich Novy [Mon, 1 Aug 2011 11:54:43 +0000 (13:54 +0200)]
Fix misleading error message when gpg key is expired (RhBug:672727)

13 years agoSanity check signatures even if we dont have a key
Panu Matilainen [Thu, 14 Jul 2011 11:05:32 +0000 (14:05 +0300)]
Sanity check signatures even if we dont have a key

- Fixes a regression originating all the way back from commit
  c7fc09d585ff3831924f72f61d990aa791f2c3f2 (ie rpm >= 4.8.0)
  where a package with a bogus signature can slip through undetected
  if we dont have a key for it.
- This additional sanity check on the signature prevents is enough
  to prevent the fuzzed package in RhBug:721225 from crashing us
  by stopping the bad package at the front door. That we don't have
  proper tag data validation is another, much wider issue...

13 years agoFix memleak on keys with more than one user id
Panu Matilainen [Wed, 13 Jul 2011 13:19:01 +0000 (16:19 +0300)]
Fix memleak on keys with more than one user id

- This is not "correct", we should permit more than one user id.
  Leaking memory is still worse than not leaking, corrent behavior
  or not.

13 years agoFix crash on PGP packets/armors with more than one key (RhBug:667582)
Panu Matilainen [Wed, 13 Jul 2011 13:05:34 +0000 (16:05 +0300)]
Fix crash on PGP packets/armors with more than one key (RhBug:667582)

- While OpenPGP permits arbitrary number of keys per packet/armor,
  we can't handle more than one, error out early.  The poor user
  wont get much of a clue as to what went wrong, but thats still
  better than crashing and burning.
- Return NULL from pgpPrtPubkeyParams() on errors and pass it onwards
  from pgpPrtKey() which propagates it up to callers. Besides
  the crash, this also fixes the error path from pgpNewPublicKey()
  failures.

13 years agoOops, rpmPubkeyDig() should return NULL if pgpPrtPkts() fails
Panu Matilainen [Wed, 13 Jul 2011 12:46:21 +0000 (15:46 +0300)]
Oops, rpmPubkeyDig() should return NULL if pgpPrtPkts() fails

13 years agoOnly increment number of query/verify sources when we encounter new types
Panu Matilainen [Wed, 13 Jul 2011 11:03:32 +0000 (14:03 +0300)]
Only increment number of query/verify sources when we encounter new types

- This makes it legal to specify the same query/verify source more
  than once. Not that it makes a whole lot of sense to do so, but
  complaining "only one type of query/verify permitted at a time" seems
  silly as well if you're just (accidentally) specifying the same
  source twice. Besides, this makes the code a bit cleaner.
- Kinda related to RhBug:691930.

13 years agoFix the sanity check on number of query/verify sources (RhBug:691930)
Panu Matilainen [Wed, 13 Jul 2011 10:56:15 +0000 (13:56 +0300)]
Fix the sanity check on number of query/verify sources (RhBug:691930)

- Prior to commit 2e672f3fae9d8ff7ee64ae13cfa2fe65272c2ede, the
  callback would get called twice for every option so the expected
  number of query/verify sources was doubled. Now the numbers
  match with reality, adjust the check.

13 years agoWhoops, wrong variable passed to io debugging
Panu Matilainen [Tue, 12 Jul 2011 07:51:07 +0000 (10:51 +0300)]
Whoops, wrong variable passed to io debugging

13 years agoCleanup fdRead(), fdWrite() and fdSeek() a bit
Panu Matilainen [Mon, 11 Jul 2011 09:37:12 +0000 (12:37 +0300)]
Cleanup fdRead(), fdWrite() and fdSeek() a bit

- Remove unnecessary fluff, these are very simple operations
  and dont need any temporary variables, re-re-redundant NULL checking
  etc, its already done at the caller level.

13 years agoCosmetics: remove empty comments and such
Panu Matilainen [Mon, 11 Jul 2011 09:33:31 +0000 (12:33 +0300)]
Cosmetics: remove empty comments and such

13 years agoDont bother checking for NULL fd on stats collection
Panu Matilainen [Mon, 11 Jul 2011 09:20:12 +0000 (12:20 +0300)]
Dont bother checking for NULL fd on stats collection

- All the places calling these are already checking for NULL fd,
  no point re-re-re-re-re-checking it

13 years agoCentralize most of the debug goo as well
Panu Matilainen [Mon, 11 Jul 2011 09:19:22 +0000 (12:19 +0300)]
Centralize most of the debug goo as well

13 years agoJust pass fd pointers around instead of "cookies" cast to fd
Panu Matilainen [Mon, 11 Jul 2011 09:05:58 +0000 (12:05 +0300)]
Just pass fd pointers around instead of "cookies" cast to fd

- There's not a whole lot of point passing our own data structure
  around in void pointers and re-re-re-re-re-recasting them to fd's
  again all over the place. Just pass the damn fd to begin with.

13 years agoCentralize fd digests collection
Panu Matilainen [Mon, 11 Jul 2011 08:55:58 +0000 (11:55 +0300)]
Centralize fd digests collection

- Instead of requiring every io type to remember to update digests
  on their own, do it centrally on Fread() and Fwrite().
- This changes the digest calculation on writes slightly: previously
  we calculated the digests regardless whether the actual write
  succeeded or not, now we do this similarly to reads and only
  update the digests on success.

13 years agoCentralize fd stats collection
Panu Matilainen [Mon, 11 Jul 2011 08:46:35 +0000 (11:46 +0300)]
Centralize fd stats collection

- Instead of requiring every io type to call stats on their own,
  simply call the stat updates from the main functions Fread() etc

13 years agoEliminate unused leftover bytesRemain member from FD_t
Panu Matilainen [Mon, 11 Jul 2011 08:33:15 +0000 (11:33 +0300)]
Eliminate unused leftover bytesRemain member from FD_t

- This used to be relevant for remote io but now its just unused.
- Also remove the "simulate EOF" on NULL fd returns while at it,
  these seem simply wrong (considering Fread() and Fwrite() behave
  more like read() and write rather than fread() and fwrite())

13 years agoMinor cosmetics cleanup to Fseek()
Panu Matilainen [Mon, 11 Jul 2011 08:12:36 +0000 (11:12 +0300)]
Minor cosmetics cleanup to Fseek()

13 years agoReturn an error on Fread() / Fwrite() on NULL fd
Panu Matilainen [Mon, 11 Jul 2011 08:03:16 +0000 (11:03 +0300)]
Return an error on Fread() / Fwrite() on NULL fd

- Merrily returning success on read/write on NULL fd just is not
  sane. If something breaks because of this then that something
  needs fixing instead...
- Also return code type was mismatching in both, these return
  ssize_t not int.

13 years agoImplement Ftell() for zlib versions that support it
Panu Matilainen [Mon, 11 Jul 2011 07:22:33 +0000 (10:22 +0300)]
Implement Ftell() for zlib versions that support it

13 years agoAdd basic test for Ftell() in python
Panu Matilainen [Mon, 11 Jul 2011 07:13:00 +0000 (10:13 +0300)]
Add basic test for Ftell() in python

13 years agoUse a vector for Ftell() functionality too
Panu Matilainen [Mon, 11 Jul 2011 07:12:14 +0000 (10:12 +0300)]
Use a vector for Ftell() functionality too

13 years agoRemove pointless fdSeekNot() "not implemented" function
Panu Matilainen [Mon, 11 Jul 2011 06:19:55 +0000 (09:19 +0300)]
Remove pointless fdSeekNot() "not implemented" function

- Fseek() and friends already return -2 for not implemented functions,
  this is not needed at all

13 years agoAdd a simple test for Fflush() functionality in python
Panu Matilainen [Fri, 8 Jul 2011 11:54:42 +0000 (14:54 +0300)]
Add a simple test for Fflush() functionality in python

- Prior to previous patch this segfaulted and tracebacked...

13 years agoFix totally broken Fflush() operation
Panu Matilainen [Fri, 8 Jul 2011 11:48:54 +0000 (14:48 +0300)]
Fix totally broken Fflush() operation

- This only ever worked for fpio, for all other types it returns
  bogons or crashes and burns.
- Use the file op vectors to find our fflush function instead
  of #ifdef/#endif if/else/ifelse jungle.
- Notably fdio and ufdio do not have a fflush() equivalent because
  they dont need one. Use a dummy function to always return success to
  differentiate from -2 aka "not supported by this io type"

13 years agoAxe the broken fpio support for good
Panu Matilainen [Fri, 8 Jul 2011 07:43:00 +0000 (10:43 +0300)]
Axe the broken fpio support for good

- The whole thing is extremely hacky and failing to properly take
  fundamental differences in eg fread() and read() semantics into
  account (the whole rpmio fd is confused over this: Fread() claims
  to be fread() clone but reads behave with read() semantics
  and we dont provide feof() equivalent etc), special cased all over
  the io code when vectors exist for this purpose etc (not that fpio
  is the only offender in that regard)... RIP. Nothing should miss
  this but if we'd ever want to add it back, it'd better be done
  right at least.
- This COULD silently break somebody's code if they rely on the broken
  special case semantics of fpio mode, but most likely rpm itself
  was the only thing using fpio (and relying on the behavior) and
  even then, mostly only to get a FILE stream pointer out of it.
  Now we'll just silently return a fdio descriptor, as we do for any
  unrecognized io mode... (another sigh)

13 years agozlib is mandatory, fail at configure if missing + remove conditionals
Panu Matilainen [Fri, 8 Jul 2011 07:31:34 +0000 (10:31 +0300)]
zlib is mandatory, fail at configure if missing + remove conditionals

- Unlike bz2 and xz/lz, zlib compression is not tracked by any rpmlib
  feature and is part of the original package format really, zlib
  simply must be always present.

13 years agoEliminate the last two fpio uses in rpm codebase
Panu Matilainen [Fri, 8 Jul 2011 07:20:02 +0000 (10:20 +0300)]
Eliminate the last two fpio uses in rpm codebase

- Both relate to reading manifests and it doesn't make the damnest
  difference what io mode these use as rpmReadPackageManifest()
  opens its own stream on the fd with fdopen() which works on
  any io type, not just fpio..

13 years agoEliminate the uuugly and stupid fdGetFILE() from the API
Panu Matilainen [Fri, 8 Jul 2011 07:18:53 +0000 (10:18 +0300)]
Eliminate the uuugly and stupid fdGetFILE() from the API

13 years agoIf we need a FILE stream then get one...
Panu Matilainen [Thu, 7 Jul 2011 19:51:29 +0000 (22:51 +0300)]
If we need a FILE stream then get one...

- Replace the hysterical "lets see if the temp creation gave an fpio
  fd (it didn't), if not open another fd and then get its private
  FILE pointer" fiddling: since we need a FILE stream then open one
  with fdopen(), duh. Grabbing a rpmio fd to begin with is stupid enough
  when all we want is a stream, but wanting to use rpmMkTempFile()
  functionality...
- Also fixes an fd+mem leak in the unlikely but possible case that
  rpmMkTempFile() succeeds but fdopen() fails.

13 years agoTake advantage of Fdescr() in rpmReadPackageFile()
Panu Matilainen [Thu, 7 Jul 2011 14:26:56 +0000 (17:26 +0300)]
Take advantage of Fdescr() in rpmReadPackageFile()

- If fn to rpmReadPackageFile() is NULL, use Fdescr() value to give
  more meaningful errors
- Change a couple of places where we haven't got a clue of the file
  name to take advantage of the above

13 years agoTeach python rpmio bindings about Fdescr()
Panu Matilainen [Thu, 7 Jul 2011 13:27:03 +0000 (16:27 +0300)]
Teach python rpmio bindings about Fdescr()

- Similarly to python file object having o.name, export Fdescr()
  as fd.name. Python uses <foo> for non-paths but [foo] seems like
  a safer choice wrt accidental redirections.
- Also add a basic testcase for fd.name

13 years agoRemember path (or other description) in fd's, add getter
Panu Matilainen [Thu, 7 Jul 2011 12:47:47 +0000 (15:47 +0300)]
Remember path (or other description) in fd's, add getter

- If opened by path, we obviously want to use that. Otherwise
  generate a description lazily on first Fdescr() call: on Linux
  we can grab something relatively meaningful by looking up from /proc
  (this is why we want to be lazy here...). If that's not available
  or fails, just generate a string on the current fdno. Actual
  paths are returned as is, other descriptions are bracketed,
  (eg "[mumble 123]").
- This makes it possible to give more meaningful error messages in
  places where we only get an fd from somebody (related to RhBug:522160)

13 years agoEliminate fdNew() from the API
Panu Matilainen [Thu, 7 Jul 2011 10:55:16 +0000 (13:55 +0300)]
Eliminate fdNew() from the API

- Nobody should be able to create file descriptors which are not
  attached to a file/descriptor of some kind, the only sane
  fd constructors are Fopen(), Fdopen() and fdDup().
- The same applies to fdFree() but its a bit more complicated,
  punting that till later...

13 years agoFurther streamline & sanitize lead handling
Panu Matilainen [Thu, 7 Jul 2011 08:55:28 +0000 (11:55 +0300)]
Further streamline & sanitize lead handling

- Never log anything from rpmLeadRead(), instead return an error message
  the callers can log if they see fit
- Add a return value for the lead type (which is the only bit of
  info from the lead we sometimes resort to using)
- Permit NULL pointers on all return values
- Eliminate rpmLeadCheck() and rpmLeadType() from the internal API,
  these are now combined into rpmLeadRead().
- Fix up the callers: only (re)signing needs the actual lead,
  signature verification only cares if its valid or not and
  package reading only wants the type from the lead (annoying but...)

13 years agoOnly bother mallocing lead for return if read actually succeeded
Panu Matilainen [Thu, 7 Jul 2011 08:17:29 +0000 (11:17 +0300)]
Only bother mallocing lead for return if read actually succeeded

- Doesn't make much of a difference now, just paving way for next steps

13 years agoEliminate remaining assert()'s in rpmlead.c
Panu Matilainen [Wed, 6 Jul 2011 09:53:59 +0000 (12:53 +0300)]
Eliminate remaining assert()'s in rpmlead.c

- Blowing up with assert() on freeing NULL is just dumb...
- rpmLeadWrite() can easily be made to handle NULL lead gracefully

13 years agoMake rpmLeadRead() return an allocated lead, fixup callers
Panu Matilainen [Wed, 6 Jul 2011 09:42:56 +0000 (12:42 +0300)]
Make rpmLeadRead() return an allocated lead, fixup callers

- Requiring callers to allocate a lead "buffer" for reading into
  is just DUMB (greetings to self back in 2008, sigh). This avoids
  having to deal with freeing the lead in case the read failed, and
  allows getting rid of rpmLeadNew() completely.

13 years agoStart beating a little bit of sense into the braindamaged rpmlead API
Panu Matilainen [Wed, 6 Jul 2011 09:09:21 +0000 (12:09 +0300)]
Start beating a little bit of sense into the braindamaged rpmlead API

- rpmLeadNew() should not populate the struct, only allocate it
- The only case where we're creating new lead data is
  rpmLeadFromHeader(), move all initialization there, and add a comment
  for RhBug:717898. Also eliminate the stupid assert, we can
  easily handle NULL header here.

13 years agoAdd tests for header getattr() behavior sanity
Panu Matilainen [Wed, 6 Jul 2011 08:20:44 +0000 (11:20 +0300)]
Add tests for header getattr() behavior sanity

13 years agoFix the broken python header __getattr__() behavior, take 13 (or so)
Panu Matilainen [Wed, 6 Jul 2011 08:05:42 +0000 (11:05 +0300)]
Fix the broken python header  __getattr__() behavior, take 13 (or so)

- Tags as header attributes seemed like a nice idea at the time... but
  has been a PITA due to side-effects it causes, such as breaking
  getattr() use for "capability testing", eg:
      >>> h2 = copy.deepcopy(h)
      Traceback (most recent call last):
        File "<stdin>", line 1, in <module>
        File "/usr/lib64/python2.7/copy.py", line 172, in deepcopy
          copier = getattr(x, "__deepcopy__", None)
      ValueError: unknown header tag
- Since we can't really go removing the brainded feature (somebody might
  actually be using it) try harder to fix it: if its not an actual
  attribute, save the exception we got from PyObject_GenericGetAttr()
  and if its not a valid tag either, restore the original exception.
  This allows cases like the above __deepcopy__ to work properly.

13 years agoAdd __reduce__() method to python header object
Panu Matilainen [Wed, 6 Jul 2011 07:22:01 +0000 (10:22 +0300)]
Add __reduce__() method to python header object

- This allows header objects to be pickled and also copied correctly
  with python's copy.copy()
- Split the header to string-conversion into a separate helper function,
  used by the now largely unnecessary unload() method and __reduce__().

13 years agoRevert the ds, ts, fi and spec python object creation commits
Panu Matilainen [Wed, 6 Jul 2011 05:16:12 +0000 (08:16 +0300)]
Revert the ds, ts, fi and spec python object creation commits

- Hasty push-finger syndrom, while its not exactly plain wrong to
  do things this way, it doesn't really make sense for these types
  either. Python's own file object permits reinitialization though,
  so leaving rpm.fd() the way it is now.
- This reverts the following commits:
  d056df28c38e602d82b4f9b527c686037074e660
  3f77c3146da46a49f44b17fa66139fbe2dd9e45c
  7214b2e0a271b7a7b3df312c58593878cbf56504
  dc50fb2863c81159fb4cc8b25ce3862720c0cce5

13 years agoBring back c++ "protection" to rpmsq, oops
Panu Matilainen [Tue, 5 Jul 2011 19:46:18 +0000 (22:46 +0300)]
Bring back c++ "protection" to rpmsq, oops

- The beginning of c++ extern block went with the dishwater in commit
  269df02ae1fc3955bee4e5f471b1172c04c714e2

13 years agoFix/sanitize rpm.ds python object creation a bit
Panu Matilainen [Fri, 1 Jul 2011 11:39:19 +0000 (14:39 +0300)]
Fix/sanitize rpm.ds python object creation a bit

- Move all actual initialization work into tp_init, permit
  reinitialization without leaking and use PyType_GenericNew for tp_new.

13 years agoFix/sanitize rpm.ts python object creation a bit
Panu Matilainen [Fri, 1 Jul 2011 11:25:47 +0000 (14:25 +0300)]
Fix/sanitize rpm.ts python object creation a bit

- Move all actual initialization work into tp_init, permit
  reinitialization without leaking and use PyType_GenericNew for tp_new.

13 years agoFix/sanitize rpm.fi python object creation a bit
Panu Matilainen [Fri, 1 Jul 2011 10:37:48 +0000 (13:37 +0300)]
Fix/sanitize rpm.fi python object creation a bit

- Move all actual initialization work into tp_init, permit
  reinitialization without leaking and use PyType_GenericNew for
  tp_new, eliminate internal rpmfi_Wrap() use.
  There's one user for rpmfi_Wrap() in rpmte-py.c which needs fixing
  later...
- Remove unused fiFromFi() helper function

13 years agoFix/sanitize rpm.spec python object creation
Panu Matilainen [Fri, 1 Jul 2011 09:55:53 +0000 (12:55 +0300)]
Fix/sanitize rpm.spec python object creation

- Specs are not really immutable, move the initialization work into
  tp_init and use PyType_GenericNew for tp_new since we're not
  doing anything special there.
- Eliminate the stupid spec_Wrap() thing and hide specPkg_Wrap()
  out of side (TODO later...)

13 years agoAdd a simple and stupid test case for python spec parse
Panu Matilainen [Fri, 1 Jul 2011 09:33:55 +0000 (12:33 +0300)]
Add a simple and stupid test case for python spec parse

13 years agoFix/sanitize rpm.fd python object creation
Panu Matilainen [Fri, 1 Jul 2011 09:08:04 +0000 (12:08 +0300)]
Fix/sanitize rpm.fd python object creation

- FD's are not really immutable, move the initialization work into
  tp_init and use PyType_GenericNew for tp_new since we're not
  doing anything special there.
- Remove half a dozen different unnecessary exit points

13 years agoFix the totally broken rpm.fd() read method
Panu Matilainen [Fri, 1 Jul 2011 08:19:02 +0000 (11:19 +0300)]
Fix the totally broken rpm.fd() read method

13 years agoAdd basic test for rpmio python bindings
Panu Matilainen [Fri, 1 Jul 2011 08:14:26 +0000 (11:14 +0300)]
Add basic test for rpmio python bindings

13 years agoFix explicit directory %attr() when %defattr() is active (RhBug:481875)
Panu Matilainen [Tue, 28 Jun 2011 10:01:59 +0000 (13:01 +0300)]
Fix explicit directory %attr() when %defattr() is active (RhBug:481875)

- parseForAttr() doesn't know whether it's dealing with a directory or
  a file, so it can't know which defaults it should use.
  Move all the decision making on which of the explicit/default/implicit
  attributes into addFile() where we do know what kind of entry we're
  dealing with, and only parse in parseForAttr().
- Update the test-case status to expect success now.

13 years agoAdd a test-case for various %attr and %defattr combinations
Panu Matilainen [Tue, 28 Jun 2011 07:34:13 +0000 (10:34 +0300)]
Add a test-case for various %attr and %defattr combinations

- Currently this fails expectedly due to RhBug:681540 on the last
  directory of the test rpm.

13 years agoEnable GLOB_ONLYDIR of the bundled glob() on platforms that support it
Panu Matilainen [Tue, 28 Jun 2011 05:37:41 +0000 (08:37 +0300)]
Enable GLOB_ONLYDIR of the bundled glob() on platforms that support it

13 years agoPay attention to dir vs file when building (RhBug:505995)
Panu Matilainen [Mon, 27 Jun 2011 11:52:22 +0000 (14:52 +0300)]
Pay attention to dir vs file when building (RhBug:505995)

- Preserve trailing slash if it exists, and also add one on explicit
  %dir entires. This lets rpmGlob() and friends to skip any matching
  files that might be present, fixing both test-cases in RhBug:505995.

13 years agoHonor trailing slash in rpmGlob()
Panu Matilainen [Mon, 27 Jun 2011 11:09:17 +0000 (14:09 +0300)]
Honor trailing slash in rpmGlob()

- Only return directories if a pattern contains a trailing slash.
  Use GLOB_ONLYDIR hint if available but as this is unreliable,
  we need to stat the paths to be sure.
- Hysterically enough, rpm bundles its own copy of glob() which does
  have GLOB_ONLYDIR but ATM it doesn't get build because HAVE_D_TYPE
  isn't defined outside glibc build environment which is where our glob
  originally came from...

13 years agoRemove ugly isDir recurse prevention hack on build
Panu Matilainen [Mon, 27 Jun 2011 09:41:39 +0000 (12:41 +0300)]
Remove ugly isDir recurse prevention hack on build

- We know if we're already fts-walking by the way addFile() gets called,
  dont corrupt fl->isDir for no good reason.

13 years agoEliminate static BUFSIZ use in filelist parsing
Panu Matilainen [Thu, 23 Jun 2011 06:47:10 +0000 (09:47 +0300)]
Eliminate static BUFSIZ use in filelist parsing

- In the unlikely event of filelist line being longer than BUFSIZ
  we'd previously end up truncating the line, which is stupid
  since we can just as easily make the buffer large enough.

13 years agoUse ARGV_t for filelist current locale storage
Panu Matilainen [Tue, 21 Jun 2011 13:27:18 +0000 (16:27 +0300)]
Use ARGV_t for filelist current locale storage

- Avoids having to manually do search, sort, join, free etc for
  no good reason. Could be further simplified with argvSplit() etc
  and sanitized overall but leaving that for another day...

13 years agoEliminate redundant noGlob member from filelist
Panu Matilainen [Tue, 21 Jun 2011 11:53:05 +0000 (14:53 +0300)]
Eliminate redundant noGlob member from filelist

- Since the only thing where globs are not permitted are %dev entires,
  check for device explicitcly in the glob part. Doh.

13 years agoEliminate redundant special docs tracking members in filelist
Panu Matilainen [Tue, 21 Jun 2011 11:43:03 +0000 (14:43 +0300)]
Eliminate redundant special docs tracking members in filelist

13 years agoEliminate unused fileCount member from FileList struct
Panu Matilainen [Tue, 21 Jun 2011 11:33:48 +0000 (14:33 +0300)]
Eliminate unused fileCount member from FileList struct

13 years agoAdd DWARF-4 support to debugedit (RhBug:707677)
Jakub Jelinek [Fri, 17 Jun 2011 13:40:20 +0000 (16:40 +0300)]
Add DWARF-4 support to debugedit (RhBug:707677)

Signed-off-by: Panu Matilainen <pmatilai@redhat.com>
13 years agoAvoid extra newlines in parsed spec output outside preamble
Panu Matilainen [Fri, 17 Jun 2011 11:25:44 +0000 (14:25 +0300)]
Avoid extra newlines in parsed spec output outside preamble

13 years agoAdd --parse option to rpmspec tool to dump parsed spec contents
Panu Matilainen [Fri, 17 Jun 2011 10:53:43 +0000 (13:53 +0300)]
Add --parse option to rpmspec tool to dump parsed spec contents

- This is somewhat like 'gcc -E', useful for analyzing/troubleshooting
  what happens inside the preprocessing.

13 years agoSupport retrieving the spec contents in parsed format
Panu Matilainen [Fri, 17 Jun 2011 10:44:39 +0000 (13:44 +0300)]
Support retrieving the spec contents in parsed format

- Collect the preprocessed (conditionals, macros etc evaluated)
  lines to a separate stringbuf, make rpmSpecGetSection() return
  that on RPMBUILD_NONE "section" (hack, but so is abusing RPMBUILD_FOO
  for the section here so shrug)

13 years agoError on unclosed macros & trailing line continuations in spec (RhBug:681567)
Panu Matilainen [Thu, 16 Jun 2011 16:21:54 +0000 (19:21 +0300)]
Error on unclosed macros & trailing line continuations in spec (RhBug:681567)

- Track the starting line in case copyNextLineFromOFI() indicates
  a multiline-construct. If we get an EOF from readLineFromOFI()
  while inside multiline read, its an illegal construct of some kind
  and we can even spit out a reasonably meaningful error pointing
  out the starting line number of the bad construct.

13 years agoTry to generate fileclass in the tag ext at runtime if missing from header
Panu Matilainen [Thu, 16 Jun 2011 09:26:42 +0000 (12:26 +0300)]
Try to generate fileclass in the tag ext at runtime if missing from header
- For non-regular files we can easily generate this information based
  on file mode + in case of symlinks, the link target is available
  in the header elsewhere. This also means --fileclass will return
  at least partial data for packages built with the external depgen.
- Clean up fileclassTag() a bit while at it, removing redundant fluff.
- Arguably this "magic" should be done inside rpmfiFClass() instead, but
  that'd require changing the API to return malloced data.

13 years agoExport rpmteFailed() to python bindings
Panu Matilainen [Thu, 16 Jun 2011 05:48:57 +0000 (08:48 +0300)]
Export rpmteFailed() to python bindings

- Kinda related to RhBug:661962, yum relies on callbacks to catch
  install/erase errors but this is not accurate: on erase the
  element can be ambiguous as the callback only gives a name (sigh).
  In addition, elements can be skipped entirely if "parent" element
  fails, in which case no callbacks are issued so these cases would go
  completely unnoticed when relying on callbacks alone. te.Failed()
  gives users such as yum a chance to have a look at the real status
  of elements (after the transaction).

13 years agoDon't remove buildroot docdir on %doc usage (ticket #836)
Panu Matilainen [Mon, 13 Jun 2011 08:52:54 +0000 (11:52 +0300)]
Don't remove buildroot docdir on %doc usage (ticket #836)
- Some software installs its own documentation and if you try to
  combine it with %doc, rpmbuild will abort with mysterious
  "cpio bad magic" or such errors because what was assumed to be
  there was not, as %doc would 'rm -rf' the docdir upon first
  invocation. I don't see any good reason to disallow sharing the
  same directory for %doc and documentation installed by software
  "make install" - the other alternative would be forcing %doc to
  go to some other location, only making docs harder to find.
- Also at least Mageia (and prior to that Mandriva) has been doing
  this for quite some time now.

13 years agoAdjust script detection rules to work with file >= 5.07 too (RhBug:712251)
Panu Matilainen [Fri, 10 Jun 2011 09:08:45 +0000 (12:08 +0300)]
Adjust script detection rules to work with file >= 5.07 too (RhBug:712251)
- Somewhere between file 5.05 and 5.07 it started adding encoding
  to script descriptions, eg "<mumble> script text executable" became
  "<mumble> script, <encoding> text executable" breaking what had
  been working for 10+ years in the case of old find-requires.
- Permit either comma or space after "script", this works for both
  old and new file.

13 years agoAdd bunch of further rpm-python tests for this and that
Panu Matilainen [Thu, 9 Jun 2011 12:13:46 +0000 (15:13 +0300)]
Add bunch of further rpm-python tests for this and that

13 years agoEww, python ds.Instance() doesn't take any arguments
Panu Matilainen [Thu, 9 Jun 2011 11:25:37 +0000 (14:25 +0300)]
Eww, python ds.Instance() doesn't take any arguments
- ...means its been broken all along, sigh

13 years agoAdd a bunch of db match/key iterator test-cases in python
Panu Matilainen [Thu, 9 Jun 2011 10:44:10 +0000 (13:44 +0300)]
Add a bunch of db match/key iterator test-cases in python
- This would've caught the breakage introduced in commit
  7e4415fcc5e11cfd4cd9d0dfe19568be73f15d74, but better late than never...

13 years agoRearrange test-suite python helper macros a bit
Panu Matilainen [Thu, 9 Jun 2011 10:19:14 +0000 (13:19 +0300)]
Rearrange test-suite python helper macros a bit
- Handle double [] "escaping" at RPM_PYRUN to avoid surprises when
  its used on its own
- Spin python-wrapped AT_CHECK into a macro of its own (RPMPY_CHECK)
- What formerly was RPMPY_CHECK is now RPMPY_TEST: this represents
  one entire testcase with all its setup and cleanup, whereas
  RPMPY_CHECK (the new one) might be used several times within a
  single test