Package: dpkg
Version: 1.20.7.1
Severity: normal
Tags: patch

Dear Maintainer,

When upgrading the kernel on one of my machines I got hit with
  Preparing to unpack .../linux-image-5.10.0-1-amd64_5.10.5-1_amd64.deb ...
  Unpacking linux-image-5.10.0-1-amd64:amd64 (5.10.5-1) over (5.10.4-1) ...
  dpkg: error processing archive 
/var/cache/apt/archives/linux-image-5.10.0-1-amd64_5.10.5-1_amd64.deb 
(--unpack):
   unable to make backup link of './boot/System.map-5.10.0-1-amd64' before 
installing new version: Operation not permitted
  dpkg-deb: error: paste subprocess was killed by signal (Broken pipe)
  Errors were encountered while processing:
   /var/cache/apt/archives/linux-image-5.10.0-1-amd64_5.10.5-1_amd64.deb
  E: Sub-process /usr/bin/dpkg returned an error code (1)

I have /boot on FAT, which does not support more than one link per file;
please consider the attached patch,
based on b0c80a72a9a32e17953483e1fb6b66dcfd8d0096,
that falls back to rename(2).

Best,
наб

-- Package-specific info:
System tainted due to merged-usr-via-symlinks.

-- System Information:
Debian Release: 10.7
  APT prefers stable-updates
  APT policy: (500, 'stable-updates'), (500, 'stable')
Architecture: amd64 (x86_64)
Foreign Architectures: i386

Kernel: Linux 4.19.0-13-amd64 (SMP w/24 CPU cores)
Kernel taint flags: TAINT_PROPRIETARY_MODULE, TAINT_WARN, 
TAINT_FIRMWARE_WORKAROUND, TAINT_OOT_MODULE, TAINT_UNSIGNED_MODULE
Locale: LANG=en_GB.UTF-8, LC_CTYPE=en_GB.UTF-8 (charmap=UTF-8), 
LANGUAGE=en_GB:en (charmap=UTF-8)
Shell: /bin/sh linked to /usr/bin/dash
Init: systemd (via /run/systemd/system)
LSM: AppArmor: enabled

Versions of packages dpkg depends on:
ii  libbz2-1.0   1.0.6-9.2~deb10u1
ii  libc6        2.28-10
ii  liblzma5     5.2.4-1
ii  libselinux1  2.8-1+b1
ii  tar          1.30+dfsg-6
ii  zlib1g       1:1.2.11.dfsg-1

dpkg recommends no packages.

Versions of packages dpkg suggests:
ii  apt            1.8.2.2
pn  debsig-verify  <none>

-- Configuration Files:
/etc/logrotate.d/alternatives changed [not included]
/etc/logrotate.d/dpkg changed [not included]

-- no debconf information
From b0c80a72a9a32e17953483e1fb6b66dcfd8d0096 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=D0=BD=D0=B0=D0=B1?= <nabijaczlew...@nabijaczleweli.xyz>
Date: Tue, 12 Jan 2021 18:28:26 +0100
Subject: [PATCH] Fall back from link(2) to rename(2) if the underlying
 filesystem does not support it
X-Mutt-PGP: OS

Most notably, this likely fixes kernel upgrades with /boot on FAT
---
 src/archives.c | 13 ++++++++++---
 1 file changed, 10 insertions(+), 3 deletions(-)

diff --git a/src/archives.c b/src/archives.c
index 96079ab1f..f38deee0a 100644
--- a/src/archives.c
+++ b/src/archives.c
@@ -1061,9 +1061,16 @@ tarobject(struct tar_archive *tar, struct tar_entry *ti)
       tarobject_set_se_context(fnamevb.buf, fnametmpvb.buf, stab.st_mode);
     } else {
       debug(dbg_eachfiledetail, "tarobject nondirectory, 'link' backup");
-      if (link(fnamevb.buf,fnametmpvb.buf))
-        ohshite(_("unable to make backup link of '%.255s' before installing new version"),
-                ti->name);
+      if (link(fnamevb.buf,fnametmpvb.buf)) {
+        if (errno == EPERM) {
+          debug(dbg_eachfiledetail, "unable to link, falling back to nonatomic");
+          if (rename(fnamevb.buf,fnametmpvb.buf))
+            ohshite(_("unable to move aside '%.255s' to install new version"),
+                    ti->name);
+        } else
+          ohshite(_("unable to make backup link of '%.255s' before installing new version"),
+                  ti->name);
+      }
     }
   }
 
-- 
2.20.1

Attachment: signature.asc
Description: PGP signature

Reply via email to