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 = "GPL-2.0-or-later"
6LIC_FILES_CHKSUM = "file://psplash.h;beginline=1;endline=8;md5=8f232c1e95929eacab37f00900580224"
7DEPENDS = "gdk-pixbuf-native"
8
9SRCREV = "ecc1913756698d0c87ad8fa10e44b29537f09ad1"
10PV = "0.1+git"
11
12SRC_URI = "git://git.yoctoproject.org/${BPN};branch=master;protocol=https \
13           file://psplash-init \
14           file://psplash-start.service \
15           file://psplash-systemd.service \
16           ${SPLASH_IMAGES}"
17UPSTREAM_CHECK_COMMITS = "1"
18
19SPLASH_IMAGES = "file://psplash-poky-img.png;outsuffix=default"
20
21python __anonymous() {
22    oldpkgs = d.getVar("PACKAGES").split()
23    splashfiles = d.getVar('SPLASH_IMAGES').split()
24    mlprefix = d.getVar('MLPREFIX') or ''
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    for p in pkgs:
50        d.prependVar("PACKAGES", "%s%s " % (mlprefix, p))
51
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("RDEPENDS:%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)} progress-bar fullscreen"
69
70PACKAGECONFIG[systemd] = "--with-systemd,--without-systemd,systemd"
71PACKAGECONFIG[fullscreen] = "--enable-img-fullscreen"
72PACKAGECONFIG[startup-msg] = ",--disable-startup-msg"
73PACKAGECONFIG[progress-bar] = ",--disable-progress-bar"
74
75ALTERNATIVE_PRIORITY = "100"
76ALTERNATIVE_LINK_NAME[psplash] = "${bindir}/psplash"
77
78python do_compile () {
79    import shutil
80    import subprocess
81
82    # Build a separate executable for each splash image
83    workdir = d.getVar('UNPACKDIR')
84    convertscript = "%s/make-image-header.sh" % d.getVar('S')
85    destfile = "%s/psplash-poky-img.h" % d.getVar('B')
86    localfiles = d.getVar('SPLASH_LOCALPATHS').split()
87    outputfiles = d.getVar('SPLASH_INSTALL').split()
88    for localfile, outputfile in zip(localfiles, outputfiles):
89        if localfile.endswith(".png"):
90            if subprocess.call([ convertscript, os.path.join(workdir, localfile), 'POKY' ], cwd=workdir):
91                bb.fatal("Error calling convert script '%s'" % (convertscript))
92            fbase = os.path.splitext(localfile)[0]
93            shutil.copyfile(os.path.join(workdir, "%s-img.h" % fbase), destfile)
94        else:
95            shutil.copyfile(os.path.join(workdir, localfile), destfile)
96        # For some reason just updating the header is not enough, we have to touch the .c
97        # file in order to get it to rebuild
98        os.utime("%s/psplash.c" % d.getVar('S'), None)
99        bb.build.exec_func("oe_runmake", d)
100        shutil.copyfile("psplash", outputfile)
101}
102
103do_install:append() {
104	if ${@bb.utils.contains('DISTRO_FEATURES', 'sysvinit', 'true', 'false', d)}; then
105		install -d ${D}${sysconfdir}/init.d/
106		install -m 0755 ${UNPACKDIR}/psplash-init ${D}${sysconfdir}/init.d/psplash.sh
107
108		# make fifo for psplash
109		install -d ${D}/mnt
110		mkfifo ${D}/mnt/psplash_fifo
111	fi
112
113	if ${@bb.utils.contains('DISTRO_FEATURES', 'systemd', 'true', 'false', d)}; then
114		install -d ${D}${systemd_system_unitdir}
115		install -m 644 ${UNPACKDIR}/psplash-start.service ${D}/${systemd_system_unitdir}
116		install -m 644 ${UNPACKDIR}/psplash-systemd.service ${D}/${systemd_system_unitdir}
117	fi
118
119	install -d ${D}${bindir}
120	for i in ${SPLASH_INSTALL} ; do
121		install -m 0755 $i ${D}${bindir}/$i
122	done
123	rm -f ${D}${bindir}/psplash
124}
125
126SYSTEMD_PACKAGES = "${@bb.utils.contains('DISTRO_FEATURES','systemd','${PN}','',d)}"
127SYSTEMD_SERVICE:${PN} += "${@bb.utils.contains('PACKAGECONFIG', 'systemd', 'psplash-start.service psplash-systemd.service', '', d)}"
128
129INITSCRIPT_NAME = "psplash.sh"
130INITSCRIPT_PARAMS = "start 0 S . stop 20 0 1 6 ."
131
132FILES:${PN} += "/mnt"
133