blob: 6e2910b5e30f99d7f545f5b46ec14a96111b6289 [file] [log] [blame]
#!/usr/bin/env python3.8
# Copyright 2018 The Fuchsia Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
import argparse
import json
import os
import shutil
import subprocess
import sys
def extract(pm, far_path, workdir, repository):
if not os.path.exists(workdir):
args = [pm, '-o', workdir, '-r', repository, 'expand', far_path]
subprocess.check_output(args, stderr=subprocess.STDOUT)
def main():
parser = argparse.ArgumentParser()
parser.add_argument('--pm-tool', help='Path to pm tool')
parser.add_argument('--name', help='Name of prebuilt package')
'--archive', help='Path to archive containing prebuilt package')
parser.add_argument('--workdir', help='Path to working directory')
parser.add_argument('--repository', help='Repository host name')
args = parser.parse_args()
extract(args.pm_tool, args.archive, args.workdir, args.repository)
with open(os.path.join(args.workdir, 'package_manifest.json')) as f:
manifest = json.load(f)
if manifest.get('package').get('name') !=
'Prebuilt package name {} does not match the name contained within {}\n'
.format(, args.archive))
return 1
return 0
if __name__ == '__main__':