platform/upstream/rpm.git
12 years agoCorrectly quote tr [:blank:] in OCaml dependency scripts.
Richard W.M. Jones [Wed, 22 Feb 2012 11:46:16 +0000 (11:46 +0000)]
Correctly quote tr [:blank:] in OCaml dependency scripts.

This fixes: https://bugzilla.redhat.com/show_bug.cgi?id=796149

Signed-off-by: Panu Matilainen <pmatilai@redhat.com>
12 years agoExplicitly remap device numbers along with inodes at build
Panu Matilainen [Wed, 29 Feb 2012 09:04:25 +0000 (11:04 +0200)]
Explicitly remap device numbers along with inodes at build

- Buildroot cannot cross filesystem boundaries without evil tricks,
  which is what the fs boundary sanity check from commit
  7a9a5505667c681044bacb21c9b84ac66c062fe7 was intended to catch.
  However in the case of source rpms, spec and sources can legitimately
  reside on different filesystems (one case of this is rpmbuild -ts
  from cwd on different fs than the %_topdir) and needs to be permitted.
- Since we flatten the inodes to appear from a single filesystem,
  we need to also flatten the device numbers to match this. Turns
  out handling this is simpler than trying to prevent it :) Oh well...
  As we use the actual fs values for build-time hardlink discovery
  this should correctly handle hardlinks even if packaging crosses
  fs boundaries.
- Device number 1 which we use is probably equally bogus on all
  platforms, but this is irrelevant as the device and inode numbers
  are only used for hardlink discovery.

12 years agoOnly consider rpmdb growth for added packages
Panu Matilainen [Tue, 28 Feb 2012 13:22:32 +0000 (15:22 +0200)]
Only consider rpmdb growth for added packages

- Blargh, dumb thinko in previous commit: removed packages wont
  necessarily decrease the rpmdb size, but they dont increase it
  either.

12 years agoFix invalid memory access from rpmdb growth estimation (RhBug:766260)
Panu Matilainen [Tue, 28 Feb 2012 12:53:29 +0000 (14:53 +0200)]
Fix invalid memory access from rpmdb growth estimation (RhBug:766260)

- The dsi retrieved from rpmtsDbDSI() would become invalid whenever
  ts->dsi structure got realloced, ie anytime when disk space is
  calculated for a different fs than where the rpmdb resides. This
  is likely to be the real issue behind RhBug:766260 and also RhBug:671056.
  Just call rpmtsUpdateDSI() directly with suitable arguments for the
  rpmdb to avoid the special (re)alloc paths.
- In addition, consider the db growth for packages with no files too.

12 years agoDon't process spec %include in false branch of %if clauses (RhBug:782970)
Panu Matilainen [Tue, 28 Feb 2012 10:18:10 +0000 (12:18 +0200)]
Don't process spec %include in false branch of %if clauses (RhBug:782970)

12 years agoUnbreak rpm -V output (RhBug:797964)
Panu Matilainen [Tue, 28 Feb 2012 08:31:28 +0000 (10:31 +0200)]
Unbreak rpm -V output (RhBug:797964)

- Commit ac0ab016a5ec31e65eb0c0910a5a6f1199aae3e7 unintentionally
  changed the order of the problems shown in verify strings due to
  a dumb oversight (greetings to self, duh). In other words, this
  fixes a verify output regression in rpm >= 4.9.x by restoring
  the long-standing (and documented) order of the verify output chars.
- Also fix the testcase which unfortunately was only added after
  the output-changing commit so it didn't catch the breakage either :-/

12 years agoAdd a testcase for tag extension bad file name triplet detection
Panu Matilainen [Tue, 21 Feb 2012 14:51:08 +0000 (16:51 +0200)]
Add a testcase for tag extension bad file name triplet detection

12 years agoRaise exception in python on headerGet() invalid data failure
Panu Matilainen [Tue, 21 Feb 2012 14:49:51 +0000 (16:49 +0200)]
Raise exception in python on headerGet() invalid data failure

12 years agoTest for file data tag sanity in fnTag() extensions
Panu Matilainen [Tue, 21 Feb 2012 14:24:18 +0000 (16:24 +0200)]
Test for file data tag sanity in fnTag() extensions

- Basename and dirindex counts must be equal, dirnames count must be
  larger than zero and no larger than number of basenames. Check
  that directory indexes are within range. Additionally file states
  array size, if used, must equal to the genaral file count.

12 years agoFix crash on INSTFILENAMES extension on non-installed package
Panu Matilainen [Tue, 21 Feb 2012 13:59:34 +0000 (15:59 +0200)]
Fix crash on INSTFILENAMES extension on non-installed package

- Packages with no RPMTAG_FILESTATES cannot have installed files
  from our POV, just exit early in that case.
- Rerrange the exit path a bit and only call rpmtdFreeData() on
  file states if the corresponding headerGet() call was actually
  made. Wont make any difference yet, but once we have other jumps
  to exit it will.

12 years agoSanitize filename tag extension handling
Panu Matilainen [Tue, 21 Feb 2012 12:34:57 +0000 (14:34 +0200)]
Sanitize filename tag extension handling

- Rename rpmfiBuildFNames() to fnTag() and push all the td manipulation
  there, making all the various different fn-related tags differ by
  just the arguments to fnTag() and allowing central error etc
  handling. No functional changes (yet) though.

12 years agoFlag error in tag container for non-extension tag retrieval
Panu Matilainen [Tue, 21 Feb 2012 12:14:09 +0000 (14:14 +0200)]
Flag error in tag container for non-extension tag retrieval

- This should mostly be a can't happen case, but at least in theory
  region retrieval could fail. So could unknown data type, but a header
  with unknown data types shouldn't even load... Anyway, there could
  be further error cases we might be able to flag here.

12 years agoAdd error indicator flag for tag data containers
Panu Matilainen [Tue, 21 Feb 2012 11:52:18 +0000 (13:52 +0200)]
Add error indicator flag for tag data containers

- Tag retrieval can in some cases fail, especially so for tag
  extensions. The headerGet() interface doesn't directly allow
  distinguishing between non-existent tag and existent but invalid,
  but we can sneak in that information through in the tag data flags.

12 years agoAdd getter for rpmtd flags
Panu Matilainen [Tue, 21 Feb 2012 11:50:34 +0000 (13:50 +0200)]
Add getter for rpmtd flags

- While these are mostly of rpmtd-internal interest only, there are
  cases when caller might want to know...

12 years agoRemap inode numbers to fit into 32bit integer space on build (RhBug:714678)
Panu Matilainen [Fri, 10 Feb 2012 08:40:45 +0000 (10:40 +0200)]
Remap inode numbers to fit into 32bit integer space on build (RhBug:714678)

- 64bit inode numbers lose their uniquity when brutally truncated
  to 32bit integers as we've done so far. This can and will cause rpm
  (and cpio) to mix up arbitrary file entries as hardlinks and vice versa.
- As the only interesting aspect of inode numbers is whether they're
  equal to something else or not, we dont have to carry the "physical"
  on-disk value to preserve semantics. So we can just remap the
  inode numbers to something that fits our 32bit integer tags
  without causing compatibility complexies with older rpms and
  cpio (and since we can't handle more than INT32_MAX files in a package
  anyway, breaking compatibility for this would be just braindead dumb).
  An extremely simple way to achieve this is to use our
  build-time file list index as the basis of stored inode number.
- In theory this breaks inode-device pairing, but as the buildroot
  cannot span across filesystems in any remotely normal conditions,
  just add a sanity check to catch the dirty tricksters...
- Based on a patch by Zdenek Pavlas, just further simplified and
  buildroot fs boundary sanity check added.

12 years agoAlso test that total size is calculated correctly wrt hardlinks
Panu Matilainen [Thu, 9 Feb 2012 12:16:29 +0000 (14:16 +0200)]
Also test that total size is calculated correctly wrt hardlinks

12 years agoAdd a rough-cut testcase for hardlink handling
Panu Matilainen [Wed, 8 Feb 2012 15:45:34 +0000 (17:45 +0200)]
Add a rough-cut testcase for hardlink handling

- Check that we get expected number of links in package generation,
  that all the files got installed and that the linked files are
  actually hardlinks (for our purposes, plain inode suffices)

12 years agoAdd tag extension to calculate hardlink count for files
Panu Matilainen [Wed, 8 Feb 2012 13:40:02 +0000 (15:40 +0200)]
Add tag extension to calculate hardlink count for files

12 years agoSwitch back to former, much smaller BDB memory pool size (RhBug:752897)
Panu Matilainen [Wed, 8 Feb 2012 08:56:09 +0000 (10:56 +0200)]
Switch back to former, much smaller BDB memory pool size (RhBug:752897)

- A larger cache is beneficial in various scenarios, but triggers
  horrible worst-case performance under memory pressure (or so my
  current theory goes, there might be other factors too). The
  worst-case degration is orders of magnitude bigger than the best-case
  improvements from the larger cache and for many use-cases doesn't
  make a whole lot difference.  We could/should tune the cache with
  priorizing indexes and all, and perhaps dynamically select the
  cache size but for now, the 1Mb cache size is known to "just work".

12 years agoAdd --test option to rpmkeys
Panu Matilainen [Fri, 3 Feb 2012 10:46:22 +0000 (12:46 +0200)]
Add --test option to rpmkeys

- Allows, well, testing whether a key could be imported before actually
  doing it

12 years agoHonor RPMTRANS_FLAG_TEST in rpmtsImportPubkey()
Panu Matilainen [Fri, 3 Feb 2012 10:23:31 +0000 (12:23 +0200)]
Honor RPMTRANS_FLAG_TEST in rpmtsImportPubkey()

12 years agoRemove the arbitrary limitation on transaction keyring change
Panu Matilainen [Thu, 2 Feb 2012 17:13:03 +0000 (19:13 +0200)]
Remove the arbitrary limitation on transaction keyring change

- There are some situations where switching keyrings might be wanted,
  especially as long as we dont export a way to pass keyring as
  an argument to package reading/verification functions. Since thereäs
  no technical reason to disallow it, might as well allow it...

12 years agoDisable signature checking during database rebuild by default
Panu Matilainen [Thu, 2 Feb 2012 12:36:41 +0000 (14:36 +0200)]
Disable signature checking during database rebuild by default

- While it would be perfectly reasonable to perform signature
  checking during db rebuild, this is problematic as long as our
  keys live in the same database we're rebuilding: the environment
  might be paniced, the indexes required for key lookups might be
  corrupt or non-existent etc - one would assume there's a reason for
  the db is getting rebuilt in the first place. When signature checking
  is enabled, we're forced to generate missing indexes on the potentially
  borked database we're just about to rebuild, which might not go very
  well, and since they keyring loading has no clue its getting called
  from middle of db rebuild it'll try to use a shared environment
  which might be broken ... etc.

12 years agoUse private environment for database rebuilds too, document
Panu Matilainen [Thu, 2 Feb 2012 12:31:17 +0000 (14:31 +0200)]
Use private environment for database rebuilds too, document

- One of the more common reasons for users to do --rebuilddb is
  a paniced environment. Throwing DB_RUNRECOVER errors at the user
  who is trying to recover by rebuilding the db isn't terribly
  productive (RhBug:590710). Use a private environment while
  rebuilding for both the original and new database, and dont bother
  with CDB which only slows things down when there are no other
  players present.
- Verify wants the same flags but for different reasons...

12 years agoNever load ts keyring if signature checking is disabled
Panu Matilainen [Thu, 2 Feb 2012 11:53:38 +0000 (13:53 +0200)]
Never load ts keyring if signature checking is disabled

- Loading the pubkeys from database numerous often unwanted side-effects,
  if signature checking is disabled then there's no point loading
  the keys either.
- Commit cad147070e5513312d851f44998012e8f0cdf1e3 did this for
  rpmReadPackageFile() specifically but we really want it honored
  for all operations including headerCheck() and friends, handle
  it centrally in loadKeys() for simplicity.

12 years agoDon't free up file info sets on transaction test-runs
Panu Matilainen [Wed, 1 Feb 2012 15:48:20 +0000 (17:48 +0200)]
Don't free up file info sets on transaction test-runs

- We'd like to get rid of the potentially huge amounts of memory
  eaten by file info sets as early as possible, but when there's a
  chance that we'll get called again with either added transacation
  elements or on-disk changes, such as %pretrans changing something
  underneath us, we need to (be able to) recalculate everything
  from scratch. Only free up the memory when we know we dont need
  it anymore, ie on an actual transaction run.
- This doesn't change anything for rpm itself, for yum and others
  which do a separate test-transaction first, it means %pretrans
  directory<->symlink replacement hacks and the like have a chance
  of working again. I'm sure there's a bug filed on this somewhere but...

12 years agoUse rpmReadHeader() on signature checking path too
Panu Matilainen [Mon, 30 Jan 2012 08:23:51 +0000 (10:23 +0200)]
Use rpmReadHeader() on signature checking path too

- rpmReadHeader() performs far more initial sanity checks on the header
  than headerRead() does, and makes behavior consistent with eg query
  and install paths. As an added bonus we'll get more detailed
  error messages too.

12 years agoAdd a basic testcase for bogus filename triplet detection
Panu Matilainen [Sat, 28 Jan 2012 16:03:42 +0000 (18:03 +0200)]
Add a basic testcase for bogus filename triplet detection

12 years agoTest for filename triplet sanity in rpmfiNew()
Panu Matilainen [Sat, 28 Jan 2012 15:53:11 +0000 (17:53 +0200)]
Test for filename triplet sanity in rpmfiNew()

- Basename and dirindex counts must be equal, dirnames count must be
  larger than zero and no larger than number of basenames. Check
  that directory indexes are within range.
- There are mountains of further checks to be added here (and elsewhere)
  but we gotta start somewhere... and filename triplets are one of the more
  critical elements we got.

12 years agoxcalloc() cannot return NULL, remove redundant check
Panu Matilainen [Sat, 28 Jan 2012 15:23:16 +0000 (17:23 +0200)]
xcalloc() cannot return NULL, remove redundant check

12 years agoDon't assume rpmfiNew() always succeeds
Panu Matilainen [Sat, 28 Jan 2012 15:07:42 +0000 (17:07 +0200)]
Don't assume rpmfiNew() always succeeds

- Add NULL checks and add/adjust comments where appropriate.
- The remaining callers should handle NULL fi gracefully if not
  entirely correctly: rpmfiFC() returns 0 on NULL fi, so these
  callers just see the erronous file info set as "no files" case.
  Something to fine-tune later...

12 years agoAdd a basic testcase for bogus (incomplete) header detection
Panu Matilainen [Sat, 28 Jan 2012 13:54:40 +0000 (15:54 +0200)]
Add a basic testcase for bogus (incomplete) header detection

12 years agoAdd some basic sanity checks to rpmte creation, allow rpmteNew() to fail
Panu Matilainen [Sat, 28 Jan 2012 13:20:48 +0000 (15:20 +0200)]
Add some basic sanity checks to rpmte creation, allow rpmteNew() to fail

- Verify that a header at least has the very basic elements like
  name, version, release, os and arch (except for gpg-pubkeys which
  dont have the latter two, sigh), fail if not.
- rpmfiNew() cannot currently fail but handling this error will allow
  sanity checking the file metadata which can be inconsistent even if
  a header is "physically" consistent.
- We'll eventually want to have sanity checks on dependency sets too, but
  unlike rpmfiNew(), rpmdsNew() currently returns NULL for non-existent
  dependencies (eg most packages do not have conflicts or obsoletes) to
  save memory. Either that needs to change or we'll need to check
  for tag existence for the meaning of a returned NULL here.

12 years agoDon't assume rpmteNew() always succeeds, part III
Panu Matilainen [Sat, 28 Jan 2012 13:17:02 +0000 (15:17 +0200)]
Don't assume rpmteNew() always succeeds, part III

- Return error from verifyscript if rpmteNew() fails. This can't
  currently happen but handling this error makes it possible to
  do sanity checks on the header contents, such as file list integrity etc.
  Unlikely to occur for installed packages, but verify can be run
  on non-installed packages as well, where failure is more of a possibility.

12 years agoMove TR_ADDED file size init into addTE()
Panu Matilainen [Sat, 28 Jan 2012 12:50:16 +0000 (14:50 +0200)]
Move TR_ADDED file size init into addTE()

- No functional changes, just stuffing it there along with most
  other rpmte init work and remove the pointless switch-case while at it

12 years agoDon't assume rpmteNew() always succeeds, part II
Panu Matilainen [Sat, 28 Jan 2012 12:18:35 +0000 (14:18 +0200)]
Don't assume rpmteNew() always succeeds, part II

- Return error from rpmtsAddInstallElement() if rpmteNew() fails. This
  can't currently happen, but handling this error makes it possible
  to do sanity checks on the header contents, such as file list integrity.

12 years agoError out early if rpmdb open fails on upgrade element addition
Panu Matilainen [Sat, 28 Jan 2012 12:11:08 +0000 (14:11 +0200)]
Error out early if rpmdb open fails on upgrade element addition

- If we can't open the rpmdb then we cannot correctly process the
  upgrade, error out early. Mostly a "can't happen" case though.
  Also makes the logic a bit clearer, hopefully.

12 years agoDon't assume rpmteNew() always succeeds, part I
Panu Matilainen [Sat, 28 Jan 2012 11:18:53 +0000 (13:18 +0200)]
Don't assume rpmteNew() always succeeds, part I

- Return error from removePackage() if rpmteNew() fails. This can't
  currently happen and is unlikely anyway on already installed
  packages (this is more interesting for added packages) but
  just in case...
- Handling failure from upgrade- and obsoletes erasures is trickier
  both can add any number of erasure elements, and if one of them
  fails we'd need to undo all the erasures caused by this element.
  Just add a reminder comment for now.

12 years agoAxe unused cruft
Panu Matilainen [Tue, 17 Jan 2012 11:17:31 +0000 (13:17 +0200)]
Axe unused cruft

12 years agoKill off yet more repackage remnants from fsm
Panu Matilainen [Tue, 17 Jan 2012 10:50:51 +0000 (12:50 +0200)]
Kill off yet more repackage remnants from fsm

- CPIO_ALL_HARDLINKS flag and related code has been unused and dead
  since rpm >= 4.6.x

12 years agoLift hard-link payload writing to helper function, fsmStage is big enough
Panu Matilainen [Tue, 17 Jan 2012 10:33:26 +0000 (12:33 +0200)]
Lift hard-link payload writing to helper function, fsmStage is big enough

12 years agoEliminate FSM_WOPEN, FSM_WRITE and FSM_WCLOSE stages
Panu Matilainen [Tue, 17 Jan 2012 09:03:27 +0000 (11:03 +0200)]
Eliminate FSM_WOPEN, FSM_WRITE and FSM_WCLOSE stages

- These are nothing but unnecessarily specialized Fopen(), Fwrite() and
  Fclose() for what is a purely local need in expandRegular(). Move
  the local stuff where it belongs.

12 years agoEliminate FSM_ROPEN, FSM_READ and FSM_RCLOSE stages
Panu Matilainen [Tue, 17 Jan 2012 08:52:46 +0000 (10:52 +0200)]
Eliminate FSM_ROPEN, FSM_READ and FSM_RCLOSE stages

- These are nothing but unnecessarily specialized Fopen(), Fread() and
  Fclose() for what is a purely local need in writeFile(). Move
  the local stuff where it belongs.

12 years agoEliminate file digest related members from fsm struct
Panu Matilainen [Tue, 17 Jan 2012 07:01:38 +0000 (09:01 +0200)]
Eliminate file digest related members from fsm struct

- Both digest algo and the current file digest from header are
  only needed inside expandRegular(), push the stuff down there.

12 years agoEliminate the now obviously unnecessary opath member from fsm struct
Panu Matilainen [Mon, 16 Jan 2012 12:35:37 +0000 (14:35 +0200)]
Eliminate the now obviously unnecessary opath member from fsm struct

12 years agoAvoid fsm->opath usage for symlink target
Panu Matilainen [Mon, 16 Jan 2012 12:30:40 +0000 (14:30 +0200)]
Avoid fsm->opath usage for symlink target

- Instead of behind-the-scenes pointer updating, use fsm->wrbuf
  explicitly for the link target. Doesn't make it less hackish
  but at least it now stands out.

12 years agoAvoid fsm->opath usage in fsmMakeLinks()
Panu Matilainen [Mon, 16 Jan 2012 12:17:35 +0000 (14:17 +0200)]
Avoid fsm->opath usage in fsmMakeLinks()

- opath is the file that links will be made to, we grab it at the
  start and free at the end. No need to save and restore what we
  dont modify, one more fsm->opath usage down...

12 years agoRemove unused FSM_MKLINKS stage
Panu Matilainen [Mon, 16 Jan 2012 12:13:38 +0000 (14:13 +0200)]
Remove unused FSM_MKLINKS stage

12 years agoAvoid fsm->opath usage in final file rename
Panu Matilainen [Mon, 16 Jan 2012 11:58:51 +0000 (13:58 +0200)]
Avoid fsm->opath usage in final file rename

- Hopefully this makes the actual operation stand out more clearly
  with the unnecessary fsm->opath fiddling out of the picture,
  other than that there's not much to gain here.

12 years agoEliminate unnecessary fsm->path/opath shuffle on unlink
Panu Matilainen [Mon, 16 Jan 2012 11:15:09 +0000 (13:15 +0200)]
Eliminate unnecessary fsm->path/opath shuffle on unlink

- No need to save and restore what we dont modify...
- Add comments to double-check later for couple of fishy looking bits

12 years agoEliminate unnecessary fsm->path/opath shuffle on backup renaming
Panu Matilainen [Mon, 16 Jan 2012 10:28:52 +0000 (12:28 +0200)]
Eliminate unnecessary fsm->path/opath shuffle on backup renaming

- Makes the code much more obvious to follow since we're not swapping
  path/opath back and forwards just to be able to use a throwaway
  path for the rename. Dont bother null-checking on logging,
  if one of the paths was null we'd be dead already.
- Also fixes an ancient memleak: when osuffix is in use, fsm->path
  gets newly malloced before fsmVerify() but this part did another
  allocation on it, didn't save and restore fsm->path .. and nothing
  was freeing the original (local) allocation of fsm->path, only
  restoring the previous value.

12 years agoEliminate unnecessary st_mode save-modify-restore on dir creation
Panu Matilainen [Mon, 16 Jan 2012 09:40:37 +0000 (11:40 +0200)]
Eliminate unnecessary st_mode save-modify-restore on dir creation

12 years agoEliminate unnecessary save-modify-restore around fsmUtime()
Panu Matilainen [Mon, 16 Jan 2012 09:31:02 +0000 (11:31 +0200)]
Eliminate unnecessary save-modify-restore around fsmUtime()

12 years agoEliminate unnecessary save-modify-restore on fifo creation
Panu Matilainen [Mon, 16 Jan 2012 09:27:49 +0000 (11:27 +0200)]
Eliminate unnecessary save-modify-restore on fifo creation

12 years agoMove symlink() to separate helper function
Panu Matilainen [Fri, 13 Jan 2012 16:15:30 +0000 (18:15 +0200)]
Move symlink() to separate helper function

- Similar to mkfifo(), mknod() & friends, doesn't do much but for
  consistency and fsmStage() size sanity...

12 years agoEliminate stupid fsm->path/opath in FSM_COMMIT now that we can
Panu Matilainen [Fri, 13 Jan 2012 16:05:44 +0000 (18:05 +0200)]
Eliminate stupid fsm->path/opath in FSM_COMMIT now that we can

- Now that we can directly operate on temporarily variables instead
  of having to save-ping-restore-pong them, lets do so...
- Also eliminating NULL-checks on the path variables in logging - if
  either of the paths were NULL we would've already crashed in rename()

12 years agoBlarg, stupid stupid mistake breaking symlink handling
Panu Matilainen [Fri, 13 Jan 2012 15:54:23 +0000 (17:54 +0200)]
Blarg, stupid stupid mistake breaking symlink handling

- Introduced in commit d15bf56a70fdc2322a8d71f255241c20d895834f and
  uncaught prior to push as none of the test-suite cases involve
  symlinks. This is what happens when trying to quickly rewrite
  git history to put combine a forgotten change into earlier ones,
  guilty as charged :(

12 years agoOnly pass what little is actually needed in fsmMkdirs()
Panu Matilainen [Fri, 13 Jan 2012 15:02:23 +0000 (17:02 +0200)]
Only pass what little is actually needed in fsmMkdirs()

- Once all the other cruft has been carved out, turns out this needs
  nothing but a directory iterator which we can init and free
  in the caller easily enough, and selabel handle (duh). All the
  rest is independent of fsm internals in reality.

12 years agoEliminate stupid fsm->sb.st_mode abuse from fsmMkdirs()
Panu Matilainen [Fri, 13 Jan 2012 14:47:02 +0000 (16:47 +0200)]
Eliminate stupid fsm->sb.st_mode abuse from fsmMkdirs()

- At the point where this runs there's probably nothing at all to
  save and restore in the stat buf anyway, but it's just stupid to
  abuse that when all we need is a local mode_t temp variable. Fix
  it now that we can.

12 years agoMove mknod() to separate helper function
Panu Matilainen [Fri, 13 Jan 2012 14:39:55 +0000 (16:39 +0200)]
Move mknod() to separate helper function

- Similar to mknod() and all, this doesn't do anything that special
  but fsmStage() is big enough as it is.

12 years agoMove mkfifo() to separate helper function
Panu Matilainen [Fri, 13 Jan 2012 14:34:47 +0000 (16:34 +0200)]
Move mkfifo() to separate helper function

- Similar to the other fsm syscall wrappers, this doesn't do anything
  that special, but fsmStage() is big enough without things like
  this inline.

12 years agoChange fsmReadLink() to take "normal" arguments
Panu Matilainen [Fri, 13 Jan 2012 14:21:11 +0000 (16:21 +0200)]
Change fsmReadLink() to take "normal" arguments

- This doesn't need access to the entire fsm, it just needs a buffer
  to place the results in / return errors. Currently the "out" buffer
  is (ab)used for the results, this just forces that to stand out
  and should make it easier to sanitize later.

12 years agoChange fsmUtime() to take "normal" arguments
Panu Matilainen [Fri, 13 Jan 2012 13:23:23 +0000 (15:23 +0200)]
Change fsmUtime() to take "normal" arguments

- This doesn't need access to the entire fsm, just path and mtime
  from coming from a header originally. Will allow eliminating
  save -> abuse -> restore behavior in caller but leaving till later...

12 years agoChange fsmChown(), fsmLChown() and fsmChmod() to take "normal" arguments
Panu Matilainen [Fri, 13 Jan 2012 13:14:24 +0000 (15:14 +0200)]
Change fsmChown(), fsmLChown() and fsmChmod() to take "normal" arguments

- None of these needs access to the entire fsm, they only
  exist to map and filter errors to rpm special needs and to
  create debug swew on top of the plain syscalls.

12 years agoChange fsmMkdir() to take "normal" arguments
Panu Matilainen [Fri, 13 Jan 2012 13:06:06 +0000 (15:06 +0200)]
Change fsmMkdir() to take "normal" arguments

- This doesn't need access to the entire fsm, it only exists to
  map errors to CPIOERR_* and create debug foo. This will allow
  eliminating save -> abuse -> restore behavior in callers, but
  leaving that till later.

12 years agoChange fsmStat() to take "normal" arguments
Panu Matilainen [Fri, 13 Jan 2012 12:47:19 +0000 (14:47 +0200)]
Change fsmStat() to take "normal" arguments

- This doesn't need access to the entire fsm, just regular stat()
  args and a flag whether to use lstat() or stat(). "followlinks"
  or such would be saner name for the flag but leaving that for now...

12 years agoChange fsmRename() to take "normal" arguments
Panu Matilainen [Fri, 13 Jan 2012 11:01:24 +0000 (13:01 +0200)]
Change fsmRename() to take "normal" arguments

- This doesn't need access to the entire fsm, just regular rename()
  args and a flags to see whether "secure" delete should be done.
  In itself this only looks like more trouble, but all the callers
  are fiddling and saving and restoring with fsm->[o]path just
  to call this, which we can now avoid. Leaving sanitizing the
  callers till later though, this is a minefield...

12 years agoChange fsmUnlink() and fsmRmdir() to take "normal" arguments
Panu Matilainen [Fri, 13 Jan 2012 10:36:01 +0000 (12:36 +0200)]
Change fsmUnlink() and fsmRmdir() to take "normal" arguments

- Neither of these needs access to the entire fsm, they mostly
  exist to create debug cruft and to map errors to CPIOERR_*

12 years agoSanitize file capability setting in fsm
Panu Matilainen [Fri, 13 Jan 2012 09:36:28 +0000 (11:36 +0200)]
Sanitize file capability setting in fsm

- Move parsing, setting and freeing of capabilities into simple
  helper function, there's no point whatsoever having the current
  capability stored in fsm when it only complicates freeing and all.
  WTH was I thinking when implementing this? (well, everything in
  fsm was done that way so...  but that's a lame excuse)

12 years agoSanitize selinux labeling in fsm
Panu Matilainen [Fri, 13 Jan 2012 09:08:47 +0000 (11:08 +0200)]
Sanitize selinux labeling in fsm

- Move all the label foobar into a simple helper function which
  finds, sets and frees the context if selinux is enabled, use
  for both regular operation and orphan directory labeling.
  Simplifies things a good deal...
- While the selabel handle can change during a transaction, it
  wont change while the fsm is running so its sufficient to grab
  it on entry instead of repeatedly calling rpmtsSELabelHandle() after
  figuring out where in the world our ts might be.

12 years agoEliminate unused subdir member from fsm struct
Panu Matilainen [Fri, 13 Jan 2012 08:27:11 +0000 (10:27 +0200)]
Eliminate unused subdir member from fsm struct

12 years agoEliminate silly sufbuf from fsm struct
Panu Matilainen [Fri, 13 Jan 2012 08:19:50 +0000 (10:19 +0200)]
Eliminate silly sufbuf from fsm struct

- Allocate fsm->suffix directly when suffix is needed instead.
  Doesn't change anything, only makes life that little bit simpler.

12 years agoEnsure installs always use a temp suffix on files
Panu Matilainen [Fri, 13 Jan 2012 08:06:09 +0000 (10:06 +0200)]
Ensure installs always use a temp suffix on files

- This bogosity goes back to commit fcf6b50378eaeac4c1f7ca215b33586b4d41072f
  which was supposed to fix files getting erased if time() returns
  errors (RhBug:223931). Problem is, this "fix" didn't fix anything
  at all as the suffix still wouldn't be created in the error
  case, even if the FSM_UNDO part did the right thing. We always
  want a suffix on installs, it doesn't matter *what* the suffix is.

12 years agoRemove unused "orphan" directory creation tracking variable from fsm
Panu Matilainen [Fri, 13 Jan 2012 07:41:25 +0000 (09:41 +0200)]
Remove unused "orphan" directory creation tracking variable from fsm

12 years agoMove directory tracking variables out of fsm struct to local scope
Panu Matilainen [Fri, 13 Jan 2012 07:30:06 +0000 (09:30 +0200)]
Move directory tracking variables out of fsm struct to local scope

- These are not used or needed outside fsmMkdirs() so its just
  plain dumb to have them in the big struct. No functional changes,
  just taming the fsm monster a little bit.

12 years agoAdd bunch of links to test-suite chroot to allow selinux to work
Panu Matilainen [Fri, 13 Jan 2012 05:54:51 +0000 (07:54 +0200)]
Add bunch of links to test-suite chroot to allow selinux to work

- With the new warning on failure to open selinux labels from
  commit 7a8b75d26605cf7a3fde9f624a80d6fb8390fcbd, the test-suite
  fails on large number of tests due to the extra output. This
  takes care of these false alarms on F16 at least.
- Recent selinux wants /etc/selinux and /sys (for /sys/fs/selinux),
  older ones would want /selinux. Add in /proc for good measure,
  selinux doesn't need it butit wont hurt either, other things will
  want it sooner or later.

12 years agoremove the 'path' parameter of rpmtsSELabelInit()
Ales Kozumplik [Thu, 22 Dec 2011 13:53:51 +0000 (14:53 +0100)]
remove the 'path' parameter of rpmtsSELabelInit()

- It is always selinux_file_context_path() anyway.

12 years agoselinux: reopen label between transactions if necessary (RhBug: 746073)
Ales Kozumplik [Thu, 22 Dec 2011 13:34:03 +0000 (14:34 +0100)]
selinux: reopen label between transactions if necessary (RhBug: 746073)

12 years agoShow arch in --last output too (RhBug:768516)
Panu Matilainen [Thu, 12 Jan 2012 07:52:34 +0000 (09:52 +0200)]
Show arch in --last output too (RhBug:768516)

12 years agoEliminate now unnecessary runFsm() helper from psm
Panu Matilainen [Wed, 11 Jan 2012 13:35:16 +0000 (15:35 +0200)]
Eliminate now unnecessary runFsm() helper from psm

12 years agoEliminate no longer needed RPMFI_ISBUILD and RPMFI_ISSOURCE internal flags
Panu Matilainen [Wed, 11 Jan 2012 13:30:50 +0000 (15:30 +0200)]
Eliminate no longer needed RPMFI_ISBUILD and RPMFI_ISSOURCE internal flags

12 years agoTurn FSM into a blackbox, much like PSM is
Panu Matilainen [Wed, 11 Jan 2012 13:11:37 +0000 (15:11 +0200)]
Turn FSM into a blackbox, much like PSM is

- Similar in spirit to PSM blackbox treatment in
  commit df9cdb1321ada8e3b120771f91a2eefab4ac2ad5, 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.

12 years agoEliminate archiveSize member from rpmfi
Panu Matilainen [Wed, 11 Jan 2012 10:17:31 +0000 (12:17 +0200)]
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...

12 years agoExplicitly tell rpmfiNew() when its being used for build
Panu Matilainen [Wed, 11 Jan 2012 10:16:53 +0000 (12:16 +0200)]
Explicitly tell rpmfiNew() when its being used for build

- Eliminate feeble heuristic on archive size tag not being set during
  build for detecting this and have build code explicitly pass
  RPMFI_ISBUILD flag instead.
- Also eliminate the pointless isSource variable from rpmfiNew() while.

12 years agoIssue package install/erase progress callbacks on justdb operation too
Panu Matilainen [Wed, 11 Jan 2012 09:06:16 +0000 (11:06 +0200)]
Issue package install/erase progress callbacks on justdb operation too

- Large --justdb operations can take considerable amount of time as well,
  getting progress bars for it is nice even if hardly necessary...

12 years agoEliminate fluff from PSM_INIT
Panu Matilainen [Wed, 11 Jan 2012 08:47:28 +0000 (10:47 +0200)]
Eliminate fluff from PSM_INIT

- rpmpsmStage() runs with RPMRC_OK as assumed result, no need to
  set explicitly here.
- Dont bother testing for justdb flag here. The justdb case doesn't
  need fi->apath but it doesn't exactly hurt either, and we'll want
  to eliminate the apath kludge sooner or later anyway.

12 years agoUpdate translations & sync with transifex
Panu Matilainen [Wed, 11 Jan 2012 07:07:05 +0000 (09:07 +0200)]
Update translations & sync with transifex

12 years agoOops, forgot to mark our new progress messages for translation
Panu Matilainen [Tue, 10 Jan 2012 18:26:55 +0000 (20:26 +0200)]
Oops, forgot to mark our new progress messages for translation

12 years agoAdapt perl and python fileattrs to file 5.10 magics
Ville Skyttä [Tue, 10 Jan 2012 08:48:13 +0000 (10:48 +0200)]
Adapt perl and python fileattrs to file 5.10 magics

- file 5.10 has changed magics at least for perl and python scripts, samples:

  5.09: a /usr/bin/perl -w script, ASCII text executable, with very long lines
  5.10: Perl script, ASCII text executable, with very long lines

  5.09: a /usr/bin/python script, ASCII text executable
  5.10: Python script, ASCII text executable

Signed-off-by: Panu Matilainen <pmatilai@redhat.com>
12 years agoTransaction element parent is a transaction element, not an integer
Panu Matilainen [Tue, 10 Jan 2012 08:38:31 +0000 (10:38 +0200)]
Transaction element parent is a transaction element, not an integer

- Ehm, this has been broken in the python bindings since the start,
  nobody noticed. Of course the parent value isn't particularly
  useful in normal usage but still...

12 years agoMinor cleanup to rpmte_Key()
Panu Matilainen [Tue, 10 Jan 2012 08:35:30 +0000 (10:35 +0200)]
Minor cleanup to rpmte_Key()

- Fix misleading indentation, initialize Key on declaration.
  No functional changes.

12 years agoAnd finally, permit --hash and --percent cli-switches on erasures too
Panu Matilainen [Thu, 5 Jan 2012 14:23:17 +0000 (16:23 +0200)]
And finally, permit --hash and --percent cli-switches on erasures too

12 years agoAdd erasure callback support to rpmShowProgress() and enable on rpmErase()
Panu Matilainen [Thu, 5 Jan 2012 14:17:33 +0000 (16:17 +0200)]
Add erasure callback support to rpmShowProgress() and enable on rpmErase()

- Just use the same bits as install does, they behave the same for
  our purposes. On upgrades the output would get confusing especially
  with --hash when package versions aren't output'ed, so we print
  out extra output when entering install and erase stages. Only
  do this when --hash is used (ie a human is probably watching us)
  to hopefully avoid breaking scripts (including our test-suite) that
  rely on the ages old behavior of non-hashed output.

12 years agoIssue actual erasure progress callbacks too
Panu Matilainen [Thu, 5 Jan 2012 13:18:28 +0000 (15:18 +0200)]
Issue actual erasure progress callbacks too

- Whereas on install the progress is measured by bytes written to
  disk vs total archive size, on erase the best we can do is
  going by the number of files in the package. Fsm iterates backwards
  on erase so we can't just use fsm->ix but need to re-revert the value.

12 years agoClean up progress callbacks in fsm/psm machinery
Panu Matilainen [Thu, 5 Jan 2012 12:48:22 +0000 (14:48 +0200)]
Clean up progress callbacks in fsm/psm machinery

- Move notifications from fsm to psm side for sanity and symmetry,
  psm already has members to hold the callback state.
- Replace PSM_NOTIFY "state" with a helper function that both
  fsm and psm itself use (except for error callbacks which are
  a bit different)
- Init psm->total early, this doesn't change and can now be
  used to refer to "all done" value whatever it happens to be,
  instead of magic "100" values etc.
- Packages with no files are now handled through the same path
  as everything else from progress reporting pov, we just skip calls
  to fsm if there are no files.
- Issue stop callbacks for install as well. While INST_CLOSE_FILE
  can be (and is currently) used to detect this condition, its
  conceptually an entirely different thing.
- Fix erasure callback parameters, they were reversed (starting from
  total and ending with 0, ehh...)

12 years agoAdd enum for RPMCALLBACK_INST_STOP callback event
Panu Matilainen [Thu, 5 Jan 2012 12:34:46 +0000 (14:34 +0200)]
Add enum for RPMCALLBACK_INST_STOP callback event

- Unused atm but we'll be adding this shortly

12 years agoPass and remember the controlling psm (if any) in fsm
Panu Matilainen [Thu, 5 Jan 2012 12:24:33 +0000 (14:24 +0200)]
Pass and remember the controlling psm (if any) in fsm

12 years agoEliminate repackage notification remnants from fsm
Panu Matilainen [Wed, 4 Jan 2012 10:01:11 +0000 (12:01 +0200)]
Eliminate repackage notification remnants from fsm

- This has been unused and dead code since rpm >= 4.6.0

12 years agoUse rpmtsNotify() directly for psm error callbacks
Panu Matilainen [Wed, 4 Jan 2012 09:31:00 +0000 (11:31 +0200)]
Use rpmtsNotify() directly for psm error callbacks

- On error we're already on our way out of the psm, no point mucking
  with the psm state. No functional changes, just makes the code
  a little bit shorter.

12 years agodocument -D and -E in man.
Ales Kozumplik [Wed, 4 Jan 2012 15:47:04 +0000 (16:47 +0100)]
document -D and -E in man.