Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[FAILED] DietPi-Installer | /var/lib/dpkg/info/base-files.postinst configure #6407

Closed
DigiDr opened this issue Jun 3, 2023 · 8 comments
Closed
Labels
External bug 🐞 For bugs which are not caused by DietPi. Installer 💠 Issues related to DietPi-Installer and/or pre-image used Solution available 🥂 Definite solution has been done
Milestone

Comments

@DigiDr
Copy link

DigiDr commented Jun 3, 2023

Creating a bug report/issue

Required Information

I tried the installer on a Rock Pi E (A Radxa device - strangely missing from OOB support), using https://dietpi.com/docs/hardware/#make-your-own-distribution.

It fails at: [FAILED] DietPi-Installer | /var/lib/dpkg/info/base-files.postinst configure in two places:

  1. it tries to get touch? root/.profile directly - but there is no root directory yet (easily fixed in sub shell)
  2. it tries to rm /var/lock/ - but does not do this recursively and there are a couple of files in there (easily fixed in sub shell)

Otherwise working perfectly!

@MichaIng
Copy link
Owner

MichaIng commented Jun 3, 2023

Many thanks for reporting.

mkdir /root/.profile

This is a file, not a directory. I checked the package, and it ships /root as directory natively, and postinst runs afterwards, copies the .profile (file!) into this directory. So if this did not happen in your case, then something else failed, e.g. an issue with the drive or filesystem. /var/lock should never be a directory but a symlink. Indeed the base-files' postinst script tries to remove it via rmdir if it is not a symlink yet which intentionally fails if it is not empty, as only the admin will know whether the content is still needed or not. However, if whichever base image you used ships /var/lock as directory, then it is a pretty broken image and I would use a different one.

So, where did you get the image from? If you used one from Radxa, I highly recommend the one from Armbian instead, which won't cause these issues: https://www.armbian.com/rockpie/

@DigiDr
Copy link
Author

DigiDr commented Jun 3, 2023 via email

@steeevvo
Copy link

Had the same issue on a clean install of Armbian / OrangePi Zero 2. Created root folder and it carried on.

@MichaIng
Copy link
Owner

Did you guys use Bullseye or Bookworm images?

@DigiDr
Copy link
Author

DigiDr commented Jun 10, 2023 via email

@MichaIng
Copy link
Owner

Hmm, /var/lock is indeed shipped as directory by their images. I have no idea how this is even possible, as they use debootstrap as well, if I'm not mistaken, which definitely creates it as symlink to /run/lock. This is common since, I don't know, dozens of years, I don't remember this being ever different, so impossible that any common tools create this any different, other than Armbian's own tools, obviously having a bug regarding this.

However, the package ships the symlink (as well as the /root directory) regularly as package content, so whatever other things exist, those should be overwritten.

Just tested it and indeed if /var/lock is a directory, it is not overwritten, if it is a file, it is. Strange behaviour, but then the postinst migration step makes sense. The migration however is only done if the package is not installed before, which is the reason we actively call /var/lib/dpkg/info/base-files.postinst configure in our installer to force it. And this indeed fails if that directory has content:

root@VM-Bookworm:/tmp# rm /var/lock
root@VM-Bookworm:/tmp# mkdir /var/lock
root@VM-Bookworm:/tmp# > /var/lock/test
root@VM-Bookworm:/tmp# /var/lib/dpkg/info/base-files.postinst configure
rmdir: failed to remove '/var/lock': Directory not empty

Easy to fix by checking after the package install whether it is a symlink, and if not, just removing it before calling the postinst.

Now about /root. This works well here:

root@VM-Bookworm:/tmp# rm -R /root/
root@VM-Bookworm:/tmp# dpkg -i base-files_12.4_amd64.deb
(Reading database ... 15843 files and directories currently installed.)
Preparing to unpack base-files_12.4_amd64.deb ...
Unpacking base-files (12.4) over (12.4) ...
Setting up base-files (12.4) ...
root@VM-Bookworm:/tmp# ls -Al /root/
total 0
root@VM-Bookworm:/tmp# /var/lib/dpkg/info/base-files.postinst configure
root@VM-Bookworm:/tmp# ls -Al /root/
total 8.0K
-rw-r--r-- 1 root root 571 Apr 10  2021 .bashrc
-rw-r--r-- 1 root root 161 Jul  9  2019 .profile

I will test with an actual Armbian image.

@MichaIng MichaIng added the Installer 💠 Issues related to DietPi-Installer and/or pre-image used label Jun 10, 2023
@MichaIng
Copy link
Owner

Found it:

root@rockpi-e:/tmp# apt policy base-files
base-files:
  Installed: 23.05.1--bookworm-1armbian1-B9e4a
  Candidate: 23.05.1--bookworm-1armbian1-B9e4a
  Version table:
 *** 23.05.1--bookworm-1armbian1-B9e4a 100
        100 /var/lib/dpkg/status
     12.4 500
        500 http://deb.debian.org/debian bookworm/main arm64 Packages
root@rockpi-e:/tmp# apt install --reinstall base-files
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
Reinstallation of base-files is not possible, it cannot be downloaded.
0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.

Armbian ships their images with an own base-files package, but their Bookworm repository does not contain this package (yet), so it cannot be reinstalled. Our installer even removes the related suites, to only leave the Armbian kernel/bootloader suites in place, so it wouldn't be possible to reinstall it even if they added it to their repo (as it is a downgrade due to their year-based version string). Not so trivial to solve:

echo -e '\''Package: base-files\nPin: origin *\nPin-Priority: 1000'\'' > /etc/apt/preferences.d/99dietpi-base-files
apt --reinstall install base-files
rm /etc/apt/preferences.d/99dietpi-base-files

MichaIng added a commit that referenced this issue Jun 10, 2023
- DietPi-Installer | Fix two issues found with current Armbian Bookworm images: They ship with an own base-files we want to replace with Debian's and errornously /var/lock being a directory, which fails to be migrated if it has content already. Many thanks to @DigiDr for reporting those issues: #6407
@MichaIng MichaIng added the Solution available 🥂 Definite solution has been done label Jun 10, 2023
@MichaIng MichaIng added this to the v8.19 milestone Jun 10, 2023
@MichaIng MichaIng added External bug 🐞 For bugs which are not caused by DietPi. and removed Investigating 🤔 labels Jun 10, 2023
@MichaIng
Copy link
Owner

Both issues fixed in dev branch: bfcf773

@MichaIng MichaIng closed this as completed Jul 1, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
External bug 🐞 For bugs which are not caused by DietPi. Installer 💠 Issues related to DietPi-Installer and/or pre-image used Solution available 🥂 Definite solution has been done
Projects
None yet
Development

No branches or pull requests

3 participants