aboutsummaryrefslogtreecommitdiffstats
path: root/scripts
diff options
context:
space:
mode:
authorDarren Hart <dvhart@linux.intel.com>2014-05-27 12:47:45 -0700
committerRichard Purdie <richard.purdie@linuxfoundation.org>2014-05-28 08:19:30 +0100
commit19c6c2e191b077a2411b53c3ee89de4f414f0326 (patch)
tree1859ec2290cafc01c9511637ffb178979e52a22d /scripts
parentf3d62a9eb9c47356e6150fdd55f790c159e620c7 (diff)
downloadopenembedded-core-contrib-19c6c2e191b077a2411b53c3ee89de4f414f0326.tar.gz
ddimage: Support Mac OS
Update the ddimage script to allow it to work on Mac OS too. The biggest difference is sysfs vs diskutil and in the syntax of the stat command between Mac OS and Linux, unfortunately. Workarounds using ls, cut, and columns got really fragile really quickly. Relying on stat and switching on uname seemed the more robust solution. (From OE-Core rev: 8962fe11a0697348affb8a1ab95abca4995470a6) Signed-off-by: Darren Hart <dvhart@linux.intel.com> Cc: Koen Kooi <koen@dominion.thruhere.net> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'scripts')
-rwxr-xr-xscripts/contrib/ddimage25
1 files changed, 20 insertions, 5 deletions
diff --git a/scripts/contrib/ddimage b/scripts/contrib/ddimage
index 93ebeafc31..a503f11d0d 100755
--- a/scripts/contrib/ddimage
+++ b/scripts/contrib/ddimage
@@ -1,7 +1,8 @@
#!/bin/sh
-#BLACKLIST_DEVICES="/dev/sda /dev/sdb /dev/sdc /dev/sdd /dev/sde"
-BLACKLIST_DEVICES="/dev/sda"
+# 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
@@ -14,9 +15,15 @@ image_details() {
IMG=$1
echo "Image details"
echo "============="
- echo " image: $(stat --printf '%N\n' $IMG)"
- echo " size: $(stat -L --printf '%s bytes\n' $IMG)"
- echo " modified: $(stat -L --printf '%y\n' $IMG)"
+ 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 ""
}
@@ -27,6 +34,14 @@ device_details() {
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)"