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=16;md5=840fb2356b10a85bed78dd09dc7745c6"
7
8SRCREV = "2015f7073e98dd9562db0936a254af5ef56356cf"
9PV = "0.1+git${SRCPV}"
10PR = "r15"
11
12SRC_URI = "git://git.yoctoproject.org/${BPN} \
13           file://psplash-init \
14           ${SPLASH_IMAGES}"
15UPSTREAM_CHECK_COMMITS = "1"
16
17SPLASH_IMAGES = "file://psplash-poky-img.h;outsuffix=default"
18
19python __anonymous() {
20    oldpkgs = d.getVar("PACKAGES").split()
21    splashfiles = d.getVar('SPLASH_IMAGES').split()
22    pkgs = []
23    localpaths = []
24    haspng = False
25    for uri in splashfiles:
26        fetcher = bb.fetch2.Fetch([uri], d)
27        flocal = os.path.basename(fetcher.localpath(uri))
28        fbase = os.path.splitext(flocal)[0]
29        outsuffix = fetcher.ud[uri].parm.get("outsuffix")
30        if not outsuffix:
31            if fbase.startswith("psplash-"):
32                outsuffix = fbase[8:]
33            else:
34                outsuffix = fbase
35            if outsuffix.endswith('-img'):
36                outsuffix = outsuffix[:-4]
37        outname = "psplash-%s" % outsuffix
38        if outname == '' or outname in oldpkgs:
39            bb.fatal("The output name '%s' derived from the URI %s is not valid, please specify the outsuffix parameter" % (outname, uri))
40        else:
41            pkgs.append(outname)
42        if flocal.endswith(".png"):
43            haspng = True
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    if haspng:
51        d.appendVar("DEPENDS", " gdk-pixbuf-native")
52
53    d.prependVar("PACKAGES", "%s " % (" ".join(pkgs)))
54    mlprefix = d.getVar('MLPREFIX') or ''
55    pn = d.getVar('PN') or ''
56    for p in pkgs:
57        ep = '%s%s' % (mlprefix, p)
58        epsplash = '%s%s' % (mlprefix, 'psplash')
59        d.setVar("FILES_%s" % ep, "${bindir}/%s" % p)
60        d.setVar("ALTERNATIVE_%s" % ep, 'psplash')
61        d.setVarFlag("ALTERNATIVE_TARGET_%s" % ep, 'psplash', '${bindir}/%s' % p)
62        d.appendVar("RDEPENDS_%s" % ep, " %s" % pn)
63        if p == "psplash-default":
64            d.appendVar("RRECOMMENDS_%s" % pn, " %s" % ep)
65}
66
67S = "${WORKDIR}/git"
68
69inherit autotools pkgconfig update-rc.d update-alternatives
70
71ALTERNATIVE_PRIORITY = "100"
72ALTERNATIVE_LINK_NAME[psplash] = "${bindir}/psplash"
73
74python do_compile () {
75    import shutil
76    import subprocess
77
78    # Build a separate executable for each splash image
79    workdir = d.getVar('WORKDIR')
80    convertscript = "%s/make-image-header.sh" % d.getVar('S')
81    destfile = "%s/psplash-poky-img.h" % d.getVar('S')
82    localfiles = d.getVar('SPLASH_LOCALPATHS').split()
83    outputfiles = d.getVar('SPLASH_INSTALL').split()
84    for localfile, outputfile in zip(localfiles, outputfiles):
85        if localfile.endswith(".png"):
86            if subprocess.call([ convertscript, os.path.join(workdir, localfile), 'POKY' ], cwd=workdir):
87                bb.fatal("Error calling convert script '%s'" % (convertscript))
88            fbase = os.path.splitext(localfile)[0]
89            shutil.copyfile(os.path.join(workdir, "%s-img.h" % fbase), destfile)
90        else:
91            shutil.copyfile(os.path.join(workdir, localfile), destfile)
92        # For some reason just updating the header is not enough, we have to touch the .c
93        # file in order to get it to rebuild
94        os.utime("%s/psplash.c" % d.getVar('S'), None)
95        bb.build.exec_func("oe_runmake", d)
96        shutil.copyfile("psplash", outputfile)
97}
98
99do_install_append() {
100	install -d ${D}${sysconfdir}/init.d/
101	install -m 0755 ${WORKDIR}/psplash-init ${D}${sysconfdir}/init.d/psplash.sh
102	install -d ${D}${bindir}
103	for i in ${SPLASH_INSTALL} ; do
104		install -m 0755 $i ${D}${bindir}/$i
105	done
106	rm -f ${D}${bindir}/psplash
107}
108
109INITSCRIPT_NAME = "psplash.sh"
110INITSCRIPT_PARAMS = "start 0 S . stop 20 0 1 6 ."
111
112PACKAGE_WRITE_DEPS_append = " ${@bb.utils.contains('DISTRO_FEATURES','systemd','systemd-systemctl-native','',d)}"
113pkg_postinst_${PN} () {
114	if ${@bb.utils.contains('DISTRO_FEATURES','systemd','true','false',d)}; then
115		if [ -n "$D" ]; then
116			OPTS="--root=$D"
117		fi
118		systemctl $OPTS mask psplash.service
119	fi
120}
121