all: update formatting style

Signed-off-by: Luca Di Maio <luca.dimaio1@gmail.com>
This commit is contained in:
Luca Di Maio 2024-05-02 09:07:01 +02:00
parent 772e86b161
commit 25ced537c1
No known key found for this signature in database
GPG Key ID: 1CC3874E5EC80A3E
15 changed files with 103 additions and 46 deletions

View File

@ -33,7 +33,8 @@ version="1.7.2.0"
# None
# Outputs:
# print usage with examples.
show_help() {
show_help()
{
cat << EOF
distrobox version: ${version}

View File

@ -113,7 +113,8 @@ done
# None
# Outputs:
# print usage with examples.
show_help() {
show_help()
{
cat << EOF
distrobox version: ${version}
@ -245,7 +246,8 @@ fi
# None
# Outputs:
# execution of the proper distrobox-create command.
run_distrobox() {
run_distrobox()
{
name="${1}"
# Skip item if --name used and no match is found
@ -456,7 +458,8 @@ run_distrobox() {
# None
# Outputs:
# a value string sanitized
sanitize_variable() {
sanitize_variable()
{
variable="${1}"
# If there are spaces but no quotes, let's add them
@ -479,7 +482,8 @@ sanitize_variable() {
# None
# Outputs:
# None
parse_file() {
parse_file()
{
file="${1}"
name=""

View File

@ -41,7 +41,9 @@
# containers.
#
# SUDO_USER is a variable set by SUDO and can be used to check whether the script was called by it. Same thing for DOAS_USER, set by DOAS.
if { [ -n "${SUDO_USER}" ] || [ -n "${DOAS_USER}" ]; } && [ "$(id -ru)" -eq 0 ]; then
if {
[ -n "${SUDO_USER}" ] || [ -n "${DOAS_USER}" ]
} && [ "$(id -ru)" -eq 0 ]; then
printf >&2 "Running %s via SUDO/DOAS is not supported. Instead, please try running:\n" "$(basename "${0}")"
printf >&2 " %s --root %s\n" "$(basename "${0}")" "$*"
exit 1
@ -164,7 +166,8 @@ fi
# None
# Outputs:
# print usage with examples.
show_help() {
show_help()
{
cat << EOF
distrobox version: ${version}
@ -241,7 +244,8 @@ EOF
# None
# Outputs:
# print usage with examples.
show_compatibility() {
show_compatibility()
{
if [ ! -e "${app_cache_dir}/distrobox-compatibility-${version}" ] ||
[ ! -s "${app_cache_dir}/distrobox-compatibility-${version}" ]; then
mkdir -p "${app_cache_dir}"
@ -573,7 +577,8 @@ fi
# None
# Outputs:
# prints the image name of the newly cloned container
get_clone_image() {
get_clone_image()
{
# We need to clone a container.
# to do this we will commit the container and create a new tag. Then use it
# as image for the new container.
@ -639,7 +644,8 @@ get_clone_image() {
# None
# Outputs:
# prints the podman, docker or lilipod command to create the distrobox container
generate_create_command() {
generate_create_command()
{
# Set the container hostname the same as the container name.
result_command="${container_manager} create"
# use the host's namespace for ipc, network, pid, ulimit

View File

@ -55,7 +55,8 @@ trap cleanup TERM INT HUP EXIT
# None
# Outputs:
# None
cleanup() {
cleanup()
{
rm -f "${app_cache_dir}/.${container_name}.fifo"
if [ -n "${logs_pid:-}" ]; then
kill "${logs_pid:-}" 2> /dev/null || :
@ -71,7 +72,9 @@ cleanup() {
# containers.
#
# SUDO_USER is a variable set by SUDO and can be used to check whether the script was called by it. Same thing for DOAS_USER, set by DOAS.
if { [ -n "${SUDO_USER}" ] || [ -n "${DOAS_USER}" ]; } && [ "$(id -ru)" -eq 0 ]; then
if {
[ -n "${SUDO_USER}" ] || [ -n "${DOAS_USER}" ]
} && [ "$(id -ru)" -eq 0 ]; then
printf >&2 "Running %s via SUDO/DOAS is not supported. Instead, please try running:\n" "$(basename "${0}")"
printf >&2 " %s --root %s\n" "$(basename "${0}")" "$*"
exit 1
@ -161,7 +164,8 @@ fi
# None
# Outputs:
# print usage with examples.
show_help() {
show_help()
{
cat << EOF
distrobox version: ${version}
@ -365,7 +369,8 @@ fi
# XDG_CONFIG_DIRS
# Outputs:
# prints the podman, docker or lilipod command to enter the distrobox container
generate_enter_command() {
generate_enter_command()
{
result_command="${container_manager} exec"
result_command="${result_command}
--interactive"

View File

@ -31,7 +31,9 @@
# containers.
#
# SUDO_USER is a variable set by SUDO and can be used to check whether the script was called by it. Same thing for DOAS_USER, set by DOAS.
if { [ -n "${SUDO_USER}" ] || [ -n "${DOAS_USER}" ]; } && [ "$(id -ru)" -eq 0 ]; then
if {
[ -n "${SUDO_USER}" ] || [ -n "${DOAS_USER}" ]
} && [ "$(id -ru)" -eq 0 ]; then
printf >&2 "Running %s via SUDO/DOAS is not supported. Instead, please try running:\n" "$(basename "${0}")"
printf >&2 " %s --root %s\n" "$(basename "${0}")" "$*"
exit 1
@ -95,7 +97,8 @@ done
# None
# Outputs:
# print usage with examples.
show_help() {
show_help()
{
cat << EOF
distrobox version: ${version}
@ -218,7 +221,8 @@ fi
# None
# Outputs:
# prints the distrobox-create command handling special flags
generate_ephemeral_create_command() {
generate_ephemeral_create_command()
{
result_command="${distrobox_path}/distrobox-create"
if [ -n "${container_manager_additional_flags}" ]; then
result_command="${result_command} \
@ -254,7 +258,8 @@ generate_ephemeral_create_command() {
# None
# Outputs:
# None
cleanup() {
cleanup()
{
trap - TERM INT HUP
# shellcheck disable=SC2086
"${distrobox_path}"/distrobox-rm ${extra_flags} --force "${name}" --yes

View File

@ -72,7 +72,8 @@ done
# None
# Outputs:
# print usage with examples.
show_help() {
show_help()
{
cat << EOF
distrobox version: ${version}
@ -330,7 +331,8 @@ fi
# None
# Outputs:
# print generated script.
generate_script() {
generate_script()
{
cat << EOF
#!/bin/sh
# distrobox_binary
@ -363,7 +365,8 @@ EOF
# Outputs:
# a generated_script in dest_path
# or error code.
export_binary() {
export_binary()
{
# Ensure the binary we're exporting is installed
if [ ! -f "${exported_bin}" ]; then
printf >&2 "Error: cannot find %s.\n" "${exported_bin}"
@ -431,7 +434,8 @@ export_binary() {
# needed icons in /run/host/$host_home/.local/share/icons
# needed desktop files in /run/host/$host_home/.local/share/applications
# or error code.
export_application() {
export_application()
{
canon_dirs=""
IFS=":"
@ -622,7 +626,8 @@ export_application() {
# Outputs:
# a list of exported apps
# or error code.
list_exported_applications() {
list_exported_applications()
{
# In this phase we search for applications exported.
# First find command will grep through all files in the canonical directories
# and only list files that contain the $DISTROBOX_ENTER_PATH.
@ -659,7 +664,8 @@ list_exported_applications() {
# Outputs:
# a list of exported apps
# or error code.
list_exported_binaries() {
list_exported_binaries()
{
# In this phase we search for binaries exported.
# First find command will grep through all files in the canonical directories
# and only list files that contain the comment "# distrobox_binary".

View File

@ -29,7 +29,9 @@
# containers.
#
# SUDO_USER is a variable set by SUDO and can be used to check whether the script was called by it. Same thing for DOAS_USER, set by DOAS.
if { [ -n "${SUDO_USER}" ] || [ -n "${DOAS_USER}" ]; } && [ "$(id -ru)" -eq 0 ]; then
if {
[ -n "${SUDO_USER}" ] || [ -n "${DOAS_USER}" ]
} && [ "$(id -ru)" -eq 0 ]; then
printf >&2 "Running %s via SUDO/DOAS is not supported. Instead, please try running:\n" "$(basename "${0}")"
printf >&2 " %s --root %s\n" "$(basename "${0}")" "$*"
exit 1
@ -90,7 +92,8 @@ done
# None
# Outputs:
# print usage with examples.
show_help() {
show_help()
{
cat << EOF
distrobox version: ${version}

View File

@ -42,7 +42,8 @@ version="1.7.2.0"
# None
# Outputs:
# print usage with examples.
show_help() {
show_help()
{
cat << EOF
distrobox version: ${version}

View File

@ -60,7 +60,8 @@ version="1.7.2.0"
# None
# Outputs:
# print usage with examples.
show_help() {
show_help()
{
cat << EOF
distrobox version: ${version}
@ -221,7 +222,8 @@ fi
# None
# Outputs:
# Comma-separated list of locked mount flags
get_locked_mount_flags() {
get_locked_mount_flags()
{
src="$1"
prev=""
locked_flags=""
@ -267,7 +269,8 @@ get_locked_mount_flags() {
# None
# Outputs:
# original path the link is pointing
init_readlink() {
init_readlink()
{
# shellcheck disable=SC2010
ls -l "${1}" | grep -Eo '\->.*' | cut -d' ' -f2- | sed 's|\.\./|/|g'
}
@ -284,7 +287,8 @@ init_readlink() {
# Outputs:
# No output if all ok
# Error if not
mount_bind() {
mount_bind()
{
source_dir="$1"
target_dir="$2"
mount_flags=""
@ -412,7 +416,9 @@ PATH="${PATH}:/bin:/sbin:/usr/bin:/usr/sbin"
# Check if dependencies are met for the script to run.
if [ "${upgrade}" -ne 0 ] ||
[ "${missing_packages}" -ne 0 ] ||
{ [ -n "${container_additional_packages}" ] && [ ! -e /.containersetupdone ]; }; then
{
[ -n "${container_additional_packages}" ] && [ ! -e /.containersetupdone ]
}; then
# Detect the available package manager
# install minimal dependencies needed to bootstrap the container:
@ -1694,7 +1700,9 @@ if [ -d "/usr/lib/rpm/macros.d/" ] && [ "${init}" -eq 0 ]; then
EOF
fi
if { [ -d "/etc/dpkg/dpkg.cfg.d/" ] || [ -d "/usr/share/libalpm/scripts" ]; } && [ "${init}" -eq 0 ]; then
if {
[ -d "/etc/dpkg/dpkg.cfg.d/" ] || [ -d "/usr/share/libalpm/scripts" ]
} && [ "${init}" -eq 0 ]; then
printf "distrobox: Setting up package manager hooks...\n"
cat << EOF > /etc/distrobox-pre-hook.sh
#!/bin/sh

View File

@ -30,7 +30,9 @@
# containers.
#
# SUDO_USER is a variable set by SUDO and can be used to check whether the script was called by it. Same thing for DOAS_USER, set by DOAS.
if { [ -n "${SUDO_USER}" ] || [ -n "${DOAS_USER}" ]; } && [ "$(id -ru)" -eq 0 ]; then
if {
[ -n "${SUDO_USER}" ] || [ -n "${DOAS_USER}" ]
} && [ "$(id -ru)" -eq 0 ]; then
printf >&2 "Running %s via SUDO/DOAS is not supported. Instead, please try running:\n" "$(basename "${0}")"
printf >&2 " %s --root %s\n" "$(basename "${0}")" "$*"
exit 1
@ -97,7 +99,8 @@ fi
# None
# Outputs:
# print usage with examples.
show_help() {
show_help()
{
cat << EOF
distrobox version: ${version}

View File

@ -33,7 +33,9 @@
# containers.
#
# SUDO_USER is a variable set by SUDO and can be used to check whether the script was called by it. Same thing for DOAS_USER, set by DOAS.
if { [ -n "${SUDO_USER}" ] || [ -n "${DOAS_USER}" ]; } && [ "$(id -ru)" -eq 0 ]; then
if {
[ -n "${SUDO_USER}" ] || [ -n "${DOAS_USER}" ]
} && [ "$(id -ru)" -eq 0 ]; then
printf >&2 "Running %s via SUDO/DOAS is not supported. Instead, please try running:\n" "$(basename "${0}")"
printf >&2 " %s --root %s\n" "$(basename "${0}")" "$*"
exit 1
@ -116,7 +118,8 @@ container_name_list=""
# None
# Outputs:
# print usage with examples.
show_help() {
show_help()
{
cat << EOF
distrobox version: ${version}
@ -291,7 +294,8 @@ fi
# None
# Outputs:
# None
cleanup_exports() {
cleanup_exports()
{
container_name="$1"
IFS='¤'
printf "Removing exported binaries...\n"
@ -334,7 +338,8 @@ cleanup_exports() {
# None
# Outputs:
# None
delete_container() {
delete_container()
{
container_name="$1"
# Inspect the container we're working with.
container_status="$(${container_manager} inspect --type container \

View File

@ -32,7 +32,9 @@
# containers.
#
# SUDO_USER is a variable set by SUDO and can be used to check whether the script was called by it. Same thing for DOAS_USER, set by DOAS.
if { [ -n "${SUDO_USER}" ] || [ -n "${DOAS_USER}" ]; } && [ "$(id -ru)" -eq 0 ]; then
if {
[ -n "${SUDO_USER}" ] || [ -n "${DOAS_USER}" ]
} && [ "$(id -ru)" -eq 0 ]; then
printf >&2 "Running %s via SUDO/DOAS is not supported. Instead, please try running:\n" "$(basename "${0}")"
printf >&2 " %s --root %s\n" "$(basename "${0}")" "$*"
exit 1
@ -111,7 +113,8 @@ fi
# None
# Outputs:
# print usage with examples.
show_help() {
show_help()
{
cat << EOF
distrobox version: ${version}

View File

@ -24,7 +24,9 @@
# containers.
#
# SUDO_USER is a variable set by SUDO and can be used to check whether the script was called by it. Same thing for DOAS_USER, set by DOAS.
if { [ -n "${SUDO_USER}" ] || [ -n "${DOAS_USER}" ]; } && [ "$(id -ru)" -eq 0 ]; then
if {
[ -n "${SUDO_USER}" ] || [ -n "${DOAS_USER}" ]
} && [ "$(id -ru)" -eq 0 ]; then
printf >&2 "Running %s via SUDO/DOAS is not supported. Instead, please try running:\n" "$(basename "${0}")"
printf >&2 " %s --root %s\n" "$(basename "${0}")" "$*"
exit 1
@ -94,7 +96,8 @@ container_name=""
# None
# Outputs:
# print usage with examples.
show_help() {
show_help()
{
cat << EOF
distrobox version: ${version}

View File

@ -28,7 +28,8 @@ version=1.7.2.0
# None
# Outputs:
# print usage with examples.
show_help() {
show_help()
{
cat << EOF
install --prefix /usr/local
@ -132,7 +133,9 @@ if [ -e "${curr_dir}/distrobox-enter" ]; then
else
printf >&2 "\033[1;31m Checking dependencies...\n\033[0m"
# check that we have base dependencies
if ! { command -v curl > /dev/null || command -v wget > /dev/null; } || ! command -v tar > /dev/null; then
if ! {
command -v curl > /dev/null || command -v wget > /dev/null
} || ! command -v tar > /dev/null; then
printf >&2 "Online install depends on tar and either curl or wget\n"
printf >&2 "Ensure you have all dependencies installed.\n"
exit 1

View File

@ -26,7 +26,8 @@ verbose=0
# None
# Outputs:
# print usage with examples.
show_help() {
show_help()
{
cat << EOF
uninstall --prefix /usr/local