summaryrefslogtreecommitdiffstats
path: root/meta/classes-recipe/xmlcatalog.bbclass
blob: 5826d0a8b5120ee0c61939d3e8f629dba09237c3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
#
# Copyright OpenEmbedded Contributors
#
# SPDX-License-Identifier: MIT
#

DEPENDS = "libxml2-native"

# A whitespace-separated list of XML catalogs to be registered, for example
# "${sysconfdir}/xml/docbook-xml.xml".
XMLCATALOGS ?= ""

SYSROOT_PREPROCESS_FUNCS:append = " xmlcatalog_sstate_postinst"

xmlcatalog_complete() {
	ROOTCATALOG="${STAGING_ETCDIR_NATIVE}/xml/catalog"
	if [ ! -f $ROOTCATALOG ]; then
		mkdir --parents $(dirname $ROOTCATALOG)
		xmlcatalog --noout --create $ROOTCATALOG
	fi
	for CATALOG in ${XMLCATALOGS}; do
		xmlcatalog --noout --add nextCatalog unused file://$CATALOG $ROOTCATALOG
	done
}

xmlcatalog_sstate_postinst() {
	mkdir -p ${SYSROOT_DESTDIR}${bindir}
	dest=${SYSROOT_DESTDIR}${bindir}/postinst-${PN}-xmlcatalog
	echo '#!/bin/sh' > $dest
	echo '${xmlcatalog_complete}' >> $dest
	chmod 0755 $dest
}