diff options
author | Lyndon Brown <jnqnfe@gmail.com> | 2020-03-10 19:54:08 +0000 |
---|---|---|
committer | Luca Boccassi <bluca@debian.org> | 2020-03-11 09:55:37 +0000 |
commit | 6cec4a7a74708bc70d7572b85019bb9ae0332e47 (patch) | |
tree | 3e0991387194cf735b2f333f914cbedc11a21e73 | |
parent | 744141c60f55144b4d8944ba0d745adcc4b34116 (diff) | |
download | vyos-live-build-6cec4a7a74708bc70d7572b85019bb9ae0332e47.tar.gz vyos-live-build-6cec4a7a74708bc70d7572b85019bb9ae0332e47.zip |
exit: fix no /usr/bin/env error
if you execute the bootstrap stage with no internet connection, you get
the following output:
```
[2020-03-10 19:18:46] lb bootstrap
P: Setting up clean exit handler
[2020-03-10 19:18:46] lb bootstrap_cache restore
[2020-03-10 19:18:46] lb bootstrap_debootstrap
P: Begin bootstrapping system...
P: If the following stage fails, the most likely cause of the problem is with your mirror configuration or a caching proxy.
P: Running debootstrap (download-only)...
I: Retrieving InRelease
I: Retrieving Release
E: Failed getting release file http://deb.debian.org/debian/dists/buster/Release
P: Begin unmounting filesystems...
P: Saving caches...
chroot: failed to run command ‘/usr/bin/env’: No such file or directory
```
the last line looked suspicious. investigating it turns out that there was
a deficiency in the exit handler.
when debootstrap fails to download what it needs due to lack of a
connection, that failure due to `set -e` causes the Exit() handler to kick
in. Part of this includes outputting the "Saving caches..." line, before
then making a call to Save_package_cache(). That in turn runs the following
command:
```
Chroot chroot "apt-get autoclean" || true
```
The Chroot() function includes a line starting with:
```
${_LINUX32} chroot "${CHROOT}" /usr/bin/env
```
which is the source of the last output line.
the reason we see this unexpected output is that with bootstrapping having
failed, there is no /usr/bin/env within the chroot so it is bound to fail.
the fact is, the exit handler has no business trying to pretty much
anything that it does if the bootstrap_debootstrap stage has not
completed.
this implements such a restriction and thus resolves the problem of this
unexpected and confusing output in the described situation.
we will now see:
```
[2020-03-10 19:18:46] lb bootstrap
P: Setting up clean exit handler
[2020-03-10 19:18:46] lb bootstrap_cache restore
[2020-03-10 19:18:46] lb bootstrap_debootstrap
P: Begin bootstrapping system...
P: If the following stage fails, the most likely cause of the problem is with your mirror configuration or a caching proxy.
P: Running debootstrap (download-only)...
I: Retrieving InRelease
I: Retrieving Release
E: Failed getting release file http://deb.debian.org/debian/dists/buster/Release
```
-rwxr-xr-x | functions/exit.sh | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/functions/exit.sh b/functions/exit.sh index 0aa334a5c..9add3612c 100755 --- a/functions/exit.sh +++ b/functions/exit.sh @@ -18,6 +18,12 @@ Exit () set | grep -e ^LB fi + # Skip if we have not yet completed the initial bootstrapping (bootstrap_debootstrap) + # (nothing to be done; avoids unhelpful messages) + if [ ! -e .build/bootstrap ]; then + return ${VALUE} + fi + # Always exit true in case we are not able to unmount # (e.g. due to running processes in chroot from user customizations) Echo_message "Begin unmounting filesystems..." |