meta-app-framework: Add Flutter app icon installation
[AGL/meta-agl.git] / meta-app-framework / classes / agl-app.bbclass
1 #
2 # AGL application systemd unit installation class
3 #
4
5 # Systemd template unit
6 # * agl-app, agl-app-web, agl-app-flutter valid
7 AGL_APP_TEMPLATE ?= "agl-app"
8
9 # Application ID
10 # This is what the application will be referred to in the list
11 # exposed to clients by applaunchd, and generally ends up as the
12 # identifier used by agl-compositor for application surface
13 # activation.
14 AGL_APP_ID ?= "${BPN}"
15
16 # Application display name
17 AGL_APP_NAME ?= "${AGL_APP_ID}"
18
19 # Application executable
20 # * agl-app template only
21 # Use if the application ID and the executable name are both
22 # different from the package name and each other as well.
23 AGL_APP_EXEC ?= "${AGL_APP_ID}"
24
25 # Web application bundle directory (non-absolute, so directory
26 # name under /usr/lib/wam_apps)
27 # * agl-app-web template only
28 # Use if the web application bundle installs to a directory that
29 # is not the same as the package name.
30 AGL_APP_WAM_DIR ?= "${BPN}"
31
32 do_install:append () {
33     install -d ${D}${systemd_system_unitdir}
34     ln -s ${AGL_APP_TEMPLATE}\@.service \
35         ${D}${systemd_system_unitdir}/${AGL_APP_TEMPLATE}\@${AGL_APP_ID}.service
36
37     # NOTE: Unit & Service changes could potentially be collected
38     #       and a single override .conf created, but things will be
39     #       kept simple for now.
40
41     if [ "${AGL_APP_EXEC}" != "${AGL_APP_ID}" ]; then
42         install -d ${D}${systemd_system_unitdir}/${AGL_APP_TEMPLATE}\@${AGL_APP_ID}.service.d
43         cat <<-EOF > ${D}${systemd_system_unitdir}/${AGL_APP_TEMPLATE}\@${AGL_APP_ID}.service.d/exec.conf
44         [Service]
45         ExecStart=
46         ExecStart=${AGL_APP_EXEC}
47         EOF
48     fi
49
50     if [ "${AGL_APP_NAME}" != "${AGL_APP_ID}" ]; then
51         install -d ${D}${systemd_system_unitdir}/${AGL_APP_TEMPLATE}\@${AGL_APP_ID}.service.d
52         cat <<-EOF > ${D}${systemd_system_unitdir}/${AGL_APP_TEMPLATE}\@${AGL_APP_ID}.service.d/name.conf
53         [Unit]
54         Description=
55         Description=${AGL_APP_NAME}
56         EOF
57     fi
58
59     if [ "${AGL_APP_TEMPLATE}" = "agl-app-web" -a "${AGL_APP_ID}" != "${BPN}" ]; then
60         # The application ID does not necessarily match the package name
61         # used in the WAM install hierarchy, and the IDs are hard-coded in
62         # some of the web apps, so if necessary create an override for the
63         # environment variable used in place of directly deriving from %i
64         # (which will always be the app id).
65         install -d ${D}${systemd_system_unitdir}/${AGL_APP_TEMPLATE}\@${AGL_APP_ID}.service.d
66         cat <<-EOF > ${D}${systemd_system_unitdir}/${AGL_APP_TEMPLATE}\@${AGL_APP_ID}.service.d/wam.conf
67         [Service]
68         Environment=AGL_APP_WAM_DIR=${AGL_APP_WAM_DIR}
69         EOF
70     fi
71
72     if [ "${AGL_APP_TEMPLATE}" = "agl-app-flutter" ]; then
73        # Install icon if present
74        if [ -f ${S}/package/${AGL_APP_ID}.svg ]; then
75           install -d ${D}${datadir}/icons/hicolor/scalable
76           install -m 0644 ${S}/package/${AGL_APP_ID}.svg ${D}${datadir}/icons/hicolor/scalable/
77        fi
78    fi
79 }
80
81 FILES:${PN}:append = " ${systemd_system_unitdir} ${datadir}/icons"
82
83 RDEPENDS:${PN}:append = " applaunchd-template-${AGL_APP_TEMPLATE}"