summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEd Bartosh <ed.bartosh@linux.intel.com>2015-06-15 18:47:56 +0300
committerRichard Purdie <richard.purdie@linuxfoundation.org>2015-06-23 11:47:28 +0100
commit68d8f6d2e4a8d3d15ddc5b5404c5f75b7bd1950c (patch)
treec2a1ad46e715eba3c6880bc0c85aa9b05f8322a3
parent99a7c5b50dd824b4fb7fdfb77e71157ed096d8e2 (diff)
downloadpoky-68d8f6d2e4a8d3d15ddc5b5404c5f75b7bd1950c.tar.gz
init-install: code cleanup: replace /dev/$device -> $device
Shortened code by including /dev/ prefix into variable. (From OE-Core rev: f2fe5735a2d2c5a5cbadd3486aa24a4931655526) Signed-off-by: Ed Bartosh <ed.bartosh@linux.intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
-rw-r--r--meta/recipes-core/initrdscripts/files/init-install-efi.sh38
-rw-r--r--meta/recipes-core/initrdscripts/files/init-install.sh54
2 files changed, 46 insertions, 46 deletions
diff --git a/meta/recipes-core/initrdscripts/files/init-install-efi.sh b/meta/recipes-core/initrdscripts/files/init-install-efi.sh
index dca1432e40..74372b0c96 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
83 exit 1 83 exit 1
84fi 84fi
85 85
86device=$TARGET_DEVICE_NAME 86device=/dev/$TARGET_DEVICE_NAME
87 87
88# 88#
89# The udev automounter can cause pain here, kill it 89# The udev automounter can cause pain here, kill it
@@ -94,12 +94,12 @@ rm -f /etc/udev/scripts/mount*
94# 94#
95# Unmount anything the automounter had mounted 95# Unmount anything the automounter had mounted
96# 96#
97umount /dev/${device}* 2> /dev/null || /bin/true 97umount ${device}* 2> /dev/null || /bin/true
98 98
99mkdir -p /tmp 99mkdir -p /tmp
100cat /proc/mounts > /etc/mtab 100cat /proc/mounts > /etc/mtab
101 101
102disk_size=$(parted /dev/${device} unit mb print | grep Disk | cut -d" " -f 3 | sed -e "s/MB//") 102disk_size=$(parted ${device} unit mb print | grep Disk | cut -d" " -f 3 | sed -e "s/MB//")
103 103
104swap_size=$((disk_size*swap_ratio/100)) 104swap_size=$((disk_size*swap_ratio/100))
105rootfs_size=$((disk_size-boot_size-swap_size)) 105rootfs_size=$((disk_size-boot_size-swap_size))
@@ -117,32 +117,32 @@ if [ ! "${device#mmcblk}" = "${device}" ]; then
117 part_prefix="p" 117 part_prefix="p"
118 rootwait="rootwait" 118 rootwait="rootwait"
119fi 119fi
120bootfs=/dev/${device}${part_prefix}1 120bootfs=${device}${part_prefix}1
121rootfs=/dev/${device}${part_prefix}2 121rootfs=${device}${part_prefix}2
122swap=/dev/${device}${part_prefix}3 122swap=${device}${part_prefix}3
123 123
124echo "*****************" 124echo "*****************"
125echo "Boot partition size: $boot_size MB ($bootfs)" 125echo "Boot partition size: $boot_size MB ($bootfs)"
126echo "Rootfs partition size: $rootfs_size MB ($rootfs)" 126echo "Rootfs partition size: $rootfs_size MB ($rootfs)"
127echo "Swap partition size: $swap_size MB ($swap)" 127echo "Swap partition size: $swap_size MB ($swap)"
128echo "*****************" 128echo "*****************"
129echo "Deleting partition table on /dev/${device} ..." 129echo "Deleting partition table on ${device} ..."
130dd if=/dev/zero of=/dev/${device} bs=512 count=2 130dd if=/dev/zero of=${device} bs=512 count=2
131 131
132echo "Creating new partition table on /dev/${device} ..." 132echo "Creating new partition table on ${device} ..."
133parted /dev/${device} mklabel gpt 133parted ${device} mklabel gpt
134 134
135echo "Creating boot partition on $bootfs" 135echo "Creating boot partition on $bootfs"
136parted /dev/${device} mkpart boot fat32 0% $boot_size 136parted ${device} mkpart boot fat32 0% $boot_size
137parted /dev/${device} set 1 boot on 137parted ${device} set 1 boot on
138 138
139echo "Creating rootfs partition on $rootfs" 139echo "Creating rootfs partition on $rootfs"
140parted /dev/${device} mkpart root ext3 $rootfs_start $rootfs_end 140parted ${device} mkpart root ext3 $rootfs_start $rootfs_end
141 141
142echo "Creating swap partition on $swap" 142echo "Creating swap partition on $swap"
143parted /dev/${device} mkpart swap linux-swap $swap_start 100% 143parted ${device} mkpart swap linux-swap $swap_start 100%
144 144
145parted /dev/${device} print 145parted ${device} print
146 146
147echo "Formatting $bootfs to vfat..." 147echo "Formatting $bootfs to vfat..."
148mkfs.vfat $bootfs 148mkfs.vfat $bootfs
@@ -163,13 +163,13 @@ mount -o rw,loop,noatime,nodiratime /run/media/$1/$2 /src_root
163echo "Copying rootfs files..." 163echo "Copying rootfs files..."
164cp -a /src_root/* /tgt_root 164cp -a /src_root/* /tgt_root
165if [ -d /tgt_root/etc/ ] ; then 165if [ -d /tgt_root/etc/ ] ; then
166 boot_uuid=$(blkid -o value -s UUID /dev/${device}1) 166 boot_uuid=$(blkid -o value -s UUID ${device}1)
167 swap_part_uuid=$(blkid -o value -s PARTUUID /dev/${device}3) 167 swap_part_uuid=$(blkid -o value -s PARTUUID ${device}3)
168 echo "/dev/disk/by-partuuid/$swap_part_uuid swap swap defaults 0 0" >> /tgt_root/etc/fstab 168 echo "/dev/disk/by-partuuid/$swap_part_uuid swap swap defaults 0 0" >> /tgt_root/etc/fstab
169 echo "UUID=$boot_uuid /boot vfat defaults 1 2" >> /tgt_root/etc/fstab 169 echo "UUID=$boot_uuid /boot vfat defaults 1 2" >> /tgt_root/etc/fstab
170 # We dont want udev to mount our root device while we're booting... 170 # We dont want udev to mount our root device while we're booting...
171 if [ -d /tgt_root/etc/udev/ ] ; then 171 if [ -d /tgt_root/etc/udev/ ] ; then
172 echo "/dev/${device}" >> /tgt_root/etc/udev/mount.blacklist 172 echo "${device}" >> /tgt_root/etc/udev/mount.blacklist
173 fi 173 fi
174fi 174fi
175 175
@@ -185,7 +185,7 @@ mkdir -p $EFIDIR
185cp /run/media/$1/EFI/BOOT/*.efi $EFIDIR 185cp /run/media/$1/EFI/BOOT/*.efi $EFIDIR
186 186
187if [ -f /run/media/$1/EFI/BOOT/grub.cfg ]; then 187if [ -f /run/media/$1/EFI/BOOT/grub.cfg ]; then
188 root_part_uuid=$(blkid -o value -s PARTUUID /dev/${device}2) 188 root_part_uuid=$(blkid -o value -s PARTUUID ${device}2)
189 GRUBCFG="$EFIDIR/grub.cfg" 189 GRUBCFG="$EFIDIR/grub.cfg"
190 cp /run/media/$1/EFI/BOOT/grub.cfg $GRUBCFG 190 cp /run/media/$1/EFI/BOOT/grub.cfg $GRUBCFG
191 # Update grub config for the installed image 191 # 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 e1e7cb1bd3..0593b3c716 100644
--- a/meta/recipes-core/initrdscripts/files/init-install.sh
+++ b/meta/recipes-core/initrdscripts/files/init-install.sh
@@ -82,7 +82,7 @@ else
82 exit 1 82 exit 1
83fi 83fi
84 84
85device=$TARGET_DEVICE_NAME 85device=/dev/$TARGET_DEVICE_NAME
86 86
87# 87#
88# The udev automounter can cause pain here, kill it 88# The udev automounter can cause pain here, kill it
@@ -93,7 +93,7 @@ rm -f /etc/udev/scripts/mount*
93# 93#
94# Unmount anything the automounter had mounted 94# Unmount anything the automounter had mounted
95# 95#
96umount /dev/${device}* 2> /dev/null || /bin/true 96umount ${device}* 2> /dev/null || /bin/true
97 97
98if [ ! -b /dev/loop0 ] ; then 98if [ ! -b /dev/loop0 ] ; then
99 mknod /dev/loop0 b 7 0 99 mknod /dev/loop0 b 7 0
@@ -104,7 +104,7 @@ if [ ! -L /etc/mtab ]; then
104 cat /proc/mounts > /etc/mtab 104 cat /proc/mounts > /etc/mtab
105fi 105fi
106 106
107disk_size=$(parted /dev/${device} unit mb print | grep Disk | cut -d" " -f 3 | sed -e "s/MB//") 107disk_size=$(parted ${device} unit mb print | grep Disk | cut -d" " -f 3 | sed -e "s/MB//")
108 108
109grub_version=$(grub-install -v|sed 's/.* \([0-9]\).*/\1/') 109grub_version=$(grub-install -v|sed 's/.* \([0-9]\).*/\1/')
110 110
@@ -136,14 +136,14 @@ fi
136 136
137if [ $grub_version -eq 0 ] ; then 137if [ $grub_version -eq 0 ] ; then
138 bios_boot='' 138 bios_boot=''
139 bootfs=/dev/${device}${part_prefix}1 139 bootfs=${device}${part_prefix}1
140 rootfs=/dev/${device}${part_prefix}2 140 rootfs=${device}${part_prefix}2
141 swap=/dev/${device}${part_prefix}3 141 swap=${device}${part_prefix}3
142else 142else
143 bios_boot=/dev/${device}${part_prefix}1 143 bios_boot=${device}${part_prefix}1
144 bootfs=/dev/${device}${part_prefix}2 144 bootfs=${device}${part_prefix}2
145 rootfs=/dev/${device}${part_prefix}3 145 rootfs=${device}${part_prefix}3
146 swap=/dev/${device}${part_prefix}4 146 swap=${device}${part_prefix}4
147fi 147fi
148 148
149echo "*****************" 149echo "*****************"
@@ -152,32 +152,32 @@ echo "Boot partition size: $boot_size MB ($bootfs)"
152echo "Rootfs partition size: $rootfs_size MB ($rootfs)" 152echo "Rootfs partition size: $rootfs_size MB ($rootfs)"
153echo "Swap partition size: $swap_size MB ($swap)" 153echo "Swap partition size: $swap_size MB ($swap)"
154echo "*****************" 154echo "*****************"
155echo "Deleting partition table on /dev/${device} ..." 155echo "Deleting partition table on ${device} ..."
156dd if=/dev/zero of=/dev/${device} bs=512 count=2 156dd if=/dev/zero of=${device} bs=512 count=2
157 157
158echo "Creating new partition table on /dev/${device} ..." 158echo "Creating new partition table on ${device} ..."
159if [ $grub_version -eq 0 ] ; then 159if [ $grub_version -eq 0 ] ; then
160 parted /dev/${device} mktable msdos 160 parted ${device} mktable msdos
161 echo "Creating boot partition on $bootfs" 161 echo "Creating boot partition on $bootfs"
162 parted /dev/${device} mkpart primary ext3 0% $boot_size 162 parted ${device} mkpart primary ext3 0% $boot_size
163else 163else
164 parted /dev/${device} mktable gpt 164 parted ${device} mktable gpt
165 echo "Creating BIOS boot partition on $bios_boot" 165 echo "Creating BIOS boot partition on $bios_boot"
166 parted /dev/${device} mkpart bios_boot 0% $bios_boot_size 166 parted ${device} mkpart bios_boot 0% $bios_boot_size
167 parted /dev/${device} set 1 bios_grub on 167 parted ${device} set 1 bios_grub on
168 echo "Creating boot partition on $bootfs" 168 echo "Creating boot partition on $bootfs"
169 parted /dev/${device} mkpart boot ext3 $boot_start $boot_size 169 parted ${device} mkpart boot ext3 $boot_start $boot_size
170fi 170fi
171 171
172echo "Creating rootfs partition on $rootfs" 172echo "Creating rootfs partition on $rootfs"
173[ $grub_version -eq 0 ] && pname='primary' || pname='root' 173[ $grub_version -eq 0 ] && pname='primary' || pname='root'
174parted /dev/${device} mkpart $pname ext3 $rootfs_start $rootfs_end 174parted ${device} mkpart $pname ext3 $rootfs_start $rootfs_end
175 175
176echo "Creating swap partition on $swap" 176echo "Creating swap partition on $swap"
177[ $grub_version -eq 0 ] && pname='primary' || pname='swap' 177[ $grub_version -eq 0 ] && pname='primary' || pname='swap'
178parted /dev/${device} mkpart $pname linux-swap $swap_start 100% 178parted ${device} mkpart $pname linux-swap $swap_start 100%
179 179
180parted /dev/${device} print 180parted ${device} print
181 181
182echo "Formatting $bootfs to ext3..." 182echo "Formatting $bootfs to ext3..."
183mkfs.ext3 $bootfs 183mkfs.ext3 $bootfs
@@ -211,7 +211,7 @@ if [ -d /tgt_root/etc/ ] ; then
211 echo "$bootdev /boot ext3 defaults 1 2" >> /tgt_root/etc/fstab 211 echo "$bootdev /boot ext3 defaults 1 2" >> /tgt_root/etc/fstab
212 # We dont want udev to mount our root device while we're booting... 212 # We dont want udev to mount our root device while we're booting...
213 if [ -d /tgt_root/etc/udev/ ] ; then 213 if [ -d /tgt_root/etc/udev/ ] ; then
214 echo "/dev/${device}" >> /tgt_root/etc/udev/mount.blacklist 214 echo "${device}" >> /tgt_root/etc/udev/mount.blacklist
215 fi 215 fi
216fi 216fi
217umount /tgt_root 217umount /tgt_root
@@ -222,8 +222,8 @@ mount $bootfs /boot
222echo "Preparing boot partition..." 222echo "Preparing boot partition..."
223if [ -f /etc/grub.d/00_header -a $grub_version -ne 0 ] ; then 223if [ -f /etc/grub.d/00_header -a $grub_version -ne 0 ] ; then
224 echo "Preparing custom grub2 menu..." 224 echo "Preparing custom grub2 menu..."
225 root_part_uuid=$(blkid -o value -s PARTUUID /dev/${device}3) 225 root_part_uuid=$(blkid -o value -s PARTUUID ${device}3)
226 boot_uuid=$(blkid -o value -s UUID /dev/${device}2) 226 boot_uuid=$(blkid -o value -s UUID ${device}2)
227 GRUBCFG="/boot/grub/grub.cfg" 227 GRUBCFG="/boot/grub/grub.cfg"
228 mkdir -p $(dirname $GRUBCFG) 228 mkdir -p $(dirname $GRUBCFG)
229 cat >$GRUBCFG <<_EOF 229 cat >$GRUBCFG <<_EOF
@@ -234,10 +234,10 @@ menuentry "Linux" {
234_EOF 234_EOF
235 chmod 0444 $GRUBCFG 235 chmod 0444 $GRUBCFG
236fi 236fi
237grub-install /dev/${device} 237grub-install ${device}
238 238
239if [ $grub_version -eq 0 ] ; then 239if [ $grub_version -eq 0 ] ; then
240 echo "(hd0) /dev/${device}" > /boot/grub/device.map 240 echo "(hd0) ${device}" > /boot/grub/device.map
241 echo "Preparing custom grub menu..." 241 echo "Preparing custom grub menu..."
242 echo "default 0" > /boot/grub/menu.lst 242 echo "default 0" > /boot/grub/menu.lst
243 echo "timeout 30" >> /boot/grub/menu.lst 243 echo "timeout 30" >> /boot/grub/menu.lst