blob: 7c6007e5f313949c2752556ed0892a396569b71a [file] [log] [blame]
Doug Zongkerc9253822014-02-04 12:17:58 -08001#!/usr/bin/env python
2#
3# Copyright (C) 2014 The Android Open Source Project
4#
5# Licensed under the Apache License, Version 2.0 (the "License");
6# you may not use this file except in compliance with the License.
7# You may obtain a copy of the License at
8#
9# http://www.apache.org/licenses/LICENSE-2.0
10#
11# Unless required by applicable law or agreed to in writing, software
12# distributed under the License is distributed on an "AS IS" BASIS,
13# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14# See the License for the specific language governing permissions and
15# limitations under the License.
16
Tao Bao89fbb0f2017-01-10 10:47:58 -080017from __future__ import print_function
18
Doug Zongkerc9253822014-02-04 12:17:58 -080019import sys
20
Doug Zongkercf6d5a92014-02-18 10:57:07 -080021if sys.hexversion < 0x02070000:
Tao Bao89fbb0f2017-01-10 10:47:58 -080022 print("Python 2.7 or newer is required.", file=sys.stderr)
Doug Zongkerc9253822014-02-04 12:17:58 -080023 sys.exit(1)
24
25import os
26import common
27
28OPTIONS = common.OPTIONS
29
30def main(argv):
31 # def option_handler(o, a):
32 # return False
33
34 args = common.ParseOptions(argv, __doc__)
35 input_dir, output_dir = args
36
37 OPTIONS.info_dict = common.LoadInfoDict(input_dir)
38
39 recovery_img = common.GetBootableImage("recovery.img", "recovery.img",
40 input_dir, "RECOVERY")
41 boot_img = common.GetBootableImage("boot.img", "boot.img",
42 input_dir, "BOOT")
43
Ying Wangd89ffa82014-02-05 11:28:51 -080044 if not recovery_img or not boot_img:
45 sys.exit(0)
46
Doug Zongkerc9253822014-02-04 12:17:58 -080047 def output_sink(fn, data):
48 with open(os.path.join(output_dir, "SYSTEM", *fn.split("/")), "wb") as f:
49 f.write(data)
50
51 common.MakeRecoveryPatch(input_dir, output_sink, recovery_img, boot_img)
52
53
54if __name__ == '__main__':
55 main(sys.argv[1:])