xref: /OK3568_Linux_fs/yocto/poky/meta/recipes-devtools/bootchart2/bootchart2_0.14.9.bb (revision 4882a59341e53eb6f0b4789bf948001014eff981)
1*4882a593Smuzhiyun# Copyright (c) 2013 LG Electronics, Inc.
2*4882a593Smuzhiyun# Copyright (C) 2014 Intel Corp.
3*4882a593Smuzhiyun
4*4882a593Smuzhiyun# This recipe creates packages for the bootchart2 system-wide profiler daemon
5*4882a593Smuzhiyun# and related utilities. Depending on the images you're building, additional
6*4882a593Smuzhiyun# configuration may be needed in order to use it.
7*4882a593Smuzhiyun#
8*4882a593Smuzhiyun# Packages:
9*4882a593Smuzhiyun#   *   bootchart2 - The daemon itself.
10*4882a593Smuzhiyun#   *   pybootchartgui - Python program to visualize and display the data
11*4882a593Smuzhiyun#       collected by bootchart2 or compatible daemons such as the original
12*4882a593Smuzhiyun#       bootchart.
13*4882a593Smuzhiyun#   *   bootchartd-stop-initscript - A SysV init script to stop data collection
14*4882a593Smuzhiyun#       when booting completes (see below for details.)
15*4882a593Smuzhiyun#
16*4882a593Smuzhiyun# While bootchart2 is designed to stop collecting data roughly when the boot
17*4882a593Smuzhiyun# process completes, it is not exactly a stopwatch. It has a list of programs
18*4882a593Smuzhiyun# which are supposed signify that the boot process has completed (for example,
19*4882a593Smuzhiyun# openbox or gnome-shell,) but it waits a full 20 seconds after such a program
20*4882a593Smuzhiyun# is launched before stopping itself, to collect additional data.
21*4882a593Smuzhiyun#
22*4882a593Smuzhiyun# If you are using a window manager or GUI which isn't included in bootchart2's
23*4882a593Smuzhiyun# default configuration file, you should write bbappend file to amend
24*4882a593Smuzhiyun# bootchartd.conf and add it to EXIT_PROC. An example of this is shown in this
25*4882a593Smuzhiyun# recipe, where the Matchbox window manager (used by Sato) is added.
26*4882a593Smuzhiyun#
27*4882a593Smuzhiyun# If you want data collection to end at a certain point exactly, you should
28*4882a593Smuzhiyun# arrange for the following command to be run:
29*4882a593Smuzhiyun#   bootchartd stop
30*4882a593Smuzhiyun# You might set this command to be launched by the desktop environment shipped
31*4882a593Smuzhiyun# on the image you're building after the other startup programs are complete.
32*4882a593Smuzhiyun# This will not incur the 20 second wait period and will cause bootchart2 to
33*4882a593Smuzhiyun# behave a bit more like a stopwatch. An example of this is shown in this
34*4882a593Smuzhiyun# recipe, specifically the bootchartd-stop-initscript package, which stops data
35*4882a593Smuzhiyun# collection as the last action when switching to runlevels 2 through 5. You can
36*4882a593Smuzhiyun# add bootchartd-stop-initscript to IMAGE_INSTALL if you need to use it.
37*4882a593Smuzhiyun#
38*4882a593Smuzhiyun# Unless you're doing something special, if your image does not launch an X
39*4882a593Smuzhiyun# window manager, you will need to add bootchartd-stop-initscript to your image.
40*4882a593Smuzhiyun#
41*4882a593Smuzhiyun# Bootchart2 can be started in two ways. Data collection can be initiated by
42*4882a593Smuzhiyun# running the following command:
43*4882a593Smuzhiyun#   bootchartd start
44*4882a593Smuzhiyun# However, for the most complete data, the bootchart2 developers recommend
45*4882a593Smuzhiyun# running it as PID 1. This can be done by adding the following to the kernel
46*4882a593Smuzhiyun# command line parameters in the bootloader setup:
47*4882a593Smuzhiyun#   init=/sbin/bootchartd
48*4882a593Smuzhiyun# When invoked this way, bootchart2 will set itself up and then automatically
49*4882a593Smuzhiyun# run /sbin/init. For example, when booting the default qemux86 image, one might
50*4882a593Smuzhiyun# use a command like this:
51*4882a593Smuzhiyun#   runqemu qemux86 bootparams="initcall_debug printk.time=y quiet \
52*4882a593Smuzhiyun#                               init=/sbin/bootchartd"
53*4882a593Smuzhiyun#
54*4882a593Smuzhiyun# Neither method is actually implemented here, choose what works for you.
55*4882a593Smuzhiyun#
56*4882a593Smuzhiyun# If you are building your image with systemd instead of SysV init, bootchart2
57*4882a593Smuzhiyun# includes systemd service files to begin collection automatically at boot and
58*4882a593Smuzhiyun# end collection automatically 20 seconds after the boot process has completed.
59*4882a593Smuzhiyun# However, be aware that systemd tends to start bootchart2 relatively late into
60*4882a593Smuzhiyun# the boot process, so it's highly recommended to use bootchart2 as PID 1. If
61*4882a593Smuzhiyun# you're using systemd and you wish to use another method to stop data
62*4882a593Smuzhiyun# collection at a time of your choosing, you may do so as long as you get to it
63*4882a593Smuzhiyun# before the 20 second timeout of the systemd service files. Also, you may write
64*4882a593Smuzhiyun# a bbappend to patch bootchart2-done.timer.in to increase or decrease the
65*4882a593Smuzhiyun# timeout. Decreasing it to 0 will make it behave like
66*4882a593Smuzhiyun# bootchartd-stop-initscript.
67*4882a593Smuzhiyun#
68*4882a593Smuzhiyun# By default, when data collection is stopped, a file named bootchart.tgz will
69*4882a593Smuzhiyun# be created in /var/log. If pybootchartgui is included in your image,
70*4882a593Smuzhiyun# bootchart.png will also be created at the same time. However, this results in
71*4882a593Smuzhiyun# a noticeable hitch or pause at boot time, which may not be what you want on an
72*4882a593Smuzhiyun# embedded device. So you may prefer to omit pybootchartgui from your image. In
73*4882a593Smuzhiyun# that case, copy bootchart.tgz over to your development system and generate
74*4882a593Smuzhiyun# bootchart.png there. To get pybootchartgui on your development system, you can
75*4882a593Smuzhiyun# either install it directly from some other source, or build bootchart2-native
76*4882a593Smuzhiyun# and find pybootchartgui in the native sysroot:
77*4882a593Smuzhiyun#    bitbake bootchart2-native
78*4882a593Smuzhiyun#   ./tmp/sysroots/x86_64-linux/usr/bin/pybootchartgui /path/to/bootchart.tgz
79*4882a593Smuzhiyun# Note that, whether installed on your build system or on your image, the
80*4882a593Smuzhiyun# pybootchartgui provided by this recipe does not support the -i option. You
81*4882a593Smuzhiyun# will need to install pybootchartgui by other means in order to run it in
82*4882a593Smuzhiyun# interactive mode.
83*4882a593Smuzhiyun
84*4882a593SmuzhiyunSUMMARY = "Booting sequence and CPU,I/O usage monitor"
85*4882a593SmuzhiyunDESCRIPTION = "Monitors where the system spends its time at start, creating a graph of all processes, disk utilization, and wait time."
86*4882a593SmuzhiyunAUTHOR = "Wonhong Kwon <wonhong.kwon@lge.com>"
87*4882a593SmuzhiyunHOMEPAGE = "https://github.com/mmeeks/bootchart"
88*4882a593SmuzhiyunLICENSE = "GPL-3.0-only"
89*4882a593SmuzhiyunLIC_FILES_CHKSUM = "file://COPYING;md5=44ac4678311254db62edf8fd39cb8124"
90*4882a593Smuzhiyun
91*4882a593SmuzhiyunUPSTREAM_CHECK_GITTAGREGEX = "(?P<pver>\d+\.\d+(\.\d+)*)"
92*4882a593Smuzhiyun
93*4882a593SmuzhiyunSRC_URI = "git://github.com/xrmx/bootchart.git;branch=master;protocol=https \
94*4882a593Smuzhiyun           file://bootchartd_stop.sh \
95*4882a593Smuzhiyun           file://0001-collector-Allocate-space-on-heap-for-chunks.patch \
96*4882a593Smuzhiyun           file://0001-bootchartd.in-make-sure-only-one-bootchartd-process.patch \
97*4882a593Smuzhiyun          "
98*4882a593Smuzhiyun
99*4882a593SmuzhiyunS = "${WORKDIR}/git"
100*4882a593SmuzhiyunSRCREV = "868a2afab9da34f32c007d773b77253c93104636"
101*4882a593Smuzhiyun
102*4882a593Smuzhiyun# remove at next version upgrade or when output changes
103*4882a593SmuzhiyunPR = "r1"
104*4882a593SmuzhiyunHASHEQUIV_HASH_VERSION .= ".1"
105*4882a593Smuzhiyun
106*4882a593Smuzhiyuninherit systemd update-rc.d python3native update-alternatives
107*4882a593Smuzhiyun
108*4882a593SmuzhiyunALTERNATIVE:${PN} = "bootchartd"
109*4882a593SmuzhiyunALTERNATIVE_LINK_NAME[bootchartd] = "${base_sbindir}/bootchartd"
110*4882a593SmuzhiyunALTERNATIVE_PRIORITY = "100"
111*4882a593Smuzhiyun
112*4882a593Smuzhiyun# The only reason to build bootchart2-native is for a native pybootchartgui.
113*4882a593SmuzhiyunBBCLASSEXTEND = "native"
114*4882a593Smuzhiyun
115*4882a593SmuzhiyunSYSTEMD_SERVICE:${PN} = "bootchart2.service bootchart2-done.service bootchart2-done.timer"
116*4882a593Smuzhiyun
117*4882a593SmuzhiyunUPDATERCPN = "bootchartd-stop-initscript"
118*4882a593SmuzhiyunINITSCRIPT_NAME = "bootchartd_stop.sh"
119*4882a593SmuzhiyunINITSCRIPT_PARAMS = "start 99 2 3 4 5 ."
120*4882a593Smuzhiyun
121*4882a593Smuzhiyundo_compile:prepend () {
122*4882a593Smuzhiyun    export PY_LIBDIR="${libdir}/${PYTHON_DIR}"
123*4882a593Smuzhiyun    export BINDIR="${bindir}"
124*4882a593Smuzhiyun    export LIBDIR="/${baselib}"
125*4882a593Smuzhiyun    export EARLY_PREFIX="${root_prefix}"
126*4882a593Smuzhiyun}
127*4882a593Smuzhiyun
128*4882a593Smuzhiyundo_install () {
129*4882a593Smuzhiyun    install -d ${D}${sysconfdir} # needed for -native
130*4882a593Smuzhiyun    export PY_LIBDIR="${libdir}/${PYTHON_DIR}"
131*4882a593Smuzhiyun    export BINDIR="${bindir}"
132*4882a593Smuzhiyun    export DESTDIR="${D}"
133*4882a593Smuzhiyun    export LIBDIR="/${baselib}"
134*4882a593Smuzhiyun    export EARLY_PREFIX="${root_prefix}"
135*4882a593Smuzhiyun
136*4882a593Smuzhiyun    oe_runmake install NO_PYTHON_COMPILE=1
137*4882a593Smuzhiyun    install -d ${D}${sysconfdir}/init.d
138*4882a593Smuzhiyun    install -m 0755 ${WORKDIR}/bootchartd_stop.sh ${D}${sysconfdir}/init.d
139*4882a593Smuzhiyun
140*4882a593Smuzhiyun    echo 'EXIT_PROC="$EXIT_PROC matchbox-window-manager"' >> ${D}${sysconfdir}/bootchartd.conf
141*4882a593Smuzhiyun
142*4882a593Smuzhiyun   # Use python 3 instead of python 2
143*4882a593Smuzhiyun   sed -i -e '1s,#!.*python.*,#!${USRBINPATH}/env python3,' ${D}${bindir}/pybootchartgui
144*4882a593Smuzhiyun
145*4882a593Smuzhiyun    # The timestamps embedded in compressed man pages is not reproducible
146*4882a593Smuzhiyun    gzip -d ${D}${mandir}/man1/*.gz
147*4882a593Smuzhiyun}
148*4882a593Smuzhiyun
149*4882a593SmuzhiyunPACKAGES =+ "pybootchartgui"
150*4882a593SmuzhiyunFILES:pybootchartgui += "${PYTHON_SITEPACKAGES_DIR}/pybootchartgui ${bindir}/pybootchartgui"
151*4882a593SmuzhiyunRDEPENDS:pybootchartgui = "python3-pycairo python3-compression python3-image python3-math python3-shell python3-compression python3-codecs"
152*4882a593SmuzhiyunRDEPENDS:${PN}:class-target += "${@bb.utils.contains('DISTRO_FEATURES', 'sysvinit', 'sysvinit-pidof', 'procps', d)}"
153*4882a593SmuzhiyunRDEPENDS:${PN}:class-target += "lsb-release"
154*4882a593SmuzhiyunDEPENDS:append:class-native = " python3-pycairo-native"
155*4882a593Smuzhiyun
156*4882a593SmuzhiyunPACKAGES =+ "bootchartd-stop-initscript"
157*4882a593SmuzhiyunFILES:bootchartd-stop-initscript += "${sysconfdir}/init.d ${sysconfdir}/rc*.d"
158*4882a593SmuzhiyunRDEPENDS:bootchartd-stop-initscript = "${PN}"
159*4882a593Smuzhiyun
160*4882a593SmuzhiyunFILES:${PN} += "${base_libdir}/bootchart/bootchart-collector"
161*4882a593SmuzhiyunFILES:${PN} += "${base_libdir}/bootchart/tmpfs"
162*4882a593SmuzhiyunFILES:${PN} += "${libdir}"
163*4882a593SmuzhiyunFILES:${PN}-doc += "${datadir}/docs"
164*4882a593Smuzhiyun
165*4882a593SmuzhiyunRCONFLICTS:${PN} = "bootchart"
166