| Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 1 | HOST_DATA ?= "${TMPDIR}/host-contamination-data/" | 
|  | 2 | SWABBER_REPORT ?= "${LOG_DIR}/swabber/" | 
|  | 3 | SWABBER_LOGS ?= "${LOG_DIR}/contamination-logs" | 
|  | 4 | TRACE_LOGDIR ?= "${SWABBER_LOGS}/${PACKAGE_ARCH}" | 
|  | 5 | TRACE_LOGFILE = "${TRACE_LOGDIR}/${PN}-${PV}" | 
|  | 6 |  | 
|  | 7 | SWAB_ORIG_TASK := "${BB_DEFAULT_TASK}" | 
|  | 8 | BB_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 | 
|  | 13 | PARALLEL_MAKE_pn-openssl = "" | 
|  | 14 | PARALLEL_MAKE_pn-glibc = "" | 
|  | 15 | PARALLEL_MAKE_pn-glib-2.0 = "" | 
|  | 16 | PARALLEL_MAKE_pn-libxml2 = "" | 
|  | 17 | PARALLEL_MAKE_pn-readline = "" | 
|  | 18 | PARALLEL_MAKE_pn-util-linux = "" | 
|  | 19 | PARALLEL_MAKE_pn-binutils = "" | 
|  | 20 | PARALLEL_MAKE_pn-bison = "" | 
|  | 21 | PARALLEL_MAKE_pn-cmake = "" | 
|  | 22 | PARALLEL_MAKE_pn-elfutils = "" | 
|  | 23 | PARALLEL_MAKE_pn-gcc = "" | 
|  | 24 | PARALLEL_MAKE_pn-gcc-runtime = "" | 
|  | 25 | PARALLEL_MAKE_pn-m4 = "" | 
|  | 26 | PARALLEL_MAKE_pn-opkg = "" | 
|  | 27 | PARALLEL_MAKE_pn-pkgconfig = "" | 
|  | 28 | PARALLEL_MAKE_pn-prelink = "" | 
|  | 29 | PARALLEL_MAKE_pn-rpm = "" | 
|  | 30 | PARALLEL_MAKE_pn-tcl = "" | 
|  | 31 | PARALLEL_MAKE_pn-beecrypt = "" | 
|  | 32 | PARALLEL_MAKE_pn-curl = "" | 
|  | 33 | PARALLEL_MAKE_pn-gmp = "" | 
|  | 34 | PARALLEL_MAKE_pn-libmpc = "" | 
|  | 35 | PARALLEL_MAKE_pn-libxslt = "" | 
|  | 36 | PARALLEL_MAKE_pn-lzo = "" | 
|  | 37 | PARALLEL_MAKE_pn-popt = "" | 
|  | 38 | PARALLEL_MAKE_pn-linux-wrs = "" | 
|  | 39 | PARALLEL_MAKE_pn-libgcrypt = "" | 
|  | 40 | PARALLEL_MAKE_pn-gpgme = "" | 
|  | 41 | PARALLEL_MAKE_pn-udev = "" | 
|  | 42 | PARALLEL_MAKE_pn-gnutls = "" | 
|  | 43 |  | 
|  | 44 | python() { | 
|  | 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): | 
| Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 50 | deps = (d.getVarFlag('do_setscene', 'depends', True) or "").split() | 
| Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 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 |  | 
|  | 59 | STRACEPID = "${@os.getpid()}" | 
|  | 60 | STRACEFUNC = "imageswab_attachstrace" | 
|  | 61 |  | 
|  | 62 | do_configure[prefuncs] += "${STRACEFUNC}" | 
|  | 63 | do_compile[prefuncs] += "${STRACEFUNC}" | 
|  | 64 |  | 
|  | 65 | imageswab_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 |  | 
|  | 73 | do_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 | } | 
|  | 93 | addtask generate_swabber_report after do_${SWAB_ORIG_TASK} | 
|  | 94 | do_generate_swabber_report[depends] = "swabber-native:do_populate_sysroot" |