Fix shellcheck warnings and style (#62)

This commit is contained in:
ghtm2 2023-02-15 20:57:05 +01:00 committed by GitHub
parent c86cba4af3
commit b3c16de238
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 119 additions and 112 deletions

View file

@ -43,7 +43,7 @@ mount_point="${working_dir}"/mnt
# a problem with mounting the image due to an incorrectly calculated offset. # a problem with mounting the image due to an incorrectly calculated offset.
# The size of this script # The size of this script
scriptsize=26260 scriptsize=26210
# The size of the utils archive # The size of the utils archive
utilssize=2507588 utilssize=2507588
@ -60,10 +60,10 @@ dwarfs_cache_size="128M"
dwarfs_num_workers="2" dwarfs_num_workers="2"
# These arguments are used to rebuild the image when using the self-update function # These arguments are used to rebuild the image when using the self-update function
squashfs_comp_arguments="-b 1M -comp zstd -Xcompression-level 19" squashfs_comp_arguments=(-b 1M -comp zstd -Xcompression-level 19)
dwarfs_comp_arguments="-l7 -C zstd:level=19 --metadata-compression null \ dwarfs_comp_arguments=(-l7 -C zstd:level=19 --metadata-compression null \
-S 22 -B 2 --order nilsimsa:255:60000:60000 \ -S 22 -B 2 --order nilsimsa:255:60000:60000 \
--bloom-filter-size 11 -W 15 -w 3 --no-create-timestamp" --bloom-filter-size 11 -W 15 -w 3 --no-create-timestamp)
unset script_is_symlink unset script_is_symlink
if [ -L "${script_literal}" ]; then if [ -L "${script_literal}" ]; then
@ -161,7 +161,7 @@ if [ -z "${script_is_symlink}" ]; then
exit exit
elif [ "$1" = "-o" ]; then elif [ "$1" = "-o" ]; then
echo ${offset} echo "${offset}"
exit exit
fi fi
@ -258,17 +258,17 @@ if [ "${USE_SYS_UTILS}" != 1 ]; then
fi fi
if [ "${dwarfs_image}" = 1 ]; then if [ "${dwarfs_image}" = 1 ]; then
mount_tool="${working_dir}"/utils/dwarfs${fuse_version} mount_tool="${working_dir}"/utils/dwarfs"${fuse_version}"
extraction_tool="${working_dir}"/utils/dwarfsextract extraction_tool="${working_dir}"/utils/dwarfsextract
else else
mount_tool="${working_dir}"/utils/squashfuse${fuse_version} mount_tool="${working_dir}"/utils/squashfuse"${fuse_version}"
extraction_tool="${working_dir}"/utils/unsquashfs extraction_tool="${working_dir}"/utils/unsquashfs
fi fi
bwrap="${working_dir}"/utils/bwrap bwrap="${working_dir}"/utils/bwrap
if [ ! -f "${mount_tool}" ] || [ ! -f "${bwrap}" ]; then if [ ! -f "${mount_tool}" ] || [ ! -f "${bwrap}" ]; then
tail -c +$((scriptsize+1)) "${script}" | head -c ${utilssize} | tar -C "${working_dir}" -zxf - tail -c +$((scriptsize+1)) "${script}" | head -c "${utilssize}" | tar -C "${working_dir}" -zxf -
if [ ! -f "${mount_tool}" ] || [ ! -f "${bwrap}" ]; then if [ ! -f "${mount_tool}" ] || [ ! -f "${bwrap}" ]; then
clear clear
@ -327,10 +327,10 @@ if [ "$1" = "-e" ] && [ -z "${script_is_symlink}" ]; then
if [ "${dwarfs_image}" = 1 ]; then if [ "${dwarfs_image}" = 1 ]; then
echo "Extracting the image..." echo "Extracting the image..."
mkdir "$(basename "${script}")"_files mkdir "$(basename "${script}")"_files
launch_wrapper "${extraction_tool}" -i "${script}" -o "$(basename "${script}")"_files -O ${offset} launch_wrapper "${extraction_tool}" -i "${script}" -o "$(basename "${script}")"_files -O "${offset}"
echo "Done" echo "Done"
else else
launch_wrapper "${extraction_tool}" -o ${offset} -user-xattrs -d "$(basename "${script}")"_files "${script}" launch_wrapper "${extraction_tool}" -o "${offset}" -user-xattrs -d "$(basename "${script}")"_files "${script}"
fi fi
else else
echo "Extraction tool not found" echo "Extraction tool not found"
@ -345,7 +345,7 @@ if [ "$1" = "-H" ] && [ -z "${script_is_symlink}" ]; then
exit exit
fi fi
if ([ "$1" = "-u" ] || [ "$1" = "-U" ]) && [ -z "${script_is_symlink}" ]; then if { [ "$1" = "-u" ] || [ "$1" = "-U" ]; } && [ -z "${script_is_symlink}" ]; then
OLD_PWD="${PWD}" OLD_PWD="${PWD}"
# Check if the current directory is writable # Check if the current directory is writable
@ -376,7 +376,7 @@ if ([ "$1" = "-u" ] || [ "$1" = "-U" ]) && [ -z "${script_is_symlink}" ]; then
fi fi
fi fi
tail -c +$((scriptsize+1)) "${script}" | head -c ${utilssize} | tar -C "${update_temp_dir}" -zxf - tail -c +$((scriptsize+1)) "${script}" | head -c "${utilssize}" | tar -C "${update_temp_dir}" -zxf -
if [ "${dwarfs_image}" = 1 ]; then if [ "${dwarfs_image}" = 1 ]; then
chmod +x utils/dwarfsextract 2>/dev/null chmod +x utils/dwarfsextract 2>/dev/null
@ -421,11 +421,11 @@ if ([ "$1" = "-u" ] || [ "$1" = "-U" ]) && [ -z "${script_is_symlink}" ]; then
if [ "${dwarfs_image}" = 1 ]; then if [ "${dwarfs_image}" = 1 ]; then
mkdir sqfs mkdir sqfs
tools_wrapper "${update_temp_dir}"/utils/dwarfsextract \ tools_wrapper "${update_temp_dir}"/utils/dwarfsextract \
-i "${script}" -o sqfs -O ${offset} --cache-size "${dwarfs_cache_size}" \ -i "${script}" -o sqfs -O "${offset}" --cache-size "${dwarfs_cache_size}" \
--num-workers "${dwarfs_num_workers}" --num-workers "${dwarfs_num_workers}"
else else
tools_wrapper "${update_temp_dir}"/utils/unsquashfs \ tools_wrapper "${update_temp_dir}"/utils/unsquashfs \
-o ${offset} -user-xattrs -d sqfs "${script}" -o "${offset}" -user-xattrs -d sqfs "${script}"
fi fi
# Download or extract the utils.tar.gz and the init script depending # Download or extract the utils.tar.gz and the init script depending
@ -445,23 +445,26 @@ if ([ "$1" = "-u" ] || [ "$1" = "-U" ]) && [ -z "${script_is_symlink}" ]; then
if [ ! -s conty-start.sh ] || [ ! -s utils.tar.gz ]; then if [ ! -s conty-start.sh ] || [ ! -s utils.tar.gz ]; then
echo "Extracting the init script and the integrated utils" echo "Extracting the init script and the integrated utils"
tail -c +$((scriptsize+1)) "${script}" | head -c ${utilssize} > utils.tar.gz tail -c +$((scriptsize+1)) "${script}" | head -c "${utilssize}" > utils.tar.gz
head -c ${scriptsize} "${script}" > conty-start.sh head -c "${scriptsize}" "${script}" > conty-start.sh
fi fi
# Check if there are additional arguments passed # Check if there are additional arguments passed
shift shift
if [ -n "$1" ]; then if [ -n "$1" ]; then
packagelist="$@" packagelist=("$@")
# Check which packages to install and which ones to remove # Check which packages to install and which ones to remove
for i in ${packagelist}; do for i in "${packagelist[@]}"; do
if [ "$(echo "${i}" | head -c 1)" = "-" ]; then if [ "$(echo "${i}" | head -c 1)" = "-" ]; then
export pkgsremove="${pkgsremove} $(echo "${i}" | tail -c +2)" pkgsremove+=" ${i:1}"
else else
export pkgsinstall="${pkgsinstall} ${i}" pkgsinstall+=" ${i}"
fi fi
done done
export pkgsremove
export pkgsinstall
fi fi
# Generate a script to perform inside Conty # Generate a script to perform inside Conty
@ -511,10 +514,10 @@ EOF
echo "Creating an image" echo "Creating an image"
if [ "${dwarfs_image}" = 1 ]; then if [ "${dwarfs_image}" = 1 ]; then
tools_wrapper "${update_temp_dir}"/utils/mkdwarfs \ tools_wrapper "${update_temp_dir}"/utils/mkdwarfs \
-i sqfs -o image ${dwarfs_comp_arguments} -i sqfs -o image "${dwarfs_comp_arguments[@]}"
else else
tools_wrapper "${update_temp_dir}"/utils/mksquashfs \ tools_wrapper "${update_temp_dir}"/utils/mksquashfs \
sqfs image ${squashfs_comp_arguments} sqfs image "${squashfs_comp_arguments[@]}"
fi fi
# Combine into a single executable # Combine into a single executable
@ -574,44 +577,44 @@ run_bwrap () {
tmp|mnt|opt|media|run|var) tmp|mnt|opt|media|run|var)
;; ;;
*) *)
NEW_HOME="/home/${USER}" NEW_HOME=/home/"${USER}"
non_standard_home+=("--tmpfs" "/home" \ non_standard_home+=(--tmpfs /home \
"--bind" "${HOME}" "${NEW_HOME}" \ --bind "${HOME}" "${NEW_HOME}" \
"--setenv" "HOME" "${NEW_HOME}") --setenv "HOME" "${NEW_HOME}")
;; ;;
esac esac
fi fi
if [ "${SANDBOX}" = 1 ]; then if [ "${SANDBOX}" = 1 ]; then
sandbox_params+=("--tmpfs" "/home" \ sandbox_params+=(--tmpfs /home \
"--tmpfs" "/opt" \ --tmpfs /opt \
"--tmpfs" "/mnt" \ --tmpfs /mnt \
"--tmpfs" "/media" \ --tmpfs /media \
"--tmpfs" "/var" \ --tmpfs /var \
"--tmpfs" "/run" \ --tmpfs /run \
"--symlink" "/run" "/var/run" \ --symlink /run /var/run \
"--tmpfs" "/tmp" \ --tmpfs /tmp \
"--new-session") --new-session)
if [ -n "${non_standard_home}" ]; then if [ -n "${non_standard_home[*]}" ]; then
sandbox_params+=("--dir" "${NEW_HOME}") sandbox_params+=(--dir "${NEW_HOME}")
else else
sandbox_params+=("--dir" "${HOME}") sandbox_params+=(--dir "${HOME}")
fi fi
if [ -n "${SANDBOX_LEVEL}" ] && [ "${SANDBOX_LEVEL}" -ge 2 ]; then if [ -n "${SANDBOX_LEVEL}" ] && [ "${SANDBOX_LEVEL}" -ge 2 ]; then
sandbox_level_msg="(level 2)" sandbox_level_msg="(level 2)"
sandbox_params+=("--dir" "${XDG_RUNTIME_DIR}" \ sandbox_params+=(--dir "${XDG_RUNTIME_DIR}" \
"--ro-bind-try" "${XDG_RUNTIME_DIR}"/${wayland_socket} "${XDG_RUNTIME_DIR}"/${wayland_socket} \ --ro-bind-try "${XDG_RUNTIME_DIR}"/"${wayland_socket}" "${XDG_RUNTIME_DIR}"/"${wayland_socket}" \
"--ro-bind-try" "${XDG_RUNTIME_DIR}"/pulse "${XDG_RUNTIME_DIR}"/pulse \ --ro-bind-try "${XDG_RUNTIME_DIR}"/pulse "${XDG_RUNTIME_DIR}"/pulse \
"--ro-bind-try" "${XDG_RUNTIME_DIR}"/pipewire-0 "${XDG_RUNTIME_DIR}"/pipewire-0 \ --ro-bind-try "${XDG_RUNTIME_DIR}"/pipewire-0 "${XDG_RUNTIME_DIR}"/pipewire-0 \
"--unshare-pid" \ --unshare-pid \
"--unshare-user-try" \ --unshare-user-try \
"--unsetenv" "DBUS_SESSION_BUS_ADDRESS") --unsetenv "DBUS_SESSION_BUS_ADDRESS")
else else
sandbox_level_msg="(level 1)" sandbox_level_msg="(level 1)"
sandbox_params+=("--bind-try" "${XDG_RUNTIME_DIR}" "${XDG_RUNTIME_DIR}" \ sandbox_params+=(--bind-try "${XDG_RUNTIME_DIR}" "${XDG_RUNTIME_DIR}" \
"--bind-try" "/run/dbus" "/run/dbus") --bind-try /run/dbus /run/dbus)
fi fi
if [ -n "${SANDBOX_LEVEL}" ] && [ "${SANDBOX_LEVEL}" -ge 3 ]; then if [ -n "${SANDBOX_LEVEL}" ] && [ "${SANDBOX_LEVEL}" -ge 3 ]; then
@ -625,16 +628,16 @@ run_bwrap () {
if [ "${DISABLE_NET}" = 1 ]; then if [ "${DISABLE_NET}" = 1 ]; then
show_msg "Network is disabled" show_msg "Network is disabled"
unshare_net="--unshare-net" unshare_net=(--unshare-net)
fi fi
if [ -n "${HOME_DIR}" ]; then if [ -n "${HOME_DIR}" ]; then
show_msg "Home directory is set to ${HOME_DIR}" show_msg "Home directory is set to ${HOME_DIR}"
if [ -n "${non_standard_home}" ]; then if [ -n "${non_standard_home[*]}" ]; then
custom_home+=("--bind" "${HOME_DIR}" "${NEW_HOME}") custom_home+=(--bind "${HOME_DIR}" "${NEW_HOME}")
else else
custom_home+=("--bind" "${HOME_DIR}" "${HOME}") custom_home+=(--bind "${HOME_DIR}" "${HOME}")
fi fi
[ ! -d "${HOME_DIR}" ] && mkdir -p "${HOME_DIR}" [ ! -d "${HOME_DIR}" ] && mkdir -p "${HOME_DIR}"
@ -646,23 +649,23 @@ run_bwrap () {
fi fi
# Mount X server sockets and XAUTHORITY # Mount X server sockets and XAUTHORITY
xsockets+=("--tmpfs" "/tmp/.X11-unix") xsockets+=(--tmpfs /tmp/.X11-unix)
if [ -n "${non_standard_home}" ] && [ "${XAUTHORITY}" = "${HOME}"/.Xauthority ]; then if [ -n "${non_standard_home[*]}" ] && [ "${XAUTHORITY}" = "${HOME}"/.Xauthority ]; then
xsockets+=("--ro-bind-try" "${XAUTHORITY}" "${NEW_HOME}"/.Xauthority \ xsockets+=(--ro-bind-try "${XAUTHORITY}" "${NEW_HOME}"/.Xauthority \
"--setenv" "XAUTHORITY" "${NEW_HOME}"/.Xauthority) --setenv "XAUTHORITY" "${NEW_HOME}"/.Xauthority)
else else
xsockets+=("--ro-bind-try" "${XAUTHORITY}" "${XAUTHORITY}") xsockets+=(--ro-bind-try "${XAUTHORITY}" "${XAUTHORITY}")
fi fi
if [ "${DISABLE_X11}" != 1 ]; then if [ "${DISABLE_X11}" != 1 ]; then
if [ "$(ls /tmp/.X11-unix 2>/dev/null)" ]; then if [ "$(ls /tmp/.X11-unix 2>/dev/null)" ]; then
if [ -n "${SANDBOX_LEVEL}" ] && [ "${SANDBOX_LEVEL}" -ge 3 ]; then if [ -n "${SANDBOX_LEVEL}" ] && [ "${SANDBOX_LEVEL}" -ge 3 ]; then
xsockets+=("--ro-bind-try" "/tmp/.X11-unix/X${xephyr_display}" "/tmp/.X11-unix/X${xephyr_display}" \ xsockets+=(--ro-bind-try /tmp/.X11-unix/X"${xephyr_display}" /tmp/.X11-unix/X"${xephyr_display}" \
"--setenv" "DISPLAY" ":${xephyr_display}") --setenv "DISPLAY" :"${xephyr_display}")
else else
for s in /tmp/.X11-unix/*; do for s in /tmp/.X11-unix/*; do
xsockets+=("--bind-try" "${s}" "${s}") xsockets+=(--bind-try "${s}" "${s}")
done done
fi fi
fi fi
@ -671,9 +674,9 @@ run_bwrap () {
# Unset the DISPLAY and XAUTHORITY env variables and mount an # Unset the DISPLAY and XAUTHORITY env variables and mount an
# empty file to XAUTHORITY to invalidate it # empty file to XAUTHORITY to invalidate it
xsockets+=("--ro-bind-try" "${working_dir}"/running_"${script_id}" "${XAUTHORITY}" \ xsockets+=(--ro-bind-try "${working_dir}"/running_"${script_id}" "${XAUTHORITY}" \
"--unsetenv" "DISPLAY" \ --unsetenv "DISPLAY" \
"--unsetenv" "XAUTHORITY") --unsetenv "XAUTHORITY")
fi fi
show_msg show_msg
@ -703,7 +706,7 @@ run_bwrap () {
"${sandbox_params[@]}" \ "${sandbox_params[@]}" \
"${custom_home[@]}" \ "${custom_home[@]}" \
"${xsockets[@]}" \ "${xsockets[@]}" \
${unshare_net} \ "${unshare_net[@]}" \
--setenv PATH "${CUSTOM_PATH}" \ --setenv PATH "${CUSTOM_PATH}" \
"$@" "$@"
} }
@ -712,7 +715,7 @@ trap_exit () {
rm -f "${working_dir}"/running_"${script_id}" rm -f "${working_dir}"/running_"${script_id}"
if [ ! "$(ls "${working_dir}"/running_* 2>/dev/null)" ]; then if [ ! "$(ls "${working_dir}"/running_* 2>/dev/null)" ]; then
fusermount${fuse_version} -uz "${mount_point}" 2>/dev/null || \ fusermount"${fuse_version}" -uz "${mount_point}" 2>/dev/null || \
umount --lazy "${mount_point}" 2>/dev/null umount --lazy "${mount_point}" 2>/dev/null
if [ ! "$(ls "${mount_point}" 2>/dev/null)" ]; then if [ ! "$(ls "${mount_point}" 2>/dev/null)" ]; then
@ -777,15 +780,15 @@ if [ "$(ls "${mount_point}" 2>/dev/null)" ] || \
XEPHYR_SIZE="800x600" XEPHYR_SIZE="800x600"
fi fi
xephyr_display="$((${script_id}+2))" xephyr_display="$((script_id+2))"
if [ -S /tmp/.X11-unix/X${xephyr_display} ]; then if [ -S /tmp/.X11-unix/X"${xephyr_display}" ]; then
xephyr_display="$((${script_id}+10))" xephyr_display="$((script_id+10))"
fi fi
QUIET_MODE=1 DISABLE_NET=1 SANDBOX_LEVEL=2 run_bwrap \ QUIET_MODE=1 DISABLE_NET=1 SANDBOX_LEVEL=2 run_bwrap \
--bind-try /tmp/.X11-unix /tmp/.X11-unix \ --bind-try /tmp/.X11-unix /tmp/.X11-unix \
Xephyr -noreset -ac -br -screen ${XEPHYR_SIZE} :${xephyr_display} &>/dev/null & sleep 1 Xephyr -noreset -ac -br -screen "${XEPHYR_SIZE}" :"${xephyr_display}" &>/dev/null & sleep 1
xephyr_pid=$! xephyr_pid=$!
QUIET_MODE=1 run_bwrap openbox & sleep 1 QUIET_MODE=1 run_bwrap openbox & sleep 1
@ -807,7 +810,7 @@ if [ "$(ls "${mount_point}" 2>/dev/null)" ] || \
fi fi
if [ -n "${xephyr_pid}" ]; then if [ -n "${xephyr_pid}" ]; then
wait ${xephyr_pid} wait "${xephyr_pid}"
fi fi
else else
echo "Mounting the image failed!" echo "Mounting the image failed!"

View file

@ -150,20 +150,20 @@ if [ ! -s chaotic-keyring.pkg.tar.zst ] || [ ! -s chaotic-mirrorlist.pkg.tar.zst
exit 1 exit 1
fi fi
bootstrap_urls="mirror.osbeck.com \ bootstrap_urls=("mirror.osbeck.com" \
mirror.f4st.host \ "mirror.f4st.host" \
mirror.luzea.de" "mirror.luzea.de")
echo "Downloading Arch Linux bootstrap" echo "Downloading Arch Linux bootstrap"
for link in ${bootstrap_urls}; do for link in "${bootstrap_urls[@]}"; do
wget -q --show-progress -O archlinux-bootstrap-x86_64.tar.gz \ wget -q --show-progress -O archlinux-bootstrap-x86_64.tar.gz \
"https://${link}/archlinux/iso/latest/archlinux-bootstrap-x86_64.tar.gz" "https://${link}/archlinux/iso/latest/archlinux-bootstrap-x86_64.tar.gz"
wget -q --show-progress -O sha256sums.txt \ wget -q --show-progress -O sha256sums.txt \
"https://${link}/archlinux/iso/latest/sha256sums.txt" "https://${link}/archlinux/iso/latest/sha256sums.txt"
if [ -s sha256sums.txt ]; then if [ -s sha256sums.txt ]; then
cat sha256sums.txt | grep bootstrap-x86_64 > sha256.txt grep bootstrap-x86_64 sha256sums.txt > sha256.txt
echo "Verifying the integrity of the bootstrap" echo "Verifying the integrity of the bootstrap"
if sha256sum -c sha256.txt &>/dev/null; then if sha256sum -c sha256.txt &>/dev/null; then
@ -199,9 +199,11 @@ mv locale.gen "${bootstrap}"/etc/locale.gen
rm "${bootstrap}"/etc/pacman.d/mirrorlist rm "${bootstrap}"/etc/pacman.d/mirrorlist
mv mirrorlist "${bootstrap}"/etc/pacman.d/mirrorlist mv mirrorlist "${bootstrap}"/etc/pacman.d/mirrorlist
echo >> "${bootstrap}"/etc/pacman.conf {
echo "[multilib]" >> "${bootstrap}"/etc/pacman.conf echo
echo "Include = /etc/pacman.d/mirrorlist" >> "${bootstrap}"/etc/pacman.conf echo "[multilib]"
echo "Include = /etc/pacman.d/mirrorlist"
} >> "${bootstrap}"/etc/pacman.conf
run_in_chroot pacman-key --init run_in_chroot pacman-key --init
echo "keyserver hkps://keyserver.ubuntu.com" >> "${bootstrap}"/etc/pacman.d/gnupg/gpg.conf echo "keyserver hkps://keyserver.ubuntu.com" >> "${bootstrap}"/etc/pacman.d/gnupg/gpg.conf
@ -215,9 +217,11 @@ mv chaotic-keyring.pkg.tar.zst chaotic-mirrorlist.pkg.tar.zst "${bootstrap}"/opt
run_in_chroot pacman --noconfirm -U /opt/chaotic-keyring.pkg.tar.zst /opt/chaotic-mirrorlist.pkg.tar.zst run_in_chroot pacman --noconfirm -U /opt/chaotic-keyring.pkg.tar.zst /opt/chaotic-mirrorlist.pkg.tar.zst
rm "${bootstrap}"/opt/chaotic-keyring.pkg.tar.zst "${bootstrap}"/opt/chaotic-mirrorlist.pkg.tar.zst rm "${bootstrap}"/opt/chaotic-keyring.pkg.tar.zst "${bootstrap}"/opt/chaotic-mirrorlist.pkg.tar.zst
echo >> "${bootstrap}"/etc/pacman.conf {
echo "[chaotic-aur]" >> "${bootstrap}"/etc/pacman.conf echo
echo "Include = /etc/pacman.d/chaotic-mirrorlist" >> "${bootstrap}"/etc/pacman.conf echo "[chaotic-aur]"
echo "Include = /etc/pacman.d/chaotic-mirrorlist"
} >> "${bootstrap}"/etc/pacman.conf
# The ParallelDownloads feature of pacman # The ParallelDownloads feature of pacman
# Speeds up packages installation, especially when there are many small packages to install # Speeds up packages installation, especially when there are many small packages to install

View file

@ -8,17 +8,17 @@ script_dir="$(dirname "$(readlink -f "${BASH_SOURCE[0]}")")"
# These are the algorithms supported by the integrated squashfuse # These are the algorithms supported by the integrated squashfuse
# However, your squashfs-tools (mksquashfs) may not support some of them # However, your squashfs-tools (mksquashfs) may not support some of them
squashfs_compressor="lz4" squashfs_compressor="lz4"
squashfs_compressor_arguments="-b 256K -comp ${squashfs_compressor} -Xhc" squashfs_compressor_arguments=(-b 256K -comp "${squashfs_compressor}" -Xhc)
# Uncomment these two lines if you want better compression and your mksquashfs supports zstd # Uncomment these two lines if you want better compression and your mksquashfs supports zstd
#squashfs_compressor="zstd" #squashfs_compressor="zstd"
#squashfs_compressor_arguments="-b 1M -comp ${squashfs_compressor} -Xcompression-level 19" #squashfs_compressor_arguments=(-b 1M -comp ${squashfs_compressor} -Xcompression-level 19)
# Use dwarfs instead of squashfs # Use dwarfs instead of squashfs
dwarfs="false" dwarfs="false"
dwarfs_compressor_arguments="-l7 -C zstd:level=19 --metadata-compression null \ dwarfs_compressor_arguments=(-l7 -C zstd:level=19 --metadata-compression null \
-S 22 -B 2 --order nilsimsa:255:60000:60000 \ -S 22 -B 2 --order nilsimsa:255:60000:60000 \
--bloom-filter-size 11 -W 15 -w 3 --no-create-timestamp" --bloom-filter-size 11 -W 15 -w 3 --no-create-timestamp)
# Set to true to use an existing image if it exists # Set to true to use an existing image if it exists
# Otherwise the script will always create a new image # Otherwise the script will always create a new image
@ -51,7 +51,7 @@ if [ "${dwarfs}" != "true" ] && command -v grep 1>/dev/null; then
# mksquashfs writes its output to stderr instead of stdout # mksquashfs writes its output to stderr instead of stdout
mksquashfs &>mksquashfs_out.txt mksquashfs &>mksquashfs_out.txt
if [ ! "$(cat mksquashfs_out.txt | grep ${squashfs_compressor})" ]; then if ! grep -q "${squashfs_compressor}" mksquashfs_out.txt; then
echo "Seems like your mksquashfs doesn't support the selected" echo "Seems like your mksquashfs doesn't support the selected"
echo "compression algorithm (${squashfs_compressor})." echo "compression algorithm (${squashfs_compressor})."
echo echo
@ -82,14 +82,14 @@ if [ ! -f "${image_path}" ] || [ "${use_existing_image}" != "true" ]; then
exit 1 exit 1
fi fi
mkdwarfs -i "${bootstrap}" -o "${image_path}" ${dwarfs_compressor_arguments} mkdwarfs -i "${bootstrap}" -o "${image_path}" "${dwarfs_compressor_arguments[@]}"
else else
if ! command -v mksquashfs 1>/dev/null; then if ! command -v mksquashfs 1>/dev/null; then
echo "Please install squashfs-tools and run the script again" echo "Please install squashfs-tools and run the script again"
exit 1 exit 1
fi fi
mksquashfs "${bootstrap}" "${image_path}" ${squashfs_compressor_arguments} mksquashfs "${bootstrap}" "${image_path}" "${squashfs_compressor_arguments[@]}"
fi fi
fi fi

View file

@ -30,58 +30,58 @@ export LDFLAGS="-Wl,-O1,--sort-common,--as-needed"
mkdir -p "${script_dir}"/build-utils mkdir -p "${script_dir}"/build-utils
cd "${script_dir}"/build-utils || exit 1 cd "${script_dir}"/build-utils || exit 1
wget -q --show-progress -O lz4.tar.gz https://github.com/lz4/lz4/archive/refs/tags/v${lz4_version}.tar.gz wget -q --show-progress -O lz4.tar.gz https://github.com/lz4/lz4/archive/refs/tags/v"${lz4_version}".tar.gz
wget -q --show-progress -O zstd.tar.gz https://github.com/facebook/zstd/archive/refs/tags/v${zstd_version}.tar.gz wget -q --show-progress -O zstd.tar.gz https://github.com/facebook/zstd/archive/refs/tags/v"${zstd_version}".tar.gz
wget -q --show-progress -O bwrap.tar.gz https://github.com/containers/bubblewrap/archive/refs/tags/v${bwrap_version}.tar.gz wget -q --show-progress -O bwrap.tar.gz https://github.com/containers/bubblewrap/archive/refs/tags/v"${bwrap_version}".tar.gz
tar xf lz4.tar.gz tar xf lz4.tar.gz
tar xf zstd.tar.gz tar xf zstd.tar.gz
tar xf bwrap.tar.gz tar xf bwrap.tar.gz
if [ "${build_dwarfs}" != "true" ]; then if [ "${build_dwarfs}" != "true" ]; then
wget -q --show-progress -O squashfuse.tar.gz https://github.com/vasi/squashfuse/archive/refs/tags/${squashfuse_version}.tar.gz wget -q --show-progress -O squashfuse.tar.gz https://github.com/vasi/squashfuse/archive/refs/tags/"${squashfuse_version}".tar.gz
wget -q --show-progress -O sqfstools.tar.gz https://github.com/plougher/squashfs-tools/archive/refs/tags/${squashfs_tools_version}.tar.gz wget -q --show-progress -O sqfstools.tar.gz https://github.com/plougher/squashfs-tools/archive/refs/tags/"${squashfs_tools_version}".tar.gz
tar xf squashfuse.tar.gz tar xf squashfuse.tar.gz
tar xf sqfstools.tar.gz tar xf sqfstools.tar.gz
fi fi
cd bubblewrap-${bwrap_version} cd bubblewrap-"${bwrap_version}" || exit 1
./autogen.sh ./autogen.sh
./configure --disable-selinux --disable-man ./configure --disable-selinux --disable-man
make -j$(nproc) DESTDIR="${script_dir}"/build-utils/bin install make -j"$(nproc)" DESTDIR="${script_dir}"/build-utils/bin install
cd ../lz4-${lz4_version} cd ../lz4-"${lz4_version}" || exit 1
make -j$(nproc) DESTDIR="${script_dir}"/build-utils/bin install make -j"$(nproc)" DESTDIR="${script_dir}"/build-utils/bin install
cd ../zstd-${zstd_version} cd ../zstd-"${zstd_version}" || exit 1
ZSTD_LEGACY_SUPPORT=0 HAVE_ZLIB=0 HAVE_LZMA=0 HAVE_LZ4=0 BACKTRACE=0 make -j$(nproc) DESTDIR="${script_dir}"/build-utils/bin install ZSTD_LEGACY_SUPPORT=0 HAVE_ZLIB=0 HAVE_LZMA=0 HAVE_LZ4=0 BACKTRACE=0 make -j"$(nproc)" DESTDIR="${script_dir}"/build-utils/bin install
if [ "${build_dwarfs}" != "true" ]; then if [ "${build_dwarfs}" != "true" ]; then
cd ../squashfuse-${squashfuse_version} cd ../squashfuse-"${squashfuse_version}" || exit 1
./autogen.sh ./autogen.sh
./configure ./configure
make -j$(nproc) DESTDIR="${script_dir}"/build-utils/bin install make -j"$(nproc)" DESTDIR="${script_dir}"/build-utils/bin install
cd ../squashfs-tools-${squashfs_tools_version}/squashfs-tools cd ../squashfs-tools-"${squashfs_tools_version}"/squashfs-tools || exit 1
make -j$(nproc) GZIP_SUPPORT=1 XZ_SUPPORT=1 LZO_SUPPORT=1 LZMA_XZ_SUPPORT=1 \ make -j"$(nproc)" GZIP_SUPPORT=1 XZ_SUPPORT=1 LZO_SUPPORT=1 LZMA_XZ_SUPPORT=1 \
LZ4_SUPPORT=1 ZSTD_SUPPORT=1 XATTR_SUPPORT=1 LZ4_SUPPORT=1 ZSTD_SUPPORT=1 XATTR_SUPPORT=1
make INSTALL_DIR="${script_dir}"/build-utils/bin/usr/local/bin install make INSTALL_DIR="${script_dir}"/build-utils/bin/usr/local/bin install
fi fi
cd "${script_dir}"/build-utils cd "${script_dir}"/build-utils || exit 1
mkdir utils mkdir utils
mv bin/usr/local/bin/bwrap utils mv bin/usr/local/bin/bwrap utils
mv bin/usr/local/bin/squashfuse utils mv bin/usr/local/bin/squashfuse utils
mv bin/usr/local/bin/squashfuse_ll utils mv bin/usr/local/bin/squashfuse_ll utils
mv bin/usr/local/bin/mksquashfs utils mv bin/usr/local/bin/mksquashfs utils
mv bin/usr/local/bin/unsquashfs utils mv bin/usr/local/bin/unsquashfs utils
mv bin/usr/local/lib/liblz4.so.${lz4_version} utils/liblz4.so.1 mv bin/usr/local/lib/liblz4.so."${lz4_version}" utils/liblz4.so.1
mv bin/usr/local/lib/libzstd.so.${zstd_version} utils/libzstd.so.1 mv bin/usr/local/lib/libzstd.so."${zstd_version}" utils/libzstd.so.1
mv bin/usr/local/lib/libfuseprivate.so.0.0.0 utils/libfuseprivate.so.0 mv bin/usr/local/lib/libfuseprivate.so.0.0.0 utils/libfuseprivate.so.0
mv bin/usr/local/lib/libsquashfuse.so.0.0.0 utils/libsquashfuse.so.0 mv bin/usr/local/lib/libsquashfuse.so.0.0.0 utils/libsquashfuse.so.0
if [ ! "$(ldd utils/squashfuse | grep libfuse.so.2)" ]; then if ! ldd utils/squashfuse | grep -q libfuse.so.2; then
mv utils/squashfuse utils/squashfuse3 mv utils/squashfuse utils/squashfuse3
mv utils/squashfuse_ll utils/squashfuse3_ll mv utils/squashfuse_ll utils/squashfuse3_ll
fi fi
@ -95,28 +95,28 @@ if [ "${build_dwarfs}" = "true" ]; then
# #
# This can also be worked around by setting LC_ALL=C, but for now # This can also be worked around by setting LC_ALL=C, but for now
# let's revert the commit # let's revert the commit
cd dwarfs cd dwarfs || exit 1
git revert --no-commit aeeddaecab5d4648780b0e11dc03fca19e23409a git revert --no-commit aeeddaecab5d4648780b0e11dc03fca19e23409a
mkdir build mkdir build
cd build cd build || exit 1
cmake .. -DCMAKE_BUILD_TYPE=Release \ cmake .. -DCMAKE_BUILD_TYPE=Release \
-DPREFER_SYSTEM_ZSTD=ON -DPREFER_SYSTEM_XXHASH=ON \ -DPREFER_SYSTEM_ZSTD=ON -DPREFER_SYSTEM_XXHASH=ON \
-DPREFER_SYSTEM_GTEST=ON -DPREFER_SYSTEM_LIBFMT=ON -DPREFER_SYSTEM_GTEST=ON -DPREFER_SYSTEM_LIBFMT=ON
make -j$(nproc) make -j"$(nproc)"
make DESTDIR="${script_dir}"/build-utils/bin install make DESTDIR="${script_dir}"/build-utils/bin install
cd "${script_dir}"/build-utils cd "${script_dir}"/build-utils || exit 1
mv bin/usr/local/sbin/dwarfs2 utils/dwarfs mv bin/usr/local/sbin/dwarfs2 utils/dwarfs
mv bin/usr/local/sbin/dwarfs utils/dwarfs3 mv bin/usr/local/sbin/dwarfs utils/dwarfs3
mv bin/usr/local/bin/mkdwarfs utils mv bin/usr/local/bin/mkdwarfs utils
mv bin/usr/local/bin/dwarfsextract utils mv bin/usr/local/bin/dwarfsextract utils
fi fi
libs_list="$(ldd utils/* | grep "=> /" | awk '{print $3}' | xargs)" mapfile -t libs_list < <(ldd utils/* | awk '/=> \// {print $3}')
for i in ${libs_list}; do for i in "${libs_list[@]}"; do
if [ ! -f utils/"$(basename "${i}")" ]; then if [ ! -f utils/"$(basename "${i}")" ]; then
cp -L "${i}" utils cp -L "${i}" utils
fi fi