distro/oel: Force ARM_INSTRUCTION_SET to use OEL settings
[meta-ossystems-base.git] / classes / release-bundle-generation.bbclass
1 # -*- python -*-
2 # release-bundle-generation.bbclass
3 #
4 # Copyright (C) 2016 O.S. Systems Software Ltda.  All Rights Reserved
5 #
6 # This class include additional tasks for the release bundle
7 # generation.
8 #
9 # The main objective of this is allow reuse of this in recipes.
10 #
11 # Following variables are used, to configure the release bundle:
12 #
13 # - RELEASE_BUNDLE_NAME: Used for the release bundle filename
14 # - RELEASE_BUNDLE_TITLE: Title shown in the release bundle
15 # - RELEASE_BUNDLE_VERSION: Version shown in the release bundle
16 #
17 # Released under the MIT license (see packages/COPYING)
18
19 do_configure[noexec] = "1"
20 do_compile[noexec] = "1"
21 do_install[noexec] = "1"
22 do_populate_sysroot[noexec] = "1"
23 do_package[noexec] = "1"
24 do_package_qa[noexec] = "1"
25 do_packagedata[noexec] = "1"
26
27 LICENSE = "MIT"
28 PACKAGES = ""
29
30 INHIBIT_DEFAULT_DEPS = "1"
31
32 RELEASE_BUNDLE_NAME ?= "${DISTRO}"
33 RELEASE_BUNDLE_TITLE ?= "${@d.getVar('DISTRO_NAME', True) or d.getVar('DISTRO', True)}"
34 RELEASE_BUNDLE_VERSION ?= "${DISTRO_VERSION}"
35
36 RELEASE_BUNDLE_DEPLOY = "${DEPLOY_DIR}/release-bundle"
37 RELEASE_BUNDLE_WORKDIR = "${TMPDIR}/release-bundle/workdir"
38 RELEASE_BUNDLE_OUTPUTNAME ?= "${RELEASE_BUNDLE_NAME}-release-${RELEASE_BUNDLE_VERSION}"
39 RELEASE_BUNDLE_RECIPES_WITH_SOURCE ?= ""
40
41 SRC_URI = "file://bundle-shar-extract.sh"
42
43 python() {
44     recipes = d.getVar('RELEASE_BUNDLE_RECIPES_WITH_SOURCE', True).split()
45     d.appendVarFlag('do_release_bundle_finalize',
46                     'depends',
47                     " ".join(map(lambda x:
48                                         x + ":do_collect_recipe_source",
49                                  recipes)))
50
51     d.delVarFlag('do_build', 'recrdeptask')
52     d.delVarFlag('do_build', 'depends')
53 }
54
55 addtask collect_platform_source before do_release_bundle_finalize
56 do_collect_platform_source[cleandirs] = "${RELEASE_BUNDLE_WORKDIR}"
57 do_collect_platform_source[nostamp] = "1"
58 do_collect_platform_source() {
59     cd "${PLATFORM_ROOT_DIR}"
60
61     cpu_count=`cat /proc/cpuinfo | grep processor | wc -l`
62
63     bbdebug 1 "Compressing source repositories. Using $cpu_count jobs..."
64     repo forall --abort-on-errors --jobs=$cpu_count -c git gc --aggressive --quiet
65
66     bbdebug 1 "Copy all source repositories and pre-download files..."
67     cp --archive \
68        \
69        ${PLATFORM_ROOT_DIR}/.repo \
70        ${PLATFORM_ROOT_DIR}/sources \
71        ${PLATFORM_ROOT_DIR}/setup-environment \
72        \
73        ${RELEASE_BUNDLE_WORKDIR}
74 }
75
76 RELEASE_BUNDLE_TAR_OPTS = "--owner=root --group=root"
77 RELEASE_BUNDLE_OLDEST_KERNEL = "3.2.0"
78 RELEASE_BUNDLE_PATH = "\$HOME/src/${RELEASE_BUNDLE_NAME}/${RELEASE_BUNDLE_VERSION}"
79
80 fakeroot tar_release_bundle() {
81     mkdir -p ${RELEASE_BUNDLE_DEPLOY}
82     cd ${RELEASE_BUNDLE_WORKDIR}
83     tar ${RELEASE_BUNDLE_TAR_OPTS} -cf - . | pbzip2 > ${RELEASE_BUNDLE_DEPLOY}/${RELEASE_BUNDLE_OUTPUTNAME}.tar.bz2
84 }
85
86 addtask release_bundle_finalize after do_unpack do_collect_platform_source before do_build
87 do_release_bundle_finalize[dirs] = "${RELEASE_BUNDLE_WORKDIR}/download"
88 do_release_bundle_finalize[depends] += "pbzip2-native:do_populate_sysroot "
89 do_release_bundle_finalize() {
90     cp --archive -L ${RELEASE_BUNDLE_TMP_DOWNLOAD_CACHE}/*/* ${RELEASE_BUNDLE_WORKDIR}/
91     find ${RELEASE_BUNDLE_WORKDIR} -type d -empty -delete
92
93     tar_release_bundle
94
95     cp "${WORKDIR}/bundle-shar-extract.sh" ${RELEASE_BUNDLE_DEPLOY}/${RELEASE_BUNDLE_OUTPUTNAME}.sh
96
97     # substitute variables
98     sed -e "s#@RELEASE_BUNDLE_PATH@#${RELEASE_BUNDLE_PATH}#g" \
99         -e "s#@OLDEST_KERNEL@#${RELEASE_BUNDLE_OLDEST_KERNEL}#g" \
100         -e "s#@RELEASE_BUNDLE_TITLE@#${RELEASE_BUNDLE_TITLE}#g" \
101         -e "s#@RELEASE_BUNDLE_VERSION@#${RELEASE_BUNDLE_VERSION}#g" \
102         \
103         -i ${RELEASE_BUNDLE_DEPLOY}/${RELEASE_BUNDLE_OUTPUTNAME}.sh
104
105     # add execution permission
106     chmod +x ${RELEASE_BUNDLE_DEPLOY}/${RELEASE_BUNDLE_OUTPUTNAME}.sh
107
108     # append the SDK tarball
109     cat ${RELEASE_BUNDLE_DEPLOY}/${RELEASE_BUNDLE_OUTPUTNAME}.tar.bz2 >> ${RELEASE_BUNDLE_DEPLOY}/${RELEASE_BUNDLE_OUTPUTNAME}.sh
110
111     # delete the old tarball, we don't need it anymore
112     rm ${RELEASE_BUNDLE_DEPLOY}/${RELEASE_BUNDLE_OUTPUTNAME}.tar.bz2
113 }