1SUMMARY = "Userspace framebuffer boot logo based on usplash"
2DESCRIPTION = "PSplash is a userspace graphical boot splash screen for mainly embedded Linux devices supporting a 16bpp or 32bpp framebuffer. It has few dependencies (just libc), supports basic images and text and handles rotation. Its visual look is configurable by basic source changes. Also included is a 'client' command utility for sending information to psplash such as boot progress information."
3HOMEPAGE = "http://git.yoctoproject.org/cgit/cgit.cgi/psplash"
4SECTION = "base"
5LICENSE = "GPLv2+"
6LIC_FILES_CHKSUM = "file://psplash.h;beginline=1;endline=8;md5=8f232c1e95929eacab37f00900580224"
7DEPENDS = "gdk-pixbuf-native"
8
9SRCREV = "0a902f7cd875ccf018456451be369f05fa55f962"
10PV = "0.1+git${SRCPV}"
11PR = "r15"
12
13SRC_URI = "git://git.yoctoproject.org/${BPN} \
14           file://psplash-init \
15           file://psplash-start.service \
16           file://psplash-systemd.service \
17           ${SPLASH_IMAGES}"
18UPSTREAM_CHECK_COMMITS = "1"
19
20SPLASH_IMAGES = "file://psplash-poky-img.h;outsuffix=default"
21
22python __anonymous() {
23    oldpkgs = d.getVar("PACKAGES").split()
24    splashfiles = d.getVar('SPLASH_IMAGES').split()
25    pkgs = []
26    localpaths = []
27    for uri in splashfiles:
28        fetcher = bb.fetch2.Fetch([uri], d)
29        flocal = os.path.basename(fetcher.localpath(uri))
30        fbase = os.path.splitext(flocal)[0]
31        outsuffix = fetcher.ud[uri].parm.get("outsuffix")
32        if not outsuffix:
33            if fbase.startswith("psplash-"):
34                outsuffix = fbase[8:]
35            else:
36                outsuffix = fbase
37            if outsuffix.endswith('-img'):
38                outsuffix = outsuffix[:-4]
39        outname = "psplash-%s" % outsuffix
40        if outname == '' or outname in oldpkgs:
41            bb.fatal("The output name '%s' derived from the URI %s is not valid, please specify the outsuffix parameter" % (outname, uri))
42        else:
43            pkgs.append(outname)
44        localpaths.append(flocal)
45
46    # Set these so that we have less work to do in do_compile and do_install_append
47    d.setVar("SPLASH_INSTALL", " ".join(pkgs))
48    d.setVar("SPLASH_LOCALPATHS", " ".join(localpaths))
49
50    d.prependVar("PACKAGES", "%s " % (" ".join(pkgs)))
51    mlprefix = d.getVar('MLPREFIX') or ''
52    pn = d.getVar('PN') or ''
53    for p in pkgs:
54        ep = '%s%s' % (mlprefix, p)
55        epsplash = '%s%s' % (mlprefix, 'psplash')
56        d.setVar("FILES_%s" % ep, "${bindir}/%s" % p)
57        d.setVar("ALTERNATIVE_%s" % ep, 'psplash')
58        d.setVarFlag("ALTERNATIVE_TARGET_%s" % ep, 'psplash', '${bindir}/%s' % p)
59        d.appendVar("RDEPENDS_%s" % ep, " %s" % pn)
60        if p == "psplash-default":
61            d.appendVar("RRECOMMENDS_%s" % pn, " %s" % ep)
62}
63
64S = "${WORKDIR}/git"
65
66inherit autotools pkgconfig update-rc.d update-alternatives systemd
67
68PACKAGECONFIG ??= "${@bb.utils.filter('DISTRO_FEATURES', 'systemd', d)}"
69
70PACKAGECONFIG[systemd] = "--with-systemd,--without-systemd,systemd"
71
72ALTERNATIVE_PRIORITY = "100"
73ALTERNATIVE_LINK_NAME[psplash] = "${bindir}/psplash"
74
75python do_compile () {
76    import shutil
77    import subprocess
78
79    # Build a separate executable for each splash image
80    workdir = d.getVar('WORKDIR')
81    convertscript = "%s/make-image-header.sh" % d.getVar('S')
82    destfile = "%s/psplash-poky-img.h" % d.getVar('B')
83    localfiles = d.getVar('SPLASH_LOCALPATHS').split()
84    outputfiles = d.getVar('SPLASH_INSTALL').split()
85    for localfile, outputfile in zip(localfiles, outputfiles):
86        if localfile.endswith(".png"):
87            if subprocess.call([ convertscript, os.path.join(workdir, localfile), 'POKY' ], cwd=workdir):
88                bb.fatal("Error calling convert script '%s'" % (convertscript))
89            fbase = os.path.splitext(localfile)[0]
90            shutil.copyfile(os.path.join(workdir, "%s-img.h" % fbase), destfile)
91        else:
92            shutil.copyfile(os.path.join(workdir, localfile), destfile)
93        # For some reason just updating the header is not enough, we have to touch the .c
94        # file in order to get it to rebuild
95        os.utime("%s/psplash.c" % d.getVar('S'), None)
96        bb.build.exec_func("oe_runmake", d)
97        shutil.copyfile("psplash", outputfile)
98}
99
100do_install_append() {
101	if ${@bb.utils.contains('DISTRO_FEATURES', 'sysvinit', 'true', 'false', d)}; then
102		install -d ${D}${sysconfdir}/init.d/
103		install -m 0755 ${WORKDIR}/psplash-init ${D}${sysconfdir}/init.d/psplash.sh
104	fi
105
106	if ${@bb.utils.contains('DISTRO_FEATURES', 'systemd', 'true', 'false', d)}; then
107		install -d ${D}${systemd_unitdir}/system
108		install -m 644 ${WORKDIR}/psplash-start.service ${D}/${systemd_unitdir}/system
109		install -m 644 ${WORKDIR}/psplash-systemd.service ${D}/${systemd_unitdir}/system
110	fi
111
112	install -d ${D}${bindir}
113	for i in ${SPLASH_INSTALL} ; do
114		install -m 0755 $i ${D}${bindir}/$i
115	done
116	rm -f ${D}${bindir}/psplash
117}
118
119SYSTEMD_PACKAGES = "${@bb.utils.contains('DISTRO_FEATURES','systemd','${PN}','',d)}"
120SYSTEMD_SERVICE_${PN} += "${@bb.utils.contains('PACKAGECONFIG', 'systemd', 'psplash-start.service psplash-systemd.service', '', d)}"
121
122INITSCRIPT_NAME = "psplash.sh"
123INITSCRIPT_PARAMS = "start 0 S . stop 20 0 1 6 ."
124