How should I recreate /var/lib/dpkg/info/* ?

Halvor Raknes

Member
Joined
Apr 19, 2021
Messages
154
Reaction score
15
Credits
1,225
I accidentally deleted /var/lib/dpkg/info/* on Linux Mint 22.1 (Ubuntu 24.04). I have since run apt --fix-broken install, and sudo apt check now reports no problems. However, dpkg --audit reports that almost all installed packages are "missing the list control file in the database, they need to be reinstalled". There are about 2863 installed packages but only 77 .list files remain in /var/lib/dpkg/info. What is the recommended way to regenerate the missing .list files? Is apt reinstall $(dpkg-query ...) the right approach, or is there a better/safer method?
 


Do you have Timeshift snapshots ?

If you do, simply Restore to a snapshot taken prior to the /var/lib/dpkg/info/* deletion
 
What happens when you run an "apt update" on the system, I would think that would re-populate itself as it's only info of package information?
 
What happens when you run an "apt update" on the system, I would think that would re-populate itself as it's only info of package information?
I haven't tried that yet. I've been going up until now with the help from LLMs. First DeepSeek got me into this trouble, now I've been getting help from ChatGPT. It actually recommended I get som advice from real people on this part of the repair rather than simply following its advice…
 
I haven't tried that yet. I've been going up until now with the help from LLMs. First DeepSeek got me into this trouble, now I've been getting help from ChatGPT. It actually recommended I get som advice from real people on this part of the repair rather than simply following its advice…
Can you try running "apt update" and "apt upgrade" from the command-line and see if those run correctly without errors?
 
I followed your suggestion and ran sudo apt upgrade.

The results were encouraging:
  • Before the upgrade I had only 77 .list files in /var/lib/dpkg/info/.
  • After the upgrade I now have 585 .list files, so many package metadata files have been regenerated.
  • sudo apt check now reports no dependency problems.
However, dpkg --audit still reports that many packages are missing their .list files, and sudo dpkg --configure -a fails on these packages:
  • openssh-server
  • rsyslog
  • samba-common
  • smbclient
  • samba-common-bin
The first three all fail with:

installed <package> package post-installation script subprocess returned error exit status 10

The corresponding postinst scripts are present, and openssh-server.postinst ends with exit 0, so the failure appears to come from a command executed within the script rather than an explicit exit 10.

Does this give you any idea what the next step should be?
 
Did you als run "apt update"? Just try running a reinstall on them?
Code:
sudo apt reinstall  openssh-server rsyslog samba-common smbclient samba-common-bin
 
The first three all fail with:

installed <package> package post-installation script subprocess returned error exit status 10

The corresponding postinst scripts are present, and openssh-server.postinst ends with exit 0, so the failure appears to come from a command executed within the script rather than an explicit exit 10.

Does this give you any idea what the next step should be?
Can you share the output?
 
Is this a relevant data?

halvor@halvor-X551MA:~$ sudo apt install --reinstall openssh-server
Reading package lists... Done Building dependency tree... Done
Reading state information... Done
The following package was automatically installed and is no longer required:
libwayland-server0:i386
Use 'sudo apt autoremove' to remove it. 0 upgraded, 0 newly installed, 1 reinstalled, 0 to remove and 15 not upgraded.
5 not fully installed or removed.
After this operation, 0 B of additional disk space will be used.
E: Internal Error, No file name for openssh-server:amd64 halvor@halvor-X551MA:~$
 
Try running this?
Code:
sudo apt update
sudo apt --fix-broken install
sudo dpkg --configure -a
sudo apt install --reinstall openssh-server
 
Try running this?
Code:
sudo apt update
sudo apt --fix-broken install
sudo dpkg --configure -a
sudo apt install --reinstall openssh-server

That didn't work so well:

halvor@halvor-X551MA:~$ sudo apt update
[sudo] password for halvor:
Get:1 http://security.ubuntu.com/ubuntu noble-security InRelease [126 kB]
Get:2 https://brave-browser-apt-release.s3.brave.com stable InRelease [7 547 B]
Hit:3 https://ppa.launchpadcontent.net/deadsnakes/ppa/ubuntu noble InRelease
Get:4 https://brave-browser-apt-release.s3.brave.com stable/main amd64 Packages [34,1 kB]
Get:5 https://brave-browser-apt-release.s3.brave.com stable/main arm64 Packages [34,0 kB]
Get:6 http://security.ubuntu.com/ubuntu noble-security/main amd64 Packages [869 kB]
Get:7 http://security.ubuntu.com/ubuntu noble-security/main i386 Packages [336 kB]
Get:8 http://security.ubuntu.com/ubuntu noble-security/main Translation-en [194 kB]
Get:9 http://security.ubuntu.com/ubuntu noble-security/restricted amd64 Packages [1 185 kB]
Get:10 http://security.ubuntu.com/ubuntu noble-security/restricted Translation-en [273 kB]
Get:11 http://security.ubuntu.com/ubuntu noble-security/universe amd64 Packages [1 194 kB]
Get:12 http://security.ubuntu.com/ubuntu noble-security/universe i386 Packages [819 kB]
Get:13 http://security.ubuntu.com/ubuntu noble-security/universe Translation-en [237 kB]
Hit:14 http://no.archive.ubuntu.com/ubuntu noble InRelease
Hit:15 http://no.archive.ubuntu.com/ubuntu noble-updates InRelease
Hit:16 http://no.archive.ubuntu.com/ubuntu noble-backports InRelease
Ign:17 https://mirror.accum.se/mirror/linuxmint.com/packages xia InRelease
Hit:18 https://mirror.accum.se/mirror/linuxmint.com/packages xia Release
Fetched 5 310 kB in 4s (1 227 kB/s)
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
23 packages can be upgraded. Run 'apt list --upgradable' to see them.
halvor@halvor-X551MA:~$ sudo apt --fix-broken install
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
The following package was automatically installed and is no longer required:
libwayland-server0:i386
Use 'sudo apt autoremove' to remove it.
0 upgraded, 0 newly installed, 0 to remove and 23 not upgraded.
5 not fully installed or removed.
After this operation, 0 B of additional disk space will be used.
Setting up openssh-server (1:9.6p1-3ubuntu13.18) ...
dpkg: error processing package openssh-server (--configure):
installed openssh-server package post-installation script subprocess returned e
rror exit status 10
Setting up rsyslog (8.2312.0-3ubuntu9.2) ...
info: The user `syslog' is already a member of `adm'.
dpkg: error processing package rsyslog (--configure):
installed rsyslog package post-installation script subprocess returned error ex
it status 10
Setting up samba-common (2:4.19.5+dfsg-4ubuntu9.6) ...
dpkg: error processing package samba-common (--configure):
installed samba-common package post-installation script subprocess returned err
or exit status 10
dpkg: dependency problems prevent configuration of smbclient:
smbclient depends on samba-common (= 2:4.19.5+dfsg-4ubuntu9.6); however:
Package samba-common is not configured yet.

dpkg: error processing package smbclient (--configure):
dependency problems - leaving unconfigured
dpkg: dependency problems prevent configuration of samba-common-bin:
samba-common-bin depends on samba-common (= 2:4.19.5+dfsg-4ubuntu9.6); however:
Package samba-common is not configured yet.

dpkg: error processing package samba-common-bin (--configure):
dependency problems - leaving unconfigured
Errors were encountered while processing:
openssh-server
rsyslog
samba-common
smbclient
samba-common-bin
E: Sub-process /usr/bin/dpkg returned an error code (1)
halvor@halvor-X551MA:~$ sudo dpkg --configure -a
Setting up openssh-server (1:9.6p1-3ubuntu13.18) ...
dpkg: error processing package openssh-server (--configure):
installed openssh-server package post-installation script subprocess returned error exit status 10
Setting up rsyslog (8.2312.0-3ubuntu9.2) ...
info: The user `syslog' is already a member of `adm'.
dpkg: error processing package rsyslog (--configure):
installed rsyslog package post-installation script subprocess returned error exit status 10
Setting up samba-common (2:4.19.5+dfsg-4ubuntu9.6) ...
dpkg: error processing package samba-common (--configure):
installed samba-common package post-installation script subprocess returned error exit status 10
dpkg: dependency problems prevent configuration of smbclient:
smbclient depends on samba-common (= 2:4.19.5+dfsg-4ubuntu9.6); however:
Package samba-common is not configured yet.

dpkg: error processing package smbclient (--configure):
dependency problems - leaving unconfigured
dpkg: dependency problems prevent configuration of samba-common-bin:
samba-common-bin depends on samba-common (= 2:4.19.5+dfsg-4ubuntu9.6); however:
Package samba-common is not configured yet.

dpkg: error processing package samba-common-bin (--configure):
dependency problems - leaving unconfigured
Errors were encountered while processing:
openssh-server
rsyslog
samba-common
smbclient
samba-common-bin
halvor@halvor-X551MA:~$ sudo apt install --reinstall openssh-server
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
The following package was automatically installed and is no longer required:
libwayland-server0:i386
Use 'sudo apt autoremove' to remove it.
0 upgraded, 0 newly installed, 1 reinstalled, 0 to remove and 23 not upgraded.
5 not fully installed or removed.
After this operation, 0 B of additional disk space will be used.
E: Internal Error, No file name for openssh-server:amd64
halvor@halvor-X551MA:~$

However, I investigated further.

apt knows the package correctly:
  • apt-cache policy shows the installed and candidate version.
  • apt-cache show contains a valid Filename: pool/...deb.
  • apt-cache madison lists all available versions.
  • The corresponding .deb is already present in /var/cache/apt/archives/.
Yet sudo apt reinstall openssh-server still immediately fails with:
E: Internal Error, No file name for openssh-server:amd64
So it doesn't appear to be a missing repository entry or a missing package archive. Could this be caused by the earlier loss of most of /var/lib/dpkg/info, or is there another apt metadata database that may have become inconsistent?
 


Follow Linux.org

Staff online

Members online


Top