make blkid optional

This commit is contained in:
illiliti 2020-07-15 22:23:12 +03:00
parent 8f3b68dd38
commit 888cf4d878
3 changed files with 19 additions and 12 deletions

View File

@ -11,7 +11,7 @@ Features
- Easy to use configuration - Easy to use configuration
- Build time and init time hooks - Build time and init time hooks
- LUKS (detached header, key), LVM - LUKS (detached header, key), LVM
- mdev, mdevd, eudev - mdev, mdevd, eudev, systemd-udevd
Dependencies Dependencies
------------ ------------
@ -20,10 +20,11 @@ Dependencies
* POSIX shell * POSIX shell
* `switch_root` * `switch_root`
* `mount` * `mount`
* `blkid`
* `cpio` * `cpio`
* POSIX SD `strip` * `strip`
- Optional - Optional
* `blkid`
- Required for UUID, LABEL, PARTUUID support
* `mdev` OR `mdevd` OR `eudev` OR `systemd-udevd` * `mdev` OR `mdevd` OR `eudev` OR `systemd-udevd`
- systemd-udevd not tested - systemd-udevd not tested
* `lvm2` * `lvm2`

View File

@ -18,6 +18,13 @@ create_symlink()
{ {
[ -b "/dev/${dev_name=${DEVPATH##*/}}" ] || exit 1 [ -b "/dev/${dev_name=${DEVPATH##*/}}" ] || exit 1
read -r dm_name < "/sys/block/${dev_name}/dm/name" && {
mkdir -p /dev/mapper
ln -sf "../${dev_name}" "/dev/mapper/${dm_name:?}"
}
command -v blkid || exit 0
# prevent race condition # prevent race condition
blkid "/dev/${dev_name}" || sleep 2 blkid "/dev/${dev_name}" || sleep 2
@ -26,9 +33,4 @@ create_symlink()
LABEL) create_symlink /dev/disk/by-label "${line##*=}" ;; LABEL) create_symlink /dev/disk/by-label "${line##*=}" ;;
PARTUUID) create_symlink /dev/disk/by-partuuid "${line##*=}" ;; PARTUUID) create_symlink /dev/disk/by-partuuid "${line##*=}" ;;
esac; done esac; done
read -r dm_name < "/sys/block/${dev_name}/dm/name" && {
mkdir -p /dev/mapper
ln -sf "../${dev_name}" "/dev/mapper/${dm_name:?}"
}
} > /dev/null 2>&1 } > /dev/null 2>&1

View File

@ -126,16 +126,20 @@ prepare_initramfs()
ln -s ../run/lock "${tmpdir}/var/lock" ln -s ../run/lock "${tmpdir}/var/lock"
ln -s bin "${tmpdir}/usr/sbin" ln -s bin "${tmpdir}/usr/sbin"
# TODO make blkid optional
# copy required binaries # copy required binaries
for _binary in \ for _binary in \
\[ sh ln env kill mkdir \ \[ sh ln env kill mkdir sleep mount \
blkid sleep mount printf \ printf switch_root "${srcdir}/device-helper"
switch_root "${srcdir}/device-helper"
do do
copy_binary "$_binary" copy_binary "$_binary"
done done
if command -v blkid; then
copy_binary blkid
else
print "blkid not found. you will unable to use UUID, LABEL, PARTUUID"
fi
# copy init # copy init
cp "${srcdir}/init" "${tmpdir}/init" cp "${srcdir}/init" "${tmpdir}/init"
chmod 755 "${tmpdir}/init" chmod 755 "${tmpdir}/init"