From: Ed Bartosh <ed.bartosh@linux.intel.com>
To: openembedded-core@lists.openembedded.org
Subject: [PATCH 10/10] init-install: code cleanup: replace /dev/$device -> $device
Date: Mon, 15 Jun 2015 19:10:47 +0300 [thread overview]
Message-ID: <1434384647-2901-11-git-send-email-ed.bartosh@linux.intel.com> (raw)
In-Reply-To: <1434384647-2901-1-git-send-email-ed.bartosh@linux.intel.com>
Shortened code by including /dev/ prefix into variable.
Signed-off-by: Ed Bartosh <ed.bartosh@linux.intel.com>
diff --git a/meta/recipes-core/initrdscripts/files/init-install-efi.sh b/meta/recipes-core/initrdscripts/files/init-install-efi.sh
index dca1432..74372b0 100644
--- a/meta/recipes-core/initrdscripts/files/init-install-efi.sh
+++ b/meta/recipes-core/initrdscripts/files/init-install-efi.sh
@@ -83,7 +83,7 @@ else
exit 1
fi
-device=$TARGET_DEVICE_NAME
+device=/dev/$TARGET_DEVICE_NAME
#
# The udev automounter can cause pain here, kill it
@@ -94,12 +94,12 @@ rm -f /etc/udev/scripts/mount*
#
# Unmount anything the automounter had mounted
#
-umount /dev/${device}* 2> /dev/null || /bin/true
+umount ${device}* 2> /dev/null || /bin/true
mkdir -p /tmp
cat /proc/mounts > /etc/mtab
-disk_size=$(parted /dev/${device} unit mb print | grep Disk | cut -d" " -f 3 | sed -e "s/MB//")
+disk_size=$(parted ${device} unit mb print | grep Disk | cut -d" " -f 3 | sed -e "s/MB//")
swap_size=$((disk_size*swap_ratio/100))
rootfs_size=$((disk_size-boot_size-swap_size))
@@ -117,32 +117,32 @@ if [ ! "${device#mmcblk}" = "${device}" ]; then
part_prefix="p"
rootwait="rootwait"
fi
-bootfs=/dev/${device}${part_prefix}1
-rootfs=/dev/${device}${part_prefix}2
-swap=/dev/${device}${part_prefix}3
+bootfs=${device}${part_prefix}1
+rootfs=${device}${part_prefix}2
+swap=${device}${part_prefix}3
echo "*****************"
echo "Boot partition size: $boot_size MB ($bootfs)"
echo "Rootfs partition size: $rootfs_size MB ($rootfs)"
echo "Swap partition size: $swap_size MB ($swap)"
echo "*****************"
-echo "Deleting partition table on /dev/${device} ..."
-dd if=/dev/zero of=/dev/${device} bs=512 count=2
+echo "Deleting partition table on ${device} ..."
+dd if=/dev/zero of=${device} bs=512 count=2
-echo "Creating new partition table on /dev/${device} ..."
-parted /dev/${device} mklabel gpt
+echo "Creating new partition table on ${device} ..."
+parted ${device} mklabel gpt
echo "Creating boot partition on $bootfs"
-parted /dev/${device} mkpart boot fat32 0% $boot_size
-parted /dev/${device} set 1 boot on
+parted ${device} mkpart boot fat32 0% $boot_size
+parted ${device} set 1 boot on
echo "Creating rootfs partition on $rootfs"
-parted /dev/${device} mkpart root ext3 $rootfs_start $rootfs_end
+parted ${device} mkpart root ext3 $rootfs_start $rootfs_end
echo "Creating swap partition on $swap"
-parted /dev/${device} mkpart swap linux-swap $swap_start 100%
+parted ${device} mkpart swap linux-swap $swap_start 100%
-parted /dev/${device} print
+parted ${device} print
echo "Formatting $bootfs to vfat..."
mkfs.vfat $bootfs
@@ -163,13 +163,13 @@ mount -o rw,loop,noatime,nodiratime /run/media/$1/$2 /src_root
echo "Copying rootfs files..."
cp -a /src_root/* /tgt_root
if [ -d /tgt_root/etc/ ] ; then
- boot_uuid=$(blkid -o value -s UUID /dev/${device}1)
- swap_part_uuid=$(blkid -o value -s PARTUUID /dev/${device}3)
+ boot_uuid=$(blkid -o value -s UUID ${device}1)
+ swap_part_uuid=$(blkid -o value -s PARTUUID ${device}3)
echo "/dev/disk/by-partuuid/$swap_part_uuid swap swap defaults 0 0" >> /tgt_root/etc/fstab
echo "UUID=$boot_uuid /boot vfat defaults 1 2" >> /tgt_root/etc/fstab
# We dont want udev to mount our root device while we're booting...
if [ -d /tgt_root/etc/udev/ ] ; then
- echo "/dev/${device}" >> /tgt_root/etc/udev/mount.blacklist
+ echo "${device}" >> /tgt_root/etc/udev/mount.blacklist
fi
fi
@@ -185,7 +185,7 @@ mkdir -p $EFIDIR
cp /run/media/$1/EFI/BOOT/*.efi $EFIDIR
if [ -f /run/media/$1/EFI/BOOT/grub.cfg ]; then
- root_part_uuid=$(blkid -o value -s PARTUUID /dev/${device}2)
+ root_part_uuid=$(blkid -o value -s PARTUUID ${device}2)
GRUBCFG="$EFIDIR/grub.cfg"
cp /run/media/$1/EFI/BOOT/grub.cfg $GRUBCFG
# Update grub config for the installed image
diff --git a/meta/recipes-core/initrdscripts/files/init-install.sh b/meta/recipes-core/initrdscripts/files/init-install.sh
index df2babd..88db0a6 100644
--- a/meta/recipes-core/initrdscripts/files/init-install.sh
+++ b/meta/recipes-core/initrdscripts/files/init-install.sh
@@ -82,7 +82,7 @@ else
exit 1
fi
-device=$TARGET_DEVICE_NAME
+device=/dev/$TARGET_DEVICE_NAME
#
# The udev automounter can cause pain here, kill it
@@ -93,7 +93,7 @@ rm -f /etc/udev/scripts/mount*
#
# Unmount anything the automounter had mounted
#
-umount /dev/${device}* 2> /dev/null || /bin/true
+umount ${device}* 2> /dev/null || /bin/true
if [ ! -b /dev/loop0 ] ; then
mknod /dev/loop0 b 7 0
@@ -104,7 +104,7 @@ if [ ! -L /etc/mtab ]; then
cat /proc/mounts > /etc/mtab
fi
-disk_size=$(parted /dev/${device} unit mb print | grep Disk | cut -d" " -f 3 | sed -e "s/MB//")
+disk_size=$(parted ${device} unit mb print | grep Disk | cut -d" " -f 3 | sed -e "s/MB//")
grub_version=$(grub-install -v|sed 's/.* \([0-9]\).*/\1/')
@@ -136,14 +136,14 @@ fi
if [ $grub_version -eq 0 ] ; then
bios_boot=''
- bootfs=/dev/${device}${part_prefix}1
- rootfs=/dev/${device}${part_prefix}2
- swap=/dev/${device}${part_prefix}3
+ bootfs=${device}${part_prefix}1
+ rootfs=${device}${part_prefix}2
+ swap=${device}${part_prefix}3
else
- bios_boot=/dev/${device}${part_prefix}1
- bootfs=/dev/${device}${part_prefix}2
- rootfs=/dev/${device}${part_prefix}3
- swap=/dev/${device}${part_prefix}4
+ bios_boot=${device}${part_prefix}1
+ bootfs=${device}${part_prefix}2
+ rootfs=${device}${part_prefix}3
+ swap=${device}${part_prefix}4
fi
echo "*****************"
@@ -152,32 +152,32 @@ echo "Boot partition size: $boot_size MB ($bootfs)"
echo "Rootfs partition size: $rootfs_size MB ($rootfs)"
echo "Swap partition size: $swap_size MB ($swap)"
echo "*****************"
-echo "Deleting partition table on /dev/${device} ..."
-dd if=/dev/zero of=/dev/${device} bs=512 count=2
+echo "Deleting partition table on ${device} ..."
+dd if=/dev/zero of=${device} bs=512 count=2
-echo "Creating new partition table on /dev/${device} ..."
+echo "Creating new partition table on ${device} ..."
if [ $grub_version -eq 0 ] ; then
- parted /dev/${device} mktable msdos
+ parted ${device} mktable msdos
echo "Creating boot partition on $bootfs"
- parted /dev/${device} mkpart primary ext3 0% $boot_size
+ parted ${device} mkpart primary ext3 0% $boot_size
else
- parted /dev/${device} mktable gpt
+ parted ${device} mktable gpt
echo "Creating BIOS boot partition on $bios_boot"
- parted /dev/${device} mkpart bios_boot 0% $bios_boot_size
- parted /dev/${device} set 1 bios_grub on
+ parted ${device} mkpart bios_boot 0% $bios_boot_size
+ parted ${device} set 1 bios_grub on
echo "Creating boot partition on $bootfs"
- parted /dev/${device} mkpart boot ext3 $boot_start $boot_size
+ parted ${device} mkpart boot ext3 $boot_start $boot_size
fi
echo "Creating rootfs partition on $rootfs"
[ $grub_version -eq 0 ] && pname='primary' || pname='root'
-parted /dev/${device} mkpart $pname ext3 $rootfs_start $rootfs_end
+parted ${device} mkpart $pname ext3 $rootfs_start $rootfs_end
echo "Creating swap partition on $swap"
[ $grub_version -eq 0 ] && pname='primary' || pname='swap'
-parted /dev/${device} mkpart $pname linux-swap $swap_start 100%
+parted ${device} mkpart $pname linux-swap $swap_start 100%
-parted /dev/${device} print
+parted ${device} print
echo "Formatting $bootfs to ext3..."
mkfs.ext3 $bootfs
@@ -198,13 +198,13 @@ mount -o rw,loop,noatime,nodiratime /run/media/$1/$2 /src_root
echo "Copying rootfs files..."
cp -a /src_root/* /tgt_root
if [ -d /tgt_root/etc/ -a $grub_version -ne 0 ] ; then
- boot_uuid=$(blkid -o value -s UUID /dev/${device}2)
- swap_part_uuid=$(blkid -o value -s PARTUUID /dev/${device}4)
+ boot_uuid=$(blkid -o value -s UUID ${device}2)
+ swap_part_uuid=$(blkid -o value -s PARTUUID ${device}4)
echo "/dev/disk/by-partuuid/$swap_part_uuid swap swap defaults 0 0" >> /tgt_root/etc/fstab
echo "UUID=$boot_uuid /boot ext3 defaults 1 2" >> /tgt_root/etc/fstab
# We dont want udev to mount our root device while we're booting...
if [ -d /tgt_root/etc/udev/ ] ; then
- echo "/dev/${device}" >> /tgt_root/etc/udev/mount.blacklist
+ echo "${device}" >> /tgt_root/etc/udev/mount.blacklist
fi
fi
umount /tgt_root
@@ -215,8 +215,8 @@ mount $bootfs /boot
echo "Preparing boot partition..."
if [ -f /etc/grub.d/00_header -a $grub_version -ne 0 ] ; then
echo "Preparing custom grub2 menu..."
- root_part_uuid=$(blkid -o value -s PARTUUID /dev/${device}3)
- boot_uuid=$(blkid -o value -s UUID /dev/${device}2)
+ root_part_uuid=$(blkid -o value -s PARTUUID ${device}3)
+ boot_uuid=$(blkid -o value -s UUID ${device}2)
GRUBCFG="/boot/grub/grub.cfg"
mkdir -p $(dirname $GRUBCFG)
cat >$GRUBCFG <<_EOF
@@ -227,10 +227,10 @@ menuentry "Linux" {
_EOF
chmod 0444 $GRUBCFG
fi
-grub-install /dev/${device}
+grub-install ${device}
if [ $grub_version -eq 0 ] ; then
- echo "(hd0) /dev/${device}" > /boot/grub/device.map
+ echo "(hd0) ${device}" > /boot/grub/device.map
echo "Preparing custom grub menu..."
echo "default 0" > /boot/grub/menu.lst
echo "timeout 30" >> /boot/grub/menu.lst
--
2.1.4
prev parent reply other threads:[~2015-06-15 18:04 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-06-15 16:10 [PATCH 00/10] UUID support in installer (poky-contrib: ed/oe-core/uuid-init-install) Ed Bartosh
2015-06-15 16:10 ` [PATCH 01/10] image-live: Set syslinux timeout to 5s Ed Bartosh
2015-06-15 16:10 ` [PATCH 02/10] initramfs-live-install: Add blkid to initramfs Ed Bartosh
2015-06-15 16:10 ` [PATCH 03/10] busybox: Enable UUID-related options Ed Bartosh
2015-06-15 16:10 ` [PATCH 04/10] init-install-efi: Implement UUID support Ed Bartosh
2015-06-15 16:10 ` [PATCH 05/10] init-install: Use GPT table with GRUB 2 Ed Bartosh
2015-06-15 16:10 ` [PATCH 06/10] init-install: Implement UUID support Ed Bartosh
2015-06-15 16:10 ` [PATCH 07/10] init-install: Specify filesystem type in parted command line Ed Bartosh
2015-06-15 16:10 ` [PATCH 08/10] init-install: Specify partition name " Ed Bartosh
2015-06-15 16:10 ` [PATCH 09/10] init-install: code cleanup: Replace tabs with spaces Ed Bartosh
2015-06-15 16:10 ` Ed Bartosh [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1434384647-2901-11-git-send-email-ed.bartosh@linux.intel.com \
--to=ed.bartosh@linux.intel.com \
--cc=openembedded-core@lists.openembedded.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox