aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBob Haarman <inglorion@chromium.org>2024-02-01 16:13:01 +0000
committerChromeos LUCI <chromeos-scoped@luci-project-accounts.iam.gserviceaccount.com>2024-02-01 22:30:59 +0000
commitee70ef2a95232eb60b7fb2c1732af5040fe92160 (patch)
tree750fbc5745bbfb0fddc4528cad698b2a364bd45e
parent282120e8d66fb51b2188a435969af4b8eecf5011 (diff)
downloadtoolchain-utils-ee70ef2a95232eb60b7fb2c1732af5040fe92160.tar.gz
rust_uprev: don't update rust-bootstrap
rust_uprev.py contains code that updates the rust-bootstrap ebuild. This was previously necessary, because, without it, the version of rust-bootstrap needed to build the other rust packages would not be available. However, this is no longer true: We now update rust-bootstrap to the same version as dev-lang/rust and the others, which means that when we advance the non-bootstrap version, it will only be one step ahead of rust-bootstrap and therefore work. auto_update_rust_bootstrap.py will then take care of updating rust-bootstrap. As a result, we don't need logic for that in rust_uprev.py anymore, and this change removes it. Some code that refers to rust-bootstrap is still preserved, namely the code updates the bootstrap version encoded in cros-rustc.eclass and the code that verifies that rust-bootstrap sources and prebuilts are available on the mirror. BUG=None TEST=presubmit Change-Id: I0959bfc6d442467622b0403e6cb975d5b579aad4 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/third_party/toolchain-utils/+/5259526 Reviewed-by: George Burgess <gbiv@chromium.org> Commit-Queue: Bob Haarman <inglorion@chromium.org> Tested-by: Bob Haarman <inglorion@chromium.org>
-rwxr-xr-xrust_tools/rust_uprev.py90
-rwxr-xr-xrust_tools/rust_uprev_test.py102
2 files changed, 12 insertions, 180 deletions
diff --git a/rust_tools/rust_uprev.py b/rust_tools/rust_uprev.py
index 918368e2..c8f0f784 100755
--- a/rust_tools/rust_uprev.py
+++ b/rust_tools/rust_uprev.py
@@ -195,7 +195,6 @@ class PreparedUprev(NamedTuple):
"""Container for the information returned by prepare_uprev."""
template_version: RustVersion
- bootstrap_version: RustVersion
def compute_ebuild_path(category: str, name: str, version: RustVersion) -> Path:
@@ -331,18 +330,6 @@ def parse_commandline_args() -> argparse.Namespace:
"specified, the tool will remove the oldest version in the chroot",
)
- subparser_names.append("remove-bootstrap")
- remove_bootstrap_parser = subparsers.add_parser(
- "remove-bootstrap",
- help="Remove an old rust-bootstrap version",
- )
- remove_bootstrap_parser.add_argument(
- "--version",
- type=RustVersion.parse,
- required=True,
- help="rust-bootstrap version to remove",
- )
-
subparser_names.append("roll")
roll_parser = subparsers.add_parser(
"roll",
@@ -401,7 +388,6 @@ def prepare_uprev(
rust_version: RustVersion, template: RustVersion
) -> Optional[PreparedUprev]:
ebuild_path = find_ebuild_for_rust_version(template)
- bootstrap_version = get_rust_bootstrap_version()
if rust_version <= template:
logging.info(
@@ -416,9 +402,8 @@ def prepare_uprev(
template,
ebuild_path,
)
- logging.info("rust-bootstrap version is %s", bootstrap_version)
- return PreparedUprev(template, bootstrap_version)
+ return PreparedUprev(template)
def create_ebuild(
@@ -462,25 +447,6 @@ def set_include_profdata_src(ebuild_path: os.PathLike, include: bool) -> None:
Path(ebuild_path).write_text(contents, encoding="utf-8")
-def update_bootstrap_ebuild(new_bootstrap_version: RustVersion) -> None:
- old_ebuild = find_ebuild_path(rust_bootstrap_path(), "rust-bootstrap")
- m = re.match(r"^rust-bootstrap-(\d+.\d+.\d+)", old_ebuild.name)
- assert m, old_ebuild.name
- old_version = RustVersion.parse(m.group(1))
- new_ebuild = old_ebuild.parent.joinpath(
- f"rust-bootstrap-{new_bootstrap_version}.ebuild"
- )
- old_text = old_ebuild.read_text(encoding="utf-8")
- new_text, changes = re.subn(
- r"(RUSTC_RAW_FULL_BOOTSTRAP_SEQUENCE=\([^)]*)",
- f"\\1\t{old_version}\n",
- old_text,
- flags=re.MULTILINE,
- )
- assert changes == 1, "Failed to update RUSTC_RAW_FULL_BOOTSTRAP_SEQUENCE"
- new_ebuild.write_text(new_text, encoding="utf-8")
-
-
def update_bootstrap_version(
path: PathOrStr, new_bootstrap_version: RustVersion
) -> None:
@@ -574,19 +540,15 @@ it to the local mirror using gsutil cp.
raise Exception("Could not verify that allUsers has READER permission")
-def fetch_bootstrap_distfiles(
- old_version: RustVersion, new_version: RustVersion
-) -> None:
+def fetch_bootstrap_distfiles(version: RustVersion) -> None:
"""Fetches rust-bootstrap distfiles from the local mirror
Fetches the distfiles for a rust-bootstrap ebuild to ensure they
are available on the mirror and the local copies are the same as
the ones on the mirror.
"""
- fetch_distfile_from_mirror(
- compute_rust_bootstrap_prebuilt_name(old_version)
- )
- fetch_distfile_from_mirror(compute_rustc_src_name(new_version))
+ fetch_distfile_from_mirror(compute_rust_bootstrap_prebuilt_name(version))
+ fetch_distfile_from_mirror(compute_rustc_src_name(version))
def fetch_rust_distfiles(version: RustVersion) -> None:
@@ -797,22 +759,18 @@ def perform_step(
def prepare_uprev_from_json(obj: Any) -> Optional[PreparedUprev]:
if not obj:
return None
- version, bootstrap_version = obj
+ version = obj[0]
return PreparedUprev(
RustVersion(*version),
- RustVersion(*bootstrap_version),
)
def prepare_uprev_to_json(
prepared_uprev: Optional[PreparedUprev],
-) -> Optional[Tuple[RustVersion, RustVersion]]:
+) -> Optional[Tuple[RustVersion]]:
if prepared_uprev is None:
return None
- return (
- prepared_uprev.template_version,
- prepared_uprev.bootstrap_version,
- )
+ return (prepared_uprev.template_version,)
def create_rust_uprev(
@@ -829,7 +787,7 @@ def create_rust_uprev(
)
if prepared is None:
return
- template_version, old_bootstrap_version = prepared
+ template_version = prepared.template_version
run_step(
"mirror bootstrap sources",
@@ -850,20 +808,10 @@ def create_rust_uprev(
# to the mirror.
run_step(
"fetch bootstrap distfiles",
- lambda: fetch_bootstrap_distfiles(
- old_bootstrap_version, template_version
- ),
+ lambda: fetch_bootstrap_distfiles(template_version),
)
run_step("fetch rust distfiles", lambda: fetch_rust_distfiles(rust_version))
run_step(
- "update bootstrap ebuild",
- lambda: update_bootstrap_ebuild(template_version),
- )
- run_step(
- "update bootstrap manifest",
- lambda: ebuild_actions("dev-lang/rust-bootstrap", ["manifest"]),
- )
- run_step(
"update bootstrap version",
lambda: update_bootstrap_version(CROS_RUSTC_ECLASS, template_version),
)
@@ -961,7 +909,6 @@ def rebuild_packages(version: RustVersion):
# Remove all packages we modify to avoid depending on preinstalled
# versions. This ensures that the packages can really be built.
packages = [f"{category}/{name}" for category, name in RUST_PACKAGES]
- packages.append("dev-lang/rust-bootstrap")
for pkg in packages:
unmerge_package_if_installed(pkg)
# Mention only dev-lang/rust explicitly, so that others are pulled
@@ -1017,22 +964,6 @@ def remove_files(filename: PathOrStr, path: PathOrStr) -> None:
subprocess.check_call(["git", "rm", filename], cwd=path)
-def remove_rust_bootstrap_version(
- version: RustVersion,
- run_step: RunStepFn,
-) -> None:
- run_step(
- "remove old bootstrap ebuild",
- lambda: remove_ebuild_version(
- rust_bootstrap_path(), "rust-bootstrap", version
- ),
- )
- run_step(
- "update bootstrap manifest to delete old version",
- lambda: ebuild_actions("dev-lang/rust-bootstrap", ["manifest"]),
- )
-
-
def remove_rust_uprev(
rust_version: Optional[RustVersion],
run_step: RunStepFn,
@@ -1262,8 +1193,6 @@ def main() -> None:
)
elif args.subparser_name == "remove":
remove_rust_uprev(args.rust_version, run_step)
- elif args.subparser_name == "remove-bootstrap":
- remove_rust_bootstrap_version(args.version, run_step)
else:
# If you have added more subparser_name, please also add the handlers
# above
@@ -1288,7 +1217,6 @@ def main() -> None:
remove_rust_uprev(args.remove, run_step)
prepared = prepare_uprev_from_json(completed_steps["prepare uprev"])
assert prepared is not None, "no prepared uprev decoded from JSON"
- remove_rust_bootstrap_version(prepared.bootstrap_version, run_step)
if not args.no_upload:
run_step(
"create rust uprev CL", lambda: create_new_commit(args.uprev)
diff --git a/rust_tools/rust_uprev_test.py b/rust_tools/rust_uprev_test.py
index 38c26f22..a90f3d10 100755
--- a/rust_tools/rust_uprev_test.py
+++ b/rust_tools/rust_uprev_test.py
@@ -481,7 +481,6 @@ class PrepareUprevTest(unittest.TestCase):
"""Tests for prepare_uprev step in rust_uprev"""
def setUp(self):
- self.bootstrap_version = rust_uprev.RustVersion(1, 1, 0)
self.version_old = rust_uprev.RustVersion(1, 2, 3)
self.version_new = rust_uprev.RustVersion(1, 3, 5)
@@ -490,19 +489,9 @@ class PrepareUprevTest(unittest.TestCase):
"find_ebuild_for_rust_version",
return_value=Path("/path/to/ebuild"),
)
- @mock.patch.object(rust_uprev, "find_ebuild_path")
@mock.patch.object(rust_uprev, "get_command_output")
- def test_success_with_template(
- self, mock_command, mock_find_ebuild, _ebuild_for_version
- ):
- bootstrap_ebuild_path = Path(
- "/path/to/rust-bootstrap/",
- f"rust-bootstrap-{self.bootstrap_version}.ebuild",
- )
- mock_find_ebuild.return_value = bootstrap_ebuild_path
- expected = rust_uprev.PreparedUprev(
- self.version_old, self.bootstrap_version
- )
+ def test_success_with_template(self, mock_command, _ebuild_for_version):
+ expected = rust_uprev.PreparedUprev(self.version_old)
actual = rust_uprev.prepare_uprev(
rust_version=self.version_new, template=self.version_old
)
@@ -514,11 +503,6 @@ class PrepareUprevTest(unittest.TestCase):
"find_ebuild_for_rust_version",
return_value="/path/to/ebuild",
)
- @mock.patch.object(
- rust_uprev,
- "get_rust_bootstrap_version",
- return_value=rust_uprev.RustVersion(0, 41, 12),
- )
@mock.patch.object(rust_uprev, "get_command_output")
def test_return_none_with_template_larger_than_input(
self, mock_command, *_args
@@ -530,13 +514,9 @@ class PrepareUprevTest(unittest.TestCase):
mock_command.assert_not_called()
def test_prepare_uprev_from_json(self):
- json_result = (
- list(self.version_new),
- list(self.bootstrap_version),
- )
+ json_result = (list(self.version_new),)
expected = rust_uprev.PreparedUprev(
self.version_new,
- self.bootstrap_version,
)
actual = rust_uprev.prepare_uprev_from_json(json_result)
self.assertEqual(expected, actual)
@@ -635,51 +615,6 @@ BOOTSTRAP_VERSION="1.3.6"
)
-class UpdateBootstrapEbuildTest(unittest.TestCase):
- """Tests for rust_uprev.update_bootstrap_ebuild()"""
-
- def test_update_bootstrap_ebuild(self):
- # The update should do two things:
- # 1. Create a copy of rust-bootstrap's ebuild with the
- # new version number.
- # 2. Add the old PV to RUSTC_RAW_FULL_BOOTSTRAP_SEQUENCE.
- with tempfile.TemporaryDirectory() as tmpdir_str, mock.patch.object(
- rust_uprev, "find_ebuild_path"
- ) as mock_find_ebuild:
- tmpdir = Path(tmpdir_str)
- bootstrapdir = Path.joinpath(tmpdir, "rust-bootstrap")
- bootstrapdir.mkdir()
- old_ebuild = bootstrapdir.joinpath("rust-bootstrap-1.45.2.ebuild")
- old_ebuild.write_text(
- encoding="utf-8",
- data="""
-some text
-RUSTC_RAW_FULL_BOOTSTRAP_SEQUENCE=(
-\t1.43.1
-\t1.44.1
-)
-some more text
-""",
- )
- mock_find_ebuild.return_value = old_ebuild
- rust_uprev.update_bootstrap_ebuild(rust_uprev.RustVersion(1, 46, 0))
- new_ebuild = bootstrapdir.joinpath("rust-bootstrap-1.46.0.ebuild")
- self.assertTrue(new_ebuild.exists())
- text = new_ebuild.read_text(encoding="utf-8")
- self.assertEqual(
- text,
- """
-some text
-RUSTC_RAW_FULL_BOOTSTRAP_SEQUENCE=(
-\t1.43.1
-\t1.44.1
-\t1.45.2
-)
-some more text
-""",
- )
-
-
class UpdateRustPackagesTests(unittest.TestCase):
"""Tests for update_rust_packages step."""
@@ -787,37 +722,6 @@ class RustUprevOtherStagesTests(unittest.TestCase):
cwd=new_ebuild.parent,
)
- @mock.patch.object(rust_uprev, "find_ebuild_for_package")
- @mock.patch.object(subprocess, "check_call")
- def test_remove_rust_bootstrap_version(self, mock_call, *_args):
- bootstrap_path = os.path.join(
- rust_uprev.RUST_PATH, "..", "rust-bootstrap"
- )
- rust_uprev.remove_rust_bootstrap_version(
- self.old_version, lambda *x: ()
- )
- mock_call.has_calls(
- [
- [
- "git",
- "rm",
- os.path.join(
- bootstrap_path,
- "files",
- f"rust-bootstrap-{self.old_version}-*.patch",
- ),
- ],
- [
- "git",
- "rm",
- os.path.join(
- bootstrap_path,
- f"rust-bootstrap-{self.old_version}.ebuild",
- ),
- ],
- ]
- )
-
@mock.patch.object(subprocess, "check_call")
def test_remove_virtual_rust(self, mock_call):
with tempfile.TemporaryDirectory() as tmpdir: