Openembedded Core Discussions
 help / color / mirror / Atom feed
* [PATCH 0/1] ddimage: Support Mac OS
@ 2014-05-23  4:28 Darren Hart
  2014-05-23  4:28 ` [PATCH 1/1] " Darren Hart
  0 siblings, 1 reply; 4+ messages in thread
From: Darren Hart @ 2014-05-23  4:28 UTC (permalink / raw)
  To: openembedded-core

Darren Hart (1):
  ddimage: Support Mac OS

 scripts/contrib/ddimage | 25 ++++++++++++++++++++-----
 1 file changed, 20 insertions(+), 5 deletions(-)

-- 
1.9.1



^ permalink raw reply	[flat|nested] 4+ messages in thread

* [PATCH 1/1] ddimage: Support Mac OS
  2014-05-23  4:28 [PATCH 0/1] ddimage: Support Mac OS Darren Hart
@ 2014-05-23  4:28 ` Darren Hart
  2014-05-24 14:44   ` Koen Kooi
  0 siblings, 1 reply; 4+ messages in thread
From: Darren Hart @ 2014-05-23  4:28 UTC (permalink / raw)
  To: openembedded-core

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.

Signed-off-by: Darren Hart <dvhart@linux.intel.com>
---
 scripts/contrib/ddimage | 25 ++++++++++++++++++++-----
 1 file changed, 20 insertions(+), 5 deletions(-)

diff --git a/scripts/contrib/ddimage b/scripts/contrib/ddimage
index 93ebeaf..b66d0dd 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/disk3"
 
 # 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)"
-- 
1.9.1



^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH 1/1] ddimage: Support Mac OS
  2014-05-23  4:28 ` [PATCH 1/1] " Darren Hart
@ 2014-05-24 14:44   ` Koen Kooi
  2014-05-27 15:15     ` Darren Hart
  0 siblings, 1 reply; 4+ messages in thread
From: Koen Kooi @ 2014-05-24 14:44 UTC (permalink / raw)
  To: Darren Hart; +Cc: openembedded-core


Op 23 mei 2014, om 06:28 heeft Darren Hart <dvhart@linux.intel.com> het volgende geschreven:

> 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.
> 
> Signed-off-by: Darren Hart <dvhart@linux.intel.com>
> ---
> scripts/contrib/ddimage | 25 ++++++++++++++++++++-----
> 1 file changed, 20 insertions(+), 5 deletions(-)
> 
> diff --git a/scripts/contrib/ddimage b/scripts/contrib/ddimage
> index 93ebeaf..b66d0dd 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/disk3"

s/disk3/disk2/



^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH 1/1] ddimage: Support Mac OS
  2014-05-24 14:44   ` Koen Kooi
@ 2014-05-27 15:15     ` Darren Hart
  0 siblings, 0 replies; 4+ messages in thread
From: Darren Hart @ 2014-05-27 15:15 UTC (permalink / raw)
  To: Koen Kooi; +Cc: openembedded-core

On 5/24/14, 7:44, "Koen Kooi" <koen@dominion.thruhere.net> wrote:

>
>Op 23 mei 2014, om 06:28 heeft Darren Hart <dvhart@linux.intel.com> het
>volgende geschreven:
>
>> 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.
>> 
>> Signed-off-by: Darren Hart <dvhart@linux.intel.com>
>> ---
>> scripts/contrib/ddimage | 25 ++++++++++++++++++++-----
>> 1 file changed, 20 insertions(+), 5 deletions(-)
>> 
>> diff --git a/scripts/contrib/ddimage b/scripts/contrib/ddimage
>> index 93ebeaf..b66d0dd 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/disk3"
>
>s/disk3/disk2/

Bah, indeed. Local change snuck through in my patch. Thanks. Will correct.


-- 
Darren Hart					Open Source Technology Center
darren.hart@intel.com				            Intel Corporation





^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2014-05-27 15:14 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-05-23  4:28 [PATCH 0/1] ddimage: Support Mac OS Darren Hart
2014-05-23  4:28 ` [PATCH 1/1] " Darren Hart
2014-05-24 14:44   ` Koen Kooi
2014-05-27 15:15     ` Darren Hart

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox