fix(entrypoint.sh): Avoid error if rustup is not installed

Only move `/root/.rustup` and `/root/.cargo` directories if they exist.
This prevents errors when re-using the script in environments where
Rust is not installed (e.g. https://github.com/dockbuild/dockbuild).

Previously, `mv` would fail if either directory was missing:

```
mv: cannot stat '/root/.rustup': No such file or directory
mv: cannot stat '/root/.cargo': No such file or directory
```
This commit is contained in:
Jean-Christophe Fillion-Robin
2025-07-21 16:15:34 -04:00
parent 70cca217e4
commit f48bb9b136

View File

@@ -33,7 +33,12 @@ if [[ -n $BUILDER_UID ]] && [[ -n $BUILDER_GID ]]; then
export HOME=/home/${BUILDER_USER}
shopt -s dotglob
# Move rustup/cargo directories as they are large, and not needed as root
mv -t $HOME/ /root/.rustup /root/.cargo
if [[ -d /root/.rustup ]]; then
mv -t $HOME/ /root/.rustup
fi
if [[ -d /root/.cargo ]]; then
mv -t $HOME/ /root/.cargo
fi
# Copy the rest
cp -r /root/* $HOME/
chown -R $BUILDER_UID:$BUILDER_GID $HOME