1
0
mirror of https://github.com/home-assistant/operating-system.git synced 2025-12-19 18:08:29 +00:00

Fix scripts/enter.sh so it is usable on macOS (#4243)

* Fix scripts/enter.sh so it is usable on macOS

Also, stop requiring `sudo` for actions that do not need it

Tested by building generic_x86_64 target on a macOS machine

Signed-off-by: Marat Radchenko <marat@slonopotamus.org>

* Update scripts/enter.sh

Co-authored-by: Jan Čermák <sairon@users.noreply.github.com>

---------

Signed-off-by: Marat Radchenko <marat@slonopotamus.org>
Co-authored-by: Jan Čermák <sairon@users.noreply.github.com>
This commit is contained in:
Marat Radchenko
2025-08-20 11:24:36 +03:00
committed by GitHub
parent 419d40012f
commit effe4d3e73

View File

@@ -4,28 +4,26 @@ set -e
BUILDER_UID="$(id -u)"
BUILDER_GID="$(id -g)"
CACHE_DIR="${CACHE_DIR:-$HOME/hassos-cache}"
ARGS="$*"
COMMAND="${ARGS:-bash}"
if [ "$BUILDER_UID" -eq "0" ] || [ "$BUILDER_GID" == "0" ]; then
echo "ERROR: Please run this script as a regular (non-root) user with sudo privileges."
exit 1
fi
sudo mkdir -p "${CACHE_DIR}"
sudo chown -R "${BUILDER_UID}:${BUILDER_GID}" "${CACHE_DIR}"
sudo docker build -t hassos:local .
mkdir -p "${CACHE_DIR}"
docker build -t hassos:local .
if [ ! -f buildroot/Makefile ]; then
# Initialize git submodule
git submodule update --init
fi
# Make sure loop devices are present before starting the container
sudo losetup -f > /dev/null
if command -v losetup >/dev/null && [ ! -e /dev/loop0 ]; then
# Make sure loop devices are present before starting the container
sudo losetup -f > /dev/null
fi
# shellcheck disable=SC2086
sudo docker run -it --rm --privileged \
docker run -it --rm --privileged \
-v "$(pwd):/build" -v "${CACHE_DIR}:/cache" \
-e BUILDER_UID="${BUILDER_UID}" -e BUILDER_GID="${BUILDER_GID}" \
hassos:local ${COMMAND}
hassos:local "${@:-bash}"