blob: 89318560dbf61a32c4e9cd31526f95f08593f621 [file] [log] [blame]
Patrick Williamsc124f4f2015-09-15 14:41:29 -05001HOST_DATA ?= "${TMPDIR}/host-contamination-data/"
2SWABBER_REPORT ?= "${LOG_DIR}/swabber/"
3SWABBER_LOGS ?= "${LOG_DIR}/contamination-logs"
4TRACE_LOGDIR ?= "${SWABBER_LOGS}/${PACKAGE_ARCH}"
5TRACE_LOGFILE = "${TRACE_LOGDIR}/${PN}-${PV}"
6
7SWAB_ORIG_TASK := "${BB_DEFAULT_TASK}"
8BB_DEFAULT_TASK = "generate_swabber_report"
9
10# Several recipes don't build with parallel make when run under strace
11# Ideally these should be fixed but as a temporary measure disable parallel
12# builds for troublesome recipes
13PARALLEL_MAKE_pn-openssl = ""
14PARALLEL_MAKE_pn-glibc = ""
15PARALLEL_MAKE_pn-glib-2.0 = ""
16PARALLEL_MAKE_pn-libxml2 = ""
17PARALLEL_MAKE_pn-readline = ""
18PARALLEL_MAKE_pn-util-linux = ""
19PARALLEL_MAKE_pn-binutils = ""
20PARALLEL_MAKE_pn-bison = ""
21PARALLEL_MAKE_pn-cmake = ""
22PARALLEL_MAKE_pn-elfutils = ""
23PARALLEL_MAKE_pn-gcc = ""
24PARALLEL_MAKE_pn-gcc-runtime = ""
25PARALLEL_MAKE_pn-m4 = ""
26PARALLEL_MAKE_pn-opkg = ""
27PARALLEL_MAKE_pn-pkgconfig = ""
28PARALLEL_MAKE_pn-prelink = ""
29PARALLEL_MAKE_pn-rpm = ""
30PARALLEL_MAKE_pn-tcl = ""
31PARALLEL_MAKE_pn-beecrypt = ""
32PARALLEL_MAKE_pn-curl = ""
33PARALLEL_MAKE_pn-gmp = ""
34PARALLEL_MAKE_pn-libmpc = ""
35PARALLEL_MAKE_pn-libxslt = ""
36PARALLEL_MAKE_pn-lzo = ""
37PARALLEL_MAKE_pn-popt = ""
38PARALLEL_MAKE_pn-linux-wrs = ""
39PARALLEL_MAKE_pn-libgcrypt = ""
40PARALLEL_MAKE_pn-gpgme = ""
41PARALLEL_MAKE_pn-udev = ""
42PARALLEL_MAKE_pn-gnutls = ""
43
44python() {
45 # NOTE: It might be useful to detect host infection on native and cross
46 # packages but as it turns out to be pretty hard to do this for all native
47 # and cross packages which aren't swabber-native or one of its dependencies
48 # I have ignored them for now...
49 if not bb.data.inherits_class('native', d) and not bb.data.inherits_class('nativesdk', d) and not bb.data.inherits_class('cross', d):
50 deps = (d.getVarFlag('do_setscene', 'depends') or "").split()
51 deps.append('strace-native:do_populate_sysroot')
52 d.setVarFlag('do_setscene', 'depends', " ".join(deps))
53 logdir = d.expand("${TRACE_LOGDIR}")
54 bb.utils.mkdirhier(logdir)
55 else:
56 d.setVar('STRACEFUNC', '')
57}
58
59STRACEPID = "${@os.getpid()}"
60STRACEFUNC = "imageswab_attachstrace"
61
62do_configure[prefuncs] += "${STRACEFUNC}"
63do_compile[prefuncs] += "${STRACEFUNC}"
64
65imageswab_attachstrace () {
66 STRACE=`which strace`
67
68 if [ -x "$STRACE" ]; then
69 swabber-strace-attach "$STRACE -f -o ${TRACE_LOGFILE}-${BB_CURRENTTASK}.log -e trace=open,execve -p ${STRACEPID}" "${TRACE_LOGFILE}-traceattach-${BB_CURRENTTASK}.log"
70 fi
71}
72
73do_generate_swabber_report () {
74
75 update_distro ${HOST_DATA}
76
77 # Swabber can't create the directory for us
78 mkdir -p ${SWABBER_REPORT}
79
80 REPORTSTAMP=${SWAB_ORIG_TASK}-`date +%2m%2d%2H%2M%Y`
81
82 if [ `which ccache` ] ; then
83 CCACHE_DIR=`( ccache -s | grep "cache directory" | grep -o '[^ ]*$' 2> /dev/null )`
84 fi
85
86 if [ "$(ls -A ${HOST_DATA})" ]; then
87 echo "Generating swabber report"
88 swabber -d ${HOST_DATA} -l ${SWABBER_LOGS} -o ${SWABBER_REPORT}/report-${REPORTSTAMP}.txt -r ${SWABBER_REPORT}/extra_report-${REPORTSTAMP}.txt -c all -p ${TOPDIR} -f ${OEROOT}/meta/conf/swabber ${TOPDIR} ${OEROOT} ${CCACHE_DIR}
89 else
90 echo "No host data, cannot generate swabber report."
91 fi
92}
93addtask generate_swabber_report after do_${SWAB_ORIG_TASK}
94do_generate_swabber_report[depends] = "swabber-native:do_populate_sysroot"