| Doug Zongker | c925382 | 2014-02-04 12:17:58 -0800 | [diff] [blame] | 1 | #!/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 |  | 
|  | 17 | import sys | 
|  | 18 |  | 
| Doug Zongker | cf6d5a9 | 2014-02-18 10:57:07 -0800 | [diff] [blame^] | 19 | if sys.hexversion < 0x02070000: | 
|  | 20 | print >> sys.stderr, "Python 2.7 or newer is required." | 
| Doug Zongker | c925382 | 2014-02-04 12:17:58 -0800 | [diff] [blame] | 21 | sys.exit(1) | 
|  | 22 |  | 
|  | 23 | import os | 
|  | 24 | import common | 
|  | 25 |  | 
|  | 26 | OPTIONS = common.OPTIONS | 
|  | 27 |  | 
|  | 28 | def main(argv): | 
|  | 29 | # def option_handler(o, a): | 
|  | 30 | #   return False | 
|  | 31 |  | 
|  | 32 | args = common.ParseOptions(argv, __doc__) | 
|  | 33 | input_dir, output_dir = args | 
|  | 34 |  | 
|  | 35 | OPTIONS.info_dict = common.LoadInfoDict(input_dir) | 
|  | 36 |  | 
|  | 37 | recovery_img = common.GetBootableImage("recovery.img", "recovery.img", | 
|  | 38 | input_dir, "RECOVERY") | 
|  | 39 | boot_img = common.GetBootableImage("boot.img", "boot.img", | 
|  | 40 | input_dir, "BOOT") | 
|  | 41 |  | 
| Ying Wang | d89ffa8 | 2014-02-05 11:28:51 -0800 | [diff] [blame] | 42 | if not recovery_img or not boot_img: | 
|  | 43 | sys.exit(0) | 
|  | 44 |  | 
| Doug Zongker | c925382 | 2014-02-04 12:17:58 -0800 | [diff] [blame] | 45 | def output_sink(fn, data): | 
|  | 46 | with open(os.path.join(output_dir, "SYSTEM", *fn.split("/")), "wb") as f: | 
|  | 47 | f.write(data) | 
|  | 48 |  | 
|  | 49 | common.MakeRecoveryPatch(input_dir, output_sink, recovery_img, boot_img) | 
|  | 50 |  | 
|  | 51 |  | 
|  | 52 | if __name__ == '__main__': | 
|  | 53 | main(sys.argv[1:]) |