@ -17,16 +17,18 @@
ANSI_ESC=$'\e['
ANSI_ESC=$'\e['
md5_compat() {
if get_path md5sum >/dev/null; then
md5_compat() { md5sum | cut -c -32; }
hash_get() {
if get_path sha256sum >/dev/null; then
hash_get() { local x; x=$(sha256sum) || return 1; echo "${x:0:32}"; }
elif get_path md5sum >/dev/null; then
hash_get() { local x; x=$(md5sum) || return 1; echo "${x:0:32}"; }
elif get_path md5 >/dev/null; then
elif get_path md5 >/dev/null; then
md5_compa t() { md5; }
hash_ge t() { md5; }
else
else
die "$exname: required GNU or BSD date not found"
err "required GNU md5sum or BSD md5 not found"
return 1
fi
fi
md5_compa t
hash_ge t
}
}
@ -408,14 +410,14 @@ get_hash_image() {
p0 ""
p0 ""
[ -n "$override" ] && cat "$override"
[ -n "$override" ] && cat "$override"
true
true
} | md5_compa t
} | hash_ge t
return "${PIPESTATUS[0]}"
return "${PIPESTATUS[0]}"
}
}
get_compose_file_opt() {
get_compose_file_opt() {
local hash_bin="$1" override="$2" \
local hash_bin="$1" override="$2" \
cache_file="$COMPOSE_LAUNCHER_CACHE/$FUNCNAME.cache.$(p0 "$@" | md5_compa t)"
cache_file="$COMPOSE_LAUNCHER_CACHE/$FUNCNAME.cache.$(p0 "$@" | hash_ge t)"
if [ -e "$cache_file" ]; then
if [ -e "$cache_file" ]; then
cat "$cache_file" &&
cat "$cache_file" &&
touch "$cache_file" || return 1
touch "$cache_file" || return 1
@ -454,7 +456,7 @@ get_compose_file_opt() {
replace_compose_file_opt() {
replace_compose_file_opt() {
local hash_bin="$1" override="$2" \
local hash_bin="$1" override="$2" \
cache_file="$COMPOSE_LAUNCHER_CACHE/$FUNCNAME.cache.$(p0 "$@" | md5_compa t)"
cache_file="$COMPOSE_LAUNCHER_CACHE/$FUNCNAME.cache.$(p0 "$@" | hash_ge t)"
if [ -e "$cache_file" ]; then
if [ -e "$cache_file" ]; then
cat "$cache_file" &&
cat "$cache_file" &&
touch "$cache_file" || return 1
touch "$cache_file" || return 1
@ -565,7 +567,7 @@ get_compose_single_opts_list() {
get_volume_opt() {
get_volume_opt() {
local cache_file="$COMPOSE_LAUNCHER_CACHE/$FUNCNAME.cache.$(p0 "$@" | md5_compa t)"
local cache_file="$COMPOSE_LAUNCHER_CACHE/$FUNCNAME.cache.$(p0 "$@" | hash_ge t)"
if [ -e "$cache_file" ]; then
if [ -e "$cache_file" ]; then
cat "$cache_file" &&
cat "$cache_file" &&
touch "$cache_file" || return 1
touch "$cache_file" || return 1
@ -800,7 +802,7 @@ mk_docker_run_options() {
## get TZ value and prepare TZ_PATH
## get TZ value and prepare TZ_PATH
TZ=$(get_tz) || return 1
TZ=$(get_tz) || return 1
mkdir -p "${TZ_PATH}"
mkdir -p "${TZ_PATH}"
TZ_PATH="${TZ_PATH}/$(e "$TZ" | sha256sum | cut -c 1-8)" || return 1
TZ_PATH="${TZ_PATH}/$(e "$TZ" | hash_get | cut -c 1-8)" || return 1
[ -e "$TZ_PATH" ] || e "$TZ" > "$TZ_PATH"
[ -e "$TZ_PATH" ] || e "$TZ" > "$TZ_PATH"
## CACHE/DATA DIRS
## CACHE/DATA DIRS
@ -913,7 +915,7 @@ mk_docker_run_options() {
## Docker host is not same linux than WSL, so
## Docker host is not same linux than WSL, so
## access to root files are not the same.
## access to root files are not the same.
##YYYvlab, check on cp where is the base
##YYYvlab, check on cp where is the base
dst="$COMPOSE_LAUNCHER_CACHE/compose.$(md5_compa t < "$compose_file").yml"
dst="$COMPOSE_LAUNCHER_CACHE/compose.$(hash_ge t < "$compose_file").yml"
cp "$compose_file" "$dst"
cp "$compose_file" "$dst"
## docker host start with /c/... whereas WSL could start with /mnt/c/...
## docker host start with /c/... whereas WSL could start with /mnt/c/...
local="$dst"
local="$dst"
@ -938,12 +940,11 @@ mk_docker_run_options() {
clean_unused_sessions
clean_unused_sessions
filename=$(mktemp -p /tmp/ -t launch_opts-XXXXXXXXXXXXXXXX)
filename=$(mktemp -p /tmp/ -t launch_opts-XXXXXXXXXXXXXXXX)
p0 "${docker_run_opts[@]}" > "$filename"
p0 "${docker_run_opts[@]}" > "$filename"
sha=$(sha256sum "$filename")
sha=${sha:0:64}
src="$SESSION_DIR/$UID-$sha"
dest="/var/lib/compose/sessions/$UID-$sha"
hash=$(hash_get < "$filename") || return 1
src="$SESSION_DIR/$UID-$hash"
dest="/var/lib/compose/sessions/$UID-$hash"
additional_docker_run_opts=(
additional_docker_run_opts=(
"-v" "$SESSION_DIR/$UID-$sha :$dest:ro"
"-v" "$SESSION_DIR/$UID-$ha sh:$dest:ro"
"-e" "COMPOSE_LAUNCHER_OPTS=$dest"
"-e" "COMPOSE_LAUNCHER_OPTS=$dest"
"-e" "COMPOSE_LAUNCHER_BIN=$COMPOSE_LAUNCHER_BIN"
"-e" "COMPOSE_LAUNCHER_BIN=$COMPOSE_LAUNCHER_BIN"
)
)