1eb8dc403SDave CobbleySUMMARY = "Userspace framebuffer boot logo based on usplash"
2eb8dc403SDave CobbleyDESCRIPTION = "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."
3eb8dc403SDave CobbleyHOMEPAGE = "http://git.yoctoproject.org/cgit/cgit.cgi/psplash"
4eb8dc403SDave CobbleySECTION = "base"
57e0e3c0cSAndrew GeisslerLICENSE = "GPL-2.0-or-later"
682c905dcSAndrew GeisslerLIC_FILES_CHKSUM = "file://psplash.h;beginline=1;endline=8;md5=8f232c1e95929eacab37f00900580224"
782c905dcSAndrew GeisslerDEPENDS = "gdk-pixbuf-native"
8eb8dc403SDave Cobbley
9*169d7bccSPatrick WilliamsSRCREV = "ecc1913756698d0c87ad8fa10e44b29537f09ad1"
105082cc7fSAndrew GeisslerPV = "0.1+git"
11eb8dc403SDave Cobbley
12028142bdSAndrew GeisslerSRC_URI = "git://git.yoctoproject.org/${BPN};branch=master;protocol=https \
13eb8dc403SDave Cobbley           file://psplash-init \
1482c905dcSAndrew Geissler           file://psplash-start.service \
1582c905dcSAndrew Geissler           file://psplash-systemd.service \
16eb8dc403SDave Cobbley           ${SPLASH_IMAGES}"
17eb8dc403SDave CobbleyUPSTREAM_CHECK_COMMITS = "1"
18eb8dc403SDave Cobbley
19520786ccSPatrick WilliamsSPLASH_IMAGES = "file://psplash-poky-img.png;outsuffix=default"
20eb8dc403SDave Cobbley
21eb8dc403SDave Cobbleypython __anonymous() {
22eb8dc403SDave Cobbley    oldpkgs = d.getVar("PACKAGES").split()
23eb8dc403SDave Cobbley    splashfiles = d.getVar('SPLASH_IMAGES').split()
241e34c2d0SAndrew Geissler    mlprefix = d.getVar('MLPREFIX') or ''
25eb8dc403SDave Cobbley    pkgs = []
26eb8dc403SDave Cobbley    localpaths = []
27eb8dc403SDave Cobbley    for uri in splashfiles:
28eb8dc403SDave Cobbley        fetcher = bb.fetch2.Fetch([uri], d)
29eb8dc403SDave Cobbley        flocal = os.path.basename(fetcher.localpath(uri))
30eb8dc403SDave Cobbley        fbase = os.path.splitext(flocal)[0]
31eb8dc403SDave Cobbley        outsuffix = fetcher.ud[uri].parm.get("outsuffix")
32eb8dc403SDave Cobbley        if not outsuffix:
33eb8dc403SDave Cobbley            if fbase.startswith("psplash-"):
34eb8dc403SDave Cobbley                outsuffix = fbase[8:]
35eb8dc403SDave Cobbley            else:
36eb8dc403SDave Cobbley                outsuffix = fbase
37eb8dc403SDave Cobbley            if outsuffix.endswith('-img'):
38eb8dc403SDave Cobbley                outsuffix = outsuffix[:-4]
39eb8dc403SDave Cobbley        outname = "psplash-%s" % outsuffix
40eb8dc403SDave Cobbley        if outname == '' or outname in oldpkgs:
41eb8dc403SDave Cobbley            bb.fatal("The output name '%s' derived from the URI %s is not valid, please specify the outsuffix parameter" % (outname, uri))
42eb8dc403SDave Cobbley        else:
43eb8dc403SDave Cobbley            pkgs.append(outname)
44eb8dc403SDave Cobbley        localpaths.append(flocal)
45eb8dc403SDave Cobbley
46213cb269SPatrick Williams    # Set these so that we have less work to do in do_compile and do_install:append
47eb8dc403SDave Cobbley    d.setVar("SPLASH_INSTALL", " ".join(pkgs))
48eb8dc403SDave Cobbley    d.setVar("SPLASH_LOCALPATHS", " ".join(localpaths))
491e34c2d0SAndrew Geissler    for p in pkgs:
501e34c2d0SAndrew Geissler        d.prependVar("PACKAGES", "%s%s " % (mlprefix, p))
51eb8dc403SDave Cobbley
52eb8dc403SDave Cobbley    pn = d.getVar('PN') or ''
53eb8dc403SDave Cobbley    for p in pkgs:
54eb8dc403SDave Cobbley        ep = '%s%s' % (mlprefix, p)
55eb8dc403SDave Cobbley        epsplash = '%s%s' % (mlprefix, 'psplash')
56213cb269SPatrick Williams        d.setVar("FILES:%s" % ep, "${bindir}/%s" % p)
57213cb269SPatrick Williams        d.setVar("ALTERNATIVE:%s" % ep, 'psplash')
58eb8dc403SDave Cobbley        d.setVarFlag("ALTERNATIVE_TARGET_%s" % ep, 'psplash', '${bindir}/%s' % p)
59213cb269SPatrick Williams        d.appendVar("RDEPENDS:%s" % ep, " %s" % pn)
60eb8dc403SDave Cobbley        if p == "psplash-default":
612390b1b6SPatrick Williams            d.appendVar("RDEPENDS:%s" % pn, " %s" % ep)
62eb8dc403SDave Cobbley}
63eb8dc403SDave Cobbley
64eb8dc403SDave CobbleyS = "${WORKDIR}/git"
65eb8dc403SDave Cobbley
6682c905dcSAndrew Geisslerinherit autotools pkgconfig update-rc.d update-alternatives systemd
6782c905dcSAndrew Geissler
68b542dec1SPatrick WilliamsPACKAGECONFIG ??= "${@bb.utils.filter('DISTRO_FEATURES', 'systemd', d)} progress-bar fullscreen"
6982c905dcSAndrew Geissler
7082c905dcSAndrew GeisslerPACKAGECONFIG[systemd] = "--with-systemd,--without-systemd,systemd"
71b542dec1SPatrick WilliamsPACKAGECONFIG[fullscreen] = "--enable-img-fullscreen"
72b542dec1SPatrick WilliamsPACKAGECONFIG[startup-msg] = ",--disable-startup-msg"
73b542dec1SPatrick WilliamsPACKAGECONFIG[progress-bar] = ",--disable-progress-bar"
74eb8dc403SDave Cobbley
75eb8dc403SDave CobbleyALTERNATIVE_PRIORITY = "100"
76eb8dc403SDave CobbleyALTERNATIVE_LINK_NAME[psplash] = "${bindir}/psplash"
77eb8dc403SDave Cobbley
78eb8dc403SDave Cobbleypython do_compile () {
79eb8dc403SDave Cobbley    import shutil
801a4b7ee2SBrad Bishop    import subprocess
81eb8dc403SDave Cobbley
82eb8dc403SDave Cobbley    # Build a separate executable for each splash image
83eb8dc403SDave Cobbley    workdir = d.getVar('WORKDIR')
84eb8dc403SDave Cobbley    convertscript = "%s/make-image-header.sh" % d.getVar('S')
8582c905dcSAndrew Geissler    destfile = "%s/psplash-poky-img.h" % d.getVar('B')
86eb8dc403SDave Cobbley    localfiles = d.getVar('SPLASH_LOCALPATHS').split()
87eb8dc403SDave Cobbley    outputfiles = d.getVar('SPLASH_INSTALL').split()
88eb8dc403SDave Cobbley    for localfile, outputfile in zip(localfiles, outputfiles):
89eb8dc403SDave Cobbley        if localfile.endswith(".png"):
9019323693SBrad Bishop            if subprocess.call([ convertscript, os.path.join(workdir, localfile), 'POKY' ], cwd=workdir):
9119323693SBrad Bishop                bb.fatal("Error calling convert script '%s'" % (convertscript))
92eb8dc403SDave Cobbley            fbase = os.path.splitext(localfile)[0]
9319323693SBrad Bishop            shutil.copyfile(os.path.join(workdir, "%s-img.h" % fbase), destfile)
94eb8dc403SDave Cobbley        else:
95eb8dc403SDave Cobbley            shutil.copyfile(os.path.join(workdir, localfile), destfile)
96eb8dc403SDave Cobbley        # For some reason just updating the header is not enough, we have to touch the .c
97eb8dc403SDave Cobbley        # file in order to get it to rebuild
98eb8dc403SDave Cobbley        os.utime("%s/psplash.c" % d.getVar('S'), None)
99eb8dc403SDave Cobbley        bb.build.exec_func("oe_runmake", d)
100eb8dc403SDave Cobbley        shutil.copyfile("psplash", outputfile)
101eb8dc403SDave Cobbley}
102eb8dc403SDave Cobbley
103213cb269SPatrick Williamsdo_install:append() {
10482c905dcSAndrew Geissler	if ${@bb.utils.contains('DISTRO_FEATURES', 'sysvinit', 'true', 'false', d)}; then
105eb8dc403SDave Cobbley		install -d ${D}${sysconfdir}/init.d/
106eb8dc403SDave Cobbley		install -m 0755 ${WORKDIR}/psplash-init ${D}${sysconfdir}/init.d/psplash.sh
107d1e89497SAndrew Geissler
108d1e89497SAndrew Geissler		# make fifo for psplash
109d1e89497SAndrew Geissler		install -d ${D}/mnt
110d1e89497SAndrew Geissler		mkfifo ${D}/mnt/psplash_fifo
11182c905dcSAndrew Geissler	fi
11282c905dcSAndrew Geissler
11382c905dcSAndrew Geissler	if ${@bb.utils.contains('DISTRO_FEATURES', 'systemd', 'true', 'false', d)}; then
1145199d831SAndrew Geissler		install -d ${D}${systemd_system_unitdir}
1155199d831SAndrew Geissler		install -m 644 ${WORKDIR}/psplash-start.service ${D}/${systemd_system_unitdir}
1165199d831SAndrew Geissler		install -m 644 ${WORKDIR}/psplash-systemd.service ${D}/${systemd_system_unitdir}
11782c905dcSAndrew Geissler	fi
11882c905dcSAndrew Geissler
119eb8dc403SDave Cobbley	install -d ${D}${bindir}
120eb8dc403SDave Cobbley	for i in ${SPLASH_INSTALL} ; do
121eb8dc403SDave Cobbley		install -m 0755 $i ${D}${bindir}/$i
122eb8dc403SDave Cobbley	done
123eb8dc403SDave Cobbley	rm -f ${D}${bindir}/psplash
124eb8dc403SDave Cobbley}
125eb8dc403SDave Cobbley
12682c905dcSAndrew GeisslerSYSTEMD_PACKAGES = "${@bb.utils.contains('DISTRO_FEATURES','systemd','${PN}','',d)}"
127213cb269SPatrick WilliamsSYSTEMD_SERVICE:${PN} += "${@bb.utils.contains('PACKAGECONFIG', 'systemd', 'psplash-start.service psplash-systemd.service', '', d)}"
12882c905dcSAndrew Geissler
129eb8dc403SDave CobbleyINITSCRIPT_NAME = "psplash.sh"
130eb8dc403SDave CobbleyINITSCRIPT_PARAMS = "start 0 S . stop 20 0 1 6 ."
131d1e89497SAndrew Geissler
132213cb269SPatrick WilliamsFILES:${PN} += "/mnt"
133