Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 2 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -235,10 +235,9 @@ Those package repositories are pre-installed in Geodesic, so
all you need to do is add the packages you want via

```Dockerfile
RUN apt-get update && apt-get install -y` commands in your Dockerfile.
RUN apt-get update && apt-get install -y <package-name>...
```

The package manager will automatically select the correct architecture for the package.
commands in your Dockerfile. The package manager will automatically select the correct architecture for the package.

#### Pinning package versions in Debian

Expand Down
5 changes: 2 additions & 3 deletions README.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -236,10 +236,9 @@ usage: |-
all you need to do is add the packages you want via

```Dockerfile
RUN apt-get update && apt-get install -y` commands in your Dockerfile.
RUN apt-get update && apt-get install -y <package-name>...
```

The package manager will automatically select the correct architecture for the package.
commands in your Dockerfile. The package manager will automatically select the correct architecture for the package.

#### Pinning package versions in Debian

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
cryptography==43.0.1
cryptography==44.0.1
PyYAML==6.0.1
awscli==1.33.10
boto3==1.34.128
2 changes: 1 addition & 1 deletion os/debian/Dockerfile.debian
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ ENV XDG_CACHE_HOME=/var/cache/xdg_cache_home
RUN for dir in $XDG_DATA_HOME $XDG_CONFIG_HOME $XDG_CACHE_HOME; do \
mkdir -p $dir; chmod 777 $dir; done

ENV BANNER "geodesic"
ENV BANNER="geodesic"

# Install all packages as root
USER root
Expand Down
28 changes: 19 additions & 9 deletions rootfs/etc/profile.d/_07-term-mode.sh
Original file line number Diff line number Diff line change
Expand Up @@ -75,28 +75,38 @@ function _is_term_dark_mode() {
saved_state=$(stty -g)
trap 'stty "$saved_state"' EXIT
_terminal_trace 'Checking terminal color scheme...'
stty -echo
echo -ne '\e]10;?\a\e]11;?\a' >/dev/tty
# Timeout of 2 was not enough when waking for sleep.
# The second read should be part of the first response, should not need much time at all regardless.
# When in a signal handler, we might be waking from sleep or hibernation, so we give it a lot more time.
timeout_duration=$([[ ${GEODESIC_TERM_COLOR_SIGNAL} == "true" ]] && echo 30 || echo 1)
timeout_duration="0.6"
stty -echo
# Query the terminal for the foreground color. Use printf to ensure the string is output as a single block,
# without interference from other processes writing to the terminal.
printf '\e]10;?\a' >/dev/tty
IFS=: read -rs -t "$timeout_duration" -d $'\a' x fg_rgb </dev/tty
exit_code=$?
[[ $exit_code -gt 128 ]] || [[ -z $fg_rgb ]] && [[ ${GEODESIC_TERM_COLOR_SIGNAL} == "true" ]] && export GEODESIC_TERM_COLOR_AUTO=disabled
[[ $exit_code -gt 128 ]] || [[ -z $fg_rgb ]] && [[ ${GEODESIC_TERM_COLOR_UPDATING} == "true" ]] && export GEODESIC_TERM_COLOR_AUTO=disabled
[[ $exit_code -gt 128 ]] || exit_code=0
IFS=: read -rs -t 0.5 -d $'\a' x bg_rgb </dev/tty
((exit_code += $?))
if [[ $exit_code -eq 0 ]] && [[ -n $fg_rgb ]]; then
# Query the terminal for the background color
printf '\e]11;?\a' >/dev/tty
IFS=: read -rs -t "$timeout_duration" -d $'\a' x bg_rgb </dev/tty
exit_code=$?
[[ $exit_code -gt 128 ]] || [[ -z $bg_rgb ]] && [[ ${GEODESIC_TERM_COLOR_UPDATING} == "true" ]] && export GEODESIC_TERM_COLOR_AUTO=disabled
fi
stty "$saved_state"
trap - EXIT
else
_terminal_trace "${FUNCNAME[0]} called, but not running in a color terminal."
fi

if [[ ${GEODESIC_TERM_COLOR_SIGNAL} == "true" ]] && [[ ${GEODESIC_TERM_COLOR_AUTO} == "disabled" ]]; then
printf "\n\n\tTerminal light/dark mode detection failed from signal handler. Disabling automatic detection.\n" >&2
if [[ ${GEODESIC_TERM_COLOR_UPDATING} == "true" ]] && [[ ${GEODESIC_TERM_COLOR_AUTO} == "disabled" ]]; then
printf "\n\n################# Begin Message from Geodesic ################\n\n" >&2
printf "\tTerminal automatic light/dark mode detection failed from shell prompt hook. Disabling automatic detection.\n" >&2
printf "\tYou can manually change modes with\n\n\tupdate-terminal-color-mode [dark|light]\n\n" >&2
printf "\tYou can re-enable automatic detection with\n\n\tunset GEODESIC_TERM_COLOR_AUTO\n\n" >&2
printf "################# End Message from Geodesic ##################\n\n" >&2
echo "auto-detect-failed"
return 9
fi

if [[ $exit_code -gt 128 ]] || [[ -z $fg_rgb ]] || [[ -z $bg_rgb ]]; then
Expand Down
35 changes: 28 additions & 7 deletions rootfs/etc/profile.d/_10-colors.sh
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,15 @@ function update-terminal-color-mode() {
;;
esac

if [[ $new_mode == "unknown" ]]; then
if [[ "$new_mode" == "auto-detect-failed" ]]; then
if [[ "$quiet" == "true" ]]; then
return 9
else
new_mode="unknown"
fi
fi

if [[ "$new_mode" == "unknown" ]]; then
if ! tty -s; then
[[ "$quiet" == "true" ]] || echo "No terminal detected." >&2
elif [[ -z "$(tput op 2>/dev/null)" ]]; then
Expand Down Expand Up @@ -138,11 +146,13 @@ function _geodesic_tput_cache_init() {
;;
esac

# Treat any failure of color detection as historical default "light" mode
if [[ $new_mode == "dark" ]]; then
_geodesic_tput_cache[black]=$(tput setaf 7) # swap black and white
_geodesic_tput_cache[white]=$(tput setaf 0) # 0 is ANSI black, 7 is ANSI white
_geodesic_tput_cache[blue]=${_geodesic_tput_cache[cyan]} # blue is too dark, use cyan instead
else
new_mode="light"
_geodesic_tput_cache[yellow]=${_geodesic_tput_cache[magenta]} # yellow is too light, use magenta instead
fi

Expand Down Expand Up @@ -297,18 +307,29 @@ function reset_terminal_colors() {

_geodesic_tput_cache_init

function auto-update-terminal-color-mode() {
[[ ${GEODESIC_TERM_COLOR_UPDATING} == "true" ]] || [[ ${GEODESIC_TERM_COLOR_AUTO:-true} != "true" ]] && return 0

# Ignore repeated signals while a signal is being processed
export GEODESIC_TERM_COLOR_UPDATING=true
update-terminal-color-mode quiet
if [[ $? -eq 9 ]]; then
# If the color detection failed, we disable automatic detection.
export GEODESIC_TERM_COLOR_AUTO=disabled
fi
unset GEODESIC_TERM_COLOR_UPDATING
}

# Although SIGWINCH is a standard signal to indicate the window *size* has changed,
# some terminals (not sure which ones) also send a SIGWINCH signal when the window colors change.
# For the other terminals, catching SIGWINCH gives users an easy way of triggering a color update: resize the window.
# So we catch the signal to update the terminal colors, preserving any existing signal handlers.

# However, we do the actual color update in a separate function called from the shell prompt command,
# to avoid issues with async access to the TTY and other issues with running inside a signal handler.
function _update-terminal-color-mode-sigwinch() {
[[ ${GEODESIC_TERM_COLOR_SIGNAL} == "true" ]] || [[ ${GEODESIC_TERM_COLOR_AUTO:-true} != "true" ]] && return 0

# Ignore repeated signals while a signal is being processed
export GEODESIC_TERM_COLOR_SIGNAL=true
update-terminal-color-mode quiet
unset GEODESIC_TERM_COLOR_SIGNAL
[[ ${GEODESIC_TERM_COLOR_UPDATING} == "true" ]] || [[ ${GEODESIC_TERM_COLOR_AUTO:-true} != "true" ]] && return 0
export GEODESIC_TERM_COLOR_UPDATING="needed"
}

if [[ ${GEODESIC_TERM_COLOR_AUTO} != "unsupported" ]] && _is_color_term; then
Expand Down
5 changes: 5 additions & 0 deletions rootfs/etc/profile.d/prompt.sh
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,14 @@ function reload() {
if [ "${current_screen_size}" != "${SCREEN_SIZE}" ]; then
echo "* Screen resized to ${current_screen_size}"
export SCREEN_SIZE=${current_screen_size}
# Use this opportunity to see if the terminal color mode has changed
export GEODESIC_TERM_COLOR_UPDATING="needed"
# Instruct shell that window size has changed to ensure lines wrap correctly
kill -WINCH $$
fi
if [[ $GEODESIC_TERM_COLOR_UPDATING == "needed" ]]; then
auto-update-terminal-color-mode
fi
}

# Define our own prompt
Expand Down
12 changes: 12 additions & 0 deletions rootfs/templates/wrapper-body.sh
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,19 @@ function parse_args() {
--no-motd*)
export GEODESIC_MOTD_ENABLED=false
;;
--workspace)
# WORKSPACE_FOLDER_HOST_DIR takes precedence over WORKSPACE, but we allow the command line option to override both
# So even thought the option is --workspace, we still set WORKSPACE_FOLDER_HOST_DIR
# We unset WORKSPACE to avoid a warning later when they are both set to different values
unset WORKSPACE
[ -n "$WORKSPACE_FOLDER_HOST_DIR" ] && echo "# Ignoring WORKSPACE_FOLDER_HOST_DIR=$WORKSPACE_FOLDER_HOST_DIR because --workspace is set" >&2
WORKSPACE_FOLDER_HOST_DIR="${1}"
shift
;;
--workspace=*)
# WORKSPACE_FOLDER_HOST_DIR takes precedence over WORKSPACE, but to save ourselves hassle over parsing the option,
# we just unset WORKSPACE_FOLDER_HOST_DIR and let normal option processing set WORKSPACE
[ -n "$WORKSPACE_FOLDER_HOST_DIR" ] && echo "# Ignoring WORKSPACE_FOLDER_HOST_DIR=$WORKSPACE_FOLDER_HOST_DIR because --workspace is set" >&2
unset WORKSPACE_FOLDER_HOST_DIR
# ;& # fall through only introduced in bash 4.0, we want to remain 3.2 compatible
options+=("${arg}")
Expand Down