mirror of
https://github.com/home-assistant/operating-system.git
synced 2025-11-06 17:38:34 +00:00
* 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>
30 lines
780 B
Bash
Executable File
30 lines
780 B
Bash
Executable File
#!/bin/bash
|
|
set -e
|
|
|
|
BUILDER_UID="$(id -u)"
|
|
BUILDER_GID="$(id -g)"
|
|
CACHE_DIR="${CACHE_DIR:-$HOME/hassos-cache}"
|
|
|
|
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
|
|
|
|
mkdir -p "${CACHE_DIR}"
|
|
docker build -t hassos:local .
|
|
|
|
if [ ! -f buildroot/Makefile ]; then
|
|
# Initialize git submodule
|
|
git submodule update --init
|
|
fi
|
|
|
|
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
|
|
|
|
docker run -it --rm --privileged \
|
|
-v "$(pwd):/build" -v "${CACHE_DIR}:/cache" \
|
|
-e BUILDER_UID="${BUILDER_UID}" -e BUILDER_GID="${BUILDER_GID}" \
|
|
hassos:local "${@:-bash}"
|