assemble: fix declaration of multiple hooks, fix support for pipes. Fix #853

Signed-off-by: Luca Di Maio <luca.dimaio1@gmail.com>
This commit is contained in:
Luca Di Maio
2023-08-05 14:53:32 +02:00
parent 8710f04555
commit c4c4766cbb
2 changed files with 25 additions and 13 deletions

View File

@@ -255,36 +255,48 @@ run_distrobox() (
result_command="${result_command} --home $(sanitize_variable "${home}")"
fi
if [ -n "${init_hooks}" ]; then
IFS="|"
IFS="¤"
args=":"
for arg in ${init_hooks}; do
args="${args} && ${arg}"
if ! echo "${arg}" | grep -q ';$' &&
! echo "${arg}" | grep -q "&&$"; then
args="${args} && ${arg}"
else
args="${args} ${arg}"
fi
done
result_command="${result_command} --init-hooks $(sanitize_variable "${args}")"
fi
# Replicable flags
if [ -n "${pre_init_hooks}" ]; then
IFS="|"
IFS="¤"
args=":"
for arg in ${pre_init_hooks}; do
args="${args} && ${arg}"
if ! echo "${arg}" | grep -q ';$' &&
! echo "${arg}" | grep -q "&&$"; then
args="${args} && ${arg}"
else
args="${args} ${arg}"
fi
done
result_command="${result_command} --pre-init-hooks $(sanitize_variable "${args}")"
fi
if [ -n "${additional_packages}" ]; then
IFS="|"
IFS="¤"
args=""
for packages in ${additional_packages}; do
result_command="${result_command} --additional-packages $(sanitize_variable "${packages}")"
args="${args} ${packages}"
done
result_command="${result_command} --additional-packages $(sanitize_variable "${args}")"
fi
if [ -n "${volume}" ]; then
IFS="|"
IFS=" "
for vol in ${volume}; do
result_command="${result_command} --volume $(sanitize_variable "${vol}")"
done
fi
if [ -n "${additional_flags}" ]; then
IFS="|"
IFS="¤"
for flag in ${additional_flags}; do
result_command="${result_command} --additional-flags $(sanitize_variable "${flag}")"
done
@@ -371,8 +383,8 @@ parse_file() (
# Save options to tempfile, to source it later
touch "${tmpfile}"
if [ -n "${key}" ] && [ -n "${value}" ]; then
if grep -q "${key}" "${tmpfile}"; then
value="$(echo "${value}" | sed "s|\"|\" \${${key}} |")"
if grep -q "${key}=" "${tmpfile}"; then
value="$(echo "${value}" | sed "s|\"|\" \${${key}}¤|")"
fi
echo "${key}=${value}" >> "${tmpfile}"
fi

View File

@@ -1256,7 +1256,7 @@ if [ "${nvidia}" -eq 1 ]; then
# In the guest we need to adjust the destination path, so if we're on
# debian based containers, we need to target /usr/lib/x86_64-linux-gnu/
if [ -e "/usr/lib/x86_64-linux-gnu/" ]; then
if [ "${type}" == "link" ]; then
if [ "${type}" = "link" ]; then
cp -d "${nvidia_lib}" "/usr/lib/x86_64-linux-gnu/${dest_file}"
continue
fi
@@ -1264,7 +1264,7 @@ if [ "${nvidia}" -eq 1 ]; then
mount_bind "${nvidia_lib}" "/usr/lib/x86_64-linux-gnu/${dest_file}" ro
# /usr/lib64 is common in rpm based distros
elif [ -e "/usr/lib64" ]; then
if [ "${type}" == "link" ]; then
if [ "${type}" = "link" ]; then
cp -d "${nvidia_lib}" "/usr/lib64/${dest_file}"
continue
fi
@@ -1272,7 +1272,7 @@ if [ "${nvidia}" -eq 1 ]; then
mount_bind "${nvidia_lib}" "/usr/lib64/${dest_file}" ro
# fallback to /usr/lib if none of the previous
else
if [ "${type}" == "link" ]; then
if [ "${type}" = "link" ]; then
cp -d "${nvidia_lib}" "/usr/lib/${dest_file}"
continue
fi