diff --git a/conty-start.sh b/conty-start.sh index bccf2ca..ffbc781 100755 --- a/conty-start.sh +++ b/conty-start.sh @@ -43,7 +43,7 @@ mount_point="${working_dir}"/mnt # a problem with mounting the image due to an incorrectly calculated offset. # The size of this script -scriptsize=26260 +scriptsize=26210 # The size of the utils archive utilssize=2507588 @@ -60,10 +60,10 @@ dwarfs_cache_size="128M" dwarfs_num_workers="2" # These arguments are used to rebuild the image when using the self-update function -squashfs_comp_arguments="-b 1M -comp zstd -Xcompression-level 19" -dwarfs_comp_arguments="-l7 -C zstd:level=19 --metadata-compression null \ +squashfs_comp_arguments=(-b 1M -comp zstd -Xcompression-level 19) +dwarfs_comp_arguments=(-l7 -C zstd:level=19 --metadata-compression null \ -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 if [ -L "${script_literal}" ]; then @@ -161,7 +161,7 @@ if [ -z "${script_is_symlink}" ]; then exit elif [ "$1" = "-o" ]; then - echo ${offset} + echo "${offset}" exit fi @@ -258,17 +258,17 @@ if [ "${USE_SYS_UTILS}" != 1 ]; then fi 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 else - mount_tool="${working_dir}"/utils/squashfuse${fuse_version} + mount_tool="${working_dir}"/utils/squashfuse"${fuse_version}" extraction_tool="${working_dir}"/utils/unsquashfs fi bwrap="${working_dir}"/utils/bwrap 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 clear @@ -327,10 +327,10 @@ if [ "$1" = "-e" ] && [ -z "${script_is_symlink}" ]; then if [ "${dwarfs_image}" = 1 ]; then echo "Extracting the image..." 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" 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 else echo "Extraction tool not found" @@ -345,7 +345,7 @@ if [ "$1" = "-H" ] && [ -z "${script_is_symlink}" ]; then exit fi -if ([ "$1" = "-u" ] || [ "$1" = "-U" ]) && [ -z "${script_is_symlink}" ]; then +if { [ "$1" = "-u" ] || [ "$1" = "-U" ]; } && [ -z "${script_is_symlink}" ]; then OLD_PWD="${PWD}" # Check if the current directory is writable @@ -376,7 +376,7 @@ if ([ "$1" = "-u" ] || [ "$1" = "-U" ]) && [ -z "${script_is_symlink}" ]; then 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 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 mkdir sqfs 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}" else tools_wrapper "${update_temp_dir}"/utils/unsquashfs \ - -o ${offset} -user-xattrs -d sqfs "${script}" + -o "${offset}" -user-xattrs -d sqfs "${script}" fi # 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 echo "Extracting the init script and the integrated utils" - tail -c +$((scriptsize+1)) "${script}" | head -c ${utilssize} > utils.tar.gz - head -c ${scriptsize} "${script}" > conty-start.sh + tail -c +$((scriptsize+1)) "${script}" | head -c "${utilssize}" > utils.tar.gz + head -c "${scriptsize}" "${script}" > conty-start.sh fi # Check if there are additional arguments passed shift if [ -n "$1" ]; then - packagelist="$@" + packagelist=("$@") # 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 - export pkgsremove="${pkgsremove} $(echo "${i}" | tail -c +2)" + pkgsremove+=" ${i:1}" else - export pkgsinstall="${pkgsinstall} ${i}" + pkgsinstall+=" ${i}" fi done + + export pkgsremove + export pkgsinstall fi # Generate a script to perform inside Conty @@ -511,10 +514,10 @@ EOF echo "Creating an image" if [ "${dwarfs_image}" = 1 ]; then tools_wrapper "${update_temp_dir}"/utils/mkdwarfs \ - -i sqfs -o image ${dwarfs_comp_arguments} + -i sqfs -o image "${dwarfs_comp_arguments[@]}" else tools_wrapper "${update_temp_dir}"/utils/mksquashfs \ - sqfs image ${squashfs_comp_arguments} + sqfs image "${squashfs_comp_arguments[@]}" fi # Combine into a single executable @@ -574,44 +577,44 @@ run_bwrap () { tmp|mnt|opt|media|run|var) ;; *) - NEW_HOME="/home/${USER}" - non_standard_home+=("--tmpfs" "/home" \ - "--bind" "${HOME}" "${NEW_HOME}" \ - "--setenv" "HOME" "${NEW_HOME}") + NEW_HOME=/home/"${USER}" + non_standard_home+=(--tmpfs /home \ + --bind "${HOME}" "${NEW_HOME}" \ + --setenv "HOME" "${NEW_HOME}") ;; esac fi if [ "${SANDBOX}" = 1 ]; then - sandbox_params+=("--tmpfs" "/home" \ - "--tmpfs" "/opt" \ - "--tmpfs" "/mnt" \ - "--tmpfs" "/media" \ - "--tmpfs" "/var" \ - "--tmpfs" "/run" \ - "--symlink" "/run" "/var/run" \ - "--tmpfs" "/tmp" \ - "--new-session") + sandbox_params+=(--tmpfs /home \ + --tmpfs /opt \ + --tmpfs /mnt \ + --tmpfs /media \ + --tmpfs /var \ + --tmpfs /run \ + --symlink /run /var/run \ + --tmpfs /tmp \ + --new-session) - if [ -n "${non_standard_home}" ]; then - sandbox_params+=("--dir" "${NEW_HOME}") + if [ -n "${non_standard_home[*]}" ]; then + sandbox_params+=(--dir "${NEW_HOME}") else - sandbox_params+=("--dir" "${HOME}") + sandbox_params+=(--dir "${HOME}") fi if [ -n "${SANDBOX_LEVEL}" ] && [ "${SANDBOX_LEVEL}" -ge 2 ]; then sandbox_level_msg="(level 2)" - 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}"/pulse "${XDG_RUNTIME_DIR}"/pulse \ - "--ro-bind-try" "${XDG_RUNTIME_DIR}"/pipewire-0 "${XDG_RUNTIME_DIR}"/pipewire-0 \ - "--unshare-pid" \ - "--unshare-user-try" \ - "--unsetenv" "DBUS_SESSION_BUS_ADDRESS") + 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}"/pulse "${XDG_RUNTIME_DIR}"/pulse \ + --ro-bind-try "${XDG_RUNTIME_DIR}"/pipewire-0 "${XDG_RUNTIME_DIR}"/pipewire-0 \ + --unshare-pid \ + --unshare-user-try \ + --unsetenv "DBUS_SESSION_BUS_ADDRESS") else sandbox_level_msg="(level 1)" - sandbox_params+=("--bind-try" "${XDG_RUNTIME_DIR}" "${XDG_RUNTIME_DIR}" \ - "--bind-try" "/run/dbus" "/run/dbus") + sandbox_params+=(--bind-try "${XDG_RUNTIME_DIR}" "${XDG_RUNTIME_DIR}" \ + --bind-try /run/dbus /run/dbus) fi if [ -n "${SANDBOX_LEVEL}" ] && [ "${SANDBOX_LEVEL}" -ge 3 ]; then @@ -625,16 +628,16 @@ run_bwrap () { if [ "${DISABLE_NET}" = 1 ]; then show_msg "Network is disabled" - unshare_net="--unshare-net" + unshare_net=(--unshare-net) fi if [ -n "${HOME_DIR}" ]; then show_msg "Home directory is set to ${HOME_DIR}" - if [ -n "${non_standard_home}" ]; then - custom_home+=("--bind" "${HOME_DIR}" "${NEW_HOME}") + if [ -n "${non_standard_home[*]}" ]; then + custom_home+=(--bind "${HOME_DIR}" "${NEW_HOME}") else - custom_home+=("--bind" "${HOME_DIR}" "${HOME}") + custom_home+=(--bind "${HOME_DIR}" "${HOME}") fi [ ! -d "${HOME_DIR}" ] && mkdir -p "${HOME_DIR}" @@ -646,23 +649,23 @@ run_bwrap () { fi # 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 - xsockets+=("--ro-bind-try" "${XAUTHORITY}" "${NEW_HOME}"/.Xauthority \ - "--setenv" "XAUTHORITY" "${NEW_HOME}"/.Xauthority) + if [ -n "${non_standard_home[*]}" ] && [ "${XAUTHORITY}" = "${HOME}"/.Xauthority ]; then + xsockets+=(--ro-bind-try "${XAUTHORITY}" "${NEW_HOME}"/.Xauthority \ + --setenv "XAUTHORITY" "${NEW_HOME}"/.Xauthority) else - xsockets+=("--ro-bind-try" "${XAUTHORITY}" "${XAUTHORITY}") + xsockets+=(--ro-bind-try "${XAUTHORITY}" "${XAUTHORITY}") fi if [ "${DISABLE_X11}" != 1 ]; then if [ "$(ls /tmp/.X11-unix 2>/dev/null)" ]; 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}" \ - "--setenv" "DISPLAY" ":${xephyr_display}") + xsockets+=(--ro-bind-try /tmp/.X11-unix/X"${xephyr_display}" /tmp/.X11-unix/X"${xephyr_display}" \ + --setenv "DISPLAY" :"${xephyr_display}") else for s in /tmp/.X11-unix/*; do - xsockets+=("--bind-try" "${s}" "${s}") + xsockets+=(--bind-try "${s}" "${s}") done fi fi @@ -671,9 +674,9 @@ run_bwrap () { # Unset the DISPLAY and XAUTHORITY env variables and mount an # empty file to XAUTHORITY to invalidate it - xsockets+=("--ro-bind-try" "${working_dir}"/running_"${script_id}" "${XAUTHORITY}" \ - "--unsetenv" "DISPLAY" \ - "--unsetenv" "XAUTHORITY") + xsockets+=(--ro-bind-try "${working_dir}"/running_"${script_id}" "${XAUTHORITY}" \ + --unsetenv "DISPLAY" \ + --unsetenv "XAUTHORITY") fi show_msg @@ -703,7 +706,7 @@ run_bwrap () { "${sandbox_params[@]}" \ "${custom_home[@]}" \ "${xsockets[@]}" \ - ${unshare_net} \ + "${unshare_net[@]}" \ --setenv PATH "${CUSTOM_PATH}" \ "$@" } @@ -712,7 +715,7 @@ trap_exit () { rm -f "${working_dir}"/running_"${script_id}" 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 if [ ! "$(ls "${mount_point}" 2>/dev/null)" ]; then @@ -777,15 +780,15 @@ if [ "$(ls "${mount_point}" 2>/dev/null)" ] || \ XEPHYR_SIZE="800x600" fi - xephyr_display="$((${script_id}+2))" + xephyr_display="$((script_id+2))" - if [ -S /tmp/.X11-unix/X${xephyr_display} ]; then - xephyr_display="$((${script_id}+10))" + if [ -S /tmp/.X11-unix/X"${xephyr_display}" ]; then + xephyr_display="$((script_id+10))" fi QUIET_MODE=1 DISABLE_NET=1 SANDBOX_LEVEL=2 run_bwrap \ --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=$! QUIET_MODE=1 run_bwrap openbox & sleep 1 @@ -807,7 +810,7 @@ if [ "$(ls "${mount_point}" 2>/dev/null)" ] || \ fi if [ -n "${xephyr_pid}" ]; then - wait ${xephyr_pid} + wait "${xephyr_pid}" fi else echo "Mounting the image failed!" diff --git a/create-arch-bootstrap.sh b/create-arch-bootstrap.sh index a15a78f..90acfd5 100755 --- a/create-arch-bootstrap.sh +++ b/create-arch-bootstrap.sh @@ -150,20 +150,20 @@ if [ ! -s chaotic-keyring.pkg.tar.zst ] || [ ! -s chaotic-mirrorlist.pkg.tar.zst exit 1 fi -bootstrap_urls="mirror.osbeck.com \ - mirror.f4st.host \ - mirror.luzea.de" +bootstrap_urls=("mirror.osbeck.com" \ + "mirror.f4st.host" \ + "mirror.luzea.de") 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 \ "https://${link}/archlinux/iso/latest/archlinux-bootstrap-x86_64.tar.gz" wget -q --show-progress -O sha256sums.txt \ "https://${link}/archlinux/iso/latest/sha256sums.txt" 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" 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 mv mirrorlist "${bootstrap}"/etc/pacman.d/mirrorlist -echo >> "${bootstrap}"/etc/pacman.conf -echo "[multilib]" >> "${bootstrap}"/etc/pacman.conf -echo "Include = /etc/pacman.d/mirrorlist" >> "${bootstrap}"/etc/pacman.conf +{ + echo + echo "[multilib]" + echo "Include = /etc/pacman.d/mirrorlist" +} >> "${bootstrap}"/etc/pacman.conf run_in_chroot pacman-key --init 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 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 "Include = /etc/pacman.d/chaotic-mirrorlist" >> "${bootstrap}"/etc/pacman.conf +{ + echo + echo "[chaotic-aur]" + echo "Include = /etc/pacman.d/chaotic-mirrorlist" +} >> "${bootstrap}"/etc/pacman.conf # The ParallelDownloads feature of pacman # Speeds up packages installation, especially when there are many small packages to install diff --git a/create-conty.sh b/create-conty.sh index 38a611e..63cc483 100755 --- a/create-conty.sh +++ b/create-conty.sh @@ -8,17 +8,17 @@ script_dir="$(dirname "$(readlink -f "${BASH_SOURCE[0]}")")" # These are the algorithms supported by the integrated squashfuse # However, your squashfs-tools (mksquashfs) may not support some of them 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 #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 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 \ - --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 # 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 &>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 "compression algorithm (${squashfs_compressor})." echo @@ -82,14 +82,14 @@ if [ ! -f "${image_path}" ] || [ "${use_existing_image}" != "true" ]; then exit 1 fi - mkdwarfs -i "${bootstrap}" -o "${image_path}" ${dwarfs_compressor_arguments} + mkdwarfs -i "${bootstrap}" -o "${image_path}" "${dwarfs_compressor_arguments[@]}" else if ! command -v mksquashfs 1>/dev/null; then echo "Please install squashfs-tools and run the script again" exit 1 fi - mksquashfs "${bootstrap}" "${image_path}" ${squashfs_compressor_arguments} + mksquashfs "${bootstrap}" "${image_path}" "${squashfs_compressor_arguments[@]}" fi fi diff --git a/create-utils.sh b/create-utils.sh index bf8dbb5..47f89fd 100755 --- a/create-utils.sh +++ b/create-utils.sh @@ -30,58 +30,58 @@ export LDFLAGS="-Wl,-O1,--sort-common,--as-needed" mkdir -p "${script_dir}"/build-utils 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 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 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 bwrap.tar.gz https://github.com/containers/bubblewrap/archive/refs/tags/v"${bwrap_version}".tar.gz tar xf lz4.tar.gz tar xf zstd.tar.gz tar xf bwrap.tar.gz 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 sqfstools.tar.gz https://github.com/plougher/squashfs-tools/archive/refs/tags/${squashfs_tools_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 tar xf squashfuse.tar.gz tar xf sqfstools.tar.gz fi -cd bubblewrap-${bwrap_version} +cd bubblewrap-"${bwrap_version}" || exit 1 ./autogen.sh ./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} -make -j$(nproc) DESTDIR="${script_dir}"/build-utils/bin install +cd ../lz4-"${lz4_version}" || exit 1 +make -j"$(nproc)" DESTDIR="${script_dir}"/build-utils/bin install -cd ../zstd-${zstd_version} -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 +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 if [ "${build_dwarfs}" != "true" ]; then - cd ../squashfuse-${squashfuse_version} + cd ../squashfuse-"${squashfuse_version}" || exit 1 ./autogen.sh ./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 - make -j$(nproc) GZIP_SUPPORT=1 XZ_SUPPORT=1 LZO_SUPPORT=1 LZMA_XZ_SUPPORT=1 \ + 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 \ LZ4_SUPPORT=1 ZSTD_SUPPORT=1 XATTR_SUPPORT=1 make INSTALL_DIR="${script_dir}"/build-utils/bin/usr/local/bin install fi -cd "${script_dir}"/build-utils +cd "${script_dir}"/build-utils || exit 1 mkdir utils mv bin/usr/local/bin/bwrap utils mv bin/usr/local/bin/squashfuse utils mv bin/usr/local/bin/squashfuse_ll utils mv bin/usr/local/bin/mksquashfs 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/libzstd.so.${zstd_version} utils/libzstd.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/libfuseprivate.so.0.0.0 utils/libfuseprivate.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_ll utils/squashfuse3_ll fi @@ -95,28 +95,28 @@ if [ "${build_dwarfs}" = "true" ]; then # # This can also be worked around by setting LC_ALL=C, but for now # let's revert the commit - cd dwarfs + cd dwarfs || exit 1 git revert --no-commit aeeddaecab5d4648780b0e11dc03fca19e23409a mkdir build - cd build + cd build || exit 1 cmake .. -DCMAKE_BUILD_TYPE=Release \ -DPREFER_SYSTEM_ZSTD=ON -DPREFER_SYSTEM_XXHASH=ON \ -DPREFER_SYSTEM_GTEST=ON -DPREFER_SYSTEM_LIBFMT=ON - make -j$(nproc) + make -j"$(nproc)" 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/dwarfs utils/dwarfs3 mv bin/usr/local/bin/mkdwarfs utils mv bin/usr/local/bin/dwarfsextract utils 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 cp -L "${i}" utils fi