openwrt / packages

Community maintained packages for OpenWrt. Documentation for submitting pull requests is in CONTRIBUTING.md
GNU General Public License v2.0
3.95k stars 3.46k forks source link

schroot: Chroot setup failed: stage=setup-start #23733

Open alex9434 opened 6 months ago

alex9434 commented 6 months ago

Maintainer: @jmarcet @ptpt52 @neheb Environment: OpenWrt 23.05.2 on Arm64 (Raspberry Pi 4B)

Description: Unable to start schroot environment: Chroot setup failed: stage=setup-start

  1. Create chroot with debootstrap --no-check-gpg --arch=arm64 bullseye /srv/chroot/debian
  2. Create file in /etc/schroot/chroot.d
    [debian]
    description=Debian environment
    directory=/srv/chroot/debian
    aliases=bullseye
    type=directory
    users=root
    groups=root
    root-groups=root
  3. Start with schroot -c debian
    E: 20copyfiles: /etc/schroot/setup.d/20copyfiles: line 42: /bin/stat: not found
    E: 70services: /etc/schroot/setup.d/70services: line 48: tac: not found
    E: debian-1711263744-18335: Chroot setup failed: stage=setup-start
brada4 commented 6 months ago

Install coreutils-stat and coreutils-tac as hinted by those messages.

jmarcet commented 6 months ago

@alex9434 Can you confirm it works well with both coreutils-stat & coreutils-tac packages installed? I'm the maintainer of schroot but I've always tested the package in a box where I have all of coreutils installed.

alex9434 commented 5 months ago

@jmarcet Apologies for the delay in getting back. Yes, installing coreutils-stat & coreutils-tac solved the issue. Since I am building from source I was thinking about just using stat and tac from busybox. Would that also work?

I only now get an error message because ash is not included in the debian setup.

W: Shell ‘/bin/ash’ not available: /bin/ash: Failed to stat file: No such file or directory
W: Falling back to shell ‘/bin/bash’

shell=/bin/bash in the config solved the issue. You might want to include that in the package.

There is an additional dependency on coreutils-realpath when exiting the schroot:

E: 15killprocs: /etc/schroot/setup.d/15killprocs: line 42: realpath: not found
E: android-1712316017-2771: Chroot setup failed: stage=setup-stop

Installing coreutils-realpath solved the issue.

The only question would be whether to include in the Makefile the dependency on Busybox or coreutils. I think we can close the issue now.

jmarcet commented 5 months ago

@jmarcet Apologies for the delay in getting back. Yes, installing coreutils-stat & coreutils-tac solved the issue. Since I am building from source I was thinking about just using stat and tac from busybox. Would that also work?

@alex9434 See the PR I've opened, it includes an updated 01-openwrt.patch which brings compatibility with busybox's stat (built with BUSYBOX_CONFIG_FEATURE_STAT_FORMAT option).

I only now get an error message because ash is not included in the debian setup.

W: Shell ‘/bin/ash’ not available: /bin/ash: Failed to stat file: No such file or directory
W: Falling back to shell ‘/bin/bash’

shell=/bin/bash in the config solved the issue. You might want to include that in the package.

Where does that ash come from? I can't find it within /etc/schroot or any other of the files in the schroot ipk package, which is what I could check now.

There is an additional dependency on coreutils-realpath when exiting the schroot:

E: 15killprocs: /etc/schroot/setup.d/15killprocs: line 42: realpath: not found
E: android-1712316017-2771: Chroot setup failed: stage=setup-stop

Installing coreutils-realpath solved the issue.

Great! Thanks for the feedback :) I had missed that one.

The only question would be whether to include in the Makefile the dependency on Busybox or coreutils. I think we can close the issue now.

In the PR I've added both as options, it is missing realpath ATM though.

alex9434 commented 5 months ago

Where does that ash come from? I can't find it within /etc/schroot or any other of the files in the schroot ipk package, which is what I could check now.

ash is the default shell in OpenWrt. I think schroot tries to call the same shell. However, debootstrap installs only bash by default hence the error message.

BTW: realpath is also available in Busybox

brada4 commented 5 months ago

SHELL=/bin/sh chroot bootstrap

jmarcet commented 5 months ago

Where does that ash come from? I can't find it within /etc/schroot or any other of the files in the schroot ipk package, which is what I could check now.

ash is the default shell in OpenWrt. I think schroot tries to call the same shell. However, debootstrap installs only bash by default hence the error message.

I'm used to specify which command I want to execute with schroot, be it a shell or any other command. I was not remembering it defaults to the host's $SHELL.

BTW: realpath is also available in Busybox

I've updated the PR to also include realpath, whether from busybox or from coreutils.

alex9434 commented 4 months ago

Hi @jmarcet , I found another issue when trying to start an ubuntu schroot:

E: 20copyfiles: cp: unrecognized option: preserve=all
E: 20copyfiles: BusyBox v1.36.1 (2024-03-22 22:09:42 UTC) multi-call binary.
E: 20copyfiles: 
E: 20copyfiles: Usage: cp [-arPLHpfinlsTu] SOURCE DEST
E: 20copyfiles: or: cp [-arPLHpfinlsu] SOURCE... { -t DIRECTORY | DIRECTORY }
E: 20copyfiles: 
E: 20copyfiles: Copy SOURCEs to DEST
E: 20copyfiles: 
E: 20copyfiles:     -a  Same as -dpR
E: 20copyfiles:     -R,-r   Recurse
E: 20copyfiles:     -d,-P   Preserve symlinks (default if -R)
E: 20copyfiles:     -L  Follow all symlinks
E: 20copyfiles:     -H  Follow symlinks on command line
E: 20copyfiles:     -p  Preserve file attributes if possible
E: 20copyfiles:     -f  Overwrite
E: 20copyfiles:     -i  Prompt before overwrite
E: 20copyfiles:     -n  Don't overwrite
E: 20copyfiles:     -l,-s   Create (sym)links
E: 20copyfiles:     -T  Refuse to copy if DEST is a directory
E: 20copyfiles:     -t DIR  Copy all SOURCEs into DIR
E: 20copyfiles:     -u  Copy only newer files
E: ubuntu-1715273858-15347: Chroot setup failed: stage=setup-start

It is caused by busybox. I solved the errror by replacing preserve=all with -a in 20copyfiles. Option -d might also be sufficient. Would it make sense to update the file in the package accordingly?

brada4 commented 4 months ago

First gather more edits needed by busybox, sure worth adding patch toward flawless ux