summaryrefslogtreecommitdiffstats
path: root/scripts/contrib
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/contrib
parentf3d62a9eb9c47356e6150fdd55f790c159e620c7 (diff)
downloadpoky-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/contrib')
-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 @@
1#!/bin/sh 1#!/bin/sh
2 2
3#BLACKLIST_DEVICES="/dev/sda /dev/sdb /dev/sdc /dev/sdd /dev/sde" 3# Default to avoiding the first two disks on typical Linux and Mac OS installs
4BLACKLIST_DEVICES="/dev/sda" 4# Better safe than sorry :-)
5BLACKLIST_DEVICES="/dev/sda /dev/sdb /dev/disk1 /dev/disk2"
5 6
6# 1MB blocksize 7# 1MB blocksize
7BLOCKSIZE=1048576 8BLOCKSIZE=1048576
@@ -14,9 +15,15 @@ image_details() {
14 IMG=$1 15 IMG=$1
15 echo "Image details" 16 echo "Image details"
16 echo "=============" 17 echo "============="
17 echo " image: $(stat --printf '%N\n' $IMG)" 18 echo " image: $(basename $IMG)"
18 echo " size: $(stat -L --printf '%s bytes\n' $IMG)" 19 # stat format is different on Mac OS and Linux
19 echo " modified: $(stat -L --printf '%y\n' $IMG)" 20 if [ "$(uname)" = "Darwin" ]; then
21 echo " size: $(stat -L -f '%z bytes' $IMG)"
22 echo " modified: $(stat -L -f '%Sm' $IMG)"
23 else
24 echo " size: $(stat -L -c '%s bytes' $IMG)"
25 echo " modified: $(stat -L -c '%y' $IMG)"
26 fi
20 echo " type: $(file -L -b $IMG)" 27 echo " type: $(file -L -b $IMG)"
21 echo "" 28 echo ""
22} 29}
@@ -27,6 +34,14 @@ device_details() {
27 34
28 echo "Device details" 35 echo "Device details"
29 echo "==============" 36 echo "=============="
37
38 # Collect disk info using diskutil on Mac OS
39 if [ "$(uname)" = "Darwin" ]; then
40 diskutil info $DEVICE | egrep "(Device Node|Media Name|Total Size)"
41 return
42 fi
43
44 # Default / Linux information collection
30 echo " device: $DEVICE" 45 echo " device: $DEVICE"
31 if [ -f "/sys/class/block/$DEV/device/vendor" ]; then 46 if [ -f "/sys/class/block/$DEV/device/vendor" ]; then
32 echo " vendor: $(cat /sys/class/block/$DEV/device/vendor)" 47 echo " vendor: $(cat /sys/class/block/$DEV/device/vendor)"