diff options
author | Ed Bartosh <ed.bartosh@linux.intel.com> | 2015-06-15 18:47:56 +0300 |
---|---|---|
committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2015-06-23 11:47:28 +0100 |
commit | 68d8f6d2e4a8d3d15ddc5b5404c5f75b7bd1950c (patch) | |
tree | c2a1ad46e715eba3c6880bc0c85aa9b05f8322a3 | |
parent | 99a7c5b50dd824b4fb7fdfb77e71157ed096d8e2 (diff) | |
download | poky-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.sh | 38 | ||||
-rw-r--r-- | meta/recipes-core/initrdscripts/files/init-install.sh | 54 |
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 |
84 | fi | 84 | fi |
85 | 85 | ||
86 | device=$TARGET_DEVICE_NAME | 86 | device=/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 | # |
97 | umount /dev/${device}* 2> /dev/null || /bin/true | 97 | umount ${device}* 2> /dev/null || /bin/true |
98 | 98 | ||
99 | mkdir -p /tmp | 99 | mkdir -p /tmp |
100 | cat /proc/mounts > /etc/mtab | 100 | cat /proc/mounts > /etc/mtab |
101 | 101 | ||
102 | disk_size=$(parted /dev/${device} unit mb print | grep Disk | cut -d" " -f 3 | sed -e "s/MB//") | 102 | disk_size=$(parted ${device} unit mb print | grep Disk | cut -d" " -f 3 | sed -e "s/MB//") |
103 | 103 | ||
104 | swap_size=$((disk_size*swap_ratio/100)) | 104 | swap_size=$((disk_size*swap_ratio/100)) |
105 | rootfs_size=$((disk_size-boot_size-swap_size)) | 105 | rootfs_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" |
119 | fi | 119 | fi |
120 | bootfs=/dev/${device}${part_prefix}1 | 120 | bootfs=${device}${part_prefix}1 |
121 | rootfs=/dev/${device}${part_prefix}2 | 121 | rootfs=${device}${part_prefix}2 |
122 | swap=/dev/${device}${part_prefix}3 | 122 | swap=${device}${part_prefix}3 |
123 | 123 | ||
124 | echo "*****************" | 124 | echo "*****************" |
125 | echo "Boot partition size: $boot_size MB ($bootfs)" | 125 | echo "Boot partition size: $boot_size MB ($bootfs)" |
126 | echo "Rootfs partition size: $rootfs_size MB ($rootfs)" | 126 | echo "Rootfs partition size: $rootfs_size MB ($rootfs)" |
127 | echo "Swap partition size: $swap_size MB ($swap)" | 127 | echo "Swap partition size: $swap_size MB ($swap)" |
128 | echo "*****************" | 128 | echo "*****************" |
129 | echo "Deleting partition table on /dev/${device} ..." | 129 | echo "Deleting partition table on ${device} ..." |
130 | dd if=/dev/zero of=/dev/${device} bs=512 count=2 | 130 | dd if=/dev/zero of=${device} bs=512 count=2 |
131 | 131 | ||
132 | echo "Creating new partition table on /dev/${device} ..." | 132 | echo "Creating new partition table on ${device} ..." |
133 | parted /dev/${device} mklabel gpt | 133 | parted ${device} mklabel gpt |
134 | 134 | ||
135 | echo "Creating boot partition on $bootfs" | 135 | echo "Creating boot partition on $bootfs" |
136 | parted /dev/${device} mkpart boot fat32 0% $boot_size | 136 | parted ${device} mkpart boot fat32 0% $boot_size |
137 | parted /dev/${device} set 1 boot on | 137 | parted ${device} set 1 boot on |
138 | 138 | ||
139 | echo "Creating rootfs partition on $rootfs" | 139 | echo "Creating rootfs partition on $rootfs" |
140 | parted /dev/${device} mkpart root ext3 $rootfs_start $rootfs_end | 140 | parted ${device} mkpart root ext3 $rootfs_start $rootfs_end |
141 | 141 | ||
142 | echo "Creating swap partition on $swap" | 142 | echo "Creating swap partition on $swap" |
143 | parted /dev/${device} mkpart swap linux-swap $swap_start 100% | 143 | parted ${device} mkpart swap linux-swap $swap_start 100% |
144 | 144 | ||
145 | parted /dev/${device} print | 145 | parted ${device} print |
146 | 146 | ||
147 | echo "Formatting $bootfs to vfat..." | 147 | echo "Formatting $bootfs to vfat..." |
148 | mkfs.vfat $bootfs | 148 | mkfs.vfat $bootfs |
@@ -163,13 +163,13 @@ mount -o rw,loop,noatime,nodiratime /run/media/$1/$2 /src_root | |||
163 | echo "Copying rootfs files..." | 163 | echo "Copying rootfs files..." |
164 | cp -a /src_root/* /tgt_root | 164 | cp -a /src_root/* /tgt_root |
165 | if [ -d /tgt_root/etc/ ] ; then | 165 | if [ -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 |
174 | fi | 174 | fi |
175 | 175 | ||
@@ -185,7 +185,7 @@ mkdir -p $EFIDIR | |||
185 | cp /run/media/$1/EFI/BOOT/*.efi $EFIDIR | 185 | cp /run/media/$1/EFI/BOOT/*.efi $EFIDIR |
186 | 186 | ||
187 | if [ -f /run/media/$1/EFI/BOOT/grub.cfg ]; then | 187 | if [ -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 |
83 | fi | 83 | fi |
84 | 84 | ||
85 | device=$TARGET_DEVICE_NAME | 85 | device=/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 | # |
96 | umount /dev/${device}* 2> /dev/null || /bin/true | 96 | umount ${device}* 2> /dev/null || /bin/true |
97 | 97 | ||
98 | if [ ! -b /dev/loop0 ] ; then | 98 | if [ ! -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 |
105 | fi | 105 | fi |
106 | 106 | ||
107 | disk_size=$(parted /dev/${device} unit mb print | grep Disk | cut -d" " -f 3 | sed -e "s/MB//") | 107 | disk_size=$(parted ${device} unit mb print | grep Disk | cut -d" " -f 3 | sed -e "s/MB//") |
108 | 108 | ||
109 | grub_version=$(grub-install -v|sed 's/.* \([0-9]\).*/\1/') | 109 | grub_version=$(grub-install -v|sed 's/.* \([0-9]\).*/\1/') |
110 | 110 | ||
@@ -136,14 +136,14 @@ fi | |||
136 | 136 | ||
137 | if [ $grub_version -eq 0 ] ; then | 137 | if [ $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 |
142 | else | 142 | else |
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 |
147 | fi | 147 | fi |
148 | 148 | ||
149 | echo "*****************" | 149 | echo "*****************" |
@@ -152,32 +152,32 @@ echo "Boot partition size: $boot_size MB ($bootfs)" | |||
152 | echo "Rootfs partition size: $rootfs_size MB ($rootfs)" | 152 | echo "Rootfs partition size: $rootfs_size MB ($rootfs)" |
153 | echo "Swap partition size: $swap_size MB ($swap)" | 153 | echo "Swap partition size: $swap_size MB ($swap)" |
154 | echo "*****************" | 154 | echo "*****************" |
155 | echo "Deleting partition table on /dev/${device} ..." | 155 | echo "Deleting partition table on ${device} ..." |
156 | dd if=/dev/zero of=/dev/${device} bs=512 count=2 | 156 | dd if=/dev/zero of=${device} bs=512 count=2 |
157 | 157 | ||
158 | echo "Creating new partition table on /dev/${device} ..." | 158 | echo "Creating new partition table on ${device} ..." |
159 | if [ $grub_version -eq 0 ] ; then | 159 | if [ $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 |
163 | else | 163 | else |
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 |
170 | fi | 170 | fi |
171 | 171 | ||
172 | echo "Creating rootfs partition on $rootfs" | 172 | echo "Creating rootfs partition on $rootfs" |
173 | [ $grub_version -eq 0 ] && pname='primary' || pname='root' | 173 | [ $grub_version -eq 0 ] && pname='primary' || pname='root' |
174 | parted /dev/${device} mkpart $pname ext3 $rootfs_start $rootfs_end | 174 | parted ${device} mkpart $pname ext3 $rootfs_start $rootfs_end |
175 | 175 | ||
176 | echo "Creating swap partition on $swap" | 176 | echo "Creating swap partition on $swap" |
177 | [ $grub_version -eq 0 ] && pname='primary' || pname='swap' | 177 | [ $grub_version -eq 0 ] && pname='primary' || pname='swap' |
178 | parted /dev/${device} mkpart $pname linux-swap $swap_start 100% | 178 | parted ${device} mkpart $pname linux-swap $swap_start 100% |
179 | 179 | ||
180 | parted /dev/${device} print | 180 | parted ${device} print |
181 | 181 | ||
182 | echo "Formatting $bootfs to ext3..." | 182 | echo "Formatting $bootfs to ext3..." |
183 | mkfs.ext3 $bootfs | 183 | mkfs.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 |
216 | fi | 216 | fi |
217 | umount /tgt_root | 217 | umount /tgt_root |
@@ -222,8 +222,8 @@ mount $bootfs /boot | |||
222 | echo "Preparing boot partition..." | 222 | echo "Preparing boot partition..." |
223 | if [ -f /etc/grub.d/00_header -a $grub_version -ne 0 ] ; then | 223 | if [ -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 |
236 | fi | 236 | fi |
237 | grub-install /dev/${device} | 237 | grub-install ${device} |
238 | 238 | ||
239 | if [ $grub_version -eq 0 ] ; then | 239 | if [ $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 |