diff options
author | Paul Eggleton <paul.eggleton@linux.intel.com> | 2013-03-22 19:53:52 +0000 |
---|---|---|
committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2013-03-23 11:41:13 +0000 |
commit | 59e48153877269d5eea393ad2f6d1827f74720ac (patch) | |
tree | 1fc56600125082af451cf86c0c1347804bad36e7 /meta/classes/buildhistory.bbclass | |
parent | 9e366e153234114ab3c51e4bb8e3452593f64070 (diff) | |
download | poky-59e48153877269d5eea393ad2f6d1827f74720ac.tar.gz |
classes/buildhistory: implement history collection for SDKs
SDKs are constructed in a similar manner to images, and the contents can
be influenced by a number of different factors, thus tracking the
contents of produced SDKs when buildhistory is enabled can help detect
the same kinds of issues as with images.
This required adding POPULATE_SDK_POST_HOST_COMMAND and
SDK_POSTPROCESS_COMMAND variables so that data collection functions can
be injected at the appropriate points in the SDK construction process,
as well as moving the list_installed_packages and
rootfs_list_installed_depends functions from the rootfs_{rpm,ipk,deb} to
the package_{rpm,ipk,deb} classes so they can also be called during
do_populate_sdk as well as do_rootfs.
Implements [YOCTO #3964].
(From OE-Core rev: c3736064483d4840e38cb1b8c13d2dd3a26b36aa)
Signed-off-by: Paul Eggleton <paul.eggleton@linux.intel.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'meta/classes/buildhistory.bbclass')
-rw-r--r-- | meta/classes/buildhistory.bbclass | 130 |
1 files changed, 90 insertions, 40 deletions
diff --git a/meta/classes/buildhistory.bbclass b/meta/classes/buildhistory.bbclass index 07b3c1edaf..b559ebf8ac 100644 --- a/meta/classes/buildhistory.bbclass +++ b/meta/classes/buildhistory.bbclass | |||
@@ -3,14 +3,15 @@ | |||
3 | # | 3 | # |
4 | # Based in part on testlab.bbclass and packagehistory.bbclass | 4 | # Based in part on testlab.bbclass and packagehistory.bbclass |
5 | # | 5 | # |
6 | # Copyright (C) 2011 Intel Corporation | 6 | # Copyright (C) 2013 Intel Corporation |
7 | # Copyright (C) 2007-2011 Koen Kooi <koen@openembedded.org> | 7 | # Copyright (C) 2007-2011 Koen Kooi <koen@openembedded.org> |
8 | # | 8 | # |
9 | 9 | ||
10 | BUILDHISTORY_FEATURES ?= "image package" | 10 | BUILDHISTORY_FEATURES ?= "image package sdk" |
11 | BUILDHISTORY_DIR ?= "${TMPDIR}/buildhistory" | 11 | BUILDHISTORY_DIR ?= "${TMPDIR}/buildhistory" |
12 | BUILDHISTORY_DIR_IMAGE = "${BUILDHISTORY_DIR}/images/${MACHINE_ARCH}/${TCLIBC}/${IMAGE_BASENAME}" | 12 | BUILDHISTORY_DIR_IMAGE = "${BUILDHISTORY_DIR}/images/${MACHINE_ARCH}/${TCLIBC}/${IMAGE_BASENAME}" |
13 | BUILDHISTORY_DIR_PACKAGE = "${BUILDHISTORY_DIR}/packages/${MULTIMACH_TARGET_SYS}/${PN}" | 13 | BUILDHISTORY_DIR_PACKAGE = "${BUILDHISTORY_DIR}/packages/${MULTIMACH_TARGET_SYS}/${PN}" |
14 | BUILDHISTORY_DIR_SDK = "${BUILDHISTORY_DIR}/sdk/${SDK_NAME}" | ||
14 | BUILDHISTORY_COMMIT ?= "0" | 15 | BUILDHISTORY_COMMIT ?= "0" |
15 | BUILDHISTORY_COMMIT_AUTHOR ?= "buildhistory <buildhistory@${DISTRO}>" | 16 | BUILDHISTORY_COMMIT_AUTHOR ?= "buildhistory <buildhistory@${DISTRO}>" |
16 | BUILDHISTORY_PUSH_REPO ?= "" | 17 | BUILDHISTORY_PUSH_REPO ?= "" |
@@ -315,69 +316,91 @@ def write_pkghistory(pkginfo, d): | |||
315 | os.unlink(filevarpath) | 316 | os.unlink(filevarpath) |
316 | 317 | ||
317 | 318 | ||
318 | buildhistory_get_image_installed() { | 319 | buildhistory_get_installed() { |
319 | # Anything requiring the use of the packaging system should be done in here | 320 | mkdir -p $1 |
320 | # in case the packaging files are going to be removed for this image | ||
321 | |||
322 | if [ "${@base_contains('BUILDHISTORY_FEATURES', 'image', '1', '0', d)}" = "0" ] ; then | ||
323 | return | ||
324 | fi | ||
325 | |||
326 | mkdir -p ${BUILDHISTORY_DIR_IMAGE} | ||
327 | 321 | ||
328 | # Get list of installed packages | 322 | # Get list of installed packages |
329 | pkgcache="${BUILDHISTORY_DIR_IMAGE}/installed-packages.tmp" | 323 | pkgcache="$1/installed-packages.tmp" |
330 | list_installed_packages file | sort > $pkgcache | 324 | list_installed_packages file | sort > $pkgcache |
331 | 325 | ||
332 | cat $pkgcache | awk '{ print $1 }' > ${BUILDHISTORY_DIR_IMAGE}/installed-package-names.txt | 326 | cat $pkgcache | awk '{ print $1 }' > $1/installed-package-names.txt |
333 | cat $pkgcache | awk '{ print $2 }' | xargs -n1 basename > ${BUILDHISTORY_DIR_IMAGE}/installed-packages.txt | 327 | cat $pkgcache | awk '{ print $2 }' | xargs -n1 basename > $1/installed-packages.txt |
334 | 328 | ||
335 | # Produce dependency graph | 329 | # Produce dependency graph |
336 | # First, filter out characters that cause issues for dot | 330 | # First, filter out characters that cause issues for dot |
337 | rootfs_list_installed_depends | sed -e 's:-:_:g' -e 's:\.:_:g' -e 's:+::g' > ${BUILDHISTORY_DIR_IMAGE}/depends.tmp | 331 | rootfs_list_installed_depends | sed -e 's:-:_:g' -e 's:\.:_:g' -e 's:+::g' > $1/depends.tmp |
338 | # Change delimiter from pipe to -> and set style for recommend lines | 332 | # Change delimiter from pipe to -> and set style for recommend lines |
339 | sed -i -e 's:|: -> :' -e 's:\[REC\]:[style=dotted]:' -e 's:$:;:' ${BUILDHISTORY_DIR_IMAGE}/depends.tmp | 333 | sed -i -e 's:|: -> :' -e 's:\[REC\]:[style=dotted]:' -e 's:$:;:' $1/depends.tmp |
340 | # Add header, sorted and de-duped contents and footer and then delete the temp file | 334 | # Add header, sorted and de-duped contents and footer and then delete the temp file |
341 | printf "digraph depends {\n node [shape=plaintext]\n" > ${BUILDHISTORY_DIR_IMAGE}/depends.dot | 335 | printf "digraph depends {\n node [shape=plaintext]\n" > $1/depends.dot |
342 | cat ${BUILDHISTORY_DIR_IMAGE}/depends.tmp | sort | uniq >> ${BUILDHISTORY_DIR_IMAGE}/depends.dot | 336 | cat $1/depends.tmp | sort | uniq >> $1/depends.dot |
343 | echo "}" >> ${BUILDHISTORY_DIR_IMAGE}/depends.dot | 337 | echo "}" >> $1/depends.dot |
344 | rm ${BUILDHISTORY_DIR_IMAGE}/depends.tmp | 338 | rm $1/depends.tmp |
345 | 339 | ||
346 | # Produce installed package sizes list | 340 | # Produce installed package sizes list |
347 | printf "" > ${BUILDHISTORY_DIR_IMAGE}/installed-package-sizes.tmp | 341 | printf "" > $1/installed-package-sizes.tmp |
348 | cat $pkgcache | while read pkg pkgfile | 342 | cat $pkgcache | while read pkg pkgfile |
349 | do | 343 | do |
350 | if [ -f $pkgfile ] ; then | 344 | if [ -f $pkgfile ] ; then |
351 | pkgsize=`du -k $pkgfile | head -n1 | awk '{ print $1 }'` | 345 | pkgsize=`du -k $pkgfile | head -n1 | awk '{ print $1 }'` |
352 | echo $pkgsize $pkg >> ${BUILDHISTORY_DIR_IMAGE}/installed-package-sizes.tmp | 346 | echo $pkgsize $pkg >> $1/installed-package-sizes.tmp |
353 | fi | 347 | fi |
354 | done | 348 | done |
355 | cat ${BUILDHISTORY_DIR_IMAGE}/installed-package-sizes.tmp | sort -n -r | awk '{print $1 "\tKiB " $2}' > ${BUILDHISTORY_DIR_IMAGE}/installed-package-sizes.txt | 349 | cat $1/installed-package-sizes.tmp | sort -n -r | awk '{print $1 "\tKiB " $2}' > $1/installed-package-sizes.txt |
356 | rm ${BUILDHISTORY_DIR_IMAGE}/installed-package-sizes.tmp | 350 | rm $1/installed-package-sizes.tmp |
357 | 351 | ||
358 | # We're now done with the cache, delete it | 352 | # We're now done with the cache, delete it |
359 | rm $pkgcache | 353 | rm $pkgcache |
360 | 354 | ||
361 | # Produce some cut-down graphs (for readability) | 355 | if [ "$2" != "sdk" ] ; then |
362 | grep -v kernel_image ${BUILDHISTORY_DIR_IMAGE}/depends.dot | grep -v kernel_2 | grep -v kernel_3 > ${BUILDHISTORY_DIR_IMAGE}/depends-nokernel.dot | 356 | # Produce some cut-down graphs (for readability) |
363 | grep -v libc6 ${BUILDHISTORY_DIR_IMAGE}/depends-nokernel.dot | grep -v libgcc > ${BUILDHISTORY_DIR_IMAGE}/depends-nokernel-nolibc.dot | 357 | grep -v kernel_image $1/depends.dot | grep -v kernel_2 | grep -v kernel_3 > $1/depends-nokernel.dot |
364 | grep -v update_ ${BUILDHISTORY_DIR_IMAGE}/depends-nokernel-nolibc.dot > ${BUILDHISTORY_DIR_IMAGE}/depends-nokernel-nolibc-noupdate.dot | 358 | grep -v libc6 $1/depends-nokernel.dot | grep -v libgcc > $1/depends-nokernel-nolibc.dot |
365 | grep -v kernel_module ${BUILDHISTORY_DIR_IMAGE}/depends-nokernel-nolibc-noupdate.dot > ${BUILDHISTORY_DIR_IMAGE}/depends-nokernel-nolibc-noupdate-nomodules.dot | 359 | grep -v update_ $1/depends-nokernel-nolibc.dot > $1/depends-nokernel-nolibc-noupdate.dot |
360 | grep -v kernel_module $1/depends-nokernel-nolibc-noupdate.dot > $1/depends-nokernel-nolibc-noupdate-nomodules.dot | ||
361 | fi | ||
366 | 362 | ||
367 | # add complementary package information | 363 | # add complementary package information |
368 | if [ -e ${WORKDIR}/complementary_pkgs.txt ]; then | 364 | if [ -e ${WORKDIR}/complementary_pkgs.txt ]; then |
369 | cp ${WORKDIR}/complementary_pkgs.txt ${BUILDHISTORY_DIR_IMAGE} | 365 | cp ${WORKDIR}/complementary_pkgs.txt $1 |
370 | fi | 366 | fi |
371 | } | 367 | } |
372 | 368 | ||
373 | buildhistory_get_imageinfo() { | 369 | buildhistory_get_image_installed() { |
370 | # Anything requiring the use of the packaging system should be done in here | ||
371 | # in case the packaging files are going to be removed for this image | ||
372 | |||
374 | if [ "${@base_contains('BUILDHISTORY_FEATURES', 'image', '1', '0', d)}" = "0" ] ; then | 373 | if [ "${@base_contains('BUILDHISTORY_FEATURES', 'image', '1', '0', d)}" = "0" ] ; then |
375 | return | 374 | return |
376 | fi | 375 | fi |
377 | 376 | ||
378 | # List the files in the image, but exclude date/time etc. | 377 | buildhistory_get_installed ${BUILDHISTORY_DIR_IMAGE} |
378 | } | ||
379 | |||
380 | buildhistory_get_sdk_installed() { | ||
381 | # Anything requiring the use of the packaging system should be done in here | ||
382 | # in case the packaging files are going to be removed for this SDK | ||
383 | |||
384 | if [ "${@base_contains('BUILDHISTORY_FEATURES', 'sdk', '1', '0', d)}" = "0" ] ; then | ||
385 | return | ||
386 | fi | ||
387 | |||
388 | buildhistory_get_installed ${BUILDHISTORY_DIR_SDK}/$1 sdk | ||
389 | } | ||
390 | |||
391 | buildhistory_list_files() { | ||
392 | # List the files in the specified directory, but exclude date/time etc. | ||
379 | # This awk script is somewhat messy, but handles where the size is not printed for device files under pseudo | 393 | # This awk script is somewhat messy, but handles where the size is not printed for device files under pseudo |
380 | ( cd ${IMAGE_ROOTFS} && find . -ls | awk '{ if ( $7 ~ /[0-9]/ ) printf "%s %10-s %10-s %10s %s %s %s\n", $3, $5, $6, $7, $11, $12, $13 ; else printf "%s %10-s %10-s %10s %s %s %s\n", $3, $5, $6, 0, $10, $11, $12 }' | sort -k5 > ${BUILDHISTORY_DIR_IMAGE}/files-in-image.txt ) | 394 | ( cd $1 && find . -ls | awk '{ if ( $7 ~ /[0-9]/ ) printf "%s %10-s %10-s %10s %s %s %s\n", $3, $5, $6, $7, $11, $12, $13 ; else printf "%s %10-s %10-s %10s %s %s %s\n", $3, $5, $6, 0, $10, $11, $12 }' | sort -k5 > $2 ) |
395 | } | ||
396 | |||
397 | |||
398 | buildhistory_get_imageinfo() { | ||
399 | if [ "${@base_contains('BUILDHISTORY_FEATURES', 'image', '1', '0', d)}" = "0" ] ; then | ||
400 | return | ||
401 | fi | ||
402 | |||
403 | buildhistory_list_files ${IMAGE_ROOTFS} ${BUILDHISTORY_DIR_IMAGE}/files-in-image.txt | ||
381 | 404 | ||
382 | # Record some machine-readable meta-information about the image | 405 | # Record some machine-readable meta-information about the image |
383 | printf "" > ${BUILDHISTORY_DIR_IMAGE}/image-info.txt | 406 | printf "" > ${BUILDHISTORY_DIR_IMAGE}/image-info.txt |
@@ -395,11 +418,32 @@ ${@buildhistory_get_layers(d)} | |||
395 | END | 418 | END |
396 | } | 419 | } |
397 | 420 | ||
421 | buildhistory_get_sdkinfo() { | ||
422 | if [ "${@base_contains('BUILDHISTORY_FEATURES', 'sdk', '1', '0', d)}" = "0" ] ; then | ||
423 | return | ||
424 | fi | ||
425 | |||
426 | buildhistory_list_files ${SDK_OUTPUT} ${BUILDHISTORY_DIR_SDK}/files-in-sdk.txt | ||
427 | |||
428 | # Record some machine-readable meta-information about the SDK | ||
429 | printf "" > ${BUILDHISTORY_DIR_SDK}/sdk-info.txt | ||
430 | cat >> ${BUILDHISTORY_DIR_SDK}/sdk-info.txt <<END | ||
431 | ${@buildhistory_get_sdkvars(d)} | ||
432 | END | ||
433 | sdksize=`du -ks ${SDK_OUTPUT} | awk '{ print $1 }'` | ||
434 | echo "SDKSIZE = $sdksize" >> ${BUILDHISTORY_DIR_SDK}/sdk-info.txt | ||
435 | } | ||
436 | |||
398 | # By prepending we get in before the removal of packaging files | 437 | # By prepending we get in before the removal of packaging files |
399 | ROOTFS_POSTPROCESS_COMMAND =+ "buildhistory_get_image_installed ; " | 438 | ROOTFS_POSTPROCESS_COMMAND =+ "buildhistory_get_image_installed ; " |
400 | 439 | ||
401 | IMAGE_POSTPROCESS_COMMAND += " buildhistory_get_imageinfo ; " | 440 | IMAGE_POSTPROCESS_COMMAND += " buildhistory_get_imageinfo ; " |
402 | 441 | ||
442 | POPULATE_SDK_POST_TARGET_COMMAND += "buildhistory_get_sdk_installed target ; " | ||
443 | POPULATE_SDK_POST_HOST_COMMAND += "buildhistory_get_sdk_installed host ; " | ||
444 | |||
445 | SDK_POSTPROCESS_COMMAND += "buildhistory_get_sdkinfo ; " | ||
446 | |||
403 | def buildhistory_get_layers(d): | 447 | def buildhistory_get_layers(d): |
404 | layertext = "Configured metadata layers:\n%s\n" % '\n'.join(get_layers_branch_rev(d)) | 448 | layertext = "Configured metadata layers:\n%s\n" % '\n'.join(get_layers_branch_rev(d)) |
405 | return layertext | 449 | return layertext |
@@ -418,15 +462,11 @@ def squashspaces(string): | |||
418 | import re | 462 | import re |
419 | return re.sub("\s+", " ", string).strip() | 463 | return re.sub("\s+", " ", string).strip() |
420 | 464 | ||
421 | 465 | def outputvars(vars, listvars, d): | |
422 | def buildhistory_get_imagevars(d): | 466 | vars = vars.split() |
423 | imagevars = "DISTRO DISTRO_VERSION USER_CLASSES IMAGE_CLASSES IMAGE_FEATURES IMAGE_LINGUAS IMAGE_INSTALL BAD_RECOMMENDATIONS ROOTFS_POSTPROCESS_COMMAND IMAGE_POSTPROCESS_COMMAND" | ||
424 | listvars = "USER_CLASSES IMAGE_CLASSES IMAGE_FEATURES IMAGE_LINGUAS IMAGE_INSTALL BAD_RECOMMENDATIONS" | ||
425 | |||
426 | imagevars = imagevars.split() | ||
427 | listvars = listvars.split() | 467 | listvars = listvars.split() |
428 | ret = "" | 468 | ret = "" |
429 | for var in imagevars: | 469 | for var in vars: |
430 | value = d.getVar(var, True) or "" | 470 | value = d.getVar(var, True) or "" |
431 | if var in listvars: | 471 | if var in listvars: |
432 | # Squash out spaces | 472 | # Squash out spaces |
@@ -434,6 +474,16 @@ def buildhistory_get_imagevars(d): | |||
434 | ret += "%s = %s\n" % (var, value) | 474 | ret += "%s = %s\n" % (var, value) |
435 | return ret.rstrip('\n') | 475 | return ret.rstrip('\n') |
436 | 476 | ||
477 | def buildhistory_get_imagevars(d): | ||
478 | imagevars = "DISTRO DISTRO_VERSION USER_CLASSES IMAGE_CLASSES IMAGE_FEATURES IMAGE_LINGUAS IMAGE_INSTALL BAD_RECOMMENDATIONS ROOTFS_POSTPROCESS_COMMAND IMAGE_POSTPROCESS_COMMAND" | ||
479 | listvars = "USER_CLASSES IMAGE_CLASSES IMAGE_FEATURES IMAGE_LINGUAS IMAGE_INSTALL BAD_RECOMMENDATIONS" | ||
480 | return outputvars(imagevars, listvars, d) | ||
481 | |||
482 | def buildhistory_get_sdkvars(d): | ||
483 | sdkvars = "DISTRO DISTRO_VERSION SDK_NAME SDK_VERSION SDKMACHINE SDKIMAGE_FEATURES BAD_RECOMMENDATIONS" | ||
484 | listvars = "SDKIMAGE_FEATURES BAD_RECOMMENDATIONS" | ||
485 | return outputvars(sdkvars, listvars, d) | ||
486 | |||
437 | 487 | ||
438 | buildhistory_commit() { | 488 | buildhistory_commit() { |
439 | if [ ! -d ${BUILDHISTORY_DIR} ] ; then | 489 | if [ ! -d ${BUILDHISTORY_DIR} ] ; then |