57 parser = argparse.ArgumentParser()
58
59 parser.add_argument('--pm-bin', dest='pm_bin', action='store', required=True)
60 parser.add_argument('--package-dir', dest='package_dir', action='store', required=True)
61 parser.add_argument('--manifest-file', dest='manifest_file', action='store', required=False)
62 parser.add_argument(
63 '--manifest-json-file', dest='manifest_json_file', action='store', required=True
64 )
65 parser.add_argument('--far-name', dest='far_name', action='store', required=False)
66 parser.add_argument('--api-level', dest='api_level', action='store', required=False)
67
68 args = parser.parse_args()
69
70 assert os.path.exists(args.pm_bin)
71 assert os.path.exists(args.package_dir)
72 pkg_dir = args.package_dir
73
74 if not os.path.exists(os.path.join(pkg_dir, 'meta', 'package')):
76
77 output_dir = os.path.abspath(pkg_dir + '_out')
78 if not os.path.exists(output_dir):
79 os.makedirs(output_dir)
80
81 manifest_file = None
82 if args.manifest_file is not None:
83 assert os.path.exists(args.manifest_file)
84 manifest_file = args.manifest_file
85 else:
87
88 pm_command_base = [
89 args.pm_bin,
90 '-o',
91 output_dir,
92 '-n',
93 args.far_name,
94 '-m',
95 manifest_file,
96 ]
97
98
99
100 try:
101
102 build_command = ['build', '--output-package-manifest', args.manifest_json_file]
103
104 if args.api_level is not None:
105 build_command = ['--api-level', args.api_level] + build_command
106
107 archive_command = [
108 'archive', '--output=' + os.path.join(os.path.dirname(output_dir), args.far_name + "-0")
109 ]
110
111 pm_commands = [build_command, archive_command]
112
113 for pm_command in pm_commands:
114 subprocess.check_output(pm_command_base + pm_command)
115 except subprocess.CalledProcessError as e:
116 print(
'==================== Manifest contents =========================================')
117 with open(manifest_file, 'r') as manifest:
118 sys.stdout.write(manifest.read())
119 print(
'==================== End manifest contents =====================================')
120 meta_contents_path = os.path.join(output_dir, 'meta', 'contents')
121 if os.path.exists(meta_contents_path):
122 print(
'==================== meta/contents =============================================')
123 with open(meta_contents_path, 'r') as meta_contents:
124 sys.stdout.write(meta_contents.read())
125 print(
'==================== End meta/contents =========================================')
126 raise
127
128 return 0
129
130
def CreateMetaPackage(dst_root, far_name)
def print(*args, **kwargs)