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
|
if [[ "${OSTYPE}" = darwin* ]]; then
|
||||||
declare -r READLINK=greadlink
|
declare -r READLINK=greadlink
|
||||||
declare -r TAR=gtar
|
declare -r TAR=gtar
|
||||||
@@ -306,13 +324,23 @@ case "${format}" in
|
|||||||
;;
|
;;
|
||||||
tar.xz)
|
tar.xz)
|
||||||
echo "Creating archive: ${output}"
|
echo "Creating archive: ${output}"
|
||||||
# NOTE: override xz default block size, as otherwise with the size of our
|
# Note: we create one XZ block per TAR entry.
|
||||||
# uncompressed data (< 100 MiB), we never benefit from multi-threading:
|
tarfile="${tmpdir}/release.tar"
|
||||||
# level 9 → 64 MiB dictionary → ×3 default block size = 192 MiB.
|
tarindex="${tarfile}.index"
|
||||||
# With a block size of 32 MiB, compression with 4 threads is ~2.7 times faster,
|
blocklist="${tmpdir}/release.blocklist"
|
||||||
# for a final output size increase of just 200 KiB (less than 1%).
|
# Create the initial uncompressed TAR file.
|
||||||
"${tar_compress_cmd[@]}" |
|
"${tar_compress_cmd[@]}" --file="${tarfile}"
|
||||||
xz -9 --block-size=32M ${jobs:+--threads=${jobs}} "${options[@]}" |
|
# 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}"
|
write_to_file "${output}"
|
||||||
;;
|
;;
|
||||||
tar.zst)
|
tar.zst)
|
||||||
|
|||||||
Reference in new issue
Block a user