Openembedded Core Discussions
 help / color / mirror / Atom feed
* [PATCH 1/2] mkefidisk.sh: Fix redirection to 1
@ 2014-07-21 22:45 Darren Hart
  2014-07-21 22:45 ` [PATCH 2/2] mkefidisk.sh: Add signal handling Darren Hart
  0 siblings, 1 reply; 3+ messages in thread
From: Darren Hart @ 2014-07-21 22:45 UTC (permalink / raw)
  To: openembedded-core; +Cc: Darren Hart

The current script intends to redirect stderr to stdout, but instead
redirects to a file named 1. No doubt a regex replace error.

Replace all instances of 2>1 with 2>&1.

Signed-off-by: Darren Hart <dvhart@linux.intel.com>
---
 scripts/contrib/mkefidisk.sh | 38 +++++++++++++++++++-------------------
 1 file changed, 19 insertions(+), 19 deletions(-)

diff --git a/scripts/contrib/mkefidisk.sh b/scripts/contrib/mkefidisk.sh
index 7ec373e..44ab8d5 100755
--- a/scripts/contrib/mkefidisk.sh
+++ b/scripts/contrib/mkefidisk.sh
@@ -257,22 +257,22 @@ echo ""
 info "Partitioning installation media ($DEVICE)"
 
 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"
+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 $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 $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 $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 $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 $DEVICE mkpart primary $SWAP_START 100% >$OUT 2>&1 || die "Failed to create SWAP partition"
 
 if [ $DEBUG -eq 1 ]; then
 	parted $DEVICE print
@@ -291,34 +291,34 @@ unmount_device || die "Failed to unmount $DEVICE partitions"
 info "Formating partitions"
 debug "Formatting $BOOTFS as vfat"
 if [ ! "${DEVICE#/dev/loop}" = "${DEVICE}" ]; then
-	mkfs.vfat -I $BOOTFS -n "EFI" >$OUT 2>1 || die "Failed to format $BOOTFS"
+	mkfs.vfat -I $BOOTFS -n "EFI" >$OUT 2>&1 || die "Failed to format $BOOTFS"
 else
-	mkfs.vfat $BOOTFS -n "EFI" >$OUT 2>1 || die "Failed to format $BOOTFS"
+	mkfs.vfat $BOOTFS -n "EFI" >$OUT 2>&1 || die "Failed to format $BOOTFS"
 fi
 
 debug "Formatting $ROOTFS as ext3"
-mkfs.ext3 -F $ROOTFS -L "ROOT" >$OUT 2>1 || die "Failed to format $ROOTFS"
+mkfs.ext3 -F $ROOTFS -L "ROOT" >$OUT 2>&1 || die "Failed to format $ROOTFS"
 
 debug "Formatting swap partition ($SWAP)"
-mkswap $SWAP >$OUT 2>1 || die "Failed to prepare swap"
+mkswap $SWAP >$OUT 2>&1 || die "Failed to prepare swap"
 
 
 #
 # Installing to $DEVICE
 #
 debug "Mounting images and device in preparation for installation"
-mount -o loop $HDDIMG $HDDIMG_MNT >$OUT 2>1 || error "Failed to mount $HDDIMG"
-mount -o loop $HDDIMG_MNT/rootfs.img $HDDIMG_ROOTFS_MNT >$OUT 2>1 || error "Failed to mount rootfs.img"
-mount $ROOTFS $ROOTFS_MNT >$OUT 2>1 || error "Failed to mount $ROOTFS on $ROOTFS_MNT"
-mount $BOOTFS $BOOTFS_MNT >$OUT 2>1 || error "Failed to mount $BOOTFS on $BOOTFS_MNT"
+mount -o loop $HDDIMG $HDDIMG_MNT >$OUT 2>&1 || error "Failed to mount $HDDIMG"
+mount -o loop $HDDIMG_MNT/rootfs.img $HDDIMG_ROOTFS_MNT >$OUT 2>&1 || error "Failed to mount rootfs.img"
+mount $ROOTFS $ROOTFS_MNT >$OUT 2>&1 || error "Failed to mount $ROOTFS on $ROOTFS_MNT"
+mount $BOOTFS $BOOTFS_MNT >$OUT 2>&1 || error "Failed to mount $BOOTFS on $BOOTFS_MNT"
 
 info "Preparing boot partition"
 EFIDIR="$BOOTFS_MNT/EFI/BOOT"
-cp $HDDIMG_MNT/vmlinuz $BOOTFS_MNT >$OUT 2>1 || error "Failed to copy vmlinuz"
+cp $HDDIMG_MNT/vmlinuz $BOOTFS_MNT >$OUT 2>&1 || error "Failed to copy vmlinuz"
 # Copy the efi loader and configs (booti*.efi and grub.cfg if it exists)
-cp -r $HDDIMG_MNT/EFI $BOOTFS_MNT >$OUT 2>1 || error "Failed to copy EFI dir"
+cp -r $HDDIMG_MNT/EFI $BOOTFS_MNT >$OUT 2>&1 || error "Failed to copy EFI dir"
 # Silently ignore a missing gummiboot loader dir (we might just be a GRUB image)
-cp -r $HDDIMG_MNT/loader $BOOTFS_MNT >$OUT 2>1
+cp -r $HDDIMG_MNT/loader $BOOTFS_MNT >$OUT 2>&1
 
 # Update the boot loaders configurations for an installed image
 # Remove any existing root= kernel parameters and:
@@ -349,7 +349,7 @@ GUMMI_CFG="$GUMMI_ENTRIES/boot.conf"
 if [ -d "$GUMMI_ENTRIES" ]; then
 	info "Configuring Gummiboot"
 	# remove the install target if it exists
-	rm $GUMMI_ENTRIES/install.conf >$OUT 2>1
+	rm $GUMMI_ENTRIES/install.conf >$OUT 2>&1
 
 	if [ ! -e "$GUMMI_CFG" ]; then
 		echo "ERROR: $GUMMI_CFG not found"
@@ -366,7 +366,7 @@ fi
 
 
 info "Copying ROOTFS files (this may take a while)"
-cp -a $HDDIMG_ROOTFS_MNT/* $ROOTFS_MNT >$OUT 2>1 || die "Root FS copy failed"
+cp -a $HDDIMG_ROOTFS_MNT/* $ROOTFS_MNT >$OUT 2>&1 || die "Root FS copy failed"
 
 echo "$TARGET_SWAP     swap             swap       defaults              0 0" >> $ROOTFS_MNT/etc/fstab
 
-- 
2.0.0



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

* [PATCH 2/2] mkefidisk.sh: Add signal handling
  2014-07-21 22:45 [PATCH 1/2] mkefidisk.sh: Fix redirection to 1 Darren Hart
@ 2014-07-21 22:45 ` Darren Hart
  2014-07-21 23:01   ` Darren Hart
  0 siblings, 1 reply; 3+ messages in thread
From: Darren Hart @ 2014-07-21 22:45 UTC (permalink / raw)
  To: openembedded-core; +Cc: Darren Hart

Add basic signal handling to unmount and remove any temporary files.

Signed-off-by: Darren Hart <dvhart@linux.intel.com>
---
 scripts/contrib/mkefidisk.sh | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/scripts/contrib/mkefidisk.sh b/scripts/contrib/mkefidisk.sh
index 44ab8d5..7d48b53 100755
--- a/scripts/contrib/mkefidisk.sh
+++ b/scripts/contrib/mkefidisk.sh
@@ -46,7 +46,9 @@ cleanup() {
 	if [ -d "$TMPDIR" ]; then
 		rm -rf $TMPDIR || error "Failed to remove $TMPDIR"
 	fi
+	exit $1
 }
+trap cleanup HUP INT TERM
 
 # Logging routines
 WARNINGS=0
@@ -72,8 +74,7 @@ success() {
 }
 die() {
 	error $1
-	cleanup
-	exit 1
+	cleanup 1
 }
 debug() {
 	if [ $DEBUG -eq 1 ]; then
@@ -375,10 +376,6 @@ if [ -d $ROOTFS_MNT/etc/udev/ ] ; then
 	echo "$TARGET_DEVICE" >> $ROOTFS_MNT/etc/udev/mount.blacklist
 fi
 
-
-# Call cleanup to unmount devices and images and remove the TMPDIR
-cleanup
-
 echo ""
 if [ $WARNINGS -ne 0 ] && [ $ERRORS -eq 0 ]; then
 	echo "${YELLOW}Installation completed with warnings${CLEAR}"
@@ -391,3 +388,6 @@ else
 	success "Installation completed successfully"
 fi
 echo ""
+
+# Call cleanup to unmount devices and images and remove the TMPDIR
+cleanup 0
-- 
2.0.0



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

* Re: [PATCH 2/2] mkefidisk.sh: Add signal handling
  2014-07-21 22:45 ` [PATCH 2/2] mkefidisk.sh: Add signal handling Darren Hart
@ 2014-07-21 23:01   ` Darren Hart
  0 siblings, 0 replies; 3+ messages in thread
From: Darren Hart @ 2014-07-21 23:01 UTC (permalink / raw)
  To: Darren Hart, openembedded-core

Please ignore this one (2/2), it rearranges output in a way that might
lead to someone pulling the USB key before the sync completes. I will
resend 2/2 of separately.

Apologies :/

On 7/21/14, 15:45, "Darren Hart" <dvhart@linux.intel.com> wrote:

>Add basic signal handling to unmount and remove any temporary files.
>
>Signed-off-by: Darren Hart <dvhart@linux.intel.com>
>---
> scripts/contrib/mkefidisk.sh | 12 ++++++------
> 1 file changed, 6 insertions(+), 6 deletions(-)
>
>diff --git a/scripts/contrib/mkefidisk.sh b/scripts/contrib/mkefidisk.sh
>index 44ab8d5..7d48b53 100755
>--- a/scripts/contrib/mkefidisk.sh
>+++ b/scripts/contrib/mkefidisk.sh
>@@ -46,7 +46,9 @@ cleanup() {
> 	if [ -d "$TMPDIR" ]; then
> 		rm -rf $TMPDIR || error "Failed to remove $TMPDIR"
> 	fi
>+	exit $1
> }
>+trap cleanup HUP INT TERM
> 
> # Logging routines
> WARNINGS=0
>@@ -72,8 +74,7 @@ success() {
> }
> die() {
> 	error $1
>-	cleanup
>-	exit 1
>+	cleanup 1
> }
> debug() {
> 	if [ $DEBUG -eq 1 ]; then
>@@ -375,10 +376,6 @@ if [ -d $ROOTFS_MNT/etc/udev/ ] ; then
> 	echo "$TARGET_DEVICE" >> $ROOTFS_MNT/etc/udev/mount.blacklist
> fi
> 
>-
>-# Call cleanup to unmount devices and images and remove the TMPDIR
>-cleanup
>-
> echo ""
> if [ $WARNINGS -ne 0 ] && [ $ERRORS -eq 0 ]; then
> 	echo "${YELLOW}Installation completed with warnings${CLEAR}"
>@@ -391,3 +388,6 @@ else
> 	success "Installation completed successfully"
> fi
> echo ""
>+
>+# Call cleanup to unmount devices and images and remove the TMPDIR
>+cleanup 0
>-- 
>2.0.0
>
>


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





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

end of thread, other threads:[~2014-07-21 23:01 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-07-21 22:45 [PATCH 1/2] mkefidisk.sh: Fix redirection to 1 Darren Hart
2014-07-21 22:45 ` [PATCH 2/2] mkefidisk.sh: Add signal handling Darren Hart
2014-07-21 23:01   ` Darren Hart

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