mirror of
https://gitlab.archlinux.org/tpowa/archboot.git
synced 2024-09-19 19:40:37 +02:00
merge cpio creation to common.sh
This commit is contained in:
parent
82e5b59aef
commit
96ee045596
4 changed files with 41 additions and 65 deletions
|
@ -79,9 +79,8 @@ ldconfig -r "${_ROOTFS}" &>"${_NO_LOG}" || exit 1
|
||||||
# remove /var/cache/ldconfig/aux-cache for reproducibility
|
# remove /var/cache/ldconfig/aux-cache for reproducibility
|
||||||
rm -f -- "${_ROOTFS}/var/cache/ldconfig/aux-cache"
|
rm -f -- "${_ROOTFS}/var/cache/ldconfig/aux-cache"
|
||||||
if [[ -n "${_GENERATE_IMAGE}" ]]; then
|
if [[ -n "${_GENERATE_IMAGE}" ]]; then
|
||||||
_create_cpio "${_GENERATE_IMAGE}" "${_COMP}" || exit 1
|
_create_cpio "${_ROOTFS}" "${_GENERATE_IMAGE}" || exit 1
|
||||||
_cleanup
|
_cleanup
|
||||||
echo "Build complete."
|
|
||||||
elif [[ -n "${_TARGET_DIR}" ]]; then
|
elif [[ -n "${_TARGET_DIR}" ]]; then
|
||||||
_cleanup
|
_cleanup
|
||||||
echo "Build directory complete."
|
echo "Build directory complete."
|
||||||
|
|
|
@ -306,4 +306,39 @@ _pacman_keyring() {
|
||||||
systemctl stop pacman-init.service
|
systemctl stop pacman-init.service
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
_create_cpio() {
|
||||||
|
# Reproducibility:
|
||||||
|
# set all timestamps to 0
|
||||||
|
# fd . -u --min-depth 1 -X touch -hcd "@0"
|
||||||
|
# Pipe needed as is, bsdcpio is faster but not reproducible!
|
||||||
|
# cpio, pax, tar are slower than bsdtar!
|
||||||
|
# LC_ALL=C.UTF-8 bsdtar --null -cnf - -T - |
|
||||||
|
# LC_ALL=C.UTF-8 bsdtar --null -cf - --format=newc @-
|
||||||
|
# Compression:
|
||||||
|
# use zstd it has best compression and decompression
|
||||||
|
# Result:
|
||||||
|
# Multi CPIO archive, extractable with 3cpio
|
||||||
|
pushd "${1}" >"${_NO_LOG}" || return
|
||||||
|
echo "Creating initramfs:"
|
||||||
|
fd . -u --min-depth 1 -X touch -hcd "@0"
|
||||||
|
echo "Appending directories..."
|
||||||
|
fd . -u -t d -0 | sort -z |
|
||||||
|
LC_ALL=C.UTF-8 bsdtar --null -cnf - -T - |
|
||||||
|
LC_ALL=C.UTF-8 bsdtar --null -cf - --format=newc @- > "${2}" || _abort "Image creation failed!"
|
||||||
|
echo "Appending compressed files..."
|
||||||
|
fd . -t f -t l -u -e 'bz2' -e 'gz' -e 'xz' -e 'zst' --min-depth 1 -0 | sort -z |
|
||||||
|
LC_ALL=C.UTF-8 bsdtar --null -cnf - -T - |
|
||||||
|
LC_ALL=C.UTF-8 bsdtar --null -cf - --format=newc @- >> "${2}" || _abort "Image creation failed!"
|
||||||
|
# remove compressed files, timestamps need reset!
|
||||||
|
fd . -u -e 'bz2' -e 'gz' -e 'xz' -e 'zst' --min-depth 1 -X rm
|
||||||
|
fd . -u --min-depth 1 -X touch -hcd "@0"
|
||||||
|
echo "Appending zstd compressed image..."
|
||||||
|
fd . -t f -t l -u --min-depth 1 -0 | sort -z |
|
||||||
|
LC_ALL=C.UTF-8 bsdtar --null -cnf - -T - |
|
||||||
|
LC_ALL=C.UTF-8 bsdtar --null -cf - --format=newc @- |
|
||||||
|
zstd -T0 -19 >> "${2}" || _abort "Image creation failed!"
|
||||||
|
popd >"${_NO_LOG}" || return
|
||||||
|
echo "Build complete."
|
||||||
|
}
|
||||||
# vim: set ft=sh ts=4 sw=4 et:
|
# vim: set ft=sh ts=4 sw=4 et:
|
||||||
|
|
|
@ -244,37 +244,3 @@ _install_libs() {
|
||||||
_LIB_COUNT2="$(echo "${_ROOTFS}"/lib/*.so* | wc -w)"
|
_LIB_COUNT2="$(echo "${_ROOTFS}"/lib/*.so* | wc -w)"
|
||||||
done
|
done
|
||||||
}
|
}
|
||||||
|
|
||||||
_create_cpio() {
|
|
||||||
# Reproducibility:
|
|
||||||
# set all timestamps to 0
|
|
||||||
# fd . -u --min-depth 1 -X touch -hcd "@0"
|
|
||||||
# Pipe needed as is, bsdcpio is faster but not reproducible!
|
|
||||||
# cpio, pax, tar are slower than bsdtar!
|
|
||||||
# LC_ALL=C.UTF-8 bsdtar --null -cnf - -T - |
|
|
||||||
# LC_ALL=C.UTF-8 bsdtar --null -cf - --format=newc @-
|
|
||||||
# Compression:
|
|
||||||
# use zstd it has best compression and decompression
|
|
||||||
# Result:
|
|
||||||
# Multi CPIO archive, extractable with 3cpio
|
|
||||||
pushd "${_ROOTFS}" >"${_NO_LOG}" || return
|
|
||||||
echo "Creating initramfs:"
|
|
||||||
fd . -u --min-depth 1 -X touch -hcd "@0"
|
|
||||||
echo "Appending directories..."
|
|
||||||
fd . -u -t d -0 | sort -z |
|
|
||||||
LC_ALL=C.UTF-8 bsdtar --null -cnf - -T - |
|
|
||||||
LC_ALL=C.UTF-8 bsdtar --null -cf - --format=newc @- > "${_GENERATE_IMAGE}" || _abort "Image creation failed!"
|
|
||||||
echo "Appending compressed files..."
|
|
||||||
fd . -t f -t l -u -e 'bz2' -e 'gz' -e 'xz' -e 'zst' --min-depth 1 -0 | sort -z |
|
|
||||||
LC_ALL=C.UTF-8 bsdtar --null -cnf - -T - |
|
|
||||||
LC_ALL=C.UTF-8 bsdtar --null -cf - --format=newc @- >> "${_GENERATE_IMAGE}" || _abort "Image creation failed!"
|
|
||||||
# remove compressed files, timestamps need reset!
|
|
||||||
fd . -u -e 'bz2' -e 'gz' -e 'xz' -e 'zst' --min-depth 1 -X rm
|
|
||||||
fd . -u --min-depth 1 -X touch -hcd "@0"
|
|
||||||
echo "Appending zstd compressed image..."
|
|
||||||
fd . -t f -t l -u --min-depth 1 -0 | sort -z |
|
|
||||||
LC_ALL=C.UTF-8 bsdtar --null -cnf - -T - |
|
|
||||||
LC_ALL=C.UTF-8 bsdtar --null -cf - --format=newc @- |
|
|
||||||
zstd -T0 -19 >> "${_GENERATE_IMAGE}" || _abort "Image creation failed!"
|
|
||||||
popd >"${_NO_LOG}" || return
|
|
||||||
}
|
|
||||||
|
|
|
@ -31,30 +31,6 @@ _create_initrd_dir() {
|
||||||
-k ${_KERNEL} -c /etc/archboot/${1} -d /tmp/initrd" || exit 1
|
-k ${_KERNEL} -c /etc/archboot/${1} -d /tmp/initrd" || exit 1
|
||||||
}
|
}
|
||||||
|
|
||||||
_compress_initrd() {
|
|
||||||
pushd "${_W_DIR}/tmp/initrd" >"${_NO_LOG}" || return
|
|
||||||
echo "Creating initramfs:"
|
|
||||||
fd . -u --min-depth 1 -X touch -hcd "@0"
|
|
||||||
echo "Appending directories..."
|
|
||||||
fd . -u -t d -0 | sort -z |
|
|
||||||
LC_ALL=C.UTF-8 bsdtar --null -cnf - -T - |
|
|
||||||
LC_ALL=C.UTF-8 bsdtar --null -cf - --format=newc @- > "../../${1}" || _abort "Image creation failed!"
|
|
||||||
echo "Appending compressed files..."
|
|
||||||
fd . -t f -t l -u -e 'bz2' -e 'gz' -e 'xz' -e 'zst' --min-depth 1 -0 | sort -z |
|
|
||||||
LC_ALL=C.UTF-8 bsdtar --null -cnf - -T - |
|
|
||||||
LC_ALL=C.UTF-8 bsdtar --null -cf - --format=newc @- >> "../../${1}" || _abort "Image creation failed!"
|
|
||||||
# remove compressed files, timestamps need reset!
|
|
||||||
fd . -u -e 'bz2' -e 'gz' -e 'xz' -e 'zst' --min-depth 1 -X rm
|
|
||||||
fd . -u --min-depth 1 -X touch -hcd "@0"
|
|
||||||
echo "Appending zstd compressed image..."
|
|
||||||
fd . -t f -t l -u --min-depth 1 -0 | sort -z |
|
|
||||||
LC_ALL=C.UTF-8 bsdtar --null -cnf - -T - |
|
|
||||||
LC_ALL=C.UTF-8 bsdtar --null -cf - --format=newc @- |
|
|
||||||
zstd -T0 -19 >> "../../${1}" || _abort "Image creation failed!"
|
|
||||||
popd >"${_NO_LOG}" || return
|
|
||||||
echo "Build complete."
|
|
||||||
}
|
|
||||||
|
|
||||||
_create_iso() {
|
_create_iso() {
|
||||||
mkdir -p "${1}"
|
mkdir -p "${1}"
|
||||||
cd "${1}" || exit 1
|
cd "${1}" || exit 1
|
||||||
|
@ -71,24 +47,24 @@ _create_iso() {
|
||||||
# init ramdisk
|
# init ramdisk
|
||||||
_create_initrd_dir "${_ARCH}-init.conf"
|
_create_initrd_dir "${_ARCH}-init.conf"
|
||||||
. "/etc/archboot/${_ARCH}-init.conf"
|
. "/etc/archboot/${_ARCH}-init.conf"
|
||||||
_compress_initrd "init-${_ARCH}.img"
|
_create_cpio "${_W_DIR}/tmp/initrd" "init-${_ARCH}.img"
|
||||||
if ! [[ "${_ARCH}" == "riscv64" ]]; then
|
if ! [[ "${_ARCH}" == "riscv64" ]]; then
|
||||||
# local ramdisk
|
# local ramdisk
|
||||||
echo "Generating local initramfs..."
|
echo "Generating local initramfs..."
|
||||||
_create_initrd_dir "${_CONFIG_LOCAL}"
|
_create_initrd_dir "${_W_DIR}/tmp/initrd" "${_CONFIG_LOCAL}"
|
||||||
. "/etc/archboot/${_CONFIG_LOCAL}"
|
. "/etc/archboot/${_CONFIG_LOCAL}"
|
||||||
_compress_initrd "initrd-local-${_ARCH}.img"
|
_create_cpio "${_W_DIR}/tmp/initrd" "initrd-local-${_ARCH}.img"
|
||||||
# latest ramdisk
|
# latest ramdisk
|
||||||
echo "Generating latest initramfs..."
|
echo "Generating latest initramfs..."
|
||||||
_create_initrd_dir "${_CONFIG_LATEST}"
|
_create_initrd_dir "${_CONFIG_LATEST}"
|
||||||
. "/etc/archboot/${_CONFIG_LATEST}"
|
. "/etc/archboot/${_CONFIG_LATEST}"
|
||||||
_compress_initrd "initrd-latest-${_ARCH}.img"
|
_create_cpio "${_W_DIR}/tmp/initrd" "initrd-latest-${_ARCH}.img"
|
||||||
fi
|
fi
|
||||||
# normal ramdisk
|
# normal ramdisk
|
||||||
echo "Generating normal initramfs..."
|
echo "Generating normal initramfs..."
|
||||||
_create_initrd_dir "${_ARCH}.conf"
|
_create_initrd_dir "${_ARCH}.conf"
|
||||||
. "/etc/archboot/${_ARCH}.conf"
|
. "/etc/archboot/${_ARCH}.conf"
|
||||||
_compress_initrd "initrd-${_ARCH}.img"
|
_create_cpio "${_W_DIR}/tmp/initrd" "initrd-${_ARCH}.img"
|
||||||
fi
|
fi
|
||||||
# riscv64 does not support kexec at the moment
|
# riscv64 does not support kexec at the moment
|
||||||
if ! [[ "${_ARCH}" == "riscv64" ]]; then
|
if ! [[ "${_ARCH}" == "riscv64" ]]; then
|
||||||
|
|
Loading…
Reference in a new issue