summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDenis 'GNUtoo' Carikli <GNUtoo@cyberdimension.org>2021-09-08 18:32:17 +0200
committerDenis 'GNUtoo' Carikli <GNUtoo@cyberdimension.org>2021-09-14 01:19:23 +0200
commit4bd62bf230bd83e171559f02dd0e27830246bdf4 (patch)
tree31ba1161a3da40063117969e4f9a5be403328fa4
parent93e47cacf45655f0f97ff59c622cff21f22538bc (diff)
downloadmanifest-4bd62bf230bd83e171559f02dd0e27830246bdf4.tar.gz
manifest-4bd62bf230bd83e171559f02dd0e27830246bdf4.tar.bz2
manifest-4bd62bf230bd83e171559f02dd0e27830246bdf4.zip
scripts: generate-mirror-command: Guard against updating floating revisions
We could accidentally update the branches used in Replicant 6 when trying to mirror the code meant for the next Replicant version. So we whitelist revisions to avoid accidentally doing that. Signed-off-by: Denis 'GNUtoo' Carikli <GNUtoo@cyberdimension.org>
-rwxr-xr-xscripts/generate-mirror-commands.py34
1 files changed, 34 insertions, 0 deletions
diff --git a/scripts/generate-mirror-commands.py b/scripts/generate-mirror-commands.py
index 6349bee..c7987c0 100755
--- a/scripts/generate-mirror-commands.py
+++ b/scripts/generate-mirror-commands.py
@@ -120,6 +120,24 @@ class Manifest(object):
return whitelist.get(given_remote.get('name')).get('dirname')
+ def is_revision_whitelisted(self, elm):
+ remote = self.get_project_property(elm, 'remote')
+ revision = self.get_revision(elm)
+ if remote == 'aosp' and revision == 'refs/tags/android-11.0.0_r17':
+ return True
+ if remote == 'freedesktop' and \
+ revision == '32819fe45972e0c706423d71075788a5885f7b86':
+ return True
+
+ return False
+
+ def is_revision_blacklisted(self, elm):
+ revision = self.get_revision(elm)
+ if revision == 'master':
+ return True
+
+ return False
+
def get_clone_commands(self, elm):
commands = []
@@ -130,6 +148,22 @@ class Manifest(object):
'name').replace('/', '_')
revision = self.get_revision(elm)
+ # Guard against updating the master branch of mirrors that could be used
+ # by several Replicant versions at the same time by forcing users to
+ # manually declare revisions here. The revisions have to be either
+ # whitelisted or blacklisted else we abort.
+ if not self.is_revision_whitelisted(elm) and \
+ not self.is_revision_blacklisted(elm):
+ print('/!\ The "{}" revision of {}/{} is not known by {}'.format(
+ revision, base_directory, repo_directory, sys.argv[0]))
+ print(' Please add it either to the whitelist in {}'.format(
+ 'is_revision_whitelisted'))
+ print(' or to the blacklist in {}'.format(
+ 'is_revision_blacklisted'))
+ assert(False)
+ elif self.is_revision_blacklisted(elm):
+ return []
+
commands.append("if [ ! -d {}/{}.git ] ; then".format(
base_directory, repo_directory))