scripts/xz_wrap.sh
Source file repositories/reference/linux-study-clean/scripts/xz_wrap.sh
File Facts
- System
- Linux kernel
- Corpus path
scripts/xz_wrap.sh- Extension
.sh- Size
- 3527 bytes
- Lines
- 163
- Domain
- Support Tooling And Documentation
- Bucket
- scripts
- Inferred role
- Support Tooling And Documentation: scripts
- Status
- atlas-only
Why This File Exists
Repository support layer: documentation, build tooling, samples, user-space helper tools, generated initramfs support, licenses, and validation utilities.
- Repository support layer: documentation, build tooling, samples, user-space helper tools, generated initramfs support, licenses, and validation utilities.
Dependency Surface
- No C-style include directives detected by the generator.
Detected Declarations
- No top-level syscall, struct, function, initcall, or export declaration detected by the generator.
Annotated Snippet
#!/bin/sh
# SPDX-License-Identifier: 0BSD
#
# This is a wrapper for xz to compress the kernel image using appropriate
# compression options depending on the architecture.
#
# Author: Lasse Collin <lasse.collin@tukaani.org>
# This has specialized settings for the following archs. However,
# XZ-compressed kernel isn't currently supported on every listed arch.
#
# Arch Align Notes
# arm 2/4 ARM and ARM-Thumb2
# arm64 4
# csky 2
# loongarch 4
# mips 2/4 MicroMIPS is 2-byte aligned
# parisc 4
# powerpc 4 Uses its own wrapper for compressors instead of this.
# riscv 2/4
# s390 2
# sh 2
# sparc 4
# x86 1
# A few archs use 2-byte or 4-byte aligned instructions depending on
# the kernel config. This function is used to check if the relevant
# config option is set to "y".
is_enabled()
{
grep -q "^$1=y$" include/config/auto.conf
}
# XZ_VERSION is needed to disable features that aren't available in
# old XZ Utils versions.
XZ_VERSION=$($XZ --robot --version) || exit
XZ_VERSION=$(printf '%s\n' "$XZ_VERSION" | sed -n 's/^XZ_VERSION=//p')
# Assume that no BCJ filter is available.
BCJ=
# Set the instruction alignment to 1, 2, or 4 bytes.
#
# Set the BCJ filter if one is available.
# It must match the #ifdef usage in lib/decompress_unxz.c.
case $SRCARCH in
arm)
if is_enabled CONFIG_THUMB2_KERNEL; then
ALIGN=2
BCJ=--armthumb
else
ALIGN=4
BCJ=--arm
fi
;;
arm64)
ALIGN=4
# ARM64 filter was added in XZ Utils 5.4.0.
if [ "$XZ_VERSION" -ge 50040002 ]; then
BCJ=--arm64
else
echo "$0: Upgrading to xz >= 5.4.0" \
"would enable the ARM64 filter" \
"for better compression" >&2
fi
;;
csky)
Annotation
- Atlas domain: Support Tooling And Documentation / scripts.
- Implementation status: atlas-only.
Implementation Notes
- This generated page is the file-by-file coverage layer; curated subsystem chapters should link here when they synthesize a multi-file control flow.
- Core OS pages should be promoted from atlas-only to deep-reviewed when they explain data structures, invariants, locking, lifecycle, and C implementation snippets.
- Driver-family pages are intentionally pattern-oriented unless they are part of the selected PCIe/NVMe representative device path.