Files
build/lib/functions/image/loop.sh
Ash 408bc67619 Add shebangs for shellcheck (#4493)
* Add shebangs for shellcheck

See #AR-1406

* Add shebangs for shellcheck

Also for `extensions` scripts
2022-11-27 21:44:50 +01:00

41 lines
1.1 KiB
Bash

#!/usr/bin/env bash
# check_loop_device <device_node>
#
check_loop_device() {
local device=$1
if [[ ! -b $device ]]; then
if [[ $CONTAINER_COMPAT == yes && -b /tmp/$device ]]; then
display_alert "Creating device node" "$device"
mknod -m0660 "${device}" b "0x$(stat -c '%t' "/tmp/$device")" "0x$(stat -c '%T' "/tmp/$device")"
else
exit_with_error "Device node $device does not exist"
fi
fi
}
# write_uboot <loopdev>
#
write_uboot() {
local loop=$1 revision
display_alert "Writing U-boot bootloader" "$loop" "info"
TEMP_DIR=$(mktemp -d || exit 1)
chmod 700 ${TEMP_DIR}
revision=${REVISION}
if [[ -n $UPSTREM_VER ]]; then
revision=${UPSTREM_VER}
dpkg -x "${DEB_STORAGE}/linux-u-boot-${BOARD}-${BRANCH}_${revision}_${ARCH}.deb" ${TEMP_DIR}/
else
dpkg -x "${DEB_STORAGE}/${CHOSEN_UBOOT}_${revision}_${ARCH}.deb" ${TEMP_DIR}/
fi
# source platform install to read $DIR
source ${TEMP_DIR}/usr/lib/u-boot/platform_install.sh
write_uboot_platform "${TEMP_DIR}${DIR}" "$loop"
[[ $? -ne 0 ]] && exit_with_error "U-boot bootloader failed to install" "@host"
rm -rf ${TEMP_DIR}
}