#!/usr/bin/env bash # -*- coding: utf-8 -*- # region imports source '/usr/lib/rebash/core.sh' core.import logging core.import utils core.import exceptions exceptions.activate # endregion logging.set_level info logging.set_commands_level info # NOTE: All output has to be forwarded to standard error because determined # device should be printed on standard output. in_device="$1" mkdir --parents /mnt/xmount loop_device="$(losetup --find)" if ! utils.dependency_check xmount; then logging.warn "\"xmount\" not found, assuming raw image." 1>&2 elif systemd-preserve-process-marker xmount --in qemu "$in_device" --out raw \ /mnt/xmount &>/dev/null then in_device="/mnt/xmount/*.dd" else logging.warn "\"xmount\" call failed, assuming raw image." 1>&2 fi losetup "$loop_device" $in_device --partscan udevadm settle echo "$loop_device" # region vim modline # vim: set tabstop=4 shiftwidth=4 expandtab: # vim: foldmethod=marker foldmarker=region,endregion: # endregion