Created
September 29, 2025 04:29
-
-
Save uberhacker/874beb4388188d6a8a70df927723cb3e to your computer and use it in GitHub Desktop.
Enhanced chromebrew docker container launcher based on satmandu's crewbuild script. See https://gist.github.com/satmandu.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/bash | |
| SCRIPT_NAME=$(basename "$0") | |
| USAGE="Usage: $SCRIPT_NAME armv7l|i686|x86_64" | |
| if [ ! -d "$HOME/.ssh" ]; then | |
| echo "$HOME/.ssh directory does not exist." | |
| echo "Add your GitHub ssh keys and try again." | |
| exit 1 | |
| fi | |
| if [ ! -d "$(pwd)/pkg_cache" ]; then | |
| echo "$(pwd)/pkg_cache directory does not exist." | |
| echo "Execute 'mkdir pkg_cache' and try again." | |
| exit 1 | |
| fi | |
| if [ ! -d "$(pwd)/chromebrew" ]; then | |
| echo "$(pwd)/chromebrew directory does not exist." | |
| echo "Execute 'git clone https://github.com/chromebrew/chromebrew.git' and try again." | |
| exit 1 | |
| fi | |
| if ! test "$1"; then | |
| echo "$USAGE" | |
| exit 1 | |
| fi | |
| case "$1" in | |
| aarch64|arm|armv7|armv7l|armv8) | |
| ARCH=armv7l | |
| BOARD=fievel | |
| MILESTONE=m91 | |
| PLATFORM=linux/arm/v7 | |
| ;; | |
| i386|i686|ia32|x86) | |
| ARCH=i686 | |
| BOARD=alex | |
| MILESTONE=m58 | |
| PLATFORM=linux/386 | |
| ;; | |
| ia64|x64|x86_64) | |
| ARCH=x86_64 | |
| BOARD=nocturne | |
| MILESTONE=m90 | |
| PLATFORM=linux/amd64 | |
| ;; | |
| *) | |
| echo "$USAGE" | |
| exit 1 | |
| ;; | |
| esac | |
| test "$2" && BOARD=$2 | |
| test "$3" && MILESTONE=$3 | |
| SESSION_TYPE= | |
| if [ -n "$SSH_CLIENT" ] || [ -n "$SSH_TTY" ]; then | |
| SESSION_TYPE=remote/ssh | |
| elif pstree -p | egrep --quiet --extended-regexp ".*sshd.*\($$\)"; then | |
| SESSION_TYPE=remote/ssh | |
| else | |
| case $(ps -o comm= -p $PPID) in | |
| sshd|*/sshd) SESSION_TYPE=remote/ssh;; | |
| esac | |
| fi | |
| if [ -z ${PAGER} ]; then | |
| PAGER_PASSTHROUGH= | |
| echo "PAGER is not set." | |
| else | |
| PAGER_PASSTHROUGH="-e CONTAINER_PAGER=${PAGER}" | |
| fi | |
| CONTAINER_HOME=/home/chronos/user | |
| ENVIRONMENT="-e DISPLAY=${DISPLAY:-:0.0}" | |
| #ENVIRONMENT+=" --env-file=${HOME}/chromebrew/.env" | |
| VOLUMES="-v $(pwd)/pkg_cache:/usr/local/tmp/packages" | |
| VOLUMES+=" -v $(pwd)/chromebrew:${CONTAINER_HOME}/chromebrew" | |
| VOLUMES+=" -v $(pwd):/output -v ${HOME}/.ssh:${CONTAINER_HOME}/.ssh" | |
| VOLUMES+=" -v ${HOME}/.git-prompt.sh:${CONTAINER_HOME}/.git-prompt.sh" | |
| VOLUMES+=" -v ${HOME}/.gitconfig:${CONTAINER_HOME}/.gitconfig" | |
| VOLUMES+=" -v ${HOME}/.bashrc:${CONTAINER_HOME}/.bash_profile" | |
| if ! [[ $SESSION_TYPE == remote/ssh ]] && [ -d /tmp/.X11-unix ]; then | |
| VOLUMES+=" -v /tmp/.X11-unix:/tmp/.X11-unix" | |
| fi | |
| if [ -f "$HOME"/.Xauthority ]; then | |
| VOLUMES+=" -v $HOME/.Xauthority:/home/chronos/user/.Xauthority:rw" | |
| VOLUMES+=" -v $HOME/.Xauthority:/home/chronos/.Xauthority:rw" | |
| fi | |
| IMAGE="satmandu/crewbuild:$BOARD-$ARCH.$MILESTONE" | |
| docker pull --platform $PLATFORM $IMAGE | |
| docker pull tonistiigi/binfmt | |
| docker run --privileged --rm tonistiigi/binfmt --install all | |
| echo "docker run --platform $PLATFORM --rm --net=host ${PAGER_PASSTHROUGH} ${ENVIRONMENT} ${VOLUMES} -h $(hostname)-$ARCH -it $IMAGE" | |
| docker run --platform $PLATFORM --rm --net=host ${PAGER_PASSTHROUGH} ${ENVIRONMENT} ${VOLUMES} -h $(hostname)-$ARCH -it $IMAGE |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment