Skip to content

Commit f061a58

Browse files
committed
Create source package information file
Add source-info.bbclass to create a JSON file which contains source package information. This JSON file contains the following attributes: - source_package_name - source_from The source_package_name attribute is automatically set from the ${PN} variable. The source_from attribute is read from the ${EMLINUX_SOURCE_FROM} variable, which should be defined in your recipe. For example, if the source code is not a Debian source package, set it to "non-debian": ``` EMLINUX_SOURCE_FROM="non-debian" ``` Another example: if the DISTRO variable is "emlinux-bookworm" and the source code is fetched from Debian Trixie, define the EMLINUX_SOURCE_FROM variable like this: ``` EMLINUX_SOURCE_FROM="trixie" ``` The source package information JSON file looks like the following format: ``` "emlinux-customization": { "source_package_name": "emlinux-customization", "source_from": "non-debian", } ``` This JSON file is stored in the build/tmp/deploy/images/<MACHINE>/ directory. The file name is all-source-info.json. Signed-off-by: Masami Ichikawa <masami.ichikawa@miraclelinux.com>
1 parent c13bb98 commit f061a58

File tree

4 files changed

+56
-3
lines changed

4 files changed

+56
-3
lines changed

classes/source-info.bbclass

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
2+
python do_collect_source_info() {
3+
import json
4+
5+
log_file = f"{d.getVar('T')}/source-info.json"
6+
7+
source_info = d.getVar("EMLINUX_SOURCE_FROM")
8+
if source_info is None:
9+
distro = d.getVar("DISTRO").split("-")[1]
10+
source_info = distro
11+
12+
data = {
13+
"source_package_name": d.getVar("PN"),
14+
"source_from": source_info,
15+
}
16+
17+
with open(log_file, "w") as f:
18+
json.dump(data, f, indent=4)
19+
}
20+
21+
python do_merge_source_info() {
22+
import glob
23+
import json
24+
25+
distro = d.getVar("DISTRO")
26+
distro_arch = d.getVar("DISTRO_ARCH")
27+
28+
tmpdir = d.getVar("TMPDIR")
29+
30+
basepath = f"{tmpdir}/work/{distro}-{distro_arch}"
31+
search_path = f"{basepath}/*/*/temp/source-info.json"
32+
33+
source_info = {}
34+
35+
for file in glob.glob(search_path):
36+
with open(file) as f:
37+
data = json.load(f)
38+
pkg = data["source_package_name"]
39+
source_info[pkg] = data
40+
41+
source_info = dict(sorted(source_info.items(), key=lambda x: x[0], reverse=False))
42+
43+
source_info_file = d.getVar("DEPLOY_DIR_IMAGE") + "/all-source-info.json"
44+
45+
with open(source_info_file, "w") as f:
46+
json.dump(source_info, f, indent=4)
47+
48+
}
49+
50+
addtask collect_source_info after do_dpkg_source before do_dpkg_build
51+
addtask merge_source_info after do_image before do_deploy

conf/distro/emlinux-common.inc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111

1212
require include/security_flags.inc
1313

14-
INHERIT += "sdk-installer"
14+
INHERIT += "sdk-installer source-info"
1515

1616
DISTRO_KERNELS ?= "linux-cip"
1717
KERNEL_NAME ?= "cip"

recipes-core/emlinux-customization/emlinux-customization.bb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,9 @@
1010
#
1111
FILESEXTRAPATHS:prepend := "${FILE_DIRNAME}/files:"
1212

13+
EMLINUX_SOURCE_FROM="non-debian"
1314
DESCRIPTION = "EMLinux 3.x specific customization"
14-
15+
LICENSE = "MIT"
1516
DEBIAN_DEPENDS = "netbase"
1617

1718
inherit dpkg-raw
@@ -26,4 +27,3 @@ do_install:append() {
2627
echo "PS1=\"${EMLINUX_ENVIRONMENT_VARIABLE_PS1}\"" > "${D}/etc/profile.d/ps1.sh"
2728
fi
2829
}
29-

recipes-kernel/linux/includes/linux-cip-common.inc

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,3 +17,5 @@ SRC_URI[sha256sum] = "1caa1b8e24bcfdd55c3cffd8f147f3d33282312989d85c82fc1bc39b80
1717
KBUILD_DEPENDS:append = ", zstd"
1818

1919
LIBSSL_DEP:armhf:trixie = "libssl3t64"
20+
21+
EMLINUX_SOURCE_FROM="non-debian"

0 commit comments

Comments
 (0)