summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHongxu Jia <hongxu.jia@windriver.com>2014-11-08 17:04:38 +0800
committerRichard Purdie <richard.purdie@linuxfoundation.org>2014-12-03 12:23:59 +0000
commit5030c7fb3ef919ebd98ff9c8b22e070a86e66617 (patch)
tree9f9ce4e9bbbb9442e43c3f9d805b040ec546e4e6
parent887ffa0d7e19f08b9ef1bc3edf591f6a2998b835 (diff)
downloadpoky-5030c7fb3ef919ebd98ff9c8b22e070a86e66617.tar.gz
compress_doc.bbclass: support update-alternatives
While doc file make use of update-alternatives to fix confliction, we should reconfigure update-alternatives for doc compression. Such as util-linux-doc: ... update-alternatives --install /usr/share/man/man1/last.1 last.1 /usr/share/man/man1/last.1.util-linux 100 ... was updated by doc_compress to ... update-alternatives --install /usr/share/man/man1/last.1.bz2 last.1.bz2 /usr/share/man/man1/last.1.util-linux.bz2 100 ... (From OE-Core rev: ba4dd1afc2476259eff52f8a68fba1344e0f0474) Signed-off-by: Hongxu Jia <hongxu.jia@windriver.com> Signed-off-by: Ross Burton <ross.burton@intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
-rw-r--r--meta/classes/compress_doc.bbclass46
1 files changed, 45 insertions, 1 deletions
diff --git a/meta/classes/compress_doc.bbclass b/meta/classes/compress_doc.bbclass
index afa9cd614a..9b58d82ce5 100644
--- a/meta/classes/compress_doc.bbclass
+++ b/meta/classes/compress_doc.bbclass
@@ -29,7 +29,7 @@ DOC_DECOMPRESS_CMD[gz] ?= 'gunzip -v'
29DOC_DECOMPRESS_CMD[bz2] ?= "bunzip2 -v" 29DOC_DECOMPRESS_CMD[bz2] ?= "bunzip2 -v"
30DOC_DECOMPRESS_CMD[xz] ?= "unxz -v" 30DOC_DECOMPRESS_CMD[xz] ?= "unxz -v"
31 31
32PACKAGE_PREPROCESS_FUNCS += "package_do_compress_doc" 32PACKAGE_PREPROCESS_FUNCS += "package_do_compress_doc compress_doc_updatealternatives"
33python package_do_compress_doc() { 33python package_do_compress_doc() {
34 compress_mode = d.getVar('DOC_COMPRESS', True) 34 compress_mode = d.getVar('DOC_COMPRESS', True)
35 compress_list = (d.getVar('DOC_COMPRESS_LIST', True) or '').split() 35 compress_list = (d.getVar('DOC_COMPRESS_LIST', True) or '').split()
@@ -214,3 +214,47 @@ def decompress_doc(topdir, compress_mode, decompress_cmds):
214 214
215 _process_hardlink(hardlink_dict, compress_mode, decompress_cmds, decompress) 215 _process_hardlink(hardlink_dict, compress_mode, decompress_cmds, decompress)
216 216
217python compress_doc_updatealternatives () {
218 if not bb.data.inherits_class('update-alternatives', d):
219 return
220
221 mandir = d.getVar("mandir", True)
222 infodir = d.getVar("infodir", True)
223 compress_mode = d.getVar('DOC_COMPRESS', True)
224 for pkg in (d.getVar('PACKAGES', True) or "").split():
225 old_names = (d.getVar('ALTERNATIVE_%s' % pkg, True) or "").split()
226 new_names = []
227 for old_name in old_names:
228 old_link = d.getVarFlag('ALTERNATIVE_LINK_NAME', old_name, True)
229 old_target = d.getVarFlag('ALTERNATIVE_TARGET_%s' % pkg, old_name, True) or \
230 d.getVarFlag('ALTERNATIVE_TARGET', old_name, True) or \
231 d.getVar('ALTERNATIVE_TARGET_%s' % pkg, True) or \
232 d.getVar('ALTERNATIVE_TARGET', True) or \
233 old_link
234 # Sometimes old_target is specified as relative to the link name.
235 old_target = os.path.join(os.path.dirname(old_link), old_target)
236
237 # The updatealternatives used for compress doc
238 if mandir in old_target or infodir in old_target:
239 new_name = old_name + '.' + compress_mode
240 new_link = old_link + '.' + compress_mode
241 new_target = old_target + '.' + compress_mode
242 d.delVarFlag('ALTERNATIVE_LINK_NAME', old_name)
243 d.setVarFlag('ALTERNATIVE_LINK_NAME', new_name, new_link)
244 if d.getVarFlag('ALTERNATIVE_TARGET_%s' % pkg, old_name, True):
245 d.delVarFlag('ALTERNATIVE_TARGET_%s' % pkg, old_name)
246 d.setVarFlag('ALTERNATIVE_TARGET_%s' % pkg, new_name, new_target)
247 elif d.getVarFlag('ALTERNATIVE_TARGET', old_name, True):
248 d.delVarFlag('ALTERNATIVE_TARGET', old_name)
249 d.setVarFlag('ALTERNATIVE_TARGET', new_name, new_target)
250 elif d.getVar('ALTERNATIVE_TARGET_%s' % pkg, True):
251 d.setVar('ALTERNATIVE_TARGET_%s' % pkg, new_target)
252 elif d.getVar('ALTERNATIVE_TARGET', old_name, True):
253 d.setVar('ALTERNATIVE_TARGET', new_target)
254
255 new_names.append(new_name)
256
257 if new_names:
258 d.setVar('ALTERNATIVE_%s' % pkg, ' '.join(new_names))
259}
260