diff options
author | Richard Purdie <richard.purdie@linuxfoundation.org> | 2018-08-13 11:40:03 +0000 |
---|---|---|
committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2018-08-15 09:44:33 +0100 |
commit | 65c8154f2169e6e901dd1e38d3cc893b019a8e11 (patch) | |
tree | 30a4beab6df2bd8b631638b608c0731d3427a24b /meta/lib/oe/package_manager.py | |
parent | 20c8be711f3ffbc9f7916c9e101db19bb0281efb (diff) | |
download | poky-65c8154f2169e6e901dd1e38d3cc893b019a8e11.tar.gz |
image: Add locale archive optimisation
Refactor the locale archive function from the SDK to also make it work during
general image creation. This reduces the size of the locales from 900MB to 220MB
in core-image-lsb-sdk.
The exception handling around subprocess was dropped as the standard subprocess
exception printing is better handled than the catchall exception.
(From OE-Core rev: 8ffd93bdb09b0a4a84b27dafcd684c6abba392ed)
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'meta/lib/oe/package_manager.py')
-rw-r--r-- | meta/lib/oe/package_manager.py | 49 |
1 files changed, 49 insertions, 0 deletions
diff --git a/meta/lib/oe/package_manager.py b/meta/lib/oe/package_manager.py index 64c8a91216..6011e87350 100644 --- a/meta/lib/oe/package_manager.py +++ b/meta/lib/oe/package_manager.py | |||
@@ -12,6 +12,7 @@ import oe.path | |||
12 | import string | 12 | import string |
13 | from oe.gpg_sign import get_signer | 13 | from oe.gpg_sign import get_signer |
14 | import hashlib | 14 | import hashlib |
15 | import fnmatch | ||
15 | 16 | ||
16 | # this can be used by all PM backends to create the index files in parallel | 17 | # this can be used by all PM backends to create the index files in parallel |
17 | def create_index(arg): | 18 | def create_index(arg): |
@@ -89,6 +90,47 @@ def failed_postinsts_warn(pkgs, log_path): | |||
89 | If deferring to first boot wasn't the intent, then scriptlet failure may mean an issue in the recipe, or a regression elsewhere. | 90 | If deferring to first boot wasn't the intent, then scriptlet failure may mean an issue in the recipe, or a regression elsewhere. |
90 | Details of the failure are in %s.""" %(pkgs, log_path)) | 91 | Details of the failure are in %s.""" %(pkgs, log_path)) |
91 | 92 | ||
93 | def generate_locale_archive(d, rootfs, target_arch, localedir): | ||
94 | # Pretty sure we don't need this for locale archive generation but | ||
95 | # keeping it to be safe... | ||
96 | locale_arch_options = { \ | ||
97 | "arm": ["--uint32-align=4", "--little-endian"], | ||
98 | "armeb": ["--uint32-align=4", "--big-endian"], | ||
99 | "aarch64": ["--uint32-align=4", "--little-endian"], | ||
100 | "aarch64_be": ["--uint32-align=4", "--big-endian"], | ||
101 | "sh4": ["--uint32-align=4", "--big-endian"], | ||
102 | "powerpc": ["--uint32-align=4", "--big-endian"], | ||
103 | "powerpc64": ["--uint32-align=4", "--big-endian"], | ||
104 | "mips": ["--uint32-align=4", "--big-endian"], | ||
105 | "mipsisa32r6": ["--uint32-align=4", "--big-endian"], | ||
106 | "mips64": ["--uint32-align=4", "--big-endian"], | ||
107 | "mipsisa64r6": ["--uint32-align=4", "--big-endian"], | ||
108 | "mipsel": ["--uint32-align=4", "--little-endian"], | ||
109 | "mipsisa32r6el": ["--uint32-align=4", "--little-endian"], | ||
110 | "mips64el": ["--uint32-align=4", "--little-endian"], | ||
111 | "mipsisa64r6el": ["--uint32-align=4", "--little-endian"], | ||
112 | "i586": ["--uint32-align=4", "--little-endian"], | ||
113 | "i686": ["--uint32-align=4", "--little-endian"], | ||
114 | "x86_64": ["--uint32-align=4", "--little-endian"] | ||
115 | } | ||
116 | if target_arch in locale_arch_options: | ||
117 | arch_options = locale_arch_options[target_arch] | ||
118 | else: | ||
119 | bb.error("locale_arch_options not found for target_arch=" + target_arch) | ||
120 | bb.fatal("unknown arch:" + target_arch + " for locale_arch_options") | ||
121 | |||
122 | # Need to set this so cross-localedef knows where the archive is | ||
123 | env = dict(os.environ) | ||
124 | env["LOCALEARCHIVE"] = oe.path.join(localedir, "locale-archive") | ||
125 | |||
126 | for name in os.listdir(localedir): | ||
127 | path = os.path.join(localedir, name) | ||
128 | if os.path.isdir(path): | ||
129 | cmd = ["cross-localedef", "--verbose"] | ||
130 | cmd += arch_options | ||
131 | cmd += ["--add-to-archive", path] | ||
132 | subprocess.check_output(cmd, env=env, stderr=subprocess.STDOUT) | ||
133 | |||
92 | class Indexer(object, metaclass=ABCMeta): | 134 | class Indexer(object, metaclass=ABCMeta): |
93 | def __init__(self, d, deploy_dir): | 135 | def __init__(self, d, deploy_dir): |
94 | self.d = d | 136 | self.d = d |
@@ -536,6 +578,13 @@ class PackageManager(object, metaclass=ABCMeta): | |||
536 | "'%s' returned %d:\n%s" % | 578 | "'%s' returned %d:\n%s" % |
537 | (' '.join(cmd), e.returncode, e.output.decode("utf-8"))) | 579 | (' '.join(cmd), e.returncode, e.output.decode("utf-8"))) |
538 | 580 | ||
581 | target_arch = self.d.getVar('TARGET_ARCH') | ||
582 | localedir = oe.path.join(self.target_rootfs, self.d.getVar("libdir"), "locale") | ||
583 | if os.path.exists(localedir) and os.listdir(localedir): | ||
584 | generate_locale_archive(self.d, self.target_rootfs, target_arch, localedir) | ||
585 | # And now delete the binary locales | ||
586 | self.remove(fnmatch.filter(self.list_installed(), "glibc-binary-localedata-*"), False) | ||
587 | |||
539 | def deploy_dir_lock(self): | 588 | def deploy_dir_lock(self): |
540 | if self.deploy_dir is None: | 589 | if self.deploy_dir is None: |
541 | raise RuntimeError("deploy_dir is not set!") | 590 | raise RuntimeError("deploy_dir is not set!") |