8 from pathlib import Path, PurePath
10 def sha256_file(filename):
11 sha256 = hashlib.sha256()
12 with io.open(filename, mode="rb") as fd:
14 sha256.update(content)
15 return sha256.hexdigest()
18 return json.dumps(data, indent=4, sort_keys=True)
20 def target_file_url(channel, filename):
21 basename = PurePath(filename).name
22 return '%(baseurl)s/%(channel)s/%(subdir)s/%(basename)s' % {
23 'baseurl': 'http://dl.amnesia.boum.org/tails',
25 'subdir': PurePath(basename).stem,
29 def idf_content(build_target, channel, product_name, version, img, iso):
31 'build_target': build_target,
33 'product-name': product_name,
36 'installation-paths': [
40 'url': target_file_url(channel, img),
41 'sha256': sha256_file(img),
42 'size': Path(img).stat().st_size,
48 'url': target_file_url(channel, iso),
49 'sha256': sha256_file(iso),
50 'size': Path(iso).stat().st_size,
57 if __name__ == '__main__':
59 parser = argparse.ArgumentParser()
60 parser.add_argument('--build-target', dest='build_target', default='amd64')
61 parser.add_argument('--channel', default='stable')
62 parser.add_argument('--product-name', dest='product_name', default='Tails')
63 parser.add_argument('--version', default=None, required=True,
64 help='Version of Tails .')
65 parser.add_argument('--img', default=None, required=True,
66 help='Path to the USB image.')
67 parser.add_argument('--iso', default=None, required=True,
68 help='Path to the ISO file.')
69 args = parser.parse_args()
71 print(idf_content(build_target=args.build_target,
73 product_name=args.product_name,