Clone of https://github.com/NixOS/nixpkgs.git (to stress-test knotserver)
1diff --git a/mx.py b/mx.py
2index a0b9315..b7d67a0 100755
3--- a/mx.py
4+++ b/mx.py
5@@ -238,21 +238,7 @@ def _check_file_with_sha1(path, sha1, sha1path, mustExist=True, newFile=False, l
6 f.write(value or sha1OfFile(path))
7
8 if exists(path):
9- if sha1Check and sha1:
10- if not _sha1CachedValid() or (newFile and sha1 != _sha1Cached()):
11- logv('Create/update SHA1 cache file ' + sha1path)
12- _writeSha1Cached()
13-
14- if sha1 != _sha1Cached():
15- computedSha1 = sha1OfFile(path)
16- if sha1 == computedSha1:
17- warn('Fixing corrupt SHA1 cache file ' + sha1path)
18- _writeSha1Cached(computedSha1)
19- return True
20- if logErrors:
21- size = os.path.getsize(path)
22- log_error('SHA1 of {} [size: {}] ({}) does not match expected value ({})'.format(TimeStampFile(path), size, computedSha1, sha1))
23- return False
24+ return True
25 elif mustExist:
26 if logErrors:
27 log_error("'{}' does not exist".format(path))
28@@ -1057,46 +1043,8 @@ class SuiteImport:
29 version = import_dict.get("version")
30 suite_dir = None
31 version_from = import_dict.get("versionFrom")
32- if version_from and version:
33- abort("In import for '{}': 'version' and 'versionFrom' can not be both set".format(name), context=context)
34- if version is None and version_from is None:
35- if not (in_subdir and (importer.vc_dir != importer.dir or isinstance(importer, BinarySuite))):
36- abort("In import for '{}': No version given and not a 'subdir' suite of the same repository".format(name), context=context)
37- if importer.isSourceSuite():
38- suite_dir = join(importer.vc_dir, name)
39- version = importer.version()
40- if urls is None:
41- if not in_subdir:
42- if import_dict.get("subdir") is None and importer.vc_dir != importer.dir:
43- warn("In import for '{}': No urls given but 'subdir' is not set, assuming 'subdir=True'".format(name), context)
44- in_subdir = True
45- else:
46- abort("In import for '{}': No urls given and not a 'subdir' suite".format(name), context=context)
47- return SuiteImport(name, version, None, None, dynamicImport=dynamicImport, in_subdir=in_subdir, version_from=version_from, suite_dir=suite_dir)
48- # urls a list of alternatives defined as dicts
49- if not isinstance(urls, list):
50- abort('suite import urls must be a list', context=context)
51- urlinfos = []
52- mainKind = None
53- for urlinfo in urls:
54- if isinstance(urlinfo, dict) and urlinfo.get('url') and urlinfo.get('kind'):
55- kind = urlinfo.get('kind')
56- if not VC.is_valid_kind(kind):
57- abort('suite import kind ' + kind + ' illegal', context=context)
58- else:
59- abort('suite import url must be a dict with {"url", kind", attributes', context=context)
60- vc = vc_system(kind)
61- if kind != 'binary':
62- assert not mainKind or mainKind == kind, "Only expecting one non-binary kind"
63- mainKind = kind
64- url = mx_urlrewrites.rewriteurl(urlinfo.get('url'))
65- urlinfos.append(SuiteImportURLInfo(url, kind, vc))
66- vc_kind = None
67- if mainKind:
68- vc_kind = mainKind
69- elif urlinfos:
70- vc_kind = 'binary'
71- return SuiteImport(name, version, urlinfos, vc_kind, dynamicImport=dynamicImport, in_subdir=in_subdir, version_from=version_from, suite_dir=suite_dir)
72+ suite_dir = join(get_env('MX_GIT_CACHE_DIR'), name)
73+ return SuiteImport(name, version, [], None, True, in_subdir=in_subdir, version_from=version_from, suite_dir=suite_dir)
74
75 @staticmethod
76 def get_source_urls(source, kind=None):
77@@ -1467,8 +1415,6 @@ class Suite(object):
78 :type dists: list[Distribution]
79 """
80 def __init__(self, mxDir, primary, internal, importing_suite, load, vc, vc_dir, dynamicallyImported=False):
81- if primary is True and vc_dir is None:
82- abort("The primary suite must be in a vcs repository")
83 self.imported_by = [] if primary else [importing_suite]
84 self.mxDir = mxDir
85 self.dir = dirname(mxDir)
86@@ -1496,7 +1442,7 @@ class Suite(object):
87 self._outputRoot = None
88 self._preloaded_suite_dict = None
89 self.vc = vc
90- self.vc_dir = vc_dir
91+ self.vc_dir = get_env('MX_GIT_CACHE_DIR')
92 self._preload_suite_dict()
93 self._init_imports()
94 if load:
95@@ -2405,7 +2351,9 @@ class Repository(SuiteConstituent):
96 class SourceSuite(Suite):
97 """A source suite"""
98 def __init__(self, mxDir, primary=False, load=True, internal=False, importing_suite=None, dynamicallyImported=False):
99- vc, vc_dir = VC.get_vc_root(dirname(mxDir), abortOnError=False)
100+ vc, vc_dir_test = VC.get_vc_root(dirname(mxDir), abortOnError=False)
101+ vc_dir = get_env('MX_GIT_CACHE_DIR')
102+ warn("LOOKING FOR: " + mxDir)
103 Suite.__init__(self, mxDir, primary, internal, importing_suite, load, vc, vc_dir, dynamicallyImported=dynamicallyImported)
104 logvv("SourceSuite.__init__({}), got vc={}, vc_dir={}".format(mxDir, self.vc, self.vc_dir))
105 self.projects = []
106@@ -2454,17 +2402,7 @@ class SourceSuite(Suite):
107 """
108 Gets the release tag from VC or create a time based once if VC is unavailable
109 """
110- if snapshotSuffix not in self._releaseVersion:
111- _version = self._get_early_suite_dict_property('version')
112- if _version and self.getMxCompatibility().addVersionSuffixToExplicitVersion():
113- if not self.is_release():
114- _version = _version + '-' + snapshotSuffix
115- if not _version:
116- _version = self.vc.release_version_from_tags(self.vc_dir, self.name, snapshotSuffix=snapshotSuffix)
117- if not _version:
118- _version = 'unknown-{0}-{1}'.format(platform.node(), time.strftime('%Y-%m-%d_%H-%M-%S_%Z'))
119- self._releaseVersion[snapshotSuffix] = _version
120- return self._releaseVersion[snapshotSuffix]
121+ return get_env('version')
122
123 def scm_metadata(self, abortOnError=False):
124 scm = self.scm
125@@ -2993,12 +2931,35 @@ def _find_suite_import(importing_suite, suite_import, fatalIfMissing=True, load=
126 Attempts to locate an existing suite in the local context
127 Returns the path to the mx.name dir if found else None
128 """
129- if mode == 'binary':
130- # binary suites are always stored relative to the importing suite in mx-private directory
131- return importing_suite._find_binary_suite_dir(suite_import.name)
132+ warn("FAKE CLONE: " + str(suite_import))
133+ if (suite_import.name == "truffle"):
134+ return join(get_env('TMP'), "source", "truffle", "mx.truffle")
135+ if (suite_import.name == "graal-nodejs"):
136+ return join(get_env('MX_GIT_CACHE_DIR'), "graaljs", "graal-nodejs", "mx.graal-nodejs")
137+ if (suite_import.name == "truffleruby"):
138+ return join(get_env('MX_GIT_CACHE_DIR'), "truffleruby", "mx.truffleruby")
139+ if (suite_import.name == "graalpython"):
140+ return join(get_env('MX_GIT_CACHE_DIR'), "graalpython", "mx.graalpython")
141+ if (suite_import.name == "vm"):
142+ return join(get_env('TMP'), "source", "vm", "mx.vm")
143+ if (suite_import.name == "fastr"):
144+ return join(get_env('MX_GIT_CACHE_DIR'), "fastr", "mx.fastr")
145+ if (suite_import.name == "sdk"):
146+ return join(get_env('TMP'), "source", "sdk", "mx.sdk")
147+ if (suite_import.name == "graal-js"):
148+ return join(get_env('MX_GIT_CACHE_DIR'), "graaljs", "graal-js", "mx.graal-js")
149+ if (suite_import.name == "regex"):
150+ return join(get_env('TMP'), "source", "regex", "mx.regex")
151+ if (suite_import.name == "substratevm"):
152+ return join(get_env('TMP'), "source", "substratevm", "mx.substratevm")
153+ if (suite_import.name == "tools"):
154+ return join(get_env('TMP'), "source", "tools", "mx.tools")
155+ if (suite_import.name == "sulong"):
156+ return join(get_env('TMP'), "source", "sulong", "mx.sulong")
157+ if (suite_import.name == "compiler"):
158+ return join(get_env('TMP'), "source", "compiler", "mx.compiler")
159 else:
160- # use the SuiteModel to locate a local source copy of the suite
161- return _suitemodel.find_suite_dir(suite_import)
162+ return join(get_env('MX_GIT_CACHE_DIR'), suite_import.name)
163
164 def _get_import_dir(url, mode):
165 """Return directory where the suite will be cloned to"""
166@@ -3816,7 +3777,7 @@ def getmtime(name):
167 """
168 Wrapper for builtin open function that handles long path names on Windows.
169 """
170- return os.path.getmtime(_safe_path(name))
171+ return 315532800
172
173
174 def stat(name):
175@@ -4062,57 +4023,8 @@ def _attempt_download(url, path, jarEntryName=None):
176 return False
177
178 def download(path, urls, verbose=False, abortOnError=True, verifyOnly=False):
179- """
180- Attempts to downloads content for each URL in a list, stopping after the first successful download.
181- If the content cannot be retrieved from any URL, the program is aborted, unless abortOnError=False.
182- The downloaded content is written to the file indicated by `path`.
183- """
184- if not verifyOnly:
185- ensure_dirname_exists(path)
186- assert not path.endswith(os.sep)
187-
188- # https://docs.oracle.com/javase/7/docs/api/java/net/JarURLConnection.html
189- jarURLPattern = re.compile('jar:(.*)!/(.*)')
190- verify_errors = {}
191- for url in urls:
192- if not verifyOnly or verbose:
193- log('Downloading ' + url + ' to ' + path)
194- m = jarURLPattern.match(url)
195- jarEntryName = None
196- if m:
197- url = m.group(1)
198- jarEntryName = m.group(2)
199-
200- if not _opts.trust_http and (url.lower().startswith('http://') or url.lower().startswith('ftp://')):
201- warn('Downloading from non-https URL {}. Use --trust-http mx option to suppress this warning.'.format(url))
202-
203- if verifyOnly:
204- try:
205- conn = _urlopen(url, timeout=10)
206- conn.close()
207- except (IOError, socket.timeout) as e:
208- _suggest_tlsv1_error(e)
209- verify_errors[url] = e
210- else:
211- for i in range(4):
212- if i != 0:
213- time.sleep(1)
214- warn('Retry {} to download from {}'.format(i, url))
215- if _attempt_download(url, path, jarEntryName):
216- return True # Download was successful
217-
218- if verifyOnly and len(verify_errors) < len(urls): # verify-mode at least one success -> success
219- return True
220- else: # Either verification error or no download was successful
221- msg = 'Could not download to ' + path + ' from any of the following URLs: ' + ', '.join(urls)
222- if verifyOnly: # verify-mode -> print error details
223- for url, e in verify_errors.items():
224- msg += '\n ' + url + ': ' + str(e)
225- if abortOnError:
226- abort(msg)
227- else:
228- warn(msg)
229- return False
230+ print("FAKE download(path={} urls={} verbose={} abortOnError={} verifyOnly={})".format(path, urls, verbose, abortOnError, verifyOnly))
231+ return True
232
233 def update_file(path, content, showDiff=False):
234 """
235@@ -7887,30 +7799,6 @@ class PackedResourceLibrary(ResourceLibrary):
236
237 def get_path(self, resolve):
238 extract_path = _make_absolute(self.extract_path, self.suite.dir)
239- download_path = super(PackedResourceLibrary, self).get_path(resolve)
240- if resolve and self._check_extract_needed(extract_path, download_path):
241- extract_path_tmp = tempfile.mkdtemp(suffix=basename(extract_path), dir=dirname(extract_path))
242- try:
243- # extract archive
244- Extractor.create(download_path).extract(extract_path_tmp)
245- # ensure modification time is up to date
246- os.utime(extract_path_tmp, None)
247- logv("Moving temporary directory {} to {}".format(extract_path_tmp, extract_path))
248- try:
249- # attempt atomic overwrite
250- os.rename(extract_path_tmp, extract_path)
251- except OSError:
252- # clean destination & re-try for cases where atomic overwrite doesn't work
253- rmtree(extract_path, ignore_errors=True)
254- os.rename(extract_path_tmp, extract_path)
255- except OSError as ose:
256- # Rename failed. Race with other process?
257- if self._check_extract_needed(extract_path, download_path):
258- # ok something really went wrong
259- abort("Extracting {} failed!".format(download_path), context=ose)
260- finally:
261- rmtree(extract_path_tmp, ignore_errors=True)
262-
263 return extract_path
264
265 def _check_download_needed(self):
266@@ -8430,7 +8318,7 @@ class VC(_with_metaclass(ABCMeta, object)):
267 :param str branch: a branch name
268 :param bool abortOnError: if True abort on error
269 """
270- abort(self.kind + " update_to_branch is not implemented")
271+ self.run(['hg', vcdir] + cmd)
272
273 def is_release_from_tags(self, vcdir, prefix):
274 """
275@@ -8831,7 +8719,7 @@ class HgConfig(VC):
276 return None
277
278 def parent_info(self, vcdir, abortOnError=True):
279- out = self.hg_command(vcdir, ["log", "-r", ".", "--template", "{author}|||{date|hgdate}"], abortOnError=abortOnError)
280+ out = _check_output_str(["hg", '-R', vcdir, "log", "-r", ".", "--template", "{author}|||{date|hgdate}"])
281 author, date = out.split("|||")
282 ts, _ = date.split(" ")
283 return self._sanitize_parent_info({
284@@ -14069,6 +13957,7 @@ class Archiver(SafeFileCreation):
285
286 def _add_zip(self, filename, archive_name, provenance):
287 self._add_provenance(archive_name, provenance)
288+ os.utime(filename, (315532800, 315532800))
289 self.zf.write(filename, archive_name)
290
291 def _add_str_zip(self, data, archive_name, provenance):