]> code.ossystems Code Review - openembedded-core.git/commitdiff
Add poky-trim-schemas post install script to remove unneeded schema locale translatio...
authorRichard Purdie <rpurdie@linux.intel.com>
Fri, 28 Aug 2009 16:11:57 +0000 (17:11 +0100)
committerRichard Purdie <rpurdie@linux.intel.com>
Fri, 28 Aug 2009 16:11:57 +0000 (17:11 +0100)
Signed-off-by: Richard Purdie <rpurdie@linux.intel.com>
meta-moblin/classes/moblin-image.bbclass
meta/classes/image.bbclass
scripts/poky-trim-schemas [new file with mode: 0755]

index f742777ace9ff43c191f8aed4018d0267c758137..f9bab011b0f0df164dfb37f0883bbdd9fd06651d 100644 (file)
@@ -95,3 +95,5 @@ inherit image
 
 # Create /etc/timestamp during image construction to give a reasonably sane default time setting
 ROOTFS_POSTPROCESS_COMMAND += "rootfs_update_timestamp ; "
+
+ROOTFS_POSTINSTALL_COMMAND += "rootfs_trim_schemas ; "
index 8225980f73aa61fb916a2570a51d81b7af41d912..6b0a14d9ac1fe3e03bcbbf61daad4f4908b9f29d 100644 (file)
@@ -225,6 +225,18 @@ rootfs_no_x_startup () {
        fi
 }
 
+rootfs_trim_schemas () {
+       for schema in ${IMAGE_ROOTFS}/etc/gconf/schemas/*.schemas
+       do
+               # Need this in case no files exist
+               if [ -e $schema ]; then
+                       poky-trim-schemas $schema > $schema.new
+                       mv $schema.new $schema
+               fi
+       done
+}
+
+
 # export the zap_root_password, create_etc_timestamp and remote_init_link
 EXPORT_FUNCTIONS zap_root_password create_etc_timestamp remove_init_link do_rootfs make_zimage_symlink_relative set_image_autologin rootfs_update_timestamp rootfs_no_x_startup
 
diff --git a/scripts/poky-trim-schemas b/scripts/poky-trim-schemas
new file mode 100755 (executable)
index 0000000..29fb3a1
--- /dev/null
@@ -0,0 +1,49 @@
+#! /usr/bin/env python
+
+import sys
+try:
+    import xml.etree.cElementTree as etree
+except:
+    import xml.etree.ElementTree as etree
+
+def child (elem, name):
+    for e in elem.getchildren():
+        if e.tag == name:
+            return e
+    return None
+
+def children (elem, name=None):
+    l = elem.getchildren()
+    if name:
+        l = [e for e in l if e.tag == name]
+    return l
+
+xml = etree.parse(sys.argv[1])
+
+for schema in child(xml.getroot(), "schemalist").getchildren():
+    e = child(schema, "short")
+    if e is not None:
+        schema.remove(e)
+
+    e = child(schema, "long")
+    if e is not None:
+        schema.remove(e)
+
+    for locale in children(schema, "locale"):
+        # One locale must exist so leave C locale...
+        a = locale.attrib.get("name")
+        if a == 'C':
+            continue
+        e = child(locale, "default")
+        if e is None:
+            schema.remove(locale)
+        else:
+            e = child(locale, "short")
+            if e is not None:
+                locale.remove(e)
+            e = child(locale, "long")
+            if e is not None:
+                locale.remove(e)
+
+xml.write(sys.stdout, "UTF-8")
+