1

One of my Raspberry Pi (a Pi 2 running OSMC) threw an update error. Trying to perform a manual dist-upgrade fails with a suspicious error on the apt package itself:

Preconfiguring packages ...
/tmp/ca-certificates.config.M9vjue: 70: /tmp/ca-certificates.config.M9vjue: uniq: not found
ca-certificates failed to preconfigure, with exit status 127
(Reading database ... 30176 files and directories currently installed.)
Preparing to unpack .../archives/apt_1.4.11_armhf.deb ...
/usr/bin/dpkg-maintscript-helper: 588: /usr/bin/dpkg-maintscript-helper: basename: not found
dpkg: warning: subprocess old pre-removal script returned error exit status 127
dpkg: trying script from the new package instead ...
/usr/bin/dpkg-maintscript-helper: 588: /usr/bin/dpkg-maintscript-helper: basename: not found
dpkg: error processing archive /var/cache/apt/archives/apt_1.4.11_armhf.deb (--unpack):
 subprocess new pre-removal script returned error exit status 127
Failed to try-restart apt-daily-upgrade.timer: Unit apt-daily-upgrade.timer is masked.
Failed to try-restart apt-daily.timer: Unit apt-daily.timer is masked.
/usr/bin/dpkg-maintscript-helper: 588: /usr/bin/dpkg-maintscript-helper: basename: not found
dpkg: error while cleaning up:
 subprocess installed post-installation script returned error exit status 127
Errors were encountered while processing:
 /var/cache/apt/archives/apt_1.4.11_armhf.deb
E: Sub-process /usr/bin/dpkg returned an error code (1)

and further inspection confirms apt is broken:

$ sudo dpkg --configure -a
Processing triggers for libc-bin (2.24-11+deb9u4) ...
dpkg: error processing package apt (--configure):
 package is in a very bad inconsistent state; you should
 reinstall it before attempting configuration
Errors were encountered while processing:
 apt

Removing APT (e.g. dpkg -r) for reinstallation is not really an option as rbp2-device-osmc depends on apt-utils, so it would take down the system with it.

How can I recover apt without wiping the entire installation?

5
  • As Stephen Kitt mentions, basename is missing. As well as uniq. Both are part of the coreutils package. Do you still have the coreutils package, which is tagged as Essential? You should check if you made any strange action in previous package changes. Did you add external repositories? Mix stable and unstable repositories? Attempt to downgrade packages? etc. Commented Jan 23, 2021 at 21:57
  • That Pi is used as media center running OSMC, so it is pretty much a managed system which updates on its own. Two weeks ago Kodi got stuck in a "sad face" reboot loop, so i reinstalled the media center package with apt-get install --reinstall rbp2-device-osmc. That's the only manual operation performed on it. Commented Jan 23, 2021 at 22:15
  • To address the question more properly, coreutils still seems to be present: sudo apt list --installed | grep coreutils coreutils/oldstable,now 8.26-3 armhf [installed] Commented Jan 23, 2021 at 22:17
  • Can you run the commands uniq or basename? A RPi being what it is, are you sure its micro-SD card is still fine? I'm just puzzled and out of other ideas. Commented Jan 23, 2021 at 22:23
  • Your comment on coreutils gave me an idea, which I believe fixed the issue - I'll insert more details in the answer below. Commented Jan 23, 2021 at 22:28

2 Answers 2

1

run:

sudo dpkg --unpack /var/cache/apt/archives/apt_1.4.11_armhf.deb
sudo dpkg --configure apt

or reinstall apt:

wget http://ftp.univ-nantes.fr/debian-security/pool/updates/main/a/apt/apt_1.4.11_armhf.deb
sudo dpkg -i apt_1.4.11_armhf.deb

man dpkg:

--unpack package-file...
      Unpack the package, but don't configure it. If --recursive or -R 
      option is  specified,  package-file  must  refer  to  a  directory instead.
2
  • 2
    The fact that basename isn’t found suggests there are more problems to fix; I’m not sure the --configure step will succeed :-(. Commented Jan 23, 2021 at 21:46
  • 1
    Indeed, both dpkg --unpack and dpkg -i are failing because basename isn't found. Commented Jan 23, 2021 at 21:59
1

Turns out A.B was right - something was off with coreutils, and reinstalling it overcame the issue:

# dpkg -i /var/cache/apt/archives/coreutils_8.26-3_armhf.deb
(Reading database ... 30176 files and directories currently installed.)
Preparing to unpack .../coreutils_8.26-3_armhf.deb ...
Unpacking coreutils (8.26-3) over (8.26-3) ...
Setting up coreutils (8.26-3) ...

The following pass of apt-get dist-upgrade is chugging along pretty successfully. My guess at this point is the same issue that caused the Kodi sad face loop has possibly corrupted the microSD file system, which dropped one block too many during the customary automatic self-check, resulting in parts of coreutils being lost.

Thank you A.B !!

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.