initial commit
This commit is contained in:
@@ -0,0 +1,50 @@
|
||||
#!/usr/bin/env python3
|
||||
"""Preserve the single nested Git source referenced by the collected FreeType tree."""
|
||||
import argparse
|
||||
import configparser
|
||||
import json
|
||||
from pathlib import Path
|
||||
|
||||
from collect_pdfium import ROOT, collect, run, save, sha
|
||||
|
||||
|
||||
def main():
|
||||
parser = argparse.ArgumentParser(description=__doc__)
|
||||
parser.add_argument('--output', type=Path, required=True)
|
||||
parser.add_argument('--cache', type=Path, default=ROOT / '.deps/source-archives/pdfium-gitlink')
|
||||
args = parser.parse_args()
|
||||
output, cache = args.output.resolve(), args.cache.resolve()
|
||||
if not output.is_relative_to(ROOT) or not cache.is_relative_to(ROOT):
|
||||
parser.error('Output/cache must be inside the workspace')
|
||||
collection = ROOT / 'tests/results/source-archives/pdfium-git/report.json'
|
||||
report = json.loads(collection.read_text())
|
||||
if not report['success']:
|
||||
raise ValueError('Verified parent collection required')
|
||||
parent = next(item for item in report['repositories'] if item['path'] == 'third_party/freetype/src')
|
||||
links = [(item['path'], link) for item in report['repositories'] for link in item['gitlinks']]
|
||||
if (len(links) != 1 or links[0][0] != parent['path'] or links[0][1]['path'] != 'subprojects/dlg'
|
||||
or links[0][1]['gitObject'] != '395ccad2c1e0daae535c4d20bb0a3f2424648e17'):
|
||||
raise ValueError('Unreviewed nested Git source')
|
||||
config = run(ROOT / parent['repository'], ['show', parent['revision'] + ':.gitmodules'])
|
||||
config.check_returncode()
|
||||
modules = configparser.ConfigParser(interpolation=None)
|
||||
modules.read_string(config.stdout.decode())
|
||||
source = modules['submodule "dlg"']
|
||||
if source['path'] != 'subprojects/dlg' or source['url'] != 'https://github.com/nyorain/dlg.git':
|
||||
raise ValueError('Unexpected pinned .gitmodules mapping')
|
||||
output.mkdir(parents=True, exist_ok=False); cache.mkdir(parents=True, exist_ok=True)
|
||||
(output / 'freetype.gitmodules').write_bytes(config.stdout)
|
||||
item = {'path': parent['path'] + '/' + source['path'], 'url': source['url'],
|
||||
'revision': links[0][1]['gitObject'], 'condition': 'Referenced by collected FreeType gitlink'}
|
||||
result = collect(item, cache, output)
|
||||
success = result['success'] and not result.get('gitlinks')
|
||||
save(output / 'report.json', {'success': success, 'collectorSha256': sha(Path(__file__)),
|
||||
'parentCollectionSha256': sha(collection), 'parentRevision': parent['revision'],
|
||||
'gitmodulesSha256': sha(output / 'freetype.gitmodules'), 'repositories': [result],
|
||||
'scope': 'Nested source preserved, not evidence that dlg is linked into the distributed PDFium. '
|
||||
'No source/build scripts or hooks executed.'})
|
||||
return 0 if success else 1
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
raise SystemExit(main())
|
||||
Reference in New Issue
Block a user