enigma2-plugins: rework packaging
[opendreambox.git] / meta-opendreambox / recipes-dreambox / enigma2 / enigma2-plugins.inc
1 SUMMARY = "Additional plugins for Enigma2"
2 LICENSE = "Proprietary"
3 LIC_FILES_CHKSUM = "file://COPYING;md5=8e37f34d0e40d32ea2bc90ee812c9131"
4 DEPENDS = " \
5         aio-grab \
6         avahi \
7         cdrkit \
8         cdtextinfo \
9         dbttcd \
10         dvdbackup \
11         enigma2 \
12         enigma2-streamproxy \
13         gstreamer1.0-plugins-bad \
14         gstreamer1.0-plugins-good \
15         hdparm \
16         parted \
17         python-flickrapi \
18         python-gdata \
19         python-google-api-client \
20         python-mutagen \
21         python-pycrypto \
22         python-pyopenssl \
23         python-simplejson \
24         python-transmissionrpc \
25         python-twisted \
26         python-youtube-dl \
27         smartmontools \
28         streamripper \
29         satip-client \
30 "
31
32 SRC_URI += "file://print.mak"
33
34 inherit autotools-brokensep pkgconfig pythonnative
35
36 export BUILD_SYS
37 export HOST_SYS
38 export STAGING_INCDIR
39 export STAGING_LIBDIR
40
41 do_install_append() {
42         # create lists of files installed outside of "${libdir}/enigma2/python/Plugins" or "${datadir}/meta"
43         rm -rf ${INSTALL_ROOTDIR}
44         install -d ${INSTALL_ROOTDIR}
45         SUBDIRS=`make -f Makefile -f ${WORKDIR}/print.mak print-SUBDIRS`
46         for SUBDIR in $SUBDIRS; do
47                 oe_runmake -C $SUBDIR "DESTDIR=${INSTALL_DESTDIR}" install
48                 CATEGORY=`ls -1 ${INSTALL_PLUGINSDIR} | head -n1 | tr '[:upper:]' '[:lower:]'`
49                 NAME=`echo $SUBDIR | tr '[:upper:]' '[:lower:]'`
50                 PKG="enigma2-plugin-$CATEGORY-$NAME"
51                 rm -rf ${INSTALL_METADIR} ${INSTALL_PODIR} ${INSTALL_PLUGINSDIR}
52                 find ${INSTALL_DESTDIR} -type f -name "*.la" -delete
53                 find ${INSTALL_DESTDIR} -type f -fprintf ${INSTALL_ROOTDIR}/$PKG '/%P\n'
54                 [ -s ${INSTALL_ROOTDIR}/$PKG ] || rm ${INSTALL_ROOTDIR}/$PKG
55                 rm -rf ${INSTALL_DESTDIR}
56         done
57
58         # delete unwanted files
59         find ${D} -type f -name "*.la" -delete
60 }
61
62 PACKAGES_DYNAMIC = "enigma2-plugin-*"
63 PACKAGES += "${PN}-meta ${PN}-po"
64
65 FILES_${PN} = ""
66 FILES_${PN}-meta = "${datadir}/meta"
67 FILES_${PN}-po = "${datadir}/enigma2/po"
68
69 python enigma2_plugins_split_packages() {
70     enigma2_plugindir = bb.data.expand('${libdir}/enigma2/python/Plugins', d)
71     do_split_packages(d, enigma2_plugindir, '^(\w+/\w+)', 'enigma2-plugin-%s', '%s', recursive=True, extra_depends='enigma2', match_path=True)
72
73     def parseControlFile(dir, d, package):
74         filename = os.path.join(dir, package.split('-')[-1] + "/CONTROL/control")
75         if os.path.exists(filename):
76             with open(filename) as f:
77                 for line in f.read().splitlines():
78                     try:
79                         name, value = line.strip().split(': ', 1)
80                         if name == 'Description':
81                             d.setVar('DESCRIPTION_' + package, value)
82                         elif name == 'Depends':
83                             d.appendVar('RDEPENDS_' + package, ' ' + ' '.join(value.split(', ')))
84                         elif name == 'Replaces':
85                             d.setVar('RREPLACES_' + package, ' '.join(value.split(', ')))
86                         elif name == 'Conflicts':
87                             d.setVar('RCONFLICTS_' + package, ' '.join(value.split(', ')))
88                     except:
89                         bb.fatal("Error parsing control file for package %s" % package)
90
91     def parseFileList(dir, d, package):
92         filename = os.path.join(dir, package)
93         if os.path.exists(filename):
94             varname = 'FILES_%s' % package
95             files = (d.getVar(varname, True) or "").split()
96             with open(filename) as f:
97                 for line in f.read().splitlines():
98                     if not line in files:
99                         files.append(line)
100             d.setVar(varname, ' '.join(files))
101
102     tempdir = d.getVar('INSTALL_ROOTDIR', True)
103     srcdir = d.getVar('S', True)
104     for package in d.getVar('PACKAGES', True).split():
105         if package.startswith('enigma2-plugin-'):
106             parseFileList(tempdir, d, package)
107             parseControlFile(srcdir, d, package)
108 }
109
110 PACKAGESPLITFUNCS_prepend = "enigma2_plugins_split_packages "
111
112 INSTALL_ROOTDIR = "${WORKDIR}/${PN}-packaging-tempdir"
113 INSTALL_DESTDIR = "${INSTALL_ROOTDIR}/destdir"
114 INSTALL_METADIR = "${INSTALL_DESTDIR}${datadir}/meta"
115 INSTALL_PODIR = "${INSTALL_DESTDIR}${datadir}/enigma2/po"
116 INSTALL_PLUGINSDIR = "${INSTALL_DESTDIR}${libdir}/enigma2/python/Plugins"