Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
meta/classes/image: implement ROOTFS_POSTPROCESS_COMMAND
Signed-off-by: Claudius Heine <ch@denx.de>
- Loading branch information
Showing
3 changed files
with
112 additions
and
68 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
# This software is a part of ISAR. | ||
# Copyright (C) Siemens AG, 2019 | ||
|
||
update_etc_os_release() { | ||
OS_RELEASE_BUILD_ID="" | ||
OS_RELEASE_VARIANT="" | ||
while true; do | ||
case "$1" in | ||
--build-id) OS_RELEASE_BUILD_ID=$2; shift ;; | ||
--variant) OS_RELEASE_VARIANT=$2; shift ;; | ||
-*) bbfatal "$0: invalid option specified: $1" ;; | ||
*) break ;; | ||
esac | ||
shift | ||
done | ||
|
||
if [ -n "${OS_RELEASE_BUILD_ID}" ]; then | ||
sudo sed -i '/^BUILD_ID=.*/d' '${IMAGE_ROOTFS}/etc/os-release' | ||
echo "BUILD_ID=\"${OS_RELEASE_BUILD_ID}\"" | \ | ||
sudo tee -a '${IMAGE_ROOTFS}/etc/os-release' | ||
fi | ||
if [ -n "${OS_RELEASE_VARIANT}" ]; then | ||
sudo sed -i '/^VARIANT=.*/d' '${IMAGE_ROOTFS}/etc/os-release' | ||
echo "VARIANT=\"${OS_RELEASE_VARIANT}\"" | \ | ||
sudo tee -a '${IMAGE_ROOTFS}/etc/os-release' | ||
fi | ||
} | ||
|
||
ROOTFS_POSTPROCESS_COMMAND =+ "image_postprocess_configure image_postprocess_mark" | ||
|
||
image_postprocess_configure() { | ||
# Configure root filesystem | ||
if [ -n "${DISTRO_CONFIG_SCRIPT}" ]; then | ||
sudo install -m 755 "${WORKDIR}/${DISTRO_CONFIG_SCRIPT}" "${IMAGE_ROOTFS}" | ||
TARGET_DISTRO_CONFIG_SCRIPT="$(basename ${DISTRO_CONFIG_SCRIPT})" | ||
sudo chroot ${IMAGE_ROOTFS} "/$TARGET_DISTRO_CONFIG_SCRIPT" \ | ||
"${MACHINE_SERIAL}" "${BAUDRATE_TTY}" | ||
sudo rm "${IMAGE_ROOTFS}/$TARGET_DISTRO_CONFIG_SCRIPT" | ||
fi | ||
} | ||
|
||
image_postprocess_mark() { | ||
BUILD_ID=$(get_build_id) | ||
update_etc_os_release \ | ||
--build-id "${BUILD_ID}" --variant "${DESCRIPTION}" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
# This software is a part of ISAR. | ||
# Copyright (c) Siemens AG, 2019 | ||
|
||
# Features of the rootfs creation: | ||
# available features are: | ||
# 'finalize-rootfs' - delete files needed to chroot into the rootfs | ||
ROOTFS_FEATURES ?= "" | ||
|
||
ROOTFS_POSTPROCESS_COMMAND += "${@bb.utils.contains('ROOTFS_FEATURES', 'finalize-rootfs', 'rootfs_postprocess_finalize', '', d)}" | ||
rootfs_postprocess_finalize() { | ||
sudo -s <<'EOSUDO' | ||
test ! -e "${ROOTFSDIR}/usr/share/doc/qemu-user-static" && \ | ||
find "${ROOTFSDIR}/usr/bin" \ | ||
-maxdepth 1 -name 'qemu-*-static' -type f -delete | ||
|
||
mountpoint -q '${ROOTFSDIR}/isar-apt' && \ | ||
umount -l ${ROOTFSDIR}/isar-apt | ||
rmdir --ignore-fail-on-non-empty ${ROOTFSDIR}/isar-apt | ||
|
||
mountpoint -q '${ROOTFSDIR}/base-apt' && \ | ||
umount -l ${ROOTFSDIR}/base-apt | ||
rmdir --ignore-fail-on-non-empty ${ROOTFSDIR}/base-apt | ||
|
||
mountpoint -q '${ROOTFSDIR}/dev' && \ | ||
umount -l ${ROOTFSDIR}/dev | ||
mountpoint -q '${ROOTFSDIR}/sys' && \ | ||
umount -l ${ROOTFSDIR}/proc | ||
mountpoint -q '${ROOTFSDIR}/sys' && \ | ||
umount -l ${ROOTFSDIR}/sys | ||
|
||
rm -f "${ROOTFSDIR}/etc/apt/apt.conf.d/55isar-fallback.conf" | ||
|
||
rm -f "${ROOTFSDIR}/etc/apt/sources.list.d/isar-apt.list" | ||
rm -f "${ROOTFSDIR}/etc/apt/sources.list.d/base-apt.list" | ||
|
||
mv "${ROOTFSDIR}/etc/apt/sources-list" \ | ||
"${ROOTFSDIR}/etc/apt/sources.list.d/bootstrap.list" | ||
|
||
rm -f "${ROOTFSDIR}/etc/apt/sources-list" | ||
EOSUDO | ||
} | ||
|
||
do_rootfs_postprocess[vardeps] = "${ROOTFS_POSTPROCESS_COMMAND}" | ||
python do_rootfs_postprocess() { | ||
cmds = d.getVar("ROOTFS_POSTPROCESS_COMMAND") | ||
if cmds is None or not cmds.strip(): | ||
return | ||
cmds = cmds.split() | ||
for cmd in cmds: | ||
bb.build.exec_func(cmd, d) | ||
} | ||
addtask rootfs_postprocess before do_rootfs after do_rootfs_install | ||
|
||
python do_rootfs() { | ||
"""Virtual task""" | ||
pass | ||
} | ||
addtask rootfs before do_build |