distro-build-manifest: Improve diagnostic messages
[AGL/meta-agl.git] / meta-agl-profile-core / recipes-core / distro-build-manifest / distro-build-manifest.bb
1 SUMMARY = "Distribution build manifest"
2 DESCRIPTION = "The /etc/platform-build-info file contains build manifest (SPEC-720)."
3 LICENSE = "MIT"
4
5 # information distributed by the package is machine specific
6 PACKAGE_ARCH = "${MACHINE_ARCH}"
7
8 # dependencies of ${DISTRO_MANIFEST_GENERATOR}
9 DEPENDS = "coreutils-native bash-native git-native gawk-native sed-native"
10
11 # force a rebuild everytime a build is started
12 do_compile[nostamp] = "1"
13
14 do_compilestep1 () {
15     rc=99
16     outfile=${B}/platform-build-info
17     if [ -x "${DISTRO_MANIFEST_GENERATOR}" -a -f "${DISTRO_SETUP_MANIFEST}" ]; then
18         ${DISTRO_MANIFEST_GENERATOR} ${DISTRO_SETUP_MANIFEST} deploy >${outfile}-deploy
19         rc1=$?
20         ${DISTRO_MANIFEST_GENERATOR} ${DISTRO_SETUP_MANIFEST} target >${outfile}-target
21         rc2=$?
22         ${DISTRO_MANIFEST_GENERATOR} ${DISTRO_SETUP_MANIFEST} sdk >${outfile}-sdk
23         rc=$?
24
25         if [ "$rc1" -ne 0 -o "$rc2" -ne 0 -o "$rc3" -ne 0 ]; then
26             rc=98
27         fi
28     else
29         if [ -z "${DISTRO_MANIFEST_GENERATOR}" ]; then
30             echo "The name of the generation script is not defined."
31         elif [ ! -f "${DISTRO_MANIFEST_GENERATOR}" ]; then
32             echo "Generation script ${DISTRO_MANIFEST_GENERATOR} is missing."
33         elif [ ! -x "${DISTRO_MANIFEST_GENERATOR}" ]; then
34             echo "Generation script ${DISTRO_MANIFEST_GENERATOR} isn't executable."
35         fi
36         if [ -z "${DISTRO_SETUP_MANIFEST}" ]; then
37             echo "The name of the data file is not defined."
38         elif [ ! -f "${DISTRO_SETUP_MANIFEST}" ]; then
39             echo "Data file ${DISTRO_SETUP_MANIFEST} is missing."
40         fi
41         echo "You can try to rerun aglsetup.sh to solve that issue."
42         echo "You can also try to source agl-init-build-env instead of oe-init-build-env."
43     fi
44
45     if [ "$rc" -ne  0 ]; then
46         echo "distro-build-manifest generation failed."
47     fi
48     return $rc
49 }
50
51 # borrowed to os-release.bb (output format is very close)
52 python do_compilestep2 () {
53    import shutil
54    with open(d.expand('${B}/platform-build-info-deploy'),'a') as f:
55       for field in d.getVar('BUILD_MANIFEST_FIELDS_DEPLOY').split():
56          value=d.getVar(field)
57          if value:
58             f.write('DIST_BB_{0}="{1}"\n'.format(field,value))
59
60    with open(d.expand('${B}/platform-build-info-target'),'a') as f:
61       for field in d.getVar('BUILD_MANIFEST_FIELDS_TARGET').split():
62          value=d.getVar(field)
63          if value:
64             f.write('DIST_BB_{0}="{1}"\n'.format(field,value))
65
66    with open(d.expand('${B}/platform-build-info-sdk'),'a') as f:
67       for field in d.getVar('BUILD_MANIFEST_FIELDS_SDK').split():
68          value=d.getVar(field)
69          if value:
70             f.write('DIST_BB_{0}="{1}"\n'.format(field,value))
71 }
72 do_compilestep2[vardeps] += " ${BUILD_MANIFEST_FIELDS_DEPLOY}"
73 do_compilestep2[vardeps] += " ${BUILD_MANIFEST_FIELDS_TARGET}"
74 do_compilestep2[vardeps] += " ${BUILD_MANIFEST_FIELDS_SDK}"
75
76 # combine the two steps
77 python do_compile() {
78    bb.build.exec_func("do_compilestep1",d)
79    bb.build.exec_func("do_compilestep2",d)
80 }
81
82 do_install () {
83     # install in target dir
84     install -d ${D}${sysconfdir}
85     install -m 0644 platform-build-info-target ${D}${sysconfdir}/platform-build-info
86
87     # also copy in deploy dir
88     install -d ${DEPLOY_DIR_IMAGE}
89     install -m 0644 platform-build-info-deploy ${DEPLOY_DIR_IMAGE}/platform-build-info
90
91     # and copy to nativesdk package
92     # TODO
93 }
94
95 # list of variables to add to the various manifests
96 # smalles one is 'target', then 'deploy' and finally 'sdk'
97 BUILD_MANIFEST_FIELDS_TARGET = "\
98     MACHINE_ARCH \
99     MACHINEOVERRIDES \
100     MACHINE_FEATURES \
101     DISTRO_CODENAME \
102     DISTRO_FEATURES \
103     DISTRO_BRANCH_VERSION_TAG \
104     AGLVERSION \
105     AGL_BRANCH \
106     AGLRELEASETYPE \
107 "
108
109 BUILD_MANIFEST_FIELDS_DEPLOY = "\
110     ${BUILD_MANIFEST_FIELDS_TARGET} \
111     DISTRO \
112     DISTRO_VERSION \
113     DISTROOVERRIDES \
114     TUNE_FEATURES \
115     TUNE_PKGARCH \
116     ALL_MULTILIB_PACKAGE_ARCHS \
117 "
118
119 BUILD_MANIFEST_FIELDS_SDK = "\
120     ${BUILD_MANIFEST_FIELDS_DEPLOY} \
121     HOST_SYS \
122     TARGET_SYS \
123     TARGET_VENDOR \
124     SDK_ARCH \
125     SDK_VENDOR \
126     SDK_VERSION \
127     SDK_OS \
128 "
129
130 # dont exec useless tasks
131 do_fetch[noexec] = "1"
132 do_unpack[noexec] = "1"
133 do_patch[noexec] = "1"
134 do_configure[noexec] = "1"
135