dreambox-console-image: don't install qt plugins by default
[opendreambox.git] / meta-opendreambox / recipes-dreambox / images / dreambox-console-image.inc
1 SUMMARY ?= "A Dreambox firmware image for headless systems"
2
3 # packages to build for the feed
4 DEPENDS = " \
5         gdb \
6         lsof \
7         ltrace \
8         strace \
9 "
10
11 python __anonymous() {
12     pkgtype = d.getVar('IMAGE_PKGTYPE', d)
13     if not oe.utils.inherits(d, 'package_%s' % pkgtype):
14         pn = d.getVar('PN', d)
15         raise bb.parse.SkipPackage("Unable to build %s without %s packages" % (pn, pkgtype))
16 }
17
18 BAD_RECOMMENDATIONS += " \
19     busybox-syslog \
20     libconnman-qt5-qmlplugins \
21     libnss-mdns \
22     qtbase-plugins \
23     qtdeclarative-plugins \
24     qtdeclarative-qmlplugins \
25     qtwebkit-qmlplugins \
26     udev-hwdb \
27     wpa-supplicant-passphrase \
28     xinetd \
29 "
30
31 # packages to drag into the image
32 IMAGE_INSTALL = " \
33     packagegroup-boot-systemd \
34     packagegroup-net-connman \
35     packagegroup-pkg-deb \
36     packagegroup-opendreambox-base \
37     packagegroup-opendreambox-dvbapi3 \
38 "
39
40 # enable online package management
41 IMAGE_FEATURES = "empty-root-password package-management"
42
43 # we don't want any locales, at least not in the common way.
44 IMAGE_LINGUAS = ""
45
46 # 512MB rootfs
47 IMAGE_ROOTFS_SIZE_ext4 = "524288"
48
49 inherit image
50
51 opendreambox_rootfs_postprocess() {
52     # generate /etc/image-version
53     IMAGE_DATE=`date +%Y%m%d%H%M`
54     # 0: Release, 1: Experimental
55     IMAGE_TYPE="1"
56     # e.g. 400 for release 4.0.0, if IMAGE_TYPE=0
57     IMAGE_VERSION="000"
58     echo "version=${IMAGE_TYPE}${IMAGE_VERSION}${IMAGE_DATE}" > ${IMAGE_ROOTFS}/etc/image-version
59 }
60
61 ROOTFS_POSTPROCESS_COMMAND += "opendreambox_rootfs_postprocess; "
62
63 python dreambox_image_nfo() {
64     def parse_status_file(filename, package):
65         kv = dict()
66         found = 0
67         with open(filename, 'r') as f:
68             for line in f.read().splitlines():
69                 try:
70                     key, value = line.split(': ', 1)
71                     if found == 0 and key == 'Package' and value == package:
72                         found = 1
73                     if found == 1:
74                         kv[key] = value
75                 except:
76                     if found == 1:
77                         break
78         return kv
79
80     def hash_image(filename, algorithm):
81         import hashlib
82         h = hashlib.new(algorithm)
83         with open(filename, 'r') as f:
84             while True:
85                 buf = f.read(1024 * 1024)
86                 if len(buf) == 0:
87                     return h.hexdigest()
88                 h.update(buf)
89         return None
90
91     def file_mtime(filename):
92         from datetime import datetime
93         dt = datetime.fromtimestamp(os.path.getmtime(filename))
94         return dt.isoformat(' ')
95
96     deploy_dir_image = d.getVar('DEPLOY_DIR_IMAGE', True)
97     distro_feed_uri = d.getVar('DISTRO_FEED_URI', True)
98     distro_name = d.getVar('DISTRO_NAME', True)
99     distro_version = d.getVar('DISTRO_VERSION', True)
100     image_fstypes = (d.getVar('IMAGE_FSTYPES', True) or "").split()
101     image_name = d.getVar('IMAGE_NAME', True)
102     image_pkgtype = d.getVar('IMAGE_PKGTYPE', True)
103     image_rootfs = d.getVar('IMAGE_ROOTFS', True)
104     machine = d.getVar('MACHINE', True)
105
106     if oe.utils.inherits(d, 'image_types_nfi'):
107         ext = 'nfi'
108     elif len(image_fstypes) >= 1:
109         ext = 'rootfs.%s' % image_fstypes[0]
110     else:
111         raise bb.build.FuncFailed('Invalid IMAGE_FSTYPES')
112
113     image_path = os.path.join(deploy_dir_image, '.'.join((image_name, ext)))
114
115     attr = dict()
116
117     mtime = file_mtime(image_path)
118     if mtime:
119         attr['Date'] = mtime
120
121     opkglibdir = d.getVar('OPKGLIBDIR', True)
122     if opkglibdir:
123         status_path = image_rootfs + opkglibdir + '/opkg/status'
124     else:
125         status_path = image_rootfs + '/var/lib/dpkg/status'
126
127     control = parse_status_file(status_path, 'kernel-image')
128     if 'Version' in control:
129         if 'Provides' in control:
130             attr['Kernel'] = ' '.join((control['Provides'], control['Version']))
131         else:
132             attr['Kernel'] = control['Version']
133
134     control = parse_status_file(status_path, 'dreambox-dvb-modules')
135     if 'Version' in control:
136         attr['Drivers'] = control['Version']
137
138     control = parse_status_file(status_path, 'enigma2')
139     if 'Version' in control:
140         attr['Enigma2'] = control['Version']
141
142     if distro_name and distro_version:
143         attr['Distro'] = ' '.join((distro_name, distro_version))
144
145     if machine:
146         attr['Machine'] = ' '.join(('Dreambox', machine.upper()))
147
148     if distro_feed_uri and image_pkgtype:
149         attr['Link'] = '/'.join((distro_feed_uri, image_pkgtype))
150
151     md5 = hash_image(image_path, 'md5')
152     if md5:
153         attr['MD5'] = md5
154
155     sha256 = hash_image(image_path, 'sha256')
156     if sha256:
157         attr['SHA256'] = sha256
158
159     nfo_path = os.path.join(deploy_dir_image, '%s.nfo' % image_name)
160     with open(nfo_path, 'w') as f:
161         for key, value in sorted(attr.items()):
162             f.write('%s: %s\n' % (key, value))
163 }
164
165 IMAGE_POSTPROCESS_COMMAND += "dreambox_image_nfo;"