|
8 | 8 |
|
9 | 9 | from extract_utils.extract import ( |
10 | 10 | ExtractCtx, |
| 11 | + extract_fns_type, |
11 | 12 | extract_image, |
12 | 13 | filter_already_extracted_partitions, |
13 | 14 | get_dump_dir, |
14 | 15 | ) |
| 16 | +from extract_utils.extract_pixel import ( |
| 17 | + extract_pixel_factory_image, |
| 18 | + extract_pixel_firmware, |
| 19 | + pixel_factory_image_regex, |
| 20 | + pixel_firmware_regex, |
| 21 | +) |
| 22 | +from extract_utils.extract_star import ( |
| 23 | + extract_star_firmware, |
| 24 | + star_firmware_regex, |
| 25 | +) |
15 | 26 |
|
16 | 27 | DEFAULT_EXTRACTED_PARTITIONS = [ |
17 | 28 | 'odm', |
|
41 | 52 | action='store_true', |
42 | 53 | help='Extract all files from archive', |
43 | 54 | ) |
| 55 | +parser.add_argument( |
| 56 | + '--pixel-factory', |
| 57 | + nargs='*', |
| 58 | + type=str, |
| 59 | + help='Files to extract as pixel factory image', |
| 60 | +) |
| 61 | +parser.add_argument( |
| 62 | + '--pixel-firmware', |
| 63 | + nargs='*', |
| 64 | + type=str, |
| 65 | + help='Files to extract as pixel firmware', |
| 66 | +) |
| 67 | +parser.add_argument( |
| 68 | + '--star-firmware', |
| 69 | + nargs='*', |
| 70 | + type=str, |
| 71 | + help='Files to extract as star firmware', |
| 72 | +) |
44 | 73 |
|
45 | 74 | parser.add_argument( |
46 | 75 | 'source', |
|
52 | 81 | if __name__ == '__main__': |
53 | 82 | args = parser.parse_args() |
54 | 83 |
|
| 84 | + if args.pixel_factory is not None and not args.pixel_factory: |
| 85 | + args.pixel_factory = [pixel_factory_image_regex] |
| 86 | + |
| 87 | + if args.pixel_firmware is not None and not args.pixel_firmware: |
| 88 | + args.pixel_firmware = [pixel_firmware_regex] |
| 89 | + |
| 90 | + if args.star_firmware is not None and not args.star_firmware: |
| 91 | + args.star_firmware = [star_firmware_regex] |
| 92 | + |
| 93 | + extract_fns: extract_fns_type = {} |
| 94 | + |
| 95 | + if args.pixel_factory: |
| 96 | + for extract_pattern in args.pixel_factory: |
| 97 | + extract_fns.setdefault(extract_pattern, []).append( |
| 98 | + extract_pixel_factory_image, |
| 99 | + ) |
| 100 | + |
| 101 | + if args.pixel_firmware: |
| 102 | + for extract_pattern in args.pixel_firmware: |
| 103 | + extract_fns.setdefault(extract_pattern, []).append( |
| 104 | + extract_pixel_firmware, |
| 105 | + ) |
| 106 | + |
| 107 | + if args.star_firmware: |
| 108 | + for extract_pattern in args.star_firmware: |
| 109 | + extract_fns.setdefault(extract_pattern, []).append( |
| 110 | + extract_star_firmware, |
| 111 | + ) |
| 112 | + |
55 | 113 | extract_partitions = args.partitions |
56 | 114 | if args.extra_partitions is not None: |
57 | 115 | extract_partitions += args.extra_partitions |
58 | 116 |
|
59 | 117 | ctx = ExtractCtx( |
60 | 118 | keep_dump=True, |
61 | 119 | extract_partitions=extract_partitions, |
| 120 | + extract_fns=extract_fns, |
62 | 121 | extract_all=args.all, |
63 | 122 | ) |
64 | 123 |
|
|
0 commit comments