packagegroup-agl-core-boot: add package distro-build-manifest 23/16723/9
authorStephane Desneux <stephane.desneux@iot.bzh>
Fri, 21 Sep 2018 11:24:25 +0000 (11:24 +0000)
committerStéphane Desneux <stephane.desneux@iot.bzh>
Wed, 3 Oct 2018 20:07:14 +0000 (20:07 +0000)
the purpose of distro-build-manifest is to generate and distribute a
unique build manifest for a given AGL image.

The recipe will generate the build manifest 'platform-build-info' at
each build (no caching) and this manifest is then stored in 2 locations:
 * image: in /etc/platform-build-info
 * deploy dir

Bug-AGL: SPEC-720, SPEC-1741

Change-Id: I934acc87e13d2f6ec867684af515b89a89a89338
Signed-off-by: Stephane Desneux <stephane.desneux@iot.bzh>
meta-agl-profile-core/recipes-core/distro-build-manifest/distro-build-manifest.bb [new file with mode: 0644]
meta-agl-profile-core/recipes-platform/packagegroups/packagegroup-agl-core-boot.bb

diff --git a/meta-agl-profile-core/recipes-core/distro-build-manifest/distro-build-manifest.bb b/meta-agl-profile-core/recipes-core/distro-build-manifest/distro-build-manifest.bb
new file mode 100644 (file)
index 0000000..c048f47
--- /dev/null
@@ -0,0 +1,81 @@
+SUMMARY = "Distribution build manifest"
+DESCRIPTION = "The /etc/platform-build-info file contains build manifest (SPEC-720)."
+LICENSE = "MIT"
+
+# dependencies of ${DISTRO_MANIFEST_GENERATOR}
+DEPENDS = "coreutils-native bash-native git-native gawk-native sed-native"
+
+inherit allarch
+
+# force a rebuild everytime a build is started
+do_compile[nostamp] = "1"
+
+do_compilestep1 () {
+    outfile=${B}/platform-build-info
+    if [ -f "${DISTRO_MANIFEST_GENERATOR}" -a -f "${DISTRO_SETUP_MANIFEST}" ]; then
+        ${DISTRO_MANIFEST_GENERATOR} ${DISTRO_SETUP_MANIFEST} >$outfile
+    else
+        echo "# unable to generate build manifest - please check recipe distro-build-manifest" >$outfile
+    fi
+}
+
+# borrowed to os-release.bb (output format is very close)
+python do_compilestep2 () {
+   import shutil
+   with open(d.expand('${B}/platform-build-info'),'a') as f:
+      for field in d.getVar('BUILD_MANIFEST_FIELDS').split():
+         value=d.getVar(field)
+         if value:
+            f.write('DIST_BB_{0}="{1}"\n'.format(field,value))
+}
+do_compilestep2[vardeps] += "${BUILD_MANIFEST_FIELDS}"
+
+# combine the two steps
+python do_compile() {
+   bb.build.exec_func("do_compilestep1",d)
+   bb.build.exec_func("do_compilestep2",d)
+}
+
+do_install () {
+    install -d ${D}${sysconfdir}
+    install -m 0644 platform-build-info ${D}${sysconfdir}/
+
+    # also copy in deploy dir
+    install -d ${DEPLOY_DIR_IMAGE}
+    install -m 0644 platform-build-info ${DEPLOY_DIR_IMAGE}/
+}
+
+
+# list of variables to add to the manifest
+BUILD_MANIFEST_FIELDS = "\
+    MACHINE_ARCH \
+    MACHINEOVERRIDES \
+    MACHINE_FEATURES \
+    DISTRO \
+    DISTRO_NAME \
+    DISTRO_CODENAME \
+    DISTRO_VERSION \
+    DISTRO_FEATURES \
+    DISTROOVERRIDES \
+    DISTRO_BRANCH_VERSION_TAG \
+    AGLVERSION \
+    AGL_BRANCH \
+    AGLRELEASETYPE \
+    HOST_SYS \
+    TARGET_SYS \
+    TARGET_VENDOR \
+    TUNE_FEATURES \
+    TUNE_PKGARCH \
+    ALL_MULTILIB_PACKAGE_ARCHS \
+    SDK_ARCH \
+    SDK_VENDOR \
+    SDK_VERSION \
+    SDK_OS \
+"
+
+# remove useless tasks
+deltask do_fetch
+deltask do_unpack
+deltask do_patch
+deltask do_configure
+
index 1633fed..690dc9e 100644 (file)
@@ -34,6 +34,7 @@ RDEPENDS_${PN} = "\
     base-files \
     base-passwd \
     busybox \
+    distro-build-manifest \
     rng-tools \
     run-agl-postinsts \
     ${@bb.utils.contains("DISTRO_FEATURES", "sysvinit", "${SYSVINIT_SCRIPTS}", "", d)} \