tools/mkrelease: tweak TAR.XZ output for new OTA mechanism
Create one XZ block per TAR entry.
This commit is contained in:
1 parent
8f919f993f
commit
bd89284d59
1 file changed
+35
-7
+35
-7
@@ -28,6 +28,24 @@ function reverse_entry() {
|
||||
}
|
||||
'
|
||||
|
||||
# shellcheck disable=SC2016
|
||||
declare -r AWK_TAR_BLOCKLIST='
|
||||
BEGIN {
|
||||
FS = "[: ]+"
|
||||
ORS = ""
|
||||
TAR_BS = 512
|
||||
prev_offset = 0
|
||||
}
|
||||
{
|
||||
if ($2)
|
||||
print ($2 - prev_offset) * TAR_BS ","
|
||||
prev_offset = $2
|
||||
}
|
||||
END {
|
||||
print 0
|
||||
}
|
||||
'
|
||||
|
||||
if [[ "${OSTYPE}" = darwin* ]]; then
|
||||
declare -r READLINK=greadlink
|
||||
declare -r TAR=gtar
|
||||
@@ -306,13 +324,23 @@ case "${format}" in
|
||||
;;
|
||||
tar.xz)
|
||||
echo "Creating archive: ${output}"
|
||||
# NOTE: override xz default block size, as otherwise with the size of our
|
||||
# uncompressed data (< 100 MiB), we never benefit from multi-threading:
|
||||
# level 9 → 64 MiB dictionary → ×3 default block size = 192 MiB.
|
||||
# With a block size of 32 MiB, compression with 4 threads is ~2.7 times faster,
|
||||
# for a final output size increase of just 200 KiB (less than 1%).
|
||||
"${tar_compress_cmd[@]}" |
|
||||
xz -9 --block-size=32M ${jobs:+--threads=${jobs}} "${options[@]}" |
|
||||
# Note: we create one XZ block per TAR entry.
|
||||
tarfile="${tmpdir}/release.tar"
|
||||
tarindex="${tarfile}.index"
|
||||
blocklist="${tmpdir}/release.blocklist"
|
||||
# Create the initial uncompressed TAR file.
|
||||
"${tar_compress_cmd[@]}" --file="${tarfile}"
|
||||
# Find out where each entry starts.
|
||||
"${TAR}" --block-number --list --file="${tarfile}" >"${tarindex}"
|
||||
# Generate block list for XZ.
|
||||
awk "${AWK_TAR_BLOCKLIST}" <"${tarindex}" >"${blocklist}"
|
||||
# Create the final TAR.XZ file.
|
||||
# NOTE: we set the block size to a big enough number to
|
||||
# prevent xz from splitting an entry into multiple blocks.
|
||||
xz -9 ${jobs:+--threads=${jobs}} \
|
||||
--block-size=32M \
|
||||
--block-list="$(cat "${blocklist}")" \
|
||||
"${options[@]}" --stdout "${tarfile}" |
|
||||
write_to_file "${output}"
|
||||
;;
|
||||
tar.zst)
|
||||
|
||||
Reference in new issue
Block a user