summaryrefslogtreecommitdiffstats
path: root/meta/classes/staging.bbclass
diff options
context:
space:
mode:
Diffstat (limited to 'meta/classes/staging.bbclass')
-rw-r--r--meta/classes/staging.bbclass121
1 files changed, 121 insertions, 0 deletions
diff --git a/meta/classes/staging.bbclass b/meta/classes/staging.bbclass
new file mode 100644
index 0000000..7c43e76
--- /dev/null
+++ b/meta/classes/staging.bbclass
@@ -0,0 +1,121 @@
1
2sysroot_stage_dir() {
3 src="$1"
4 dest="$2"
5 # if the src doesn't exist don't do anything
6 if [ ! -d "$src" ]; then
7 return
8 fi
9
10 mkdir -p "$dest"
11 (
12 cd $src
13 find . -print0 | cpio --null -pdlu $dest
14 )
15}
16
17sysroot_stage_libdir() {
18 src="$1"
19 dest="$2"
20
21 sysroot_stage_dir $src $dest
22}
23
24sysroot_stage_dirs() {
25 from="$1"
26 to="$2"
27
28 sysroot_stage_dir $from${includedir} $to${includedir}
29 if [ "${BUILD_SYS}" = "${HOST_SYS}" ]; then
30 sysroot_stage_dir $from${bindir} $to${bindir}
31 sysroot_stage_dir $from${sbindir} $to${sbindir}
32 sysroot_stage_dir $from${base_bindir} $to${base_bindir}
33 sysroot_stage_dir $from${base_sbindir} $to${base_sbindir}
34 sysroot_stage_dir $from${libexecdir} $to${libexecdir}
35 sysroot_stage_dir $from${sysconfdir} $to${sysconfdir}
36 sysroot_stage_dir $from${localstatedir} $to${localstatedir}
37 fi
38 if [ -d $from${libdir} ]
39 then
40 sysroot_stage_libdir $from${libdir} $to${libdir}
41 fi
42 if [ -d $from${base_libdir} ]
43 then
44 sysroot_stage_libdir $from${base_libdir} $to${base_libdir}
45 fi
46 if [ -d $from${nonarch_base_libdir} ]
47 then
48 sysroot_stage_libdir $from${nonarch_base_libdir} $to${nonarch_base_libdir}
49 fi
50 sysroot_stage_dir $from${datadir} $to${datadir}
51 # We don't care about docs/info/manpages/locales
52 rm -rf $to${mandir}/ $to${docdir}/ $to${infodir}/ ${to}${datadir}/locale/
53 rm -rf $to${datadir}/applications/ $to${datadir}/fonts/ $to${datadir}/pixmaps/
54}
55
56sysroot_stage_all() {
57 sysroot_stage_dirs ${D} ${SYSROOT_DESTDIR}
58}
59
60do_populate_sysroot[dirs] = "${SYSROOT_DESTDIR}"
61do_populate_sysroot[umask] = "022"
62
63addtask populate_sysroot after do_install
64
65SYSROOT_PREPROCESS_FUNCS ?= ""
66SYSROOT_DESTDIR = "${WORKDIR}/sysroot-destdir/"
67SYSROOT_LOCK = "${STAGING_DIR}/staging.lock"
68
69# We clean out any existing sstate from the sysroot if we rerun configure
70python sysroot_cleansstate () {
71 ss = sstate_state_fromvars(d, "populate_sysroot")
72 sstate_clean(ss, d)
73}
74do_configure[prefuncs] += "sysroot_cleansstate"
75
76
77BB_SETSCENE_VERIFY_FUNCTION = "sysroot_checkhashes"
78
79def sysroot_checkhashes(covered, tasknames, fnids, fns, d, invalidtasks = None):
80 problems = set()
81 configurefnids = set()
82 if not invalidtasks:
83 invalidtasks = xrange(len(tasknames))
84 for task in invalidtasks:
85 if tasknames[task] == "do_configure" and task not in covered:
86 configurefnids.add(fnids[task])
87 for task in covered:
88 if tasknames[task] == "do_populate_sysroot" and fnids[task] in configurefnids:
89 problems.add(task)
90 return problems
91
92python do_populate_sysroot () {
93 bb.build.exec_func("sysroot_stage_all", d)
94 for f in (d.getVar('SYSROOT_PREPROCESS_FUNCS', True) or '').split():
95 bb.build.exec_func(f, d)
96 pn = d.getVar("PN", True)
97 multiprov = d.getVar("MULTI_PROVIDER_WHITELIST", True).split()
98 provdir = d.expand("${SYSROOT_DESTDIR}${base_prefix}/sysroot-providers/")
99 bb.utils.mkdirhier(provdir)
100 for p in d.getVar("PROVIDES", True).split():
101 if p in multiprov:
102 continue
103 p = p.replace("/", "_")
104 with open(provdir + p, "w") as f:
105 f.write(pn)
106}
107
108do_populate_sysroot[vardeps] += "${SYSROOT_PREPROCESS_FUNCS}"
109
110SSTATETASKS += "do_populate_sysroot"
111do_populate_sysroot[cleandirs] = "${SYSROOT_DESTDIR}"
112do_populate_sysroot[sstate-inputdirs] = "${SYSROOT_DESTDIR}"
113do_populate_sysroot[sstate-outputdirs] = "${STAGING_DIR_HOST}/"
114do_populate_sysroot[stamp-extra-info] = "${MACHINE}"
115
116python do_populate_sysroot_setscene () {
117 sstate_setscene(d)
118}
119addtask do_populate_sysroot_setscene
120
121