Re: [OE-core] [PATCH 2/3] initramfs-framework: include install-efi module in recipe for installation

2017-07-31 Thread Patrick Ohly
On Sun, 2017-07-23 at 16:51 -0700, wei.tee...@intel.com wrote:
> +
> +SUMMARY_initramfs-module-install-efi = "initramfs support for installation 
> option"
> +RDEPENDS_initramfs-module-install-efi = "${PN}-base parted e2fsprogs-mke2fs 
> dosfstools util-linux-blkid"
> +FILES_initramfs-module-install-efi = "/init.d/install-efi.sh"

By making the install-efi module a part of initramfs-module that is
enabled unconditionally, parted now needs to be built for the target
even when only the rest of initramfs-module is used.

Can the module please be split out into its own recipe?

Alternatively one could add a PACKAGECONFIG for it, but that's less
flexible.

-- 
Best Regards, Patrick Ohly

The content of this message is my personal opinion only and although
I am an employee of Intel, the statements I make here in no way
represent Intel's position on the issue, nor am I authorized to speak
on behalf of Intel on this matter.


-- 
___
Openembedded-core mailing list
Openembedded-core@lists.openembedded.org
http://lists.openembedded.org/mailman/listinfo/openembedded-core


[OE-core] [PATCH 2/3] initramfs-framework: include install-efi module in recipe for installation

2017-07-24 Thread wei . tee . ng
From: "Ng, Wei Tee" 

Utilized the existing init-install-efi.sh script and renamed it to
install-efi.sh to manage the installation process of images in
initramfs-framework model. This script will be executed when
"install" option is being chosen in the grub menu and install
the image on the target platform. A new install-efi module is
being added in the recipe to handle the installation process
using initramfs-framework.

[YOCTO #10989]

Signed-off-by: Ng, Wei Tee 
---
This version solve the failure of the oe-selftest which is related to the 
allarch issues.

 .../initramfs-framework/install-efi.sh | 276 +
 .../initrdscripts/initramfs-framework_1.0.bb   |  19 +-
 2 files changed, 292 insertions(+), 3 deletions(-)
 create mode 100644 
meta/recipes-core/initrdscripts/initramfs-framework/install-efi.sh

diff --git a/meta/recipes-core/initrdscripts/initramfs-framework/install-efi.sh 
b/meta/recipes-core/initrdscripts/initramfs-framework/install-efi.sh
new file mode 100644
index 000..5ad3a60
--- /dev/null
+++ b/meta/recipes-core/initrdscripts/initramfs-framework/install-efi.sh
@@ -0,0 +1,276 @@
+#!/bin/sh -e
+#
+# Copyright (c) 2012, Intel Corporation.
+# All rights reserved.
+#
+# install.sh [device_name] [rootfs_name]
+#
+
+PATH=/sbin:/bin:/usr/sbin:/usr/bin
+
+# We need 20 Mb for the boot partition
+boot_size=20
+
+# 5% for swap
+swap_ratio=5
+
+# Get a list of hard drives
+hdnamelist=""
+live_dev_name=`cat /proc/mounts | grep ${1%/} | awk '{print $1}'`
+live_dev_name=${live_dev_name#\/dev/}
+# Only strip the digit identifier if the device is not an mmc
+case $live_dev_name in
+mmcblk*)
+;;
+nvme*)
+;;
+*)
+live_dev_name=${live_dev_name%%[0-9]*}
+;;
+esac
+
+echo "Searching for hard drives ..."
+
+# Some eMMC devices have special sub devices such as mmcblk0boot0 etc
+# we're currently only interested in the root device so pick them wisely
+devices=`ls /sys/block/ | grep -v mmcblk` || true
+mmc_devices=`ls /sys/block/ | grep "mmcblk[0-9]\{1,\}$"` || true
+devices="$devices $mmc_devices"
+
+for device in $devices; do
+case $device in
+loop*)
+# skip loop device
+;;
+sr*)
+# skip CDROM device
+;;
+ram*)
+# skip ram device
+;;
+*)
+# skip the device LiveOS is on
+# Add valid hard drive name to the list
+case $device in
+$live_dev_name*)
+# skip the device we are running from
+;;
+*)
+hdnamelist="$hdnamelist $device"
+;;
+esac
+;;
+esac
+done
+
+if [ -z "${hdnamelist}" ]; then
+echo "You need another device (besides the live device 
/dev/${live_dev_name}) to install the image. Installation aborted."
+exit 1
+fi
+
+TARGET_DEVICE_NAME=""
+for hdname in $hdnamelist; do
+# Display found hard drives and their basic info
+echo "---"
+echo /dev/$hdname
+if [ -r /sys/block/$hdname/device/vendor ]; then
+echo -n "VENDOR="
+cat /sys/block/$hdname/device/vendor
+fi
+if [ -r /sys/block/$hdname/device/model ]; then
+echo -n "MODEL="
+cat /sys/block/$hdname/device/model
+fi
+if [ -r /sys/block/$hdname/device/uevent ]; then
+echo -n "UEVENT="
+cat /sys/block/$hdname/device/uevent
+fi
+echo
+done
+
+# Get user choice
+while true; do
+echo "Please select an install target or press n to exit ($hdnamelist ): "
+read answer
+if [ "$answer" = "n" ]; then
+echo "Installation manually aborted."
+exit 1
+fi
+for hdname in $hdnamelist; do
+if [ "$answer" = "$hdname" ]; then
+TARGET_DEVICE_NAME=$answer
+break
+fi
+done
+if [ -n "$TARGET_DEVICE_NAME" ]; then
+break
+fi
+done
+
+if [ -n "$TARGET_DEVICE_NAME" ]; then
+echo "Installing image on /dev/$TARGET_DEVICE_NAME ..."
+else
+echo "No hard drive selected. Installation aborted."
+exit 1
+fi
+
+device=/dev/$TARGET_DEVICE_NAME
+
+#
+# The udev automounter can cause pain here, kill it
+#
+rm -f /etc/udev/rules.d/automount.rules
+rm -f /etc/udev/scripts/mount*
+
+#
+# Unmount anything the automounter had mounted
+#
+umount ${device}* 2> /dev/null || /bin/true
+
+mkdir -p /tmp
+
+# Create /etc/mtab if not present
+if [ ! -e /etc/mtab ] && [ -e /proc/mounts ]; then
+ln -sf /proc/mounts /etc/mtab
+fi
+
+disk_size=$(parted ${device} unit mb print | grep '^Disk .*: .*MB' | cut -d" " 
-f 3 | sed -e "s/MB//")
+
+swap_size=$((disk_size*swap_ratio/100))
+rootfs_size=$((disk_size-boot_size-swap_size))
+
+rootfs_start=$((boot_size))
+rootfs_end=$((rootfs_start+rootfs_size))
+swap_start=$((rootfs_end))
+
+# MMC devices are special in a couple of ways
+# 1) they use a partition prefix