summaryrefslogtreecommitdiffstats
path: root/recipes-core/initrdscripts/files/intel-x86-common/init-install-efi.sh
diff options
context:
space:
mode:
authorAnuj Mittal <anuj.mittal@intel.com>2018-07-12 22:08:22 +0800
committerAnuj Mittal <anuj.mittal@intel.com>2018-07-16 16:53:00 +0800
commitc12c16659203d677618871f660c1499152a555a8 (patch)
tree60967f8f17da1e5a6cef2908312a25b4c9514a07 /recipes-core/initrdscripts/files/intel-x86-common/init-install-efi.sh
parent7c469177e833a80443b948af63e40176c7dc6bee (diff)
downloadmeta-intel-c12c16659203d677618871f660c1499152a555a8.tar.gz
rmc: remove
It's not being maintained anymore and the scripts have not been kept in sync with upstream for quite some time. Signed-off-by: Anuj Mittal <anuj.mittal@intel.com>
Diffstat (limited to 'recipes-core/initrdscripts/files/intel-x86-common/init-install-efi.sh')
-rw-r--r--recipes-core/initrdscripts/files/intel-x86-common/init-install-efi.sh342
1 files changed, 0 insertions, 342 deletions
diff --git a/recipes-core/initrdscripts/files/intel-x86-common/init-install-efi.sh b/recipes-core/initrdscripts/files/intel-x86-common/init-install-efi.sh
deleted file mode 100644
index a7a2ad4c..00000000
--- a/recipes-core/initrdscripts/files/intel-x86-common/init-install-efi.sh
+++ /dev/null
@@ -1,342 +0,0 @@
1#!/bin/sh -e
2#
3# Copyright (c) 2016, Intel Corporation.
4# All rights reserved.
5#
6# install.sh [device_name] [rootfs_name]
7#
8# This file is a copy of file with same name in OE:
9# meta/recipes-core/initrdscripts/files/. We modify
10# it for RMC feature to deploy file blobs from RMC
11# database file to target.
12
13PATH=/sbin:/bin:/usr/sbin:/usr/bin
14
15# We need 20 Mb for the boot partition
16boot_size=20
17
18# 5% for swap
19swap_ratio=5
20
21# Get a list of hard drives
22hdnamelist=""
23live_dev_name=`cat /proc/mounts | grep ${1%/} | awk '{print $1}'`
24live_dev_name=${live_dev_name#\/dev/}
25# Only strip the digit identifier if the device is not an mmc
26case $live_dev_name in
27 mmcblk*)
28 ;;
29 nvme*)
30 ;;
31 *)
32 live_dev_name=${live_dev_name%%[0-9]*}
33 ;;
34esac
35
36echo "Searching for hard drives ..."
37
38for device in `ls /sys/block/`; do
39 case $device in
40 loop*)
41 # skip loop device
42 ;;
43 sr*)
44 # skip CDROM device
45 ;;
46 ram*)
47 # skip ram device
48 ;;
49 *)
50 # skip the device LiveOS is on
51 # Add valid hard drive name to the list
52 case $device in
53 $live_dev_name*)
54 # skip the device we are running from
55 ;;
56 *)
57 hdnamelist="$hdnamelist $device"
58 ;;
59 esac
60 ;;
61 esac
62done
63
64if [ -z "${hdnamelist}" ]; then
65 echo "You need another device (besides the live device /dev/${live_dev_name}) to install the image. Installation aborted."
66 exit 1
67fi
68
69TARGET_DEVICE_NAME=""
70for hdname in $hdnamelist; do
71 # Display found hard drives and their basic info
72 echo "-------------------------------"
73 echo /dev/$hdname
74 if [ -r /sys/block/$hdname/device/vendor ]; then
75 echo -n "VENDOR="
76 cat /sys/block/$hdname/device/vendor
77 fi
78 if [ -r /sys/block/$hdname/device/model ]; then
79 echo -n "MODEL="
80 cat /sys/block/$hdname/device/model
81 fi
82 if [ -r /sys/block/$hdname/device/uevent ]; then
83 echo -n "UEVENT="
84 cat /sys/block/$hdname/device/uevent
85 fi
86 echo
87done
88
89# Get user choice
90while true; do
91 echo "Please select an install target or press n to exit ($hdnamelist ): "
92 read answer
93 if [ "$answer" = "n" ]; then
94 echo "Installation manually aborted."
95 exit 1
96 fi
97 for hdname in $hdnamelist; do
98 if [ "$answer" = "$hdname" ]; then
99 TARGET_DEVICE_NAME=$answer
100 break
101 fi
102 done
103 if [ -n "$TARGET_DEVICE_NAME" ]; then
104 break
105 fi
106done
107
108if [ -n "$TARGET_DEVICE_NAME" ]; then
109 echo "Installing image on /dev/$TARGET_DEVICE_NAME ..."
110else
111 echo "No hard drive selected. Installation aborted."
112 exit 1
113fi
114
115device=/dev/$TARGET_DEVICE_NAME
116
117#
118# The udev automounter can cause pain here, kill it
119#
120rm -f /etc/udev/rules.d/automount.rules
121rm -f /etc/udev/scripts/mount*
122
123#
124# Unmount anything the automounter had mounted
125#
126umount ${device}* 2> /dev/null || /bin/true
127
128mkdir -p /tmp
129
130# Create /etc/mtab if not present
131if [ ! -e /etc/mtab ]; then
132 cat /proc/mounts > /etc/mtab
133fi
134
135disk_size=$(parted ${device} unit mb print | grep '^Disk .*: .*MB' | cut -d" " -f 3 | sed -e "s/MB//")
136
137swap_size=$((disk_size*swap_ratio/100))
138rootfs_size=$((disk_size-boot_size-swap_size))
139
140rootfs_start=$((boot_size))
141rootfs_end=$((rootfs_start+rootfs_size))
142swap_start=$((rootfs_end))
143
144# MMC devices are special in a couple of ways
145# 1) they use a partition prefix character 'p'
146# 2) they are detected asynchronously (need rootwait)
147rootwait=""
148part_prefix=""
149if [ ! "${device#/dev/mmcblk}" = "${device}" ] || \
150[ ! "${device#/dev/nvme}" = "${device}" ]; then
151 part_prefix="p"
152 rootwait="rootwait"
153fi
154bootfs=${device}${part_prefix}1
155rootfs=${device}${part_prefix}2
156swap=${device}${part_prefix}3
157
158echo "*****************"
159echo "Boot partition size: $boot_size MB ($bootfs)"
160echo "Rootfs partition size: $rootfs_size MB ($rootfs)"
161echo "Swap partition size: $swap_size MB ($swap)"
162echo "*****************"
163echo "Deleting partition table on ${device} ..."
164dd if=/dev/zero of=${device} bs=512 count=35
165
166echo "Creating new partition table on ${device} ..."
167parted ${device} mklabel gpt
168
169echo "Creating boot partition on $bootfs"
170parted ${device} mkpart boot fat32 0% $boot_size
171parted ${device} set 1 boot on
172
173echo "Creating rootfs partition on $rootfs"
174parted ${device} mkpart root ext3 $rootfs_start $rootfs_end
175
176echo "Creating swap partition on $swap"
177parted ${device} mkpart swap linux-swap $swap_start 100%
178
179parted ${device} print
180
181echo "Formatting $bootfs to vfat..."
182mkfs.vfat $bootfs
183
184echo "Formatting $rootfs to ext3..."
185mkfs.ext3 $rootfs
186
187echo "Formatting swap partition...($swap)"
188mkswap $swap
189
190mkdir /tgt_root
191mkdir /src_root
192mkdir -p /boot
193
194# Handling of the target root partition
195mount $rootfs /tgt_root
196mount -o rw,loop,noatime,nodiratime /run/media/$1/$2 /src_root
197echo "Copying rootfs files..."
198cp -a /src_root/* /tgt_root
199if [ -d /tgt_root/etc/ ] ; then
200 boot_uuid=$(blkid -o value -s UUID ${bootfs})
201 swap_part_uuid=$(blkid -o value -s PARTUUID ${swap})
202 echo "/dev/disk/by-partuuid/$swap_part_uuid swap swap defaults 0 0" >> /tgt_root/etc/fstab
203 echo "UUID=$boot_uuid /boot vfat defaults 1 2" >> /tgt_root/etc/fstab
204 # We dont want udev to mount our root device while we're booting...
205 if [ -d /tgt_root/etc/udev/ ] ; then
206 echo "${device}" >> /tgt_root/etc/udev/mount.blacklist
207 fi
208fi
209
210# Handling of the target boot partition
211mount $bootfs /boot
212echo "Preparing boot partition..."
213
214EFIDIR="/boot/EFI/BOOT"
215mkdir -p $EFIDIR
216# Copy the efi loader
217cp /run/media/$1/EFI/BOOT/*.efi $EFIDIR
218
219# RMC deployment
220RMC_CMD=/src_root/usr/bin/rmc
221RMC_DB=/run/media/$1/rmc.db
222
223# We don't want to quit when a step failed. For example,
224# a file system could not support some operations.
225set +e
226
227if [ -f "${RMC_DB}" ] && [ -f "${RMC_CMD}" ]; then
228 echo "Found RMC database and tool, start RMC deployment"
229 # query INSTALLER.CONFIG from RMC DB
230 if ${RMC_CMD} -B INSTALLER.CONFIG -d "${RMC_DB}" -o /tmp/installer.config; then
231 while IFS=':' read -r NAME TGT_UID TGT_GID TGT_MODE TGT_PATH; do
232 # skip comment
233 # The regexp in grep works with busybox grep which doesn't
234 # seem to have a -P to recognize '\t'. But this expression could not
235 # work with gnu grep...
236 if echo "$NAME"|grep -q $'^[ \t]*#'; then
237 continue
238 fi
239 # check if we should create a directory (last char in target path is '/')
240 # or deploy a file
241 LAST_CHAR=$(echo "${TGT_PATH:$((${#TGT_PATH}-1)):1}")
242
243 # Do not bail out for failures but user should get stderr message
244 if [ ${LAST_CHAR} = "/" ]; then
245 # name field is skipped for directory
246 echo "DIR: ${TGT_UID}:${TGT_GID}:${TGT_MODE} => ${TGT_PATH}"
247 mkdir -p "$TGT_PATH"
248 chown "${TGT_UID}:${TGT_GID}" "$TGT_PATH"
249 chmod "${TGT_MODE}" "$TGT_PATH"
250 else
251 ${RMC_CMD} -B "${NAME}" -d "${RMC_DB}" -o "${TGT_PATH}"
252 echo "FILE: ${NAME}:${TGT_UID}:${TGT_GID}:${TGT_MODE} => ${TGT_PATH}"
253 chown "${TGT_UID}:${TGT_GID}" "$TGT_PATH"
254 chmod "${TGT_MODE}" "$TGT_PATH"
255 fi
256 done < /tmp/installer.config
257 rm -rf /tmp/installer.config
258
259 # remove rmc from target since we don't think it is a valid
260 # case to run rmc after installation.
261 rm -rf /tgt_root/usr/bin/rmc
262 echo "RMC deployment finished"
263 else
264 echo "INSTALLER.CONFIG is not found, skip RMC deployment"
265 fi
266
267 # Final retouching by calling post-install hook
268 if ${RMC_CMD} -B POSTINSTALL.sh -d "${RMC_DB}" -o /tmp/POSTINSTALL.sh; then
269 echo "Found POSTINSTALL.sh execute it..."
270 chmod 500 /tmp/POSTINSTALL.sh
271 /tmp/POSTINSTALL.sh
272 rm -rf /tmp/POSTINSTALL.sh
273 fi
274fi
275set -e
276
277if [ -f /run/media/$1/EFI/BOOT/grub.cfg ]; then
278 root_part_uuid=$(blkid -o value -s PARTUUID ${rootfs})
279 GRUBCFG="$EFIDIR/grub.cfg"
280 cp /run/media/$1/EFI/BOOT/grub.cfg $GRUBCFG
281 # Update grub config for the installed image
282 # Delete the install entry
283 sed -i "/menuentry 'install'/,/^}/d" $GRUBCFG
284 # Delete the initrd lines
285 sed -i "/initrd /d" $GRUBCFG
286 # Delete any LABEL= strings
287 sed -i "s/ LABEL=[^ ]*/ /" $GRUBCFG
288 # Delete any root= strings
289 sed -i "s/ root=[^ ]*/ /g" $GRUBCFG
290 # Add the root= and other standard boot options
291 sed -i "s@linux /vmlinuz *@linux /vmlinuz root=PARTUUID=$root_part_uuid rw $rootwait quiet @" $GRUBCFG
292fi
293
294if [ -d /run/media/$1/loader ]; then
295 rootuuid=$(blkid -o value -s PARTUUID ${rootfs})
296 GUMMIBOOT_CFGS="/boot/loader/entries/*.conf"
297 if [ -d /boot/loader ]; then
298 # Don't override loader.conf RMC already deployed
299 if [ ! -f /boot/loader/loader.conf ]; then
300 cp /run/media/$1/loader/loader.conf /boot/loader/
301 fi
302 # only copy built OE entries when RMC entries don't exist.
303 if [ ! -d /boot/loader/entries ] || [ ! ls /boot/loader/entries/*.conf &>/dev/null ]; then
304 cp -dr /run/media/$1/loader/entries /boot/loader
305 fi
306 else
307 # copy config files for gummiboot
308 cp -dr /run/media/$1/loader /boot
309 # delete the install entry
310 rm -f /boot/loader/entries/install.conf
311 fi
312 # delete the initrd lines
313 sed -i "/initrd /d" $GUMMIBOOT_CFGS
314 # delete any LABEL= strings
315 sed -i "s/ LABEL=[^ ]*/ /" $GUMMIBOOT_CFGS
316 # delete any root= strings
317 sed -i "s/ root=[^ ]*/ /" $GUMMIBOOT_CFGS
318 # add the root= and other standard boot options
319 sed -i "s@options *@options root=PARTUUID=$rootuuid rw $rootwait quiet @" $GUMMIBOOT_CFGS
320 # if RMC feature presents, append global kernel command line fragment when it exists.
321 if [ -f "${RMC_DB}" ] && [ -f "${RMC_CMD}" ]; then
322 if ${RMC_CMD} -B KBOOTPARAM -d "${RMC_DB}" -o /tmp/kbootparam; then
323 sed -i "/^[ \t]*options/ s/$/ $(cat /tmp/kbootparam)/" $GUMMIBOOT_CFGS
324 rm /tmp/kbootparam
325 fi
326 fi
327fi
328
329cp /run/media/$1/vmlinuz /boot
330
331umount /src_root
332umount /tgt_root
333umount /boot
334
335sync
336
337echo "Remove your installation media, and press ENTER"
338
339read enter
340
341echo "Rebooting..."
342reboot -f