Commit Graph

12175 Commits

Author SHA1 Message Date
Panu Matilainen d203db9e9b Determine the need to set file/dir permissions in fsmCommit() by st_nlink
- When committing hardlinks, adjust st_nlink to "this is the n'th
  link to this file" value instead of passing the total number of
  links it'll have. This way we dont need a separate tracking variable
  for whether permissions should be set or not, and plugins will
  also have a reliable way to determining whether they're looking
  at a hardlink or the actual file: on install we fake it, on erasure
  it comes naturally from the stat() on the file.
2013-03-13 10:32:39 +02:00
Panu Matilainen 53df8f68db Use link order to determine setmeta need in fsmCommitLinks()
- Doesn't change anything in practise, just a different way of
  achieving the same thing. We'll be taking advantage of this
  shortly though.
2013-03-13 09:58:53 +02:00
Panu Matilainen 5fca379f4f Pass stat struct pointer as argument to fsmCommit*()
- Avoids having to declare the same helper st pointers all over and
  makes it that little bit clearer what data is being operated on
2013-03-13 09:50:49 +02:00
Panu Matilainen 0dd22bf806 Set file permissions before renaming it to final destination
- This eliminates a case where thing can entirely unnecessarily break
  on live updates if you're "lucky" enough to do something in the
  tiny window of time between rename of a file and fixing up its
  permissions. Perhaps more importantly, this avoids overwriting
  any existing files in case where we fail to set the permissions
  at all.
- For regular metadata the physical path of the file is unintresting,
  but for selinux label lookups we need the destination path
  separately, hence the previous commits.
2013-03-13 09:36:35 +02:00
Panu Matilainen bfa0f5c728 Pass destination path as a separate argument to fsmSetSELabel()
- Doesn't make any difference yet, but will be needed for next steps...
2013-03-13 09:25:39 +02:00
Panu Matilainen addfddccd8 Constuct destination path earlier in fsmCommit()
- Doesn't change anything, but necessary for the next step...
2013-03-13 09:15:37 +02:00
Panu Matilainen d49ad94fd7 Make struct stat pointers const in (some of the) obvious cases
- fsmCommit*() and saveHardLink() never modify the stat, make this
  more obvious with const. Change all the related accesses go
  through the pointer instead of &fsm->sb. Doesn't change functionality
  but opens possibilities of passing st as an argument.
2013-03-13 08:57:13 +02:00
Panu Matilainen c1f49abe0b Lift secondary index updating out of rpmdbRemove()
- Similar to commit 2139babf96,
  dunno why I didn't do this back then as well. Seems straightforward
  enough, supposedly no changes (but knock wood...)
2013-03-11 17:29:18 +02:00
Panu Matilainen a70ce07466 Rename addToIndex() to indexPut()
- Towards more consistent and perhaps saner naming
2013-03-11 17:06:35 +02:00
Panu Matilainen 656459ba44 Add crude --exportdb and --importdb operations to rpmdb utility
- Exportdb simply dumps all the headers from rpmdb into simple header
  list which is about as rpm-native and backwards and forwards compatible
  format as they come. Importdb obviously, well, imports such a
  list into rpmdb.
- Both require transaction handle: we dont want anybody running
  transactions while exporting, and importing obviously requires
  write-locking.
2013-03-11 15:37:56 +02:00
Panu Matilainen c6e84b8981 Take advantage of rpmtsImportHeader() in pubkey imports
- This makes pubkey imports guarded by transaction lock, previously
  they relied on rpmdb locking which is .. well.
- We grab the transaction handle as the first thing on entry: if
  they key happens to be already imported then this is "unnecessary",
  but if we only get the lock later then somebody else might have
  imported the same key and we end up with dupes anyway.
2013-03-11 14:53:56 +02:00
Panu Matilainen 7c4b014e20 Add a public API for importing "detached" headers into rpmdb
- This is what rpmtsImportPubkey() does anyway, and database conversion
  utilities will need it too. This is just a lock-protected
  rpmdbAdd(): the caller is required to explicitly request a
  transaction handle to guarantee just one transaction at a time.
2013-03-11 14:37:06 +02:00
Panu Matilainen bec9449c3b Fix segfault on close of non-open rpmdb
- Regression introduced in commit 690d31b1c6,
  dbiForeach() checks for NULL but dbiClose() doesn't.
2013-03-11 13:40:53 +02:00
Panu Matilainen cd9d401e90 Export rpmtxnBegin() and rpmtxnEnd()
- This allows API users to lock the transaction from other players
  long before entering rpmtsRun(): for example depsolvers first do
  calculations based on the rpmdb, download packages and only then
  start the transaction. We dutifully waited for others to complete
  on the ts lock inside rpmtsRun(), but those others could've
  invalidated all our prior calculations so continuing was potentially
  hazardous even. There are other uses too, we'll get to them
  eventually...
2013-03-11 13:20:05 +02:00
Panu Matilainen 3b9885ea51 Move transaction lock handle to transaction set centrally
- Separate lock object creation from lock acquisition: lazily (try
  to) create the lock object from rpmtxnBegin() if it doesn't
  already exist, otherwise rpmtxnBegin() and rpmtxnEnd() just
  acquire and release the lock. After all this trouble, we can
  actually nest transaction locks. At least in theory ;)
2013-03-11 12:58:04 +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
Panu Matilainen 4d0e7f78dc Make rpm locks reference counted to allow nested locking
- Note that unlike our "normal" refcounts, this counts references to
  the file descriptor itself: an open descriptor is one reference,
  and acquired locks are on top of that.
- This also moves the NULL checks to the external interface, we
  need to NULL-check there anyway so there's no point rechecking
  in internals.
2013-03-11 11:58:07 +02:00
Panu Matilainen 87188275ad Export rpmlock release method internally as well 2013-03-11 11:12:35 +02:00
Panu Matilainen 47b9d60cb3 Allow separate lock object creation and lock acquisition
- Split rpmlockNewAcquire() functionality into separate
  rpmlockNew() and rpmlockAcquire() functions, implement
  rpmlockNewAcquire() using the two.
2013-03-11 10:44:54 +02:00
Panu Matilainen f7fcb72c07 Rename rpmlockAcquire() to rpmlockNewAcquire()
- This is a lock constructor that we might want to keep around,
  but we'll also need to be able to separate new + acquire steps,
  so just making room for that...
2013-03-11 09:54:12 +02:00
Panu Matilainen 94d741b6b5 Remember rpmlock path and description in the lock object 2013-03-11 09:43:52 +02:00
Panu Matilainen 172c1581ef Make rpmlock flags available internally 2013-03-11 09:23:49 +02:00
Panu Matilainen 3821553a46 Eliminate rpmdbOpenIndex(), use specific db/index open calls instead
- Concrete functionality doesn't really change here, but this makes
  it more explicit what kind of db handle is accepted and used
  in each case: for example previously it was possible to open an
  index iterator on Packages which does not work and returns garbage,
  this should now return an error instead. Similarly extend iterator
  etc only are appropriate with indexes, this forces the issue.
2013-03-10 14:34:08 +02:00
Panu Matilainen 6dbffd6fbf Move error handling to the specialized db / index opening functions
- Looks like code duplication for now, but required for eventually
  breaking the ties between packages db and indexes
2013-03-10 14:09:48 +02:00
Panu Matilainen 690d31b1c6 Separate packages db from the indexes
- While they all are implemented on key-value BDB store currently,
  on the higher level packages and indexes are (obviously) fundamentally
  different. Again this shouldn't change anything as such, just
  further steps towards abstracting the low-level backend from
  the rpmdb level.
2013-03-10 13:54:52 +02:00
Panu Matilainen d1b5164be2 Lift db tag index rename + permission restoring to helper function
- Doesn't make much sense now but we'll need this too shortly
2013-03-10 13:42:06 +02:00
Panu Matilainen b7cd81529a Lift db tag index unlink to helper function
- Doesn't make much sense now but we'll need it shortly.
2013-03-10 13:31:34 +02:00
Panu Matilainen 6f41046206 Use the per-db tag data for all accesses
- Bury dbiTags inside newRpmdb() to force everything to use per-db
  data to eliminate dependencies on globals.
2013-03-10 12:04:54 +02:00
Panu Matilainen 9419953df2 Use a non-open db handle for finding filenames in db move and remove
- Create a db handle without opening it for the purposes of figuring
  out which paths belong to us when moving and removing databases.
  Shouldn't change anything, just steps towards removing dependencies
  to global data.
2013-03-10 11:55:40 +02:00
Panu Matilainen cffe636b58 Remember dbi tags and their number in the rpmdb struct
- Not used for anything yet, just prerequisites for next steps
2013-03-10 11:28:21 +02:00
Panu Matilainen 8623a7cbff Refactor package and index handle opening to separate functions
- These differ a fair bit, so besides paving way for next steps
  this makes the code somewhat easier to follow.
- rpmdbOpenIndex() is now mostly just a dumb wrapper that can
  be eliminated later.
2013-03-09 19:03:46 +02:00
Panu Matilainen 9308c5118b Change db index open to return an error code and dbi through pointer
- Some places dont care about the actual dbi, in others this
  just makes things more simple, and this allows us to return
  more meaningful error codes than just success/fail.
- This shouldn't change anything, except for a couple of additional
  error checks but these should be "can't happen" cases.
2013-03-09 18:20:51 +02:00
Panu Matilainen b3b1e4bc80 Refactor package and index iterator creation to separate functions
- As it happens, these two cases have actually fairly little in common.
  Besides paving the way for next steps, this actually makes the code
  easier to follow.
2013-03-09 15:49:50 +02:00
Panu Matilainen ea3fa1513f Make sure /var exists created in the test-suite root
- Rpm installation only creates /var if configured in specific way,
  but the test-suite relies on /var being there. Ensure its always
  there regardless of how rpm was configured.
2013-03-06 14:45:36 +02:00
Panu Matilainen 9e918abb4c Sanitize the hardlink test size thing
- The previous "echo $0" got actually expanded to the temporary
  build-time script name, something like /var/tmp/rpm-tmp.UtGhG1,
  which isn't what we're interested in, and depends on rpm
  configuration so can easily cause false positives. Just use
  %{name}-%{version} to get stable content.
2013-03-06 14:36:02 +02:00
Panu Matilainen ec00b3f02e Force known _tmppath during test-suite non-chroot builds
- Rpm might be configure'd with a _tmppath that isn't writable
  or even existing on the build-host, force our testing tmp directory
  to be used for package builds which cannot be executed within the
  test-root.
- Fixes a few false positives in the test-suite by making it less
  reliant on the configuration of the built rpm and build host
2013-03-06 14:35:54 +02:00
Panu Matilainen 62e7394357 Avoid relying on filesystem macro values in test suite
- The test-suite expected results are hardcoded, so we can't rely
  on rpm-defined macros as those reflect rpm's own configuration
  which could be something entirely different than our expectations.
- Fixes another big pile of false positives in the test suite
2013-03-06 14:35:49 +02:00
Panu Matilainen ccd6281e69 Main macros needs similar sed-love on install as platform macros
- Autoconf leaves things like @localstatedir@ unexpanded at build-time
  on purpose so the paths can be overridden during "make install".
  However this leaves %{_var} in macros in its unexpanded state
  unless --localstatedir is explicitly passed in, which does not
  work very well for rpm.
- Process the main macros file through the same meat grinder as
  the platform macros. Ugly as sin but... it brings the casual
  "./configure; make; make check" sequence much closer to working.
2013-03-06 14:35:41 +02:00
Mark Wielaard 96bcbca9b1 tests: Make sure testing/usr/bin exists and to copy data from srcdir.
When srcdir != builddir the data has to be copied over from the srcdir.
When any of the required progs comes from /usr/bin then there also needs
to be a usr/bin under testing. Just use the same symlink as for testing/bin.

Signed-off-by: Panu Matilainen <pmatilai@redhat.com>
2013-03-06 10:31:09 +02:00
Mark Wielaard dd0ea43f14 Fixup find-requires linking for srcdir != builddir.
When configuring with srcdir != builddir the find-requires link would fail:
ln: failed to create symbolic link './autodeps/find-requires'

Do the link in the same way as find-provides with an explicit ${srcdir}.

Signed-off-by: Panu Matilainen <pmatilai@redhat.com>
2013-03-06 10:12:21 +02:00
Mark Wielaard 51dad76334 Require dbus >= 1.3 for DBUS_TYPE_UNIX_FD usage.
Signed-off-by: Panu Matilainen <pmatilai@redhat.com>
2013-03-05 22:02:36 +02:00
Panu Matilainen 0bb2442353 Unify gzdio error handling into a helper function 2013-03-05 15:00:41 +02:00
Panu Matilainen 547a004b7e Change fd stack to use linked, individualy alloced elements
- This actually makes the code a good deal simpler than the former
  "simple" array-based stack. Besides that, this moves things into
  direction where we could have properly opaque per io-type objects.
- Fclose() is still trickier than it should be due to statistics
  and whatnot...
2013-03-05 12:02:18 +02:00
Panu Matilainen 1fe1503370 Clean up lzopen_internal() error handling
- Return NULL instead of 0 on errors for readability
- xcalloc() cannot fail so there's no point checking for it
2013-03-05 09:58:03 +02:00
Panu Matilainen 8330a9ef6e Eliminate redundant lzma/xz helper functions
- These dont make the code any easier to follow, more on the contrary...
2013-03-05 09:56:50 +02:00
Panu Matilainen 40afde0324 Remove now reduntant path argument from lzopen_internal()
- This was "used" by lzdOpen() and xzdOpen(), only those were not
  actually used by anything so...
2013-03-05 09:53:34 +02:00
Panu Matilainen 05aba9df4c Eliminate broken and redundant error checks from io _fdopen() methods
- fd, fmode and fdno are already checked for in Fdopen(), no need
  to bother here. In addition, previously if the compressed open
  failed we probably leaked the fd as we had already set the underlying
  fdno to -1.
2013-03-05 09:33:49 +02:00
Panu Matilainen b9fab00acf Pass the low-level fdno to io type _fdopen() methods
- The fd number is what they really want in the first place,
  avoids having to do the same thing everywhere over and over
2013-03-05 09:20:29 +02:00
Panu Matilainen 05e16ab025 Io stack doesn't need the parent fd anymore 2013-03-05 09:11:40 +02:00
Panu Matilainen 872fce098a Sanitize compressed io close error handling
- The fd will be nuked on close anyway so there's nothing we can
  do to preserve possible custom errors from the compressed types.
  Just return return -1 on errors in case somebody cared.
2013-03-05 09:07:03 +02:00