1*4882a593Smuzhiyun# 2*4882a593Smuzhiyun# This class is used by recipes installing mime types 3*4882a593Smuzhiyun# 4*4882a593Smuzhiyun 5*4882a593SmuzhiyunDEPENDS += "${@bb.utils.contains('BPN', 'shared-mime-info', '', 'shared-mime-info', d)}" 6*4882a593SmuzhiyunPACKAGE_WRITE_DEPS += "shared-mime-info-native" 7*4882a593SmuzhiyunMIMEDIR = "${datadir}/mime" 8*4882a593Smuzhiyun 9*4882a593Smuzhiyunmime_postinst() { 10*4882a593Smuzhiyunif [ "x$D" != "x" ]; then 11*4882a593Smuzhiyun $INTERCEPT_DIR/postinst_intercept update_mime_database ${PKG} \ 12*4882a593Smuzhiyun mlprefix=${MLPREFIX} \ 13*4882a593Smuzhiyun mimedir=${MIMEDIR} 14*4882a593Smuzhiyunelse 15*4882a593Smuzhiyun echo "Updating MIME database... this may take a while." 16*4882a593Smuzhiyun update-mime-database $D${MIMEDIR} 17*4882a593Smuzhiyunfi 18*4882a593Smuzhiyun} 19*4882a593Smuzhiyun 20*4882a593Smuzhiyunmime_postrm() { 21*4882a593Smuzhiyunif [ "x$D" != "x" ]; then 22*4882a593Smuzhiyun $INTERCEPT_DIR/postinst_intercept update_mime_database ${PKG} \ 23*4882a593Smuzhiyun mlprefix=${MLPREFIX} \ 24*4882a593Smuzhiyun mimedir=${MIMEDIR} 25*4882a593Smuzhiyunelse 26*4882a593Smuzhiyun echo "Updating MIME database... this may take a while." 27*4882a593Smuzhiyun # $D${MIMEDIR}/packages belong to package shared-mime-info-data, 28*4882a593Smuzhiyun # packages like libfm-mime depend on shared-mime-info-data. 29*4882a593Smuzhiyun # after shared-mime-info-data uninstalled, $D${MIMEDIR}/packages 30*4882a593Smuzhiyun # is removed, but update-mime-database need this dir to update 31*4882a593Smuzhiyun # database, workaround to create one and remove it later 32*4882a593Smuzhiyun if [ ! -d $D${MIMEDIR}/packages ]; then 33*4882a593Smuzhiyun mkdir -p $D${MIMEDIR}/packages 34*4882a593Smuzhiyun update-mime-database $D${MIMEDIR} 35*4882a593Smuzhiyun rmdir --ignore-fail-on-non-empty $D${MIMEDIR}/packages 36*4882a593Smuzhiyun else 37*4882a593Smuzhiyun update-mime-database $D${MIMEDIR} 38*4882a593Smuzhiyunfi 39*4882a593Smuzhiyunfi 40*4882a593Smuzhiyun} 41*4882a593Smuzhiyun 42*4882a593Smuzhiyunpython populate_packages:append () { 43*4882a593Smuzhiyun packages = d.getVar('PACKAGES').split() 44*4882a593Smuzhiyun pkgdest = d.getVar('PKGDEST') 45*4882a593Smuzhiyun mimedir = d.getVar('MIMEDIR') 46*4882a593Smuzhiyun 47*4882a593Smuzhiyun for pkg in packages: 48*4882a593Smuzhiyun mime_packages_dir = '%s/%s%s/packages' % (pkgdest, pkg, mimedir) 49*4882a593Smuzhiyun mimes_types_found = False 50*4882a593Smuzhiyun if os.path.exists(mime_packages_dir): 51*4882a593Smuzhiyun for f in os.listdir(mime_packages_dir): 52*4882a593Smuzhiyun if f.endswith('.xml'): 53*4882a593Smuzhiyun mimes_types_found = True 54*4882a593Smuzhiyun break 55*4882a593Smuzhiyun if mimes_types_found: 56*4882a593Smuzhiyun bb.note("adding mime postinst and postrm scripts to %s" % pkg) 57*4882a593Smuzhiyun postinst = d.getVar('pkg_postinst:%s' % pkg) 58*4882a593Smuzhiyun if not postinst: 59*4882a593Smuzhiyun postinst = '#!/bin/sh\n' 60*4882a593Smuzhiyun postinst += d.getVar('mime_postinst') 61*4882a593Smuzhiyun d.setVar('pkg_postinst:%s' % pkg, postinst) 62*4882a593Smuzhiyun postrm = d.getVar('pkg_postrm:%s' % pkg) 63*4882a593Smuzhiyun if not postrm: 64*4882a593Smuzhiyun postrm = '#!/bin/sh\n' 65*4882a593Smuzhiyun postrm += d.getVar('mime_postrm') 66*4882a593Smuzhiyun d.setVar('pkg_postrm:%s' % pkg, postrm) 67*4882a593Smuzhiyun if pkg != 'shared-mime-info-data': 68*4882a593Smuzhiyun bb.note("adding shared-mime-info-data dependency to %s" % pkg) 69*4882a593Smuzhiyun d.appendVar('RDEPENDS:' + pkg, " " + d.getVar('MLPREFIX')+"shared-mime-info-data") 70*4882a593Smuzhiyun} 71