cronet: Create bare version of import script

This creates a very basic (and untested!) version of an import script.
Checking this in now, so we can get better history as it evolves.

import_cronet.sh can be used to invoke copybara and set the appropriate
command line arguments.

Test: ./import_cronet.sh -l 108.0.5359.128 -n 110.0.5481.65
Change-Id: I74c6aa9245e102a1f94d0630e41ddd1079e9d41f
This commit is contained in:
Patrick Rohr 2023-02-17 15:09:44 -08:00
commit 61e83c8a19
2 changed files with 186 additions and 0 deletions

View file

@ -0,0 +1,110 @@
# Copyright 2023 Google Inc. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
common_excludes = [
# Exclude all Android build files
"**/Android.bp",
"**/Android.mk",
# Exclude existing OWNERS files
"**/OWNERS",
]
cronet_origin_files = glob(
include = [
"base/**",
"build/**",
"build/buildflag.h",
"chrome/VERSION",
"components/cronet/**",
"components/grpc_suport/**",
"components/metrics/**",
"components/nacl/**",
"components/prefs/**",
"crypto/**",
"ipc/**",
"net/**",
"url/**",
"LICENSE",
],
exclude = common_excludes + [
# Per aosp/2367109
"build/android/CheckInstallApk-debug.apk",
"build/android/unused_resources/**",
"build/linux/**",
# Per aosp/2374766
"components/cronet/ios/**",
"components/cronet/native/**",
# Exclude all third-party directories. Those are specified explicitly
# below, so no dependency can accidentally creep in.
"**/third_party/**",
],
) + glob(
# Explicitly include third-party dependencies.
# Note: some third-party dependencies include a third_party folder within
# them. So far, this has not become a problem.
include = [
"base/third_party/cityhash/**",
"base/third_party/cityhash_v103/**",
"base/third_party/double_conversion/**",
"base/third_party/dynamic_annotations/**",
"base/third_party/icu/**",
"base/third_party/nspr/**",
"base/third_party/superfasthash/**",
# TODO: we should be able to remove this dependency.
"base/third_party/symbolize/**",
"base/third_party/valgrind/**",
"base/third_party/xdg_user_dirs/**",
# Not present in source repo; requires gclient sync.
"buildtools/third_party/libc++/**",
# Not present in source repo; requires gclient sync.
"buildtools/third_party/libc++abi/**",
"net/third_party/quiche/**",
"net/third_party/uri_template/**",
"third_party/abseil-cpp/**",
"third_party/android_ndk/sources/android/cpufeatures/**",
"third_party/ashmem/**",
"third_party/boringssl/**",
"third_party/brotli/**",
# Not present in source repo; requires gclient sync.
"third_party/icu/**",
"third_party/libevent/**",
"third_party/metrics_proto/**",
"third_party/modp_b64/**",
"third_party/protobuf/**",
"third_party/zlib/**",
],
exclude = common_excludes,
)
core.workflow(
name = "import_cronet",
authoring = authoring.overwrite("Cronet Mainline Eng <cronet-mainline-eng+copybara@google.com>"),
origin = git.origin(
url = "rpc://chromium/chromium/src",
# Source ref is set by the invoking script.
ref = "overwritten-by-script",
partial_fetch = True,
),
origin_files = cronet_origin_files,
destination = git.destination(
# The destination URL is set by the invoking script.
url = "overwritten/by/script",
push = "upstream-import",
),
mode = "SQUASH",
)

View file

@ -0,0 +1,76 @@
#!/bin/bash
# Copyright 2023 Google Inc. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# Script to invoke copybara locally to import Cronet into Android.
# Inputs:
# Environment:
# ANDROID_BUILD_TOP: path the root of the current Android directory.
# Arguments:
# -l: The last revision that was imported.
# -n: The new revision to import.
OPTSTRING=l:n:
usage() {
cat <<EOF
Usage: import_cronet.sh -l last-rev -n new-rev
EOF
exit 1
}
#######################################
# Runs the copybara import of Chromium
# Globals:
# ANDROID_BUILD_TOP
# Arguments:
# last_rev, string
# new_rev, string
#######################################
do_run_copybara() {
local _last_rev=$1
local _new_rev=$2
/google/bin/releases/copybara/public/copybara/copybara \
--git-destination-url="file://${ANDROID_BUILD_TOP}/external/cronet" \
--last-rev "${_last_rev}" \
--repo-timeout 3h \
"${ANDROID_BUILD_TOP}/packages/modules/Connectivity/Cronet/tools/import/copy.bara.sky" \
import_cronet "${_new_rev}"
}
while getopts $OPTSTRING opt; do
case "${opt}" in
l) last_rev="${OPTARG}" ;;
n) new_rev="${OPTARG}" ;;
?) usage ;;
*) echo "'${opt}' '${OPTARG}'"
esac
done
# TODO: Get last-rev from METADATA file.
# Setting last-rev may only be required for the first commit.
if [ -z "${last_rev}" ]; then
echo "-l argument required"
usage
fi
if [ -z "${new_rev}" ]; then
echo "-n argument required"
usage
fi
do_run_copybara "${last_rev}" "${new_rev}"