From d97077d0261cdf642ab99cc7b8fdf722577f5dd3 Mon Sep 17 00:00:00 2001 From: Kron4ek Date: Wed, 11 Aug 2021 14:43:12 +0500 Subject: [PATCH] Split squashfs and dwarfs utils The dwarfs utils are relatively large (~20 MB when extracted) and are not needed for squashfs-compressed images, so it's better to move them into a separate archive. --- conty-start.sh | 26 +++++++++++++++++++++----- create-conty.sh | 14 ++++++++++---- create-utils.sh | 9 ++++++--- utils.tar.gz | 4 ++-- utils_dwarfs.tar.gz | 3 +++ 5 files changed, 42 insertions(+), 14 deletions(-) create mode 100644 utils_dwarfs.tar.gz diff --git a/conty-start.sh b/conty-start.sh index a23862a..6268184 100755 --- a/conty-start.sh +++ b/conty-start.sh @@ -43,11 +43,11 @@ mount_point="${working_dir}"/mnt # a problem with mounting the image due to an incorrectly calculated offset. # The size of this script -scriptsize=24850 +scriptsize=25303 # The size of the utils.tar.gz archive # utils.tar.gz contains bwrap, squashfuse and dwarfs binaries -utilssize=9144313 +utilssize=2923949 # Offset where the image is stored offset=$((scriptsize+utilssize)) @@ -404,15 +404,21 @@ if [ "$1" = "-u" ] || [ "$1" = "-U" ]; then # on what command line argument is used (-u or -U) clear if [ "$1" = "-U" ] && command -v wget 1>/dev/null; then + if [ "${dwarfs_image}" = 1 ]; then + utils="utils_dwarfs.tar.gz" + else + utils="utils.tar.gz" + fi + echo "Downloading the init script and the utils" wget -q --show-progress "https://github.com/Kron4ek/Conty/raw/master/conty-start.sh" - wget -q --show-progress "https://github.com/Kron4ek/Conty/raw/master/utils.tar.gz" + wget -q --show-progress -O utils.tar.gz "https://github.com/Kron4ek/Conty/raw/master/${utils}" fi 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 @@ -714,6 +720,12 @@ fi # Mount the image mkdir -p "${mount_point}" +# Since mounting dwarfs images is relatively slow on HDDs, it's better +# to show a message when the mounting is in process +if [ "${dwarfs_image}" = 1 ] && [ ! "$(ls "${mount_point}" 2>/dev/null)" ]; then + show_msg "Mounting the image, please wait..." +fi + if [ "$(ls "${mount_point}" 2>/dev/null)" ] || \ ( [ "${dwarfs_image}" != 1 ] && launch_wrapper "${mount_tool}" -o offset="${offset}",ro "${script}" "${mount_point}" ) || \ launch_wrapper "${mount_tool}" "${script}" "${mount_point}" -o offset="${offset}" -o debuglevel=error -o workers="${dwarfs_num_workers}" \ @@ -733,6 +745,10 @@ if [ "$(ls "${mount_point}" 2>/dev/null)" ] || \ echo 1 > "${working_dir}"/running_"${script_id}" + if [ "${dwarfs_image}" = 1 ] && [ "${QUIET_MODE}" != 1 ]; then + clear + fi + show_msg "Running Conty" if [ "${NVIDIA_FIX}" = 1 ]; then diff --git a/create-conty.sh b/create-conty.sh index 24e75fd..cd2ab47 100755 --- a/create-conty.sh +++ b/create-conty.sh @@ -25,9 +25,15 @@ bootstrap="${script_dir}"/root.x86_64 cd "${script_dir}" || exit 1 -if [ ! -f utils.tar.gz ] || [ "$(wc -c < utils.tar.gz)" -lt 1000 ]; then - rm -f utils.tar.gz - wget -q --show-progress "https://github.com/Kron4ek/Conty/raw/master/utils.tar.gz" +if [ "${dwarfs}" = "true" ]; then + utils="utils_dwarfs.tar.gz" +else + utils="utils.tar.gz" +fi + +if [ ! -f "${utils}" ] || [ "$(wc -c < "${utils}")" -lt 1000 ]; then + rm -f "${utils}" + wget -q --show-progress "https://github.com/Kron4ek/Conty/raw/master/${utils}" fi if [ ! -f conty-start.sh ]; then @@ -83,7 +89,7 @@ if [ ! -f "${image_path}" ] || [ "${use_existing_image}" != "true" ]; then fi # Combine the files into a single executable using cat -cat conty-start.sh utils.tar.gz "${image_path}" > conty.sh +cat conty-start.sh "${utils}" "${image_path}" > conty.sh chmod +x conty.sh clear diff --git a/create-utils.sh b/create-utils.sh index 3473349..adb886e 100755 --- a/create-utils.sh +++ b/create-utils.sh @@ -117,11 +117,14 @@ EOF if [ "${build_dwarfs}" = "true" ]; then echo "dwarfs ${dwarfs_version}" >> utils/info + utils="utils_dwarfs.tar.gz" +else + utils="utils.tar.gz" fi -tar -zcf utils.tar.gz utils -mv "${script_dir}"/utils.tar.gz "${script_dir}"/utils_old.tar.gz -mv utils.tar.gz "${script_dir}" +tar -zcf "${utils}" utils +mv "${script_dir}"/"${utils}" "${script_dir}"/"${utils}".old +mv "${utils}" "${script_dir}" cd "${script_dir}" || exit 1 rm -rf build-utils diff --git a/utils.tar.gz b/utils.tar.gz index 1b645de..982f77c 100644 --- a/utils.tar.gz +++ b/utils.tar.gz @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:f02bdddb8c050751aa359e3bdabac08e1e2cc6ef767f0572fb84ccaec3a6012a -size 9144313 +oid sha256:45bd5a06896afb76530520c16568849247c4719fcf0804539d3e71fac4444d65 +size 2923949 diff --git a/utils_dwarfs.tar.gz b/utils_dwarfs.tar.gz new file mode 100644 index 0000000..5f91c7c --- /dev/null +++ b/utils_dwarfs.tar.gz @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:f22893f87d79907c1d95bd0a9a3db00a9ff176739e91268aef91d5a996e26a3d +size 8874518