Skip to content

Commit 35c47fe

Browse files
authored
V4 second bugfixes (#969)
1 parent 73778fa commit 35c47fe

File tree

8 files changed

+70
-24
lines changed

8 files changed

+70
-24
lines changed

README.md

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -235,10 +235,9 @@ Those package repositories are pre-installed in Geodesic, so
235235
all you need to do is add the packages you want via
236236

237237
```Dockerfile
238-
RUN apt-get update && apt-get install -y` commands in your Dockerfile.
238+
RUN apt-get update && apt-get install -y <package-name>...
239239
```
240-
241-
The package manager will automatically select the correct architecture for the package.
240+
commands in your Dockerfile. The package manager will automatically select the correct architecture for the package.
242241

243242
#### Pinning package versions in Debian
244243

README.yaml

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -236,10 +236,9 @@ usage: |-
236236
all you need to do is add the packages you want via
237237
238238
```Dockerfile
239-
RUN apt-get update && apt-get install -y` commands in your Dockerfile.
239+
RUN apt-get update && apt-get install -y <package-name>...
240240
```
241-
242-
The package manager will automatically select the correct architecture for the package.
241+
commands in your Dockerfile. The package manager will automatically select the correct architecture for the package.
243242
244243
#### Pinning package versions in Debian
245244
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
cryptography==43.0.1
1+
cryptography==44.0.1
22
PyYAML==6.0.1
33
awscli==1.33.10
44
boto3==1.34.128

os/debian/Dockerfile.debian

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ ENV XDG_CACHE_HOME=/var/cache/xdg_cache_home
9595
RUN for dir in $XDG_DATA_HOME $XDG_CONFIG_HOME $XDG_CACHE_HOME; do \
9696
mkdir -p $dir; chmod 777 $dir; done
9797

98-
ENV BANNER "geodesic"
98+
ENV BANNER="geodesic"
9999

100100
# Install all packages as root
101101
USER root

rootfs/etc/profile.d/_07-term-mode.sh

Lines changed: 19 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -75,28 +75,38 @@ function _is_term_dark_mode() {
7575
saved_state=$(stty -g)
7676
trap 'stty "$saved_state"' EXIT
7777
_terminal_trace 'Checking terminal color scheme...'
78-
stty -echo
79-
echo -ne '\e]10;?\a\e]11;?\a' >/dev/tty
8078
# Timeout of 2 was not enough when waking for sleep.
81-
# The second read should be part of the first response, should not need much time at all regardless.
8279
# When in a signal handler, we might be waking from sleep or hibernation, so we give it a lot more time.
83-
timeout_duration=$([[ ${GEODESIC_TERM_COLOR_SIGNAL} == "true" ]] && echo 30 || echo 1)
80+
timeout_duration="0.6"
81+
stty -echo
82+
# Query the terminal for the foreground color. Use printf to ensure the string is output as a single block,
83+
# without interference from other processes writing to the terminal.
84+
printf '\e]10;?\a' >/dev/tty
8485
IFS=: read -rs -t "$timeout_duration" -d $'\a' x fg_rgb </dev/tty
8586
exit_code=$?
86-
[[ $exit_code -gt 128 ]] || [[ -z $fg_rgb ]] && [[ ${GEODESIC_TERM_COLOR_SIGNAL} == "true" ]] && export GEODESIC_TERM_COLOR_AUTO=disabled
87+
[[ $exit_code -gt 128 ]] || [[ -z $fg_rgb ]] && [[ ${GEODESIC_TERM_COLOR_UPDATING} == "true" ]] && export GEODESIC_TERM_COLOR_AUTO=disabled
8788
[[ $exit_code -gt 128 ]] || exit_code=0
88-
IFS=: read -rs -t 0.5 -d $'\a' x bg_rgb </dev/tty
89-
((exit_code += $?))
89+
if [[ $exit_code -eq 0 ]] && [[ -n $fg_rgb ]]; then
90+
# Query the terminal for the background color
91+
printf '\e]11;?\a' >/dev/tty
92+
IFS=: read -rs -t "$timeout_duration" -d $'\a' x bg_rgb </dev/tty
93+
exit_code=$?
94+
[[ $exit_code -gt 128 ]] || [[ -z $bg_rgb ]] && [[ ${GEODESIC_TERM_COLOR_UPDATING} == "true" ]] && export GEODESIC_TERM_COLOR_AUTO=disabled
95+
fi
9096
stty "$saved_state"
9197
trap - EXIT
9298
else
9399
_terminal_trace "${FUNCNAME[0]} called, but not running in a color terminal."
94100
fi
95101

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

102112
if [[ $exit_code -gt 128 ]] || [[ -z $fg_rgb ]] || [[ -z $bg_rgb ]]; then

rootfs/etc/profile.d/_10-colors.sh

Lines changed: 28 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,15 @@ function update-terminal-color-mode() {
3131
;;
3232
esac
3333

34-
if [[ $new_mode == "unknown" ]]; then
34+
if [[ "$new_mode" == "auto-detect-failed" ]]; then
35+
if [[ "$quiet" == "true" ]]; then
36+
return 9
37+
else
38+
new_mode="unknown"
39+
fi
40+
fi
41+
42+
if [[ "$new_mode" == "unknown" ]]; then
3543
if ! tty -s; then
3644
[[ "$quiet" == "true" ]] || echo "No terminal detected." >&2
3745
elif [[ -z "$(tput op 2>/dev/null)" ]]; then
@@ -138,11 +146,13 @@ function _geodesic_tput_cache_init() {
138146
;;
139147
esac
140148

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

@@ -297,18 +307,29 @@ function reset_terminal_colors() {
297307

298308
_geodesic_tput_cache_init
299309

310+
function auto-update-terminal-color-mode() {
311+
[[ ${GEODESIC_TERM_COLOR_UPDATING} == "true" ]] || [[ ${GEODESIC_TERM_COLOR_AUTO:-true} != "true" ]] && return 0
312+
313+
# Ignore repeated signals while a signal is being processed
314+
export GEODESIC_TERM_COLOR_UPDATING=true
315+
update-terminal-color-mode quiet
316+
if [[ $? -eq 9 ]]; then
317+
# If the color detection failed, we disable automatic detection.
318+
export GEODESIC_TERM_COLOR_AUTO=disabled
319+
fi
320+
unset GEODESIC_TERM_COLOR_UPDATING
321+
}
322+
300323
# Although SIGWINCH is a standard signal to indicate the window *size* has changed,
301324
# some terminals (not sure which ones) also send a SIGWINCH signal when the window colors change.
302325
# For the other terminals, catching SIGWINCH gives users an easy way of triggering a color update: resize the window.
303326
# So we catch the signal to update the terminal colors, preserving any existing signal handlers.
304-
327+
# However, we do the actual color update in a separate function called from the shell prompt command,
328+
# to avoid issues with async access to the TTY and other issues with running inside a signal handler.
305329
function _update-terminal-color-mode-sigwinch() {
306-
[[ ${GEODESIC_TERM_COLOR_SIGNAL} == "true" ]] || [[ ${GEODESIC_TERM_COLOR_AUTO:-true} != "true" ]] && return 0
307-
308330
# Ignore repeated signals while a signal is being processed
309-
export GEODESIC_TERM_COLOR_SIGNAL=true
310-
update-terminal-color-mode quiet
311-
unset GEODESIC_TERM_COLOR_SIGNAL
331+
[[ ${GEODESIC_TERM_COLOR_UPDATING} == "true" ]] || [[ ${GEODESIC_TERM_COLOR_AUTO:-true} != "true" ]] && return 0
332+
export GEODESIC_TERM_COLOR_UPDATING="needed"
312333
}
313334

314335
if [[ ${GEODESIC_TERM_COLOR_AUTO} != "unsupported" ]] && _is_color_term; then

rootfs/etc/profile.d/prompt.sh

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,9 +50,14 @@ function reload() {
5050
if [ "${current_screen_size}" != "${SCREEN_SIZE}" ]; then
5151
echo "* Screen resized to ${current_screen_size}"
5252
export SCREEN_SIZE=${current_screen_size}
53+
# Use this opportunity to see if the terminal color mode has changed
54+
export GEODESIC_TERM_COLOR_UPDATING="needed"
5355
# Instruct shell that window size has changed to ensure lines wrap correctly
5456
kill -WINCH $$
5557
fi
58+
if [[ $GEODESIC_TERM_COLOR_UPDATING == "needed" ]]; then
59+
auto-update-terminal-color-mode
60+
fi
5661
}
5762

5863
# Define our own prompt

rootfs/templates/wrapper-body.sh

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,19 @@ function parse_args() {
135135
--no-motd*)
136136
export GEODESIC_MOTD_ENABLED=false
137137
;;
138+
--workspace)
139+
# WORKSPACE_FOLDER_HOST_DIR takes precedence over WORKSPACE, but we allow the command line option to override both
140+
# So even thought the option is --workspace, we still set WORKSPACE_FOLDER_HOST_DIR
141+
# We unset WORKSPACE to avoid a warning later when they are both set to different values
142+
unset WORKSPACE
143+
[ -n "$WORKSPACE_FOLDER_HOST_DIR" ] && echo "# Ignoring WORKSPACE_FOLDER_HOST_DIR=$WORKSPACE_FOLDER_HOST_DIR because --workspace is set" >&2
144+
WORKSPACE_FOLDER_HOST_DIR="${1}"
145+
shift
146+
;;
138147
--workspace=*)
148+
# WORKSPACE_FOLDER_HOST_DIR takes precedence over WORKSPACE, but to save ourselves hassle over parsing the option,
149+
# we just unset WORKSPACE_FOLDER_HOST_DIR and let normal option processing set WORKSPACE
150+
[ -n "$WORKSPACE_FOLDER_HOST_DIR" ] && echo "# Ignoring WORKSPACE_FOLDER_HOST_DIR=$WORKSPACE_FOLDER_HOST_DIR because --workspace is set" >&2
139151
unset WORKSPACE_FOLDER_HOST_DIR
140152
# ;& # fall through only introduced in bash 4.0, we want to remain 3.2 compatible
141153
options+=("${arg}")

0 commit comments

Comments
 (0)