mirror of
https://github.com/home-assistant/operating-system.git
synced 2025-12-20 02:18:37 +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:
@@ -4,28 +4,26 @@ set -e
|
|||||||
BUILDER_UID="$(id -u)"
|
BUILDER_UID="$(id -u)"
|
||||||
BUILDER_GID="$(id -g)"
|
BUILDER_GID="$(id -g)"
|
||||||
CACHE_DIR="${CACHE_DIR:-$HOME/hassos-cache}"
|
CACHE_DIR="${CACHE_DIR:-$HOME/hassos-cache}"
|
||||||
ARGS="$*"
|
|
||||||
COMMAND="${ARGS:-bash}"
|
|
||||||
|
|
||||||
if [ "$BUILDER_UID" -eq "0" ] || [ "$BUILDER_GID" == "0" ]; then
|
if [ "$BUILDER_UID" -eq "0" ] || [ "$BUILDER_GID" == "0" ]; then
|
||||||
echo "ERROR: Please run this script as a regular (non-root) user with sudo privileges."
|
echo "ERROR: Please run this script as a regular (non-root) user with sudo privileges."
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
sudo mkdir -p "${CACHE_DIR}"
|
mkdir -p "${CACHE_DIR}"
|
||||||
sudo chown -R "${BUILDER_UID}:${BUILDER_GID}" "${CACHE_DIR}"
|
docker build -t hassos:local .
|
||||||
sudo docker build -t hassos:local .
|
|
||||||
|
|
||||||
if [ ! -f buildroot/Makefile ]; then
|
if [ ! -f buildroot/Makefile ]; then
|
||||||
# Initialize git submodule
|
# Initialize git submodule
|
||||||
git submodule update --init
|
git submodule update --init
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Make sure loop devices are present before starting the container
|
if command -v losetup >/dev/null && [ ! -e /dev/loop0 ]; then
|
||||||
sudo losetup -f > /dev/null
|
# Make sure loop devices are present before starting the container
|
||||||
|
sudo losetup -f > /dev/null
|
||||||
|
fi
|
||||||
|
|
||||||
# shellcheck disable=SC2086
|
docker run -it --rm --privileged \
|
||||||
sudo docker run -it --rm --privileged \
|
|
||||||
-v "$(pwd):/build" -v "${CACHE_DIR}:/cache" \
|
-v "$(pwd):/build" -v "${CACHE_DIR}:/cache" \
|
||||||
-e BUILDER_UID="${BUILDER_UID}" -e BUILDER_GID="${BUILDER_GID}" \
|
-e BUILDER_UID="${BUILDER_UID}" -e BUILDER_GID="${BUILDER_GID}" \
|
||||||
hassos:local ${COMMAND}
|
hassos:local "${@:-bash}"
|
||||||
|
|||||||
Reference in New Issue
Block a user