2 ALTERNATIVE_PRIORITY = "10"
3 ALTERNATIVE_LINK = "${bindir}/${ALTERNATIVE_NAME}"
5 update_alternatives_postinst() {
6 update-alternatives --install ${ALTERNATIVE_LINK} ${ALTERNATIVE_NAME} ${ALTERNATIVE_PATH} ${ALTERNATIVE_PRIORITY}
9 update_alternatives_postrm() {
10 update-alternatives --remove ${ALTERNATIVE_NAME} ${ALTERNATIVE_PATH}
13 def update_alternatives_after_parse(d):
15 if bb.data.getVar('ALTERNATIVE_NAME', d) == None:
16 raise bb.build.FuncFailed, "%s inherits update-alternatives but doesn't set ALTERNATIVE_NAME" % bb.data.getVar('FILE', d)
17 if bb.data.getVar('ALTERNATIVE_PATH', d) == None:
18 raise bb.build.FuncFailed, "%s inherits update-alternatives but doesn't set ALTERNATIVE_PATH" % bb.data.getVar('FILE', d)
20 python __anonymous() {
21 update_alternatives_after_parse(d)
24 python populate_packages_prepend () {
25 pkg = bb.data.getVar('PN', d, 1)
26 bb.note('adding update-alternatives calls to postinst/postrm for %s' % pkg)
27 postinst = bb.data.getVar('pkg_postinst_%s' % pkg, d, 1) or bb.data.getVar('pkg_postinst', d, 1)
29 postinst = '#!/bin/sh\n'
30 postinst += bb.data.getVar('update_alternatives_postinst', d, 1)
31 bb.data.setVar('pkg_postinst_%s' % pkg, postinst, d)
32 postrm = bb.data.getVar('pkg_postrm_%s' % pkg, d, 1) or bb.data.getVar('pkg_postrm', d, 1)
34 postrm = '#!/bin/sh\n'
35 postrm += bb.data.getVar('update_alternatives_postrm', d, 1)
36 bb.data.setVar('pkg_postrm_%s' % pkg, postrm, d)