cache lsblk output
This commit is contained in:
parent
87b75b2466
commit
fdbc6fb3aa
|
@ -735,10 +735,14 @@ gentoo_chroot() {
|
|||
mount --make-rslave "$ROOT_MOUNTPOINT/dev"; } || exit 1
|
||||
) || die "Could not mount virtual filesystems"
|
||||
|
||||
# Cache lsblk output, because apparently it doesn't work correctly in chroot (returns almost no info for devices, e.g. empty uuids)
|
||||
cache_lsblk_output
|
||||
|
||||
# Execute command
|
||||
einfo "Chrooting..."
|
||||
EXECUTED_IN_CHROOT=true \
|
||||
TMP_DIR=$TMP_DIR \
|
||||
TMP_DIR="$TMP_DIR" \
|
||||
CACHED_LSBLK_OUTPUT="$CACHED_LSBLK_OUTPUT" \
|
||||
exec chroot -- "$ROOT_MOUNTPOINT" "$GENTOO_INSTALL_REPO_DIR/scripts/main_chroot.sh" "$@" \
|
||||
|| die "Failed to chroot into '$ROOT_MOUNTPOINT'"
|
||||
}
|
||||
|
|
|
@ -158,13 +158,20 @@ get_device_by_uuid() {
|
|||
get_device_by_blkid_field 'UUID' "$1"
|
||||
}
|
||||
|
||||
cache_lsblk_output() {
|
||||
CACHED_LSBLK_OUTPUT="$(lsblk --all --path --pairs --output NAME,PTUUID,PARTUUID)" \
|
||||
|| die "Error while executing lsblk to cache output"
|
||||
}
|
||||
|
||||
get_device_by_ptuuid() {
|
||||
echo "get_device_by_ptuuid '$ptuuid'"
|
||||
local ptuuid="${1,,}"
|
||||
local dev
|
||||
dev="$(lsblk --all --path --pairs --output NAME,PTUUID,PARTUUID)" \
|
||||
|| die "Error while executing lsblk to find PTUUID=$ptuuid"
|
||||
echo "lsblkout: $dev"
|
||||
if [[ -n $CACHED_LSBLK_OUTPUT ]]; then
|
||||
dev="$CACHED_LSBLK_OUTPUT"
|
||||
else
|
||||
dev="$(lsblk --all --path --pairs --output NAME,PTUUID,PARTUUID)" \
|
||||
|| die "Error while executing lsblk to find PTUUID=$ptuuid"
|
||||
fi
|
||||
dev="$(grep "ptuuid=\"$ptuuid\" partuuid=\"\"" <<< "${dev,,}")" \
|
||||
|| die "Could not find PTUUID=... in lsblk output"
|
||||
dev="${dev%'" ptuuid='*}"
|
||||
|
|
Loading…
Reference in New Issue