drakkar-lig / debootstick

Generate a bootable live image from any Debian/Ubuntu filesystem tree.
62 stars 18 forks source link

Test for /etc/resolv.conf fails if file is symlink in chroot #28

Closed kgilmer closed 4 years ago

kgilmer commented 4 years ago

Background

I am evaluating your (amazing, thank you!) tool for generating a live ISO and installer for the linux project I work on. I have adapted a script to generate the chroot and when I run the script it fails with an error message. I have modified the script set -x to see what's going on and it appears that there is a file check for the existence of /etc/resolv.conf, and in the case that this file does not exist, touch is used to create it. In my case, /etc/resolv.conf is a symlink to another file, and it appears that the file check is failing, and also touch fails to modify the symlink, resulting in the script aborting.

Expected behavior

I can generate an ISO image with my chroot using debootstick on Ubuntu 20.04 w/ a Ubuntu 18.04 target system.

Actual behavior

When running the script I see:

debootstick should be run as root. Trying sudo...
I: detected target system: amd64 PC
I: generating a UEFI bootloader binary... done
I: draft image - computing a size large enough... done
I: draft image - partitioning and formatting... done
I: draft image - copying filesystem tree... done
touch: cannot touch 'etc/resolv.conf': No such file or directory

E: an error occured.
E: did you try 'debootstick --help-os-support'?
I: restoring a clean state... done

I've attached a log of the script executing with set -x in case it helps. Thanks again for your time and creation! verbose-debootstick.log

eduble commented 4 years ago

Hi Ken, I think I have seen this problem once. Can you just remove the symlink? I believe debootstick should pass if it is removed, and the target OS should recreate it on bootup. Let me know if it works.

kgilmer commented 4 years ago

Hi Etienne,

Thanks for your quick response! Sure, I can delete the symlink but as far as I can tell it's created by debootstrap, at least so as I am calling it, and so I would expect this to be a common issue. Would you accept a PR to update the file check to work for symlinks as well?

debootstrap --arch=amd64 --variant=minbase focal /tmp/chroottest
http://us.archive.ubuntu.com/ubuntu/

On Fri, Oct 2, 2020 at 7:27 AM Etienne Dublé notifications@github.com wrote:

Hi Ken, I think I have seen this problem once. Can you just remove the symlink? I believe debootstick should pass if it is removed, and the target OS should recreate it on bootup. Let me know if it works.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/drakkar-lig/debootstick/issues/28#issuecomment-702765787, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAAMEE3PFHTNGZ4QB3REVXDSIXPO7ANCNFSM4SBX5CFQ .

eduble commented 4 years ago

Sure, I can delete the symlink but as far as I can tell it's created by debootstrap, at least so as I am calling it, and so I would expect this to be a common issue.

Ok I just wanted to make sure deleting the symlink could be an appropriate workaround for anyone else, before a fix is applied.

Would you accept a PR to update the file check to work for symlinks as well?

Sure! I was quite busy with other projects, but my intent was to have a newer version of debootstick in next debian release, with newest ubuntu and debian releases (in chroot) re-tested and fixed. Given the time needed for the review process (on debian project side) this new release should be ready around the beginning of next month. If you can prepare something for this problem, you are very welcome.

kgilmer commented 4 years ago

I can no longer reproduce this error either with the Debian packaged version or a local build of debootstick. I am unsure what changed to cause the problem to disappear. I will close this issue for now and reopen if I get more details as to consistent steps to reproduce. Sorry for the churn.