aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBob Haarman <inglorion@chromium.org>2022-04-19 11:41:38 -0700
committerChromeos LUCI <chromeos-scoped@luci-project-accounts.iam.gserviceaccount.com>2022-07-28 23:04:44 +0000
commitf1c66c20439fd3465b3033289300a93f2cfc228e (patch)
tree538f24a698576d03ee27cbe96e60b069b232ba9e
parent14668ed47d28f2541792809231cfd08598c12f0c (diff)
downloadtoolchain-utils-f1c66c20439fd3465b3033289300a93f2cfc228e.tar.gz
rust_uprev: Remove flip_mirror_in_ebuild
Previously, we temporarily switched on RESTRICT="mirror" for an ebuild before updating the manifest. This allows us to fetch distfiles from their original locations (rather than the default, which is to require them to be fetched from mirrors). We don't actually need this, so this change removes the code that does this. BUG=None TEST=unit tests, also tested on rust-1.60.0 uprev Change-Id: I5f29ffad83a5826dbe523db4657d9ea17c43bcff Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/third_party/toolchain-utils/+/3594132 Commit-Queue: Bob Haarman <inglorion@chromium.org> Reviewed-by: George Burgess <gbiv@chromium.org> Tested-by: Bob Haarman <inglorion@chromium.org>
-rwxr-xr-xrust_tools/rust_uprev.py25
-rwxr-xr-xrust_tools/rust_uprev_test.py39
2 files changed, 1 insertions, 63 deletions
diff --git a/rust_tools/rust_uprev.py b/rust_tools/rust_uprev.py
index 49df7172..7e170443 100755
--- a/rust_tools/rust_uprev.py
+++ b/rust_tools/rust_uprev.py
@@ -360,27 +360,6 @@ def update_ebuild(ebuild_file: str,
new_bootstrap_version)
-def flip_mirror_in_ebuild(ebuild_file: Path, add: bool) -> None:
- restrict_re = re.compile(
- r'(?P<before>RESTRICT=")(?P<values>"[^"]*"|.*)(?P<after>")')
- with open(ebuild_file, encoding='utf-8') as f:
- contents = f.read()
- m = restrict_re.search(contents)
- assert m, 'failed to find RESTRICT variable in Rust ebuild'
- values = m.group('values')
- if add:
- if 'mirror' in values:
- return
- values += ' mirror'
- else:
- if 'mirror' not in values:
- return
- values = values.replace(' mirror', '')
- new_contents = restrict_re.sub(r'\g<before>%s\g<after>' % values, contents)
- with open(ebuild_file, 'w', encoding='utf-8') as f:
- f.write(new_contents)
-
-
def ebuild_actions(package: str,
actions: List[str],
sudo: bool = False) -> None:
@@ -482,11 +461,7 @@ def get_distdir() -> os.PathLike:
def update_manifest(ebuild_file: os.PathLike) -> None:
"""Updates the MANIFEST for the ebuild at the given path."""
ebuild = Path(ebuild_file)
- logging.info('Added "mirror" to RESTRICT to %s', ebuild.name)
- flip_mirror_in_ebuild(ebuild, add=True)
ebuild_actions(ebuild.parent.name, ['manifest'])
- logging.info('Removed "mirror" to RESTRICT from %s', ebuild.name)
- flip_mirror_in_ebuild(ebuild, add=False)
def update_rust_packages(rust_version: RustVersion, add: bool) -> None:
diff --git a/rust_tools/rust_uprev_test.py b/rust_tools/rust_uprev_test.py
index 90f59e4b..2e6e8713 100755
--- a/rust_tools/rust_uprev_test.py
+++ b/rust_tools/rust_uprev_test.py
@@ -234,48 +234,11 @@ BOOTSTRAP_VERSION="1.3.6"
class UpdateManifestTest(unittest.TestCase):
"""Tests for update_manifest step in rust_uprev"""
- # pylint: disable=protected-access
- def _run_test_flip_mirror(self, before, after, add, expect_write):
- mock_open = mock.mock_open(read_data=f'RESTRICT="{before}"')
- with mock.patch('builtins.open', mock_open):
- rust_uprev.flip_mirror_in_ebuild('', add=add)
- if expect_write:
- mock_open.return_value.__enter__().write.assert_called_once_with(
- f'RESTRICT="{after}"')
-
- def test_add_mirror_in_ebuild(self):
- self._run_test_flip_mirror(before='variable1 variable2',
- after='variable1 variable2 mirror',
- add=True,
- expect_write=True)
-
- def test_remove_mirror_in_ebuild(self):
- self._run_test_flip_mirror(before='variable1 variable2 mirror',
- after='variable1 variable2',
- add=False,
- expect_write=True)
-
- def test_add_mirror_when_exists(self):
- self._run_test_flip_mirror(before='variable1 variable2 mirror',
- after='variable1 variable2 mirror',
- add=True,
- expect_write=False)
-
- def test_remove_mirror_when_not_exists(self):
- self._run_test_flip_mirror(before='variable1 variable2',
- after='variable1 variable2',
- add=False,
- expect_write=False)
-
- @mock.patch.object(rust_uprev, 'flip_mirror_in_ebuild')
@mock.patch.object(rust_uprev, 'ebuild_actions')
- def test_update_manifest(self, mock_run, mock_flip):
+ def test_update_manifest(self, mock_run):
ebuild_file = Path('/path/to/rust/rust-1.1.1.ebuild')
rust_uprev.update_manifest(ebuild_file)
mock_run.assert_called_once_with('rust', ['manifest'])
- mock_flip.assert_has_calls(
- [mock.call(ebuild_file, add=True),
- mock.call(ebuild_file, add=False)])
class UpdateBootstrapEbuildTest(unittest.TestCase):