From mboxrd@z Thu Jan 1 00:00:00 1970 X-GM-THRID: 6617812835611181056 X-Received: by 2002:ac8:2e6e:: with SMTP id s43mr1599848qta.38.1540829638395; Mon, 29 Oct 2018 09:13:58 -0700 (PDT) X-BeenThere: isar-users@googlegroups.com Received: by 2002:a37:de11:: with SMTP id h17-v6ls600488qkj.6.gmail; Mon, 29 Oct 2018 09:13:58 -0700 (PDT) X-Google-Smtp-Source: AJdET5dxj+qymodXEK6DtcslDjAMH1sk2xlBlu3DcTaUP/6NSZyJXwzhHeUGbhAnafXRsve/lj+F X-Received: by 2002:a37:aa02:: with SMTP id t2mr9786060qke.47.1540829638118; Mon, 29 Oct 2018 09:13:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1540829638; cv=none; d=google.com; s=arc-20160816; b=05ZNczPvbHh84NXrNtCpz7jTfsAT7YR2Rk6MrSXGgw3Gfj/P4A6KoTMR3/FDex+wFy VgTCp81IyvwCNZrg/r6k151vqTqrBqxDcHyTJ9cwkJDlEG64jXy2NYVG8lQ4pDJVr7U3 p9y1Yj/l+YzTZq5OgdfyaRphSWM8ccmrBlBcFIM+s1Fjqx2gtSC2StiidQ6Emlzm/u5f seCr9k234Cva5XwJ20XFicl5UFu2Aj3N1+vcZjuUpvl9fsDnzm1pGhi7MqyL6tx92Q9H XpenZTcZ6SHhdsvk5QmElFn0nP6P39oS007DgywYpn3zQAzE9aY7a9WVNzeqZ2CNIHqy 5eJA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=mime-version:references:in-reply-to:message-id:date:subject:cc:to :from; bh=KQ1CLbEeXiL11rBsCrPXnAhzq+O1IYQ6PtGUTAqai8M=; b=Pev4t0VpnDgP82kbEgFsz7TFMTOBpkT7YHiwpvgfGJBmhCQuUEgfFKfUL3fmqU71kk X1TpgUI0Ekzl3SLGLuQMHPA2cEyXCyIxOEDqSvFIfxXYPjsBBnhcNYpwg7ML4wsxG9EM IYItEh0QqTguzfwtLZrrPzI7QdCWoi2r49+hdSbsEFQnxamQyA5FFUOdKt4t62q7iWse xIgxbg9L9MWS2mYKxHWSSjymbOPprNwM6tY7OTM2DT7nPo7bKqoQz0ZWwyobMKXXs0dP bmr3mTLfS9Y5Lzehw8fXOhk2w+SPpt75jSiE/oPs3lYGaitzF2wN5Rqm8cXdWf3FdvzZ x7sA== ARC-Authentication-Results: i=1; gmr-mx.google.com; spf=pass (google.com: domain of cedric_hombourger@mentor.com designates 192.94.38.131 as permitted sender) smtp.mailfrom=Cedric_Hombourger@mentor.com Return-Path: Received: from relay1.mentorg.com (relay1.mentorg.com. [192.94.38.131]) by gmr-mx.google.com with ESMTPS id f6-v6si112534qkg.0.2018.10.29.09.13.57 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 29 Oct 2018 09:13:57 -0700 (PDT) Received-SPF: pass (google.com: domain of cedric_hombourger@mentor.com designates 192.94.38.131 as permitted sender) client-ip=192.94.38.131; Authentication-Results: gmr-mx.google.com; spf=pass (google.com: domain of cedric_hombourger@mentor.com designates 192.94.38.131 as permitted sender) smtp.mailfrom=Cedric_Hombourger@mentor.com Received: from nat-ies.mentorg.com ([192.94.31.2] helo=svr-ies-mbx-02.mgc.mentorg.com) by relay1.mentorg.com with esmtps (TLSv1.2:ECDHE-RSA-AES256-SHA384:256) id 1gHAAv-0006QW-3h from Cedric_Hombourger@mentor.com for isar-users@googlegroups.com; Mon, 29 Oct 2018 09:13:57 -0700 Received: from localhost.localdomain (137.202.0.90) by svr-ies-mbx-02.mgc.mentorg.com (139.181.222.2) with Microsoft SMTP Server (TLS) id 15.0.1320.4; Mon, 29 Oct 2018 16:13:53 +0000 From: Cedric Hombourger To: CC: Cedric Hombourger Subject: [PATCH 4/4] isar-image: add support for OE's ROOTFS_*_COMMAND Date: Mon, 29 Oct 2018 17:13:03 +0100 Message-ID: <20181029161303.7410-5-Cedric_Hombourger@mentor.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20181029161303.7410-1-Cedric_Hombourger@mentor.com> References: <20181029161303.7410-1-Cedric_Hombourger@mentor.com> MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [137.202.0.90] X-ClientProxiedBy: SVR-IES-MBX-04.mgc.mentorg.com (139.181.222.4) To svr-ies-mbx-02.mgc.mentorg.com (139.181.222.2) X-TUID: 2/xKACQjx82L OpenEmbedded allows custom functions to be called at various stages of the root file-system generation process. Add similar capabilities to Isar. Signed-off-by: Cedric Hombourger --- doc/user_manual.md | 10 ++++++++++ meta-isar/classes/isar-image.bbclass | 17 +++++++++++++++++ meta/lib/oe/utils.py | 11 +++++++++++ 3 files changed, 38 insertions(+) create mode 100644 meta/lib/oe/utils.py diff --git a/doc/user_manual.md b/doc/user_manual.md index b702c28..0c4ed4a 100644 --- a/doc/user_manual.md +++ b/doc/user_manual.md @@ -527,6 +527,16 @@ was assembled. Isar provides scripts for Debian and Raspbian. In the event where used, your custom image recipe may need to set `DISTRO_CONFIG_SCRIPT` and use `SRC_URI` and `FILESPATH` for the script to be copied into the work directory (`WORKDIR`). +Custom (python) functions may also be called at various steps during the root file-system generation process. They should +be listed in either `ROOTFS_PREPROCESS_COMMAND` for any functions to be called before the root file-system gets populated, +`ROOTFS_POSTINSTALL_COMMAND` for functions to be called right after selected packages were installed and finally +`ROOTFS_POSTPROCESS_COMMAND` after the final configuration script and clean-up tasks were called. Functions listed in these +variables should be separated by a semi-colon sign (;). + +It should also be noted that Isar may no longer execute commands from the created root file-system after it was cleaned-up +(binaries required to support emulation of foreign architectures would have been removed). Please consider this when +designing functions to be called from `ROOTFS_POSTPROCESS_COMMAND`. + --- ## Add a Custom Application diff --git a/meta-isar/classes/isar-image.bbclass b/meta-isar/classes/isar-image.bbclass index e0508be..d5358e0 100644 --- a/meta-isar/classes/isar-image.bbclass +++ b/meta-isar/classes/isar-image.bbclass @@ -64,9 +64,26 @@ isar_image_cleanup() { sudo rm -f "${IMAGE_ROOTFS}/etc/apt/apt.conf.d/55isar-fallback.conf" } +ROOTFS_PREPROCESS_COMMAND ?= "" +ROOTFS_POSTINSTALL_COMMAND ?= "" +ROOTFS_POSTPROCESS_COMMAND ?= "" + python do_rootfs() { + from oe.utils import execute_pre_post_process + bb.build.exec_func("isar_image_gen_fstab", d) + + pre_process_cmds = d.getVar("ROOTFS_PREPROCESS_COMMAND") + execute_pre_post_process(d, pre_process_cmds) + bb.build.exec_func("isar_image_gen_rootfs", d) + + post_install_cmds = d.getVar("ROOTFS_POSTINSTALL_COMMAND") + execute_pre_post_process(d, post_install_cmds) + bb.build.exec_func("isar_image_conf_rootfs", d) bb.build.exec_func("isar_image_cleanup", d) + + post_process_cmds = d.getVar("ROOTFS_POSTPROCESS_COMMAND") + execute_pre_post_process(d, post_process_cmds) } diff --git a/meta/lib/oe/utils.py b/meta/lib/oe/utils.py new file mode 100644 index 0000000..dc3a872 --- /dev/null +++ b/meta/lib/oe/utils.py @@ -0,0 +1,11 @@ +# heavily stripped-down copy of OE's meta/lib/oe/utils.py + +def execute_pre_post_process(d, cmds): + if cmds is None: + return + + for cmd in cmds.strip().split(';'): + cmd = cmd.strip() + if cmd != '': + bb.note("Executing %s ..." % cmd) + bb.build.exec_func(cmd, d) -- 2.11.0