Skip to content
Snippets Groups Projects
Verified Commit 4627022f authored by nl6720's avatar nl6720
Browse files

hooks/archiso: implement searching for archisodevice

If `archisosearchuuid` is specified, assign `archisodevice`:
* to a device with `UUID=${archisosearchuuid}`, if it exists,
* to a device containing `archisosearchfilename` (`/boot/${archisosearchuuid}.uuid` by default).

This avoids having to specify `archisodevice`.

Related to archlinux/archiso#217
parent a71b29d7
No related branches found
No related tags found
1 merge request!48hooks/archiso: implement searching for archisodevice
......@@ -8,6 +8,11 @@ Changelog
Added
-----
- Implement searching for the archiso device using ``archisosearchuuid`` and ``archisosearchfilename``
(defaults to ``/boot/${archisosearchuuid}.uuid``) boot parameters. If a device with UUID matching
``archisosearchuuid`` does not exist, then all available block devices are mounted and searched for the
``archisosearchfilename`` file.
Changed
-------
......
......@@ -23,6 +23,14 @@ INDEX
Default: "/dev/disk/by-label/${archisolabel}"
* archisobasedir= Set the base directory where all files reside.
Default: "arch"
* archisosearchuuid= UUID used in searching for a device where archiso
files reside. If a device with such UUID does not
exist, looks for ${archisosearchfilename} in all
available devices.
Overrides ${archisodevice}.
Default: (unset)
* archisosearchfilename= File path which confirms a device is an archiso medium.
Default: "/boot/${archisosearchuuid}.uuid"
* copytoram= If set to "y", the root file system image is copied to
tmpfs.
If set to "auto", the root file system image is copied to
......
......@@ -121,6 +121,37 @@ _mnt_dev() {
fi
}
_search_for_archisodevice() {
local search_dev
# First try searching for a UUID matching $archisosearchuuid
if archisodevice="$(rootdelay="${rootdelay:-2}" resolve_device "UUID=${archisosearchuuid}")"; then
return 0
fi
install -dm755 /archisosearch
# Search for $archisosearchfilename in all available block devices
for search_dev in $(blkid -o device); do
msg ":: Searching for '${archisosearchfilename}' in '${search_dev}'"
umount /archisosearch 2>/dev/null
if mount -r "$search_dev" /archisosearch 2>/dev/null; then
if [ -e "/archisosearch${archisosearchfilename}" ]; then
archisodevice="$search_dev"
break
fi
fi
done
umount /archisosearch 2>/dev/null
rmdir /archisosearch
if [ -b "$archisodevice" ]; then
return 0
else
msg "ERROR: Device '${archisosearchuuid}' not found"
launch_interactive_shell
fi
}
_verify_checksum() {
local _status
cd "/run/archiso/bootmnt/${archisobasedir}/${arch}" || exit 1
......@@ -184,6 +215,7 @@ run_hook() {
# defined via initcpio's parse_cmdline()
[ -z "${archisodevice}" ] && archisodevice="/dev/disk/by-label/${archisolabel}"
[ -z "${cow_spacesize}" ] && cow_spacesize="256M"
[ -z "${archisosearchfilename}" ] && archisosearchfilename="/boot/${archisosearchuuid}.uuid"
# shellcheck disable=SC2154
# defined via initcpio's parse_cmdline()
if [ -n "${cow_label}" ]; then
......@@ -210,6 +242,10 @@ archiso_mount_handler() {
local newroot="${1}"
local sigfile cms_sigfile fs_img fs_img_size iso_blockdev
if [ -n "$archisosearchuuid" ]; then
_search_for_archisodevice
fi
if ! mountpoint -q "/run/archiso/bootmnt"; then
_mnt_dev "${archisodevice}" "/run/archiso/bootmnt" "-r" "defaults"
fi
......
......@@ -14,6 +14,7 @@ build() {
add_binary dmsetup
add_binary losetup
add_binary openssl
add_binary blkid
if command -v pv >/dev/null 2>&1; then
add_binary pv
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment