Skip to content
Snippets Groups Projects
Commit adcb566c authored by Jonas Höppner's avatar Jonas Höppner
Browse files

fnginstall: add postinstallation step and use it for kernel/dtb blob creation

* Remove the kernel/dtb creation and platform detection from fnginstall
* Added a target_os_postinstallation step to execute an command
  (specified by dedicated name) inside the target os via change root
  ** like user script
  ** only if the command is available
  ** this way the installation script stays generic
* Added a post installation command to the image to detect the platform
  and create the kernel/dtb blob, this should later also integrate the
  config via xml to devicetree stuff
* Moved fnginstall and fnginstall-postinstallation to
  packagegroup-core-boot using the 'fng' machine feature: This way
  the fng stuff lives in the distro layer but is enabled machine
  dependend, without adding direct dependency between the layers
parent 1fc95ae3
No related branches found
No related tags found
1 merge request!4fnginstall: add postinstallation step and use it for kernel/dtb blob creation
......@@ -403,7 +403,7 @@ while [ $# -gt 0 ]; do
exit 1
fi
;;
-l=*|--logfile=*)
-l=*|--logfile=*)
LOGFILE="${1#*=}"
;;
-l=|--logfile=) # Handle the case of an empty --logfile=
......@@ -633,21 +633,7 @@ check_startup_conditions()
# Exit if the FNGSystem version does not match
check_fng_system_version
# Determine platform in order to choose devicetree
BOARD=$( grep -E '^Hardware\s+:' /proc/cpuinfo | awk '{print tolower($6)}')
case $( grep -E '^Revision\s+:' /proc/cpuinfo | awk '{print $3}') in
61*)
CPU="imx6dl";;
6301*)
CPU="imx6q";;
6302*)
CPU="imx6qp";;
*)
echo "CPU type not supported"
exit 1
esac
PLATFORM="${CPU}-${BOARD}"
}
#===========================================================
......@@ -890,6 +876,42 @@ run_postinstall_scripts()
sync
}
#=========================================
# Executes 'postinstall' script if it exists
# in the rootfs
#=========================================
target_os_postinstall()
{
ret=0
mounttarget
TARGET_POSTINSTALL_SCRIPT="$( find "${TARGETROOT}"/usr/local/sbin "${TARGETROOT}"/usr/local/bin \
"${TARGETROOT}"/usr/sbin "${TARGETROOT}"/usr/bin \
"${TARGETROOT}"/sbin "${TARGETROOT}"/bin \
type f -name fnginstall-postinstallation 2>/dev/null | head -n 1 )"
if [ ! -z "$TARGET_POSTINSTALL_SCRIPT" ]
then
( # subshell to preserve current directory
TARGET_POSTINSTALL_SCRIPT="${TARGET_POSTINSTALL_SCRIPT##$TARGETROOT}"
milestone "Executing postinstall step $TARGET_POSTINSTALL_SCRIPT in target OS"
cd $ABSTARGETTMP
if chroot "${TARGETROOT}" "$TARGET_POSTINSTALL_SCRIPT"
then
milestone "Executing postinstall step done."
else
error_msg "Executing postinstall $TARGET_POSTINSTALL_SCRIPT step failed."
return 1
fi
return 0
)
ret=$?
fi
unmounttarget
unmountall
sync
return $ret
}
#=========================================
# Executes 'user' install script given with
# -s|--UserScript after change root in
......@@ -1038,7 +1060,7 @@ verify_file_access()
then
error_text
error_msg " Download from \"${CURL_PREFIX}/${ROOTFS}\" failed."
error_text
error_text
if [ -z "$TFTP" ]
then
......@@ -1318,22 +1340,6 @@ load_and_write_files()
mount /dev/mmcblk0p2 "${TMP_MOUNT_POINT}"/boot
load_and_untar "${ROOTFS}" "${TMP_MOUNT_POINT}"
for dtb in "${TMP_MOUNT_POINT}/"boot/*.dtb ; do
if string_ends_with "$(basename "$dtb")" "${PLATFORM}.dtb"
then
DTB="${dtb}"
fi
done
if [ -z "${DTB}" ]; then
echo "No devicetree given for platform ${PLATFORM}"
exit 1
fi
cp "${DTB}" "${TMP_MOUNT_POINT}/boot/devicetree.dtb"
# In dunfell we currently use the feature to load the devicetree directly
# after the kernel in the memory
# This is done by concat both files to one for now
cat "${TMP_MOUNT_POINT}"/boot/uImage* "${TMP_MOUNT_POINT}"/boot/devicetree.dtb > "${TMP_MOUNT_POINT}"/boot/linuximage
umount "${TMP_MOUNT_POINT}/boot"
umount "${TMP_MOUNT_POINT}"
......@@ -1421,7 +1427,7 @@ load_and_write_files()
# Rename the boot.cfg as we renamed it during the update
sed -i "s/ .*boot.cfg/ boot.cfg/" "$MD5FILE"
mv "$MD5FILE" "$MD5FILETMP"
# Start with an empty file and leave only entries for existing files
rm -f "$MD5FILE"
find "${TMP_MOUNT_POINT}" -type f | while read -r i
......@@ -1452,32 +1458,35 @@ do_update()
set -e;
# Execute Preinstall Scripts, if any
run_preinstall_scripts "$PreInstallScript"
run_preinstall_scripts "$PreInstallScript" || return $?
# Create new partition table
create_partitions
create_partitions || return $?
# Format the new partitions
format_partitions
format_partitions || return $?
# Write mandatory file (rootfs, kernel, devicetree )
load_and_write_files
load_and_write_files || return $?
# Optionally install RPM files
rpm_install "$RPM"
rpm_install "$RPM" || return $?
# Optionally erase RPM files
rpm_erase "$ERASERPM"
rpm_erase "$ERASERPM" || return $?
# Optionally install 'TFTP' files
tftp_install "$TFTPFILES"
tftp_install "$TFTPFILES" || return $?
# Optionally execute user install scripts
user_install "$USERSCRIPT"
user_install "$USERSCRIPT" || return $?
# Call postinstall in target os if it exists
# In dunfell this combines kernel and devicetree
target_os_postinstall || return $?
# Execute some tests to make sure the target partitions are there and good
postinstallation_tests
postinstallation_tests || return $?
# Execute Postinstall Scripts, if any
run_postinstall_scripts "$PostInstallScript"
run_postinstall_scripts "$PostInstallScript" || return $?
set +e;
)
......
#!/bin/sh
#
# This script is supposed to run once during the installation, called directly
# from the install script in a change root from FNG System
#
# All nessary steps should be included here
# Create linuiximage from kernel, devicetree
guf-prepare-kernel.sh
#!/bin/sh
#
# Helper script to select the used base kernel and base devicetree
# and combine those together to linux image
# In dunfell we currently use the feature to load the devicetree directly
# after the kernel in the memory by concat both files
KERNEL_FILE=$1
DEVICETREE_FILE=$2
# Make sure we have access to the bootpartition
BOOTPARTITION=/dev/mmcblk0p2
MOUNTPOINT=/boot
#========================================================
# helper functions
#========================================================
string_contains()
{
case "$1" in
*$2*) return 0
esac
return 1
}
string_ends_with()
{
case "$1" in
*$2) return 0
esac
return 1
}
get_platform()
{
# Determine platform in order to choose devicetree
BOARD=$( grep -E '^Hardware\s+:' /proc/cpuinfo | awk '{print tolower($6)}')
case $( grep -E '^Revision\s+:' /proc/cpuinfo | awk '{print $3}') in
61*)
CPU="imx6dl";;
6301*)
CPU="imx6q";;
6302*)
CPU="imx6qp";;
*)
echo "CPU type not supported"
exit 1
esac
echo "${CPU}-${BOARD}"
}
#========================================================
#========================================================
# Currently the mmc is called mmcblk1 in dunfell
# TODO allow other boot partitions for A-B boot scheme
if [ ! -b "$BOOTPARTITION" ]
then
BOOTPARTITION=/dev/mmcblk1p2
if [ ! -b "$BOOTPARTITION" ]
then
echo "Failed to detect bootpartition"
fi
fi
if ! mount | grep -q "^$BOOTPARTITION\>"
then
# Make sure the mount point is there
mkdir -p $MOUNTPOINT
# Make sure nothing is mounted there
if mount | grep -q "\<$MOUNTPOINT\>"
then
echo "Mountpoint $BOOTPARTITION already in used."
exit 1
fi
mount $BOOTPARTITION $MOUNTPOINT
MOUNTED=true
else
MOUNTPOINT="$( mount | grep "^$BOOTPARTITION\>" | awk '{print $3}' )"
MOUNTED=false
fi
if [ -z "$KERNEL_FILE" ]
then
# Read default kernel file from boot partitione
if [ -r "$MOUNTPOINT"/kernel ]
then
KERNEL_FILE="$( head -n 1 "$MOUNTPOINT"/kernel )"
else
# Mark the currently installed kernel as selected:
# (we are on fat, so we use a textfile instead of links):
KERNEL_FILE="$( find "$MOUNTPOINT" -maxdepth 1 -name "uImage*" -exec basename {} \; | head -n 1 )"
if [ -z "$KERNEL_FILE" ]
then
echo "Failed to determine the kernel file to use."
exit 1
fi
fi
fi
if [ ! -e "$MOUNTPOINT/$KERNEL_FILE" ]
then
echo "Default kernel specified ($KERNEL_FILE) not found."
echo "Please select one as parameter."
exit 1
fi
if [ -z "$DEVICETREE_FILE" ]
then
# Read default devicetree file from boot partitione
if [ -r "$MOUNTPOINT"/devicetree ]
then
DEVICETREE_FILE="$( head -n 1 "$MOUNTPOINT"/devicetree )"
else
PLATFORM="$( get_platform )"
for dtb in "$MOUNTPOINT/"*.dtb ; do
if string_ends_with "$dtb" "$PLATFORM.dtb"
then
DEVICETREE_FILE="$(basename "$dtb")"
fi
done
if [ -z "$DEVICETREE_FILE" ]; then
echo "No devicetree found for: $PLATFORM"
exit 1
fi
fi
fi
if [ ! -e "$MOUNTPOINT/$DEVICETREE_FILE" ]
then
echo "Default devicetree specified ($DEVICETREE_FILE) not found."
echo "Please select one as parameter."
exit 1
fi
# Mark the currently selected devicetree as the one
# (we are on fat, so we use a textfile instead of links):
echo "${DEVICETREE_FILE}" > "${MOUNTPOINT}/devicetree"
# Store default kernel file for later usage
echo "$KERNEL_FILE" > "$MOUNTPOINT"/kernel
# Combine both to one file called linuximage
cat "$MOUNTPOINT/$KERNEL_FILE" "$MOUNTPOINT/$DEVICETREE_FILE" > "$MOUNTPOINT"/linuximage
# Store the selected kernel
echo "$KERNEL_FILE" > "$MOUNTPOINT"/kernel
echo "$DEVICETREE_FILE" > "$MOUNTPOINT"/devicetree
sync
if $MOUNTED
then
umount "$MOUNTPOINT"
fi
exit 0
# vim: tabstop=4 expandtab shiftwidth=4 softtabstop=4
SUMMARY = "Garz & Fricke post install script to be called from Flash-N-Go System"
require conf/guf-recipe.inc
S = "${WORKDIR}"
SRC_URI = " \
file://guf-prepare-kernel.sh \
file://fnginstall-postinstallation \
"
do_install () {
install -d ${D}${bindir}
install -m 0755 fnginstall-postinstallation ${D}${bindir}
install -m 0755 guf-prepare-kernel.sh ${D}${bindir}
}
......@@ -10,6 +10,14 @@ inherit core-image features_check extrausers
REQUIRED_DISTRO_FEATURES = "wayland"
# ----------------------------------------------
# The following packages are included implicitly
# ----------------------------------------------
# bootscript -> machine
# fng-install
# fng-install-postinstallation
# ----------------------------------------------
IMAGE_FEATURES += " \
hwcodecs \
package-management \
......@@ -35,7 +43,6 @@ IMAGE_INSTALL_GRAPHICS += " \
"
IMAGE_INSTALL_GUF += " \
bootscript \
"
IMAGE_INSTALL_MULTIMEDIA += " \
......
# Use this append for all images in the guf -distro, not in fngsystem
RDEPENDS_${PN}_append = " \
fng-install \
fng-install-postinstallation \
"
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment