Commit dc6d7c39 authored by Steven Bennetts's avatar Steven Bennetts Committed by Commit Bot

Revert "chrome_repack_locales: compress .pak files on Chrome OS"

This reverts commit 17342442.

Reason for revert: This will cause problems on a device as locales/*.pak.gz will not get copied correctly. We need to update chromite first.

Original change's description:
> chrome_repack_locales: compress .pak files on Chrome OS
> 
> For trivial change to resource_bundle.cc:
> TBR=sky@chromium.org
> 
> Bug: 1017864
> Change-Id: I2afbfa8e02f952d03b36112e0093af92753876ab
> Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1883292
> Commit-Queue: Steven Bennetts <stevenjb@chromium.org>
> Reviewed-by: Andrew Grieve <agrieve@chromium.org>
> Cr-Commit-Position: refs/heads/master@{#713205}

TBR=stevenjb@chromium.org,agrieve@chromium.org

Change-Id: Ia72498979433c12facbb4a797582bd48d18ce83e
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Bug: 1017864
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1902168Reviewed-by: default avatarSteven Bennetts <stevenjb@chromium.org>
Commit-Queue: Steven Bennetts <stevenjb@chromium.org>
Cr-Commit-Position: refs/heads/master@{#713218}
parent c967cbe7
......@@ -78,7 +78,6 @@ template("chrome_repack_locales") {
"//remoting/resources",
"//ui/chromeos/strings",
]
compress = true
}
if (enable_extensions) {
source_patterns +=
......
......@@ -215,8 +215,7 @@ def ReadGrdInfo(grd_file):
def RePack(output_file, input_files, whitelist_file=None,
suppress_removed_key_output=False,
output_info_filepath=None):
suppress_removed_key_output=False):
"""Write a new data pack file by combining input pack files.
Args:
......@@ -227,7 +226,6 @@ def RePack(output_file, input_files, whitelist_file=None,
all resources.
suppress_removed_key_output: allows the caller to suppress the output from
RePackFromDataPackStrings.
output_info_file: If not None, specify the output .info filepath.
Raises:
KeyError: if there are duplicate keys or resource encoding is
......@@ -245,9 +243,7 @@ def RePack(output_file, input_files, whitelist_file=None,
resources, encoding = RePackFromDataPackStrings(
inputs, whitelist, suppress_removed_key_output)
WriteDataPack(resources, output_file, encoding)
if output_info_filepath is None:
output_info_filepath = output_file + '.info'
with open(output_info_filepath, 'w') as output_info_file:
with open(output_file + '.info', 'w') as output_info_file:
for filename in input_info_files:
with open(filename, 'r') as info_file:
output_info_file.writelines(info_file.readlines())
......
......@@ -12,12 +12,9 @@ https://dev.chromium.org/developers/design-documents/linuxresourcesandlocalizeds
from __future__ import print_function
import argparse
import gzip
import hashlib
import os
import shutil
import sys
import tempfile
# Import grit first to get local third_party modules.
import grit # pylint: disable=ungrouped-imports,unused-import
......@@ -28,24 +25,8 @@ from grit.format import data_pack
def _RepackMain(args):
output_info_filepath = args.output_pak_file + '.info'
if args.compress:
# If the file needs to be compressed, call RePack with a tempfile path,
# then compress the tempfile to args.output_pak_file.
temp_outfile = tempfile.NamedTemporaryFile()
out_path = temp_outfile.name
# Strip any non .pak extension from the .info output file path.
splitext = os.path.splitext(args.output_pak_file)
if splitext[1] != '.pak':
output_info_filepath = splitext[0] + '.info'
else:
out_path = args.output_pak_file
data_pack.RePack(out_path, args.input_pak_files, args.whitelist,
args.suppress_removed_key_output,
output_info_filepath=output_info_filepath)
if args.compress:
with gzip.open(args.output_pak_file, 'wb') as output_pak_file:
shutil.copyfileobj(temp_outfile, output_pak_file)
data_pack.RePack(args.output_pak_file, args.input_pak_files, args.whitelist,
args.suppress_removed_key_output)
def _ExtractMain(args):
......@@ -159,8 +140,6 @@ def main():
help='Path to a whitelist used to filter output pak file resource IDs.')
sub_parser.add_argument('--suppress-removed-key-output', action='store_true',
help='Do not log which keys were removed by the whitelist.')
sub_parser.add_argument('--compress', dest='compress', action='store_true',
default=False, help='Compress output_pak_file using gzip.')
sub_parser.set_defaults(func=_RepackMain)
sub_parser = sub_parsers.add_parser('extract', help='Extracts pak file')
......
......@@ -20,9 +20,6 @@ import("//tools/grit/grit_rule.gni")
# Path of the file in the application bundle, defaults to
# {{bundle_resources_dir}}/{{source_file_part}}.
#
# compress [optional]
# Gzip the resulting bundle (and append .gz to the output name).
#
# deps [optional]
# public_deps [optional]
# visibility [optional]
......@@ -35,8 +32,6 @@ template("repack") {
_repack_target_name = "${target_name}__repack"
}
_compress = defined(invoker.compress) && invoker.compress
action(_repack_target_name) {
forward_variables_from(invoker,
[
......@@ -57,12 +52,8 @@ template("repack") {
foreach(_invoker_source, invoker.sources) {
inputs += [ "${_invoker_source}.info" ]
}
_output_pak_file = invoker.output
if (_compress) {
_output_pak_file += ".gz"
}
outputs = [
_output_pak_file,
invoker.output,
"${invoker.output}.info",
]
......@@ -73,11 +64,8 @@ template("repack") {
args += [ "--whitelist=$_rebased_whitelist" ]
args += [ "--suppress-removed-key-output" ]
}
args += [ rebase_path(_output_pak_file, root_build_dir) ]
args += [ rebase_path(invoker.output, root_build_dir) ]
args += rebase_path(invoker.sources, root_build_dir)
if (_compress) {
args += [ "--compress" ]
}
}
if (_copy_data_to_bundle) {
......@@ -165,7 +153,6 @@ template("repack_locales") {
[
"copy_data_to_bundle",
"bundle_output",
"compress",
"deps",
"repack_whitelist",
"testonly",
......
......@@ -436,7 +436,7 @@ std::string ResourceBundle::LoadLocaleResources(
std::unique_ptr<DataPack> data_pack(new DataPack(SCALE_FACTOR_100P));
if (!data_pack->LoadFromPath(locale_file_path)) {
LOG(ERROR) << "failed to load locale file: " << locale_file_path;
LOG(ERROR) << "failed to load locale.pak";
NOTREACHED();
return std::string();
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment