simplify cpio creation step, with using bsdcpio in container mkinitcpio and update-installer

This commit is contained in:
Tobias Powalowski 2023-03-15 10:48:57 +01:00
parent 707e4b2a7e
commit 184884c0d5
5 changed files with 15 additions and 10 deletions

View file

@ -197,9 +197,16 @@ _set_hostname() {
echo 'archboot' > "${1}/etc/hostname"
}
# patch mkinitcpio to preserve permissions
# patch mkinitcpio to preserve permissions and use bsdcpio
# Result is this code:
# find . | bsdcpio --quiet -o -H newc |
# $compress "${COMPRESSION_OPTIONS[@]}" > "$compressout")
# pipeprogs=("find" "bsdcpio" "$compress")
_fix_initramfs_permissions() {
echo "Preserving permissions in mkinitcpio run..."
sed -i -e 's#--uid 0 --gid 0 ##g' "${1}"/usr/bin/mkinitcpio
echo "Preserving permissions and bsdcpio usage in mkinitcpio run..."
sed -i -e 's#find . -mindepth 1 -printf .*#find . | bsdcpio --quiet -o -H newc |#g' "${1}"/usr/bin/mkinitcpio
sed -i -e '/sort -z |/d' "${1}"/usr/bin/mkinitcpio
sed -i -e '/LANG=C bsdtar .*/d' "${1}"/usr/bin/mkinitcpio
sed -i -e 's#pipeprogs=.*#pipeprogs=\("find" "bsdcpio" "$compress"\)#g' "${1}"/usr/bin/mkinitcpio
}
# vim: set ft=sh ts=4 sw=4 et:

View file

@ -237,12 +237,10 @@ _kver_generic() {
}
_create_initramfs() {
#from /usr/bin/mkinitcpio.conf
# https://www.kernel.org/doc/Documentation/filesystems/ramfs-rootfs-initramfs.txt
# compress image with zstd
cd "${_W_DIR}"/tmp || exit 1
find . -mindepth 1 -printf '%P\0' | sort -z |
LANG=C bsdtar --null -cnf - -T - |
LANG=C bsdtar --null -cf - --format=newc @- | zstd --rm -T0> ${_RAM}/${_INITRD} &
find . | bsdcpio --quiet -o -H newc | zstd --rm -T0> ${_RAM}/${_INITRD} &
sleep 2
while pgrep -x zstd &>/dev/null; do
_clean_kernel_cache

View file

@ -6,7 +6,7 @@ build ()
{
map add_binary head id cksum tail test uptime w who whoami xargs \
swapon uniq seq fdisk sfdisk cfdisk parted free less \
chgrp chown dialog dmesg egrep fgrep stty sync bsdcpio hdparm \
chgrp chown dialog dmesg egrep fgrep stty sync hdparm \
dirname chroot expr bzip2 su sdparm tput \
losetup mkfifo mknod readlink lzmadec lzop xz last wall mesg utmpdump \
xzdec switch_root pivot_root chcpu ctrlaltdel gdisk sgdisk cgdisk fixparts findmnt \

View file

@ -6,7 +6,7 @@ build ()
{
apps="head id cksum tail test uptime w who whoami xargs \
swapon uniq seq fdisk sfdisk cfdisk parted free less \
chgrp dialog dmesg egrep fgrep stty sync bsdcpio hdparm \
chgrp dialog dmesg egrep fgrep stty sync hdparm \
dirname chroot expr bunzip2 bzcat bzip2 su sdparm tput \
losetup mkfifo mknod lzmadec lzop lzma lzcat unlzma unxz xzcat \
lastb last wall mesg utmpdump xzdec switch_root pivot_root chcpu ctrlaltdel \

View file

@ -19,7 +19,7 @@ build ()
mkdir echo false sleep kmod pidof touch chmod find wc uname bsdtar yes awk halt \
shutdown reboot poweroff insmod modprobe sh dd sort zstd date tee mktemp \
install pgrep mkfs.btrfs rmmod mountpoint gzip ldconfig nscd ln top df cut \
stat tr passwd od tar
stat tr passwd od tar bsdcpio
### add nano
add_binary nano