0

chromeos: Concatenate D-Bus busconfig files

To reduce disk space usage and disk IO during startup.

In Chrome OS, chromeos-chrome ebuild installs chrome.conf busconfig file whose only contents is:
  <includedir>/opt/google/chrome/dbus</includedir>

concat_dbus_conf_files.py concatenates busconfig files in /opt/google/chrome/dbus by merging each conf file's <busconfig> into one.
This is exactly the same thing as what <includedir> tag in chrome.conf does so there should be no functional changes.

Before this CL: chrome.conf includes 17 busconfig files in /opt/google/chrome/dbus
After this CL: chrome.conf includes only 2 files (i.e. chrome_dbus_services.conf and ash_dbus_services.conf).

BUG=1020044
TEST=Manually confirmed the contents of out.conf after running chromeos/tools/concat_dbus_conffiles.py out.conf ash/dbus/*.conf
TEST=Chrome boots after replacing the contents of /opt/google/chrome/dbus
TEST=Can call org.chromium.LivenessServiceInterface.CheckLiveness with dbus-send

Change-Id: Id0e572c2834a6ebec8f2e385bfbe6d1ee67fc37c
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1895021
Commit-Queue: Ryo Hashimoto <hashimoto@chromium.org>
Reviewed-by: Steven Bennetts <stevenjb@chromium.org>
Cr-Commit-Position: refs/heads/master@{#713750}
This commit is contained in:
Ryo Hashimoto
2019-11-08 06:17:23 +00:00
committed by Commit Bot
parent c750d61638
commit 5b8825109d
3 changed files with 57 additions and 4 deletions
ash
chrome/browser/chromeos
chromeos/tools

@ -1645,16 +1645,21 @@ static_library("ash_shell_lib_with_content") {
]
}
copy("dbus_service_files") {
action("dbus_service_files") {
sources = [
"dbus/org.chromium.DisplayService.conf",
"dbus/org.chromium.GesturePropertiesService.conf",
"dbus/org.chromium.LivenessService.conf",
"dbus/org.chromium.UrlHandlerService.conf",
]
output_conf_file = "$root_out_dir/dbus/ash_dbus_services.conf"
outputs = [
"$root_out_dir/dbus/{{source_file_part}}",
output_conf_file,
]
script = "//chromeos/tools/concat_dbus_conf_files.py"
args = [ rebase_path(output_conf_file, root_build_dir) ]
args += rebase_path(sources, root_build_dir)
}
test("ash_unittests") {

@ -2337,7 +2337,7 @@ source_set("chromeos") {
}
}
copy("dbus_service_files") {
action("dbus_service_files") {
sources = [
"dbus/org.chromium.ChromeFeaturesService.conf",
"dbus/org.chromium.ComponentUpdaterService.conf",
@ -2353,9 +2353,14 @@ copy("dbus_service_files") {
"dbus/org.chromium.VirtualFileRequestService.conf",
"dbus/org.chromium.VmApplicationsService.conf",
]
output_conf_file = "$root_out_dir/dbus/chrome_dbus_services.conf"
outputs = [
"$root_out_dir/dbus/{{source_file_part}}",
output_conf_file,
]
script = "//chromeos/tools/concat_dbus_conf_files.py"
args = [ rebase_path(output_conf_file, root_build_dir) ]
args += rebase_path(sources, root_build_dir)
}
static_library("arc_test_support") {

@ -0,0 +1,43 @@
#!/usr/bin/env python
# Copyright 2019 The Chromium Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
"""Concatenates D-Bus busconfig files."""
import sys
import xml.etree.ElementTree
_BUSCONFIG_FILE_HEADER="""<!DOCTYPE busconfig
PUBLIC "-//freedesktop//DTD D-Bus Bus Configuration 1.0//EN"
"http://www.freedesktop.org/standards/dbus/1.0/busconfig.dtd">
"""
def main():
if len(sys.argv) < 3:
sys.stderr.write('Usage: %s OUTFILE INFILES\n' % (sys.argv[0]))
sys.exit(1)
out_path = sys.argv[1]
in_paths = sys.argv[2:]
# Parse the first input file.
tree = xml.etree.ElementTree.parse(in_paths[0])
assert(tree.getroot().tag == 'busconfig')
# Append the remaining input files to the first file.
for path in in_paths[1:]:
current_tree = xml.etree.ElementTree.parse(path)
assert(current_tree.getroot().tag == 'busconfig')
for child in current_tree.getroot():
tree.getroot().append(child)
# Output the result.
with open(out_path, "w") as f:
f.write(_BUSCONFIG_FILE_HEADER)
tree.write(f)
if __name__ == '__main__':
main()