* [PATCH 0/3] A few minor usability fixes for mkefidisk.sh
@ 2015-04-21 13:01 Paul Eggleton
2015-04-21 13:01 ` [PATCH 1/3] mkefidisk.sh: use script mode when running parted Paul Eggleton
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: Paul Eggleton @ 2015-04-21 13:01 UTC (permalink / raw)
To: openembedded-core; +Cc: Darren Hart
The following changes since commit 166f2587468ae71988c610858aad3f7ef67eccba:
bison: don't depend on help2man (2015-04-21 11:29:30 +0100)
are available in the git repository at:
git://git.openembedded.org/openembedded-core-contrib paule/mkefidisk
http://cgit.openembedded.org/cgit.cgi/openembedded-core-contrib/log/?h=paule/mkefidisk
Paul Eggleton (3):
mkefidisk.sh: use script mode when running parted
mkefidisk.sh: fix hanging on non-writeable device
mkefidisk.sh: be more explicit with device error
scripts/contrib/mkefidisk.sh | 27 +++++++++++++++++----------
1 file changed, 17 insertions(+), 10 deletions(-)
--
2.1.0
^ permalink raw reply [flat|nested] 4+ messages in thread
* [PATCH 1/3] mkefidisk.sh: use script mode when running parted
2015-04-21 13:01 [PATCH 0/3] A few minor usability fixes for mkefidisk.sh Paul Eggleton
@ 2015-04-21 13:01 ` Paul Eggleton
2015-04-21 13:01 ` [PATCH 2/3] mkefidisk.sh: fix hanging on non-writeable device Paul Eggleton
2015-04-21 13:01 ` [PATCH 3/3] mkefidisk.sh: be more explicit with device error Paul Eggleton
2 siblings, 0 replies; 4+ messages in thread
From: Paul Eggleton @ 2015-04-21 13:01 UTC (permalink / raw)
To: openembedded-core; +Cc: Darren Hart
This avoids parted showing prompts and thus effectively hanging the
script in in the case of initially malformed disks.
Signed-off-by: Paul Eggleton <paul.eggleton@linux.intel.com>
---
scripts/contrib/mkefidisk.sh | 18 +++++++++---------
1 file changed, 9 insertions(+), 9 deletions(-)
diff --git a/scripts/contrib/mkefidisk.sh b/scripts/contrib/mkefidisk.sh
index b96b7d4..74cf40d 100755
--- a/scripts/contrib/mkefidisk.sh
+++ b/scripts/contrib/mkefidisk.sh
@@ -218,11 +218,11 @@ mkdir $BOOTFS_MNT || die "Failed to create $BOOTFS_MNT"
#
# Partition $DEVICE
#
-DEVICE_SIZE=$(parted $DEVICE unit mb print | grep ^Disk | cut -d" " -f 3 | sed -e "s/MB//")
+DEVICE_SIZE=$(parted -s $DEVICE unit mb print | grep ^Disk | cut -d" " -f 3 | sed -e "s/MB//")
# If the device size is not reported there may not be a valid label
if [ "$DEVICE_SIZE" = "" ] ; then
- parted $DEVICE mklabel msdos || die "Failed to create MSDOS partition table"
- DEVICE_SIZE=$(parted $DEVICE unit mb print | grep ^Disk | cut -d" " -f 3 | sed -e "s/MB//")
+ parted -s $DEVICE mklabel msdos || die "Failed to create MSDOS partition table"
+ DEVICE_SIZE=$(parted -s $DEVICE unit mb print | grep ^Disk | cut -d" " -f 3 | sed -e "s/MB//")
fi
SWAP_SIZE=$((DEVICE_SIZE*SWAP_RATIO/100))
ROOTFS_SIZE=$((DEVICE_SIZE-BOOT_SIZE-SWAP_SIZE))
@@ -262,22 +262,22 @@ debug "Deleting partition table on $DEVICE"
dd if=/dev/zero of=$DEVICE bs=512 count=2 >$OUT 2>&1 || die "Failed to zero beginning of $DEVICE"
debug "Creating new partition table (MSDOS) on $DEVICE"
-parted $DEVICE mklabel msdos >$OUT 2>&1 || die "Failed to create MSDOS partition table"
+parted -s $DEVICE mklabel msdos >$OUT 2>&1 || die "Failed to create MSDOS partition table"
debug "Creating boot partition on $BOOTFS"
-parted $DEVICE mkpart primary 0% $BOOT_SIZE >$OUT 2>&1 || die "Failed to create BOOT partition"
+parted -s $DEVICE mkpart primary 0% $BOOT_SIZE >$OUT 2>&1 || die "Failed to create BOOT partition"
debug "Enabling boot flag on $BOOTFS"
-parted $DEVICE set 1 boot on >$OUT 2>&1 || die "Failed to enable boot flag"
+parted -s $DEVICE set 1 boot on >$OUT 2>&1 || die "Failed to enable boot flag"
debug "Creating ROOTFS partition on $ROOTFS"
-parted $DEVICE mkpart primary $ROOTFS_START $ROOTFS_END >$OUT 2>&1 || die "Failed to create ROOTFS partition"
+parted -s $DEVICE mkpart primary $ROOTFS_START $ROOTFS_END >$OUT 2>&1 || die "Failed to create ROOTFS partition"
debug "Creating swap partition on $SWAP"
-parted $DEVICE mkpart primary $SWAP_START 100% >$OUT 2>&1 || die "Failed to create SWAP partition"
+parted -s $DEVICE mkpart primary $SWAP_START 100% >$OUT 2>&1 || die "Failed to create SWAP partition"
if [ $DEBUG -eq 1 ]; then
- parted $DEVICE print
+ parted -s $DEVICE print
fi
--
2.1.0
^ permalink raw reply related [flat|nested] 4+ messages in thread
* [PATCH 2/3] mkefidisk.sh: fix hanging on non-writeable device
2015-04-21 13:01 [PATCH 0/3] A few minor usability fixes for mkefidisk.sh Paul Eggleton
2015-04-21 13:01 ` [PATCH 1/3] mkefidisk.sh: use script mode when running parted Paul Eggleton
@ 2015-04-21 13:01 ` Paul Eggleton
2015-04-21 13:01 ` [PATCH 3/3] mkefidisk.sh: be more explicit with device error Paul Eggleton
2 siblings, 0 replies; 4+ messages in thread
From: Paul Eggleton @ 2015-04-21 13:01 UTC (permalink / raw)
To: openembedded-core; +Cc: Darren Hart
If cleanup() is called early on, as happens when the device isn't
writeable, then none of the mount point variables are set; thus the
script was calling grep with only one argument and appeared to hang
since it was waiting for input on stdin.
Signed-off-by: Paul Eggleton <paul.eggleton@linux.intel.com>
---
scripts/contrib/mkefidisk.sh | 3 +++
1 file changed, 3 insertions(+)
diff --git a/scripts/contrib/mkefidisk.sh b/scripts/contrib/mkefidisk.sh
index 74cf40d..d6bc965 100755
--- a/scripts/contrib/mkefidisk.sh
+++ b/scripts/contrib/mkefidisk.sh
@@ -136,6 +136,9 @@ unmount_device() {
}
unmount() {
+ if [ "$1" = "" ] ; then
+ return 0
+ fi
grep -q $1 /proc/mounts
if [ $? -eq 0 ]; then
debug "Unmounting $1"
--
2.1.0
^ permalink raw reply related [flat|nested] 4+ messages in thread
* [PATCH 3/3] mkefidisk.sh: be more explicit with device error
2015-04-21 13:01 [PATCH 0/3] A few minor usability fixes for mkefidisk.sh Paul Eggleton
2015-04-21 13:01 ` [PATCH 1/3] mkefidisk.sh: use script mode when running parted Paul Eggleton
2015-04-21 13:01 ` [PATCH 2/3] mkefidisk.sh: fix hanging on non-writeable device Paul Eggleton
@ 2015-04-21 13:01 ` Paul Eggleton
2 siblings, 0 replies; 4+ messages in thread
From: Paul Eggleton @ 2015-04-21 13:01 UTC (permalink / raw)
To: openembedded-core; +Cc: Darren Hart
* Specify whether the device can't be found or can't be written to
* Give a hint to use sudo
Signed-off-by: Paul Eggleton <paul.eggleton@linux.intel.com>
---
scripts/contrib/mkefidisk.sh | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/scripts/contrib/mkefidisk.sh b/scripts/contrib/mkefidisk.sh
index d6bc965..55f72b0 100755
--- a/scripts/contrib/mkefidisk.sh
+++ b/scripts/contrib/mkefidisk.sh
@@ -173,7 +173,11 @@ fi
if [ ! -w "$DEVICE" ]; then
usage
- die "Device $DEVICE does not exist or is not writable"
+ if [ ! -e "${DEVICE}" ] ; then
+ die "Device $DEVICE cannot be found"
+ else
+ die "Device $DEVICE is not writable (need to run under sudo?)"
+ fi
fi
if [ ! -e "$HDDIMG" ]; then
--
2.1.0
^ permalink raw reply related [flat|nested] 4+ messages in thread
end of thread, other threads:[~2015-04-21 13:02 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-04-21 13:01 [PATCH 0/3] A few minor usability fixes for mkefidisk.sh Paul Eggleton
2015-04-21 13:01 ` [PATCH 1/3] mkefidisk.sh: use script mode when running parted Paul Eggleton
2015-04-21 13:01 ` [PATCH 2/3] mkefidisk.sh: fix hanging on non-writeable device Paul Eggleton
2015-04-21 13:01 ` [PATCH 3/3] mkefidisk.sh: be more explicit with device error Paul Eggleton
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.