[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

[PATCH] Don't delete cached packages with %posttrans



Given the following:

1) Anaconda removes packages from the cache after they are installed.
2) Anaconda runs package scripts by pulling them from the package files.
3) PreUpgrade works like an HTTP install where all the packages are
already cached.

Guess what happens when we try to run the %posttrans script in the
kernel RPM? Yep: we've deleted the kernel package, so then anaconda
prompts you to bring up the network so it can download it again to get
the script.

The attached patch *should* make anaconda skip package deletion *iff*
the package has a %posttrans script. Two caveats: 

1) I'm not sure where the cache lives during regular HTTP installs. If
it's in memory, we probably don't want to leave the kernel package
sitting in RAM for the rest of the install. So this patch might need to
be modified so the condition is:
  if flags.cmdline.has_key("preupgrade") and hdr[rpm.RPMTAG_POSTTRANS]:
but I'm not sure. 

2) I wish I could say I've tested this patch but I've botched three
attempts in the past three hours. I'm sending it to the list anyway, to
get some discussion and inspection and I'll try testing it again
tomorrow.

-w

(ps thanks for helping me figure this out, Jeremy)
diff --git a/yuminstall.py b/yuminstall.py
index 771f629..64f51f9 100644
--- a/yuminstall.py
+++ b/yuminstall.py
@@ -191,10 +191,13 @@ class AnacondaCallback:
 
             repo = self.repos.getRepo(self.inProgressPo.repoid)
             if os.path.dirname(fn).startswith("%s/var/cache/yum/" % self.rootPath):
-                try:
-                    os.unlink(fn)
-                except OSError, e:
-                    log.debug("unable to remove file %s" %(e,))
+                if hdr[rpm.RPMTAG_POSTTRANS]:
+                    log.debug("not deleting %s as we might need it for posttrans" %(fn,))
+                else:
+                    try:
+                        os.unlink(fn)
+                    except OSError, e:
+                        log.debug("unable to remove file %s" %(e,))
 
             self.donepkgs += 1
             self.doneSize += self.inProgressPo.returnSimple("installedsize") / 1024.0

Attachment: smime.p7s
Description: S/MIME cryptographic signature


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]