summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorDenys Vlasenko <dvlasenk@redhat.com>2011-05-19 11:57:09 +0200
committerDenys Vlasenko <dvlasenk@redhat.com>2011-05-19 11:57:09 +0200
commit3ca62f220eeb8c84a5536333117694d1c5a4fa0f (patch)
tree73e88f5bab63ca2f6d2062c9c26a75bac59925a7 /src
parent1edb8cb72e7fe7912b94c12d35ea0d5a1a4bb86c (diff)
downloadabrt-3ca62f220eeb8c84a5536333117694d1c5a4fa0f.tar.gz
abrt-3ca62f220eeb8c84a5536333117694d1c5a4fa0f.tar.xz
abrt-3ca62f220eeb8c84a5536333117694d1c5a4fa0f.zip
abrt-action-install-debuginfo: fix for download error
Signed-off-by: Denys Vlasenko <dvlasenk@redhat.com>
Diffstat (limited to 'src')
-rw-r--r--src/plugins/abrt-action-install-debuginfo35
1 files changed, 20 insertions, 15 deletions
diff --git a/src/plugins/abrt-action-install-debuginfo b/src/plugins/abrt-action-install-debuginfo
index 75079ff9..2ad0790a 100644
--- a/src/plugins/abrt-action-install-debuginfo
+++ b/src/plugins/abrt-action-install-debuginfo
@@ -93,9 +93,8 @@ def ask_yes_no(prompt, retries=4):
# TODO: unpack just required debuginfo and not entire rpm?
# ..that can lead to: foo.c No such file and directory
# files is not used...
-def unpack_rpm(package_nevra, files, tmp_dir, destdir, keeprpm):
- package_name = package_nevra + ".rpm"
- package_full_path = tmp_dir + "/" + package_name
+def unpack_rpm(package_file_name, files, tmp_dir, destdir, keeprpm):
+ package_full_path = tmp_dir + "/" + package_file_name
log1("Extracting %s to %s", package_full_path, destdir)
log2("%s", files)
print _("Extracting cpio from %s") % (package_full_path)
@@ -125,7 +124,7 @@ def unpack_rpm(package_nevra, files, tmp_dir, destdir, keeprpm):
# and open it for reading
unpacked_cpio = open(unpacked_cpio_path, 'rb')
- print _("Caching files from %s made from %s") % ("unpacked.cpio", package_name)
+ print _("Caching files from %s made from %s") % ("unpacked.cpio", package_file_name)
cpio = Popen(["cpio", "-idu", "--quiet"],
stdin=unpacked_cpio, cwd=destdir, bufsize=-1)
retcode = cpio.wait()
@@ -309,17 +308,21 @@ class DebugInfoDownload(YumBase):
os.makedirs(self.cachedir)
local = os.path.join(self.tmpdir, local)
pkg.localpath = local # Hack: to set the localpath we want
- ret = self.downloadPkgs(pkglist=[pkg])
- # downloadPkgs return an non empty list on succes
- if ret:
+ err = self.downloadPkgs(pkglist=[pkg])
+ # normalize the name
+ # just str(pkg) doesn't work because it can have epoch
+ pkg_nvra = pkg.name + "-" + pkg.version + "-" + pkg.release + "." + pkg.arch
+ package_file_name = pkg_nvra + ".rpm"
+ if err:
+ # I observed a zero-length file left on error,
+ # which prevents cleanup later. Fix it:
+ try:
+ os.unlink(self.tmpdir + "/" + package_file_name)
+ except:
+ pass
print (_("Downloading package %s failed") % pkg)
else:
- # normalize the name
- # just str(pkg) doesn't work because it can have epoch
- pkg_nvra = (pkg.name + "-" + pkg.version + "-" +
- pkg.release + "." + pkg.arch)
-
- unpack_result = unpack_rpm(pkg_nvra, files, self.tmpdir,
+ unpack_result = unpack_rpm(package_file_name, files, self.tmpdir,
self.cachedir, keeprpms)
if unpack_result == RETURN_FAILURE:
# recursively delete the temp dir on failure
@@ -330,8 +333,10 @@ class DebugInfoDownload(YumBase):
downloaded_pkgs += 1
if not self.keeprpms and os.path.exists(self.tmpdir):
- print (_("All downloaded packages have been extracted, removing %s")
- % self.tmpdir)
+ # Was: "All downloaded packages have been extracted, removing..."
+ # but it was appearing even if no packages were in fact extracted
+ # (say, when there was one package, and it has download error).
+ print (_("Removing %s") % self.tmpdir)
try:
os.rmdir(self.tmpdir)
except OSError: