
This adds SPDX license headers in place of the wide assortment of things currently in our script headers. We default to GPL-2.0-only except for the oeqa code where it was clearly submitted and marked as MIT on the most part or some scripts which had the "or later" GPL versioning. The patch also drops other obsolete bits of file headers where they were encoountered such as editor modelines, obsolete maintainer information or the phrase "All rights reserved" which is now obsolete and not required in copyright headers (in this case its actually confusing for licensing as all rights were not reserved). More work is needed for OE-Core but this takes care of the bulk of the scripts and meta/lib directories. The top level LICENSE files are tweaked to match the new structure and the SPDX naming. (From OE-Core rev: f8c9c511b5f1b7dbd45b77f345cb6c048ae6763e) Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2.2 KiB
Executable File
#!/bin/sh
SPDX-License-Identifier: GPL-2.0-only
Default to avoiding the first two disks on typical Linux and Mac OS installs
Better safe than sorry :-)
BLACKLIST_DEVICES="/dev/sda /dev/sdb /dev/disk1 /dev/disk2"
1MB blocksize
BLOCKSIZE=1048576
usage() { echo "Usage: $(basename $0) IMAGE DEVICE" }
image_details() { IMG=$1 echo "Image details" echo "=============" echo " image: $(basename $IMG)" # stat format is different on Mac OS and Linux if [ "$(uname)" = "Darwin" ]; then echo " size: $(stat -L -f '%z bytes' $IMG)" echo " modified: $(stat -L -f '%Sm' $IMG)" else echo " size: $(stat -L -c '%s bytes' $IMG)" echo " modified: $(stat -L -c '%y' $IMG)" fi echo " type: $(file -L -b $IMG)" echo "" }
device_details() { DEV=$1 BLOCK_SIZE=512
echo "Device details"
echo "=============="
# Collect disk info using diskutil on Mac OS
if [ "$(uname)" = "Darwin" ]; then
diskutil info $DEVICE | egrep "(Device Node|Media Name|Total Size)"
return
fi
# Default / Linux information collection
echo " device: $DEVICE"
if [ -f "/sys/class/block/$DEV/device/vendor" ]; then
echo " vendor: $(cat /sys/class/block/$DEV/device/vendor)"
else
echo " vendor: UNKOWN"
fi
if [ -f "/sys/class/block/$DEV/device/model" ]; then
echo " model: $(cat /sys/class/block/$DEV/device/model)"
else
echo " model: UNKNOWN"
fi
if [ -f "/sys/class/block/$DEV/size" ]; then
echo " size: $(($(cat /sys/class/block/$DEV/size) * $BLOCK_SIZE)) bytes"
else
echo " size: UNKNOWN"
fi
echo ""
}
if [ $# -ne 2 ]; then usage exit 1 fi
IMAGE=$1 DEVICE=$2
if [ ! -e "$IMAGE" ]; then echo "ERROR: Image $IMAGE does not exist" usage exit 1 fi
for i in ${BLACKLIST_DEVICES}; do if [ "$i" = "$DEVICE" ]; then echo "ERROR: Device $DEVICE is blacklisted" exit 1 fi done
if [ ! -w "$DEVICE" ]; then echo "ERROR: Device $DEVICE does not exist or is not writable" usage exit 1 fi
image_details $IMAGE device_details $(basename $DEVICE)
printf "Write $IMAGE to $DEVICE [y/N]? " read RESPONSE if [ "$RESPONSE" != "y" ]; then echo "Write aborted" exit 0 fi
echo "Writing image..." if which pv >/dev/null 2>&1; then pv "$IMAGE" | dd of="$DEVICE" bs="$BLOCKSIZE" else dd if="$IMAGE" of="$DEVICE" bs="$BLOCKSIZE" fi sync