tags 591993 + patch
thanks
On 2010-08-06 21:45 +0200, Helmut Grohne wrote:
> Package: dpkg
> Version: 1.15.8.3
> Severity: normal
>
> Recently there was a file conflict between kdelibs{,5}-data.
>
> # find /usr -name "*.dpkg-tmp" | wc -l
> 0
> # dpkg -i /var/cache/apt/archives/kdelibs-data_4%3a3.5.10.dfsg.1-4_all.deb
> (Reading database ... 217862 files and directories currently installed.)
> Preparing to replace kdelibs-data 4:3.5.10.dfsg.1-3 (using
> .../kdelibs-data_4%3a3.5.10.dfsg.1-4_all.deb) ...
> Unpacking replacement kdelibs-data ...
> dpkg: error processing
> /var/cache/apt/archives/kdelibs-data_4%3a3.5.10.dfsg.1-4_all.deb (--install):
> trying to overwrite '/usr/share/doc/kde/HTML/en/common/6.png', which is also
> in package kdelibs5-data 4:4.4.5-1
> dpkg-deb: subprocess paste killed by signal (Broken pipe)
> Processing triggers for desktop-file-utils ...
> Errors were encountered while processing:
> /var/cache/apt/archives/kdelibs-data_4%3a3.5.10.dfsg.1-4_all.deb
> # find /usr -name "*.dpkg-tmp" | wc -l
> 4217
I can reproduce this and have even figured out why it happens. When
upgrading a package containing file "foo", dpkg unpacks the new version
as "foo.dpkg-new" and links the old file to a backup named
"foo.dpkg-tmp". If unpacking fails, the error unwind consists of
deleting foo.dpkg-new and renaming foo.dpkg-tmp back to foo.
All well, but there is a problem because rename(2) states:
If oldpath and newpath are existing hard links referring to the same
file, then rename() does nothing, and returns a success status.
So foo.dpkg-tmp is left on the system and needs to be unlinked. The
attached patch seems to work for me.
>From 1ccac648e7f3a25f20e619beecd1c91f5684a28f Mon Sep 17 00:00:00 2001
From: Sven Joachim <[email protected]>
Date: Thu, 12 Aug 2010 20:40:59 +0200
Subject: [PATCH] Remove spurious leftover .dpkg-tmp files after unpacking failure
Renaming the backup copy to the old name is a no-op if these are hard
links to the same file. So we need to remove the backup copy
afterwards to make sure it is gone. Closes: #591993.
---
debian/changelog | 4 ++++
src/cleanup.c | 2 ++
2 files changed, 6 insertions(+), 0 deletions(-)
diff --git a/debian/changelog b/debian/changelog
index 8dc6a24..858104d 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -10,6 +10,10 @@ dpkg (1.15.8.4) UNRELEASED; urgency=low
* When analyzing the ELF format of a binary in dpkg-shlibdeps, fallback on
usual objdump when the cross objdump failed. Closes: #591522
+ [ Sven Joachim ]
+ * Ensure removal of leftover .dpkg-tmp files after unpacking failures.
+ Closes: #591993
+
-- Guillem Jover <[email protected]> Thu, 05 Aug 2010 17:42:51 +0200
dpkg (1.15.8.3) unstable; urgency=low
diff --git a/src/cleanup.c b/src/cleanup.c
index a51eecc..ec74cf6 100644
--- a/src/cleanup.c
+++ b/src/cleanup.c
@@ -90,6 +90,8 @@ void cu_installnew(int argc, void **argv) {
/* Either we can do an atomic restore, or we've made room: */
if (rename(fnametmpvb.buf,fnamevb.buf))
ohshite(_("unable to restore backup version of `%.250s'"),namenode->name);
+ else if (unlink(fnametmpvb.buf) && errno != ENOENT)
+ ohshite(_("unable to remove backup copy of '%.250s'"), namenode->name);
} else if (namenode->flags & fnnf_placed_on_disk) {
debug(dbg_eachfiledetail,"cu_installnew removing new file");
if (unlinkorrmdir(fnamevb.buf) && errno != ENOENT && errno != ENOTDIR)
--
1.7.1