Doug Zongker | 3c84f56 | 2014-07-31 11:06:30 -0700 | [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 | """ |
| 18 | Given a target-files zipfile that does not contain images (ie, does |
| 19 | not have an IMAGES/ top-level subdirectory), produce the images and |
| 20 | add them to the zipfile. |
| 21 | |
| 22 | Usage: add_img_to_target_files target_files |
| 23 | """ |
| 24 | |
| 25 | import sys |
| 26 | |
| 27 | if sys.hexversion < 0x02070000: |
| 28 | print >> sys.stderr, "Python 2.7 or newer is required." |
| 29 | sys.exit(1) |
| 30 | |
| 31 | import errno |
| 32 | import os |
Doug Zongker | 3c84f56 | 2014-07-31 11:06:30 -0700 | [diff] [blame] | 33 | import tempfile |
| 34 | import zipfile |
| 35 | |
Doug Zongker | 3c84f56 | 2014-07-31 11:06:30 -0700 | [diff] [blame] | 36 | import build_image |
| 37 | import common |
| 38 | |
| 39 | OPTIONS = common.OPTIONS |
| 40 | |
Michael Runge | 2e0d8fc | 2014-11-13 21:41:08 -0800 | [diff] [blame] | 41 | OPTIONS.add_missing = False |
| 42 | OPTIONS.rebuild_recovery = False |
Baligh Uddin | 59f4ff1 | 2015-09-16 21:20:30 -0700 | [diff] [blame^] | 43 | OPTIONS.replace_verity_public_key = False |
| 44 | OPTIONS.replace_verity_private_key = False |
| 45 | OPTIONS.verity_signer_path = None |
Doug Zongker | 3c84f56 | 2014-07-31 11:06:30 -0700 | [diff] [blame] | 46 | |
Michael Runge | 2e0d8fc | 2014-11-13 21:41:08 -0800 | [diff] [blame] | 47 | def AddSystem(output_zip, prefix="IMAGES/", recovery_img=None, boot_img=None): |
Doug Zongker | 3c84f56 | 2014-07-31 11:06:30 -0700 | [diff] [blame] | 48 | """Turn the contents of SYSTEM into a system image and store it in |
| 49 | output_zip.""" |
Michael Runge | 2e0d8fc | 2014-11-13 21:41:08 -0800 | [diff] [blame] | 50 | |
| 51 | prebuilt_path = os.path.join(OPTIONS.input_tmp, prefix, "system.img") |
| 52 | if os.path.exists(prebuilt_path): |
| 53 | print "system.img already exists in %s, no need to rebuild..." % (prefix,) |
| 54 | return |
| 55 | |
| 56 | def output_sink(fn, data): |
Dan Albert | 8b72aef | 2015-03-23 19:13:21 -0700 | [diff] [blame] | 57 | ofile = open(os.path.join(OPTIONS.input_tmp, "SYSTEM", fn), "w") |
| 58 | ofile.write(data) |
| 59 | ofile.close() |
Michael Runge | 2e0d8fc | 2014-11-13 21:41:08 -0800 | [diff] [blame] | 60 | |
| 61 | if OPTIONS.rebuild_recovery: |
Dan Albert | 8b72aef | 2015-03-23 19:13:21 -0700 | [diff] [blame] | 62 | print "Building new recovery patch" |
| 63 | common.MakeRecoveryPatch(OPTIONS.input_tmp, output_sink, recovery_img, |
| 64 | boot_img, info_dict=OPTIONS.info_dict) |
Michael Runge | 2e0d8fc | 2014-11-13 21:41:08 -0800 | [diff] [blame] | 65 | |
Doug Zongker | fc44a51 | 2014-08-26 13:10:25 -0700 | [diff] [blame] | 66 | block_list = common.MakeTempFile(prefix="system-blocklist-", suffix=".map") |
| 67 | imgname = BuildSystem(OPTIONS.input_tmp, OPTIONS.info_dict, |
| 68 | block_list=block_list) |
Dan Albert | 8e0178d | 2015-01-27 15:53:15 -0800 | [diff] [blame] | 69 | common.ZipWrite(output_zip, imgname, prefix + "system.img") |
| 70 | common.ZipWrite(output_zip, block_list, prefix + "system.map") |
Doug Zongker | fc44a51 | 2014-08-26 13:10:25 -0700 | [diff] [blame] | 71 | |
| 72 | |
| 73 | def BuildSystem(input_dir, info_dict, block_list=None): |
| 74 | """Build the (sparse) system image and return the name of a temp |
| 75 | file containing it.""" |
| 76 | return CreateImage(input_dir, info_dict, "system", block_list=block_list) |
| 77 | |
| 78 | |
| 79 | def AddVendor(output_zip, prefix="IMAGES/"): |
| 80 | """Turn the contents of VENDOR into a vendor image and store in it |
| 81 | output_zip.""" |
Michael Runge | 2e0d8fc | 2014-11-13 21:41:08 -0800 | [diff] [blame] | 82 | |
| 83 | prebuilt_path = os.path.join(OPTIONS.input_tmp, prefix, "vendor.img") |
| 84 | if os.path.exists(prebuilt_path): |
| 85 | print "vendor.img already exists in %s, no need to rebuild..." % (prefix,) |
| 86 | return |
| 87 | |
Doug Zongker | fc44a51 | 2014-08-26 13:10:25 -0700 | [diff] [blame] | 88 | block_list = common.MakeTempFile(prefix="vendor-blocklist-", suffix=".map") |
| 89 | imgname = BuildVendor(OPTIONS.input_tmp, OPTIONS.info_dict, |
Dan Albert | 8b72aef | 2015-03-23 19:13:21 -0700 | [diff] [blame] | 90 | block_list=block_list) |
Dan Albert | 8e0178d | 2015-01-27 15:53:15 -0800 | [diff] [blame] | 91 | common.ZipWrite(output_zip, imgname, prefix + "vendor.img") |
| 92 | common.ZipWrite(output_zip, block_list, prefix + "vendor.map") |
Doug Zongker | 3c84f56 | 2014-07-31 11:06:30 -0700 | [diff] [blame] | 93 | |
| 94 | |
Doug Zongker | fc44a51 | 2014-08-26 13:10:25 -0700 | [diff] [blame] | 95 | def BuildVendor(input_dir, info_dict, block_list=None): |
| 96 | """Build the (sparse) vendor image and return the name of a temp |
| 97 | file containing it.""" |
| 98 | return CreateImage(input_dir, info_dict, "vendor", block_list=block_list) |
| 99 | |
| 100 | |
| 101 | def CreateImage(input_dir, info_dict, what, block_list=None): |
Doug Zongker | 3c84f56 | 2014-07-31 11:06:30 -0700 | [diff] [blame] | 102 | print "creating " + what + ".img..." |
| 103 | |
Doug Zongker | fc44a51 | 2014-08-26 13:10:25 -0700 | [diff] [blame] | 104 | img = common.MakeTempFile(prefix=what + "-", suffix=".img") |
Doug Zongker | 3c84f56 | 2014-07-31 11:06:30 -0700 | [diff] [blame] | 105 | |
| 106 | # The name of the directory it is making an image out of matters to |
| 107 | # mkyaffs2image. It wants "system" but we have a directory named |
| 108 | # "SYSTEM", so create a symlink. |
| 109 | try: |
| 110 | os.symlink(os.path.join(input_dir, what.upper()), |
| 111 | os.path.join(input_dir, what)) |
Dan Albert | 8b72aef | 2015-03-23 19:13:21 -0700 | [diff] [blame] | 112 | except OSError as e: |
| 113 | # bogus error on my mac version? |
| 114 | # File "./build/tools/releasetools/img_from_target_files" |
| 115 | # os.path.join(OPTIONS.input_tmp, "system")) |
| 116 | # OSError: [Errno 17] File exists |
| 117 | if e.errno == errno.EEXIST: |
Doug Zongker | 3c84f56 | 2014-07-31 11:06:30 -0700 | [diff] [blame] | 118 | pass |
| 119 | |
| 120 | image_props = build_image.ImagePropFromGlobalDict(info_dict, what) |
| 121 | fstab = info_dict["fstab"] |
| 122 | if fstab: |
Dan Albert | 8b72aef | 2015-03-23 19:13:21 -0700 | [diff] [blame] | 123 | image_props["fs_type"] = fstab["/" + what].fs_type |
Doug Zongker | 3c84f56 | 2014-07-31 11:06:30 -0700 | [diff] [blame] | 124 | |
| 125 | if what == "system": |
| 126 | fs_config_prefix = "" |
| 127 | else: |
| 128 | fs_config_prefix = what + "_" |
| 129 | |
| 130 | fs_config = os.path.join( |
| 131 | input_dir, "META/" + fs_config_prefix + "filesystem_config.txt") |
Dan Albert | 8b72aef | 2015-03-23 19:13:21 -0700 | [diff] [blame] | 132 | if not os.path.exists(fs_config): |
| 133 | fs_config = None |
Doug Zongker | 3c84f56 | 2014-07-31 11:06:30 -0700 | [diff] [blame] | 134 | |
| 135 | fc_config = os.path.join(input_dir, "BOOT/RAMDISK/file_contexts") |
Dan Albert | 8b72aef | 2015-03-23 19:13:21 -0700 | [diff] [blame] | 136 | if not os.path.exists(fc_config): |
| 137 | fc_config = None |
Doug Zongker | 3c84f56 | 2014-07-31 11:06:30 -0700 | [diff] [blame] | 138 | |
Ying Wang | a2292c9 | 2015-03-24 19:07:40 -0700 | [diff] [blame] | 139 | # Override values loaded from info_dict. |
| 140 | if fs_config: |
| 141 | image_props["fs_config"] = fs_config |
| 142 | if fc_config: |
| 143 | image_props["selinux_fc"] = fc_config |
| 144 | if block_list: |
| 145 | image_props["block_list"] = block_list |
| 146 | if image_props.get("system_root_image") == "true": |
| 147 | image_props["ramdisk_dir"] = os.path.join(input_dir, "BOOT/RAMDISK") |
| 148 | image_props["ramdisk_fs_config"] = os.path.join( |
| 149 | input_dir, "META/boot_filesystem_config.txt") |
| 150 | |
Doug Zongker | 3c84f56 | 2014-07-31 11:06:30 -0700 | [diff] [blame] | 151 | succ = build_image.BuildImage(os.path.join(input_dir, what), |
Ying Wang | a2292c9 | 2015-03-24 19:07:40 -0700 | [diff] [blame] | 152 | image_props, img) |
Doug Zongker | 3c84f56 | 2014-07-31 11:06:30 -0700 | [diff] [blame] | 153 | assert succ, "build " + what + ".img image failed" |
| 154 | |
Doug Zongker | fc44a51 | 2014-08-26 13:10:25 -0700 | [diff] [blame] | 155 | return img |
Doug Zongker | 3c84f56 | 2014-07-31 11:06:30 -0700 | [diff] [blame] | 156 | |
| 157 | |
| 158 | def AddUserdata(output_zip, prefix="IMAGES/"): |
| 159 | """Create an empty userdata image and store it in output_zip.""" |
| 160 | |
Michael Runge | 2e0d8fc | 2014-11-13 21:41:08 -0800 | [diff] [blame] | 161 | prebuilt_path = os.path.join(OPTIONS.input_tmp, prefix, "userdata.img") |
| 162 | if os.path.exists(prebuilt_path): |
| 163 | print "userdata.img already exists in %s, no need to rebuild..." % (prefix,) |
| 164 | return |
| 165 | |
Doug Zongker | 3c84f56 | 2014-07-31 11:06:30 -0700 | [diff] [blame] | 166 | image_props = build_image.ImagePropFromGlobalDict(OPTIONS.info_dict, |
| 167 | "data") |
| 168 | # We only allow yaffs to have a 0/missing partition_size. |
| 169 | # Extfs, f2fs must have a size. Skip userdata.img if no size. |
| 170 | if (not image_props.get("fs_type", "").startswith("yaffs") and |
| 171 | not image_props.get("partition_size")): |
| 172 | return |
| 173 | |
| 174 | print "creating userdata.img..." |
| 175 | |
| 176 | # The name of the directory it is making an image out of matters to |
| 177 | # mkyaffs2image. So we create a temp dir, and within it we create an |
| 178 | # empty dir named "data", and build the image from that. |
| 179 | temp_dir = tempfile.mkdtemp() |
| 180 | user_dir = os.path.join(temp_dir, "data") |
| 181 | os.mkdir(user_dir) |
| 182 | img = tempfile.NamedTemporaryFile() |
| 183 | |
| 184 | fstab = OPTIONS.info_dict["fstab"] |
| 185 | if fstab: |
Dan Albert | 8b72aef | 2015-03-23 19:13:21 -0700 | [diff] [blame] | 186 | image_props["fs_type"] = fstab["/data"].fs_type |
Doug Zongker | 3c84f56 | 2014-07-31 11:06:30 -0700 | [diff] [blame] | 187 | succ = build_image.BuildImage(user_dir, image_props, img.name) |
| 188 | assert succ, "build userdata.img image failed" |
| 189 | |
| 190 | common.CheckSize(img.name, "userdata.img", OPTIONS.info_dict) |
Tao Bao | f3282b4 | 2015-04-01 11:21:55 -0700 | [diff] [blame] | 191 | common.ZipWrite(output_zip, img.name, prefix + "userdata.img") |
Doug Zongker | 3c84f56 | 2014-07-31 11:06:30 -0700 | [diff] [blame] | 192 | img.close() |
| 193 | os.rmdir(user_dir) |
| 194 | os.rmdir(temp_dir) |
| 195 | |
| 196 | |
| 197 | def AddCache(output_zip, prefix="IMAGES/"): |
| 198 | """Create an empty cache image and store it in output_zip.""" |
| 199 | |
Michael Runge | 2e0d8fc | 2014-11-13 21:41:08 -0800 | [diff] [blame] | 200 | prebuilt_path = os.path.join(OPTIONS.input_tmp, prefix, "cache.img") |
| 201 | if os.path.exists(prebuilt_path): |
| 202 | print "cache.img already exists in %s, no need to rebuild..." % (prefix,) |
| 203 | return |
| 204 | |
Doug Zongker | 3c84f56 | 2014-07-31 11:06:30 -0700 | [diff] [blame] | 205 | image_props = build_image.ImagePropFromGlobalDict(OPTIONS.info_dict, |
| 206 | "cache") |
| 207 | # The build system has to explicitly request for cache.img. |
| 208 | if "fs_type" not in image_props: |
| 209 | return |
| 210 | |
| 211 | print "creating cache.img..." |
| 212 | |
| 213 | # The name of the directory it is making an image out of matters to |
| 214 | # mkyaffs2image. So we create a temp dir, and within it we create an |
| 215 | # empty dir named "cache", and build the image from that. |
| 216 | temp_dir = tempfile.mkdtemp() |
| 217 | user_dir = os.path.join(temp_dir, "cache") |
| 218 | os.mkdir(user_dir) |
| 219 | img = tempfile.NamedTemporaryFile() |
| 220 | |
| 221 | fstab = OPTIONS.info_dict["fstab"] |
| 222 | if fstab: |
Dan Albert | 8b72aef | 2015-03-23 19:13:21 -0700 | [diff] [blame] | 223 | image_props["fs_type"] = fstab["/cache"].fs_type |
Doug Zongker | 3c84f56 | 2014-07-31 11:06:30 -0700 | [diff] [blame] | 224 | succ = build_image.BuildImage(user_dir, image_props, img.name) |
| 225 | assert succ, "build cache.img image failed" |
| 226 | |
| 227 | common.CheckSize(img.name, "cache.img", OPTIONS.info_dict) |
Tao Bao | f3282b4 | 2015-04-01 11:21:55 -0700 | [diff] [blame] | 228 | common.ZipWrite(output_zip, img.name, prefix + "cache.img") |
Doug Zongker | 3c84f56 | 2014-07-31 11:06:30 -0700 | [diff] [blame] | 229 | img.close() |
| 230 | os.rmdir(user_dir) |
| 231 | os.rmdir(temp_dir) |
| 232 | |
| 233 | |
| 234 | def AddImagesToTargetFiles(filename): |
| 235 | OPTIONS.input_tmp, input_zip = common.UnzipTemp(filename) |
Doug Zongker | fc44a51 | 2014-08-26 13:10:25 -0700 | [diff] [blame] | 236 | |
Michael Runge | 2e0d8fc | 2014-11-13 21:41:08 -0800 | [diff] [blame] | 237 | if not OPTIONS.add_missing: |
| 238 | for n in input_zip.namelist(): |
| 239 | if n.startswith("IMAGES/"): |
| 240 | print "target_files appears to already contain images." |
| 241 | sys.exit(1) |
Doug Zongker | fc44a51 | 2014-08-26 13:10:25 -0700 | [diff] [blame] | 242 | |
Doug Zongker | 3c84f56 | 2014-07-31 11:06:30 -0700 | [diff] [blame] | 243 | try: |
Doug Zongker | fc44a51 | 2014-08-26 13:10:25 -0700 | [diff] [blame] | 244 | input_zip.getinfo("VENDOR/") |
| 245 | has_vendor = True |
| 246 | except KeyError: |
| 247 | has_vendor = False |
Doug Zongker | 3c84f56 | 2014-07-31 11:06:30 -0700 | [diff] [blame] | 248 | |
Doug Zongker | fc44a51 | 2014-08-26 13:10:25 -0700 | [diff] [blame] | 249 | OPTIONS.info_dict = common.LoadInfoDict(input_zip) |
| 250 | if "selinux_fc" in OPTIONS.info_dict: |
| 251 | OPTIONS.info_dict["selinux_fc"] = os.path.join( |
| 252 | OPTIONS.input_tmp, "BOOT", "RAMDISK", "file_contexts") |
Doug Zongker | 3c84f56 | 2014-07-31 11:06:30 -0700 | [diff] [blame] | 253 | |
Tao Bao | f3282b4 | 2015-04-01 11:21:55 -0700 | [diff] [blame] | 254 | common.ZipClose(input_zip) |
Doug Zongker | fc44a51 | 2014-08-26 13:10:25 -0700 | [diff] [blame] | 255 | output_zip = zipfile.ZipFile(filename, "a", |
| 256 | compression=zipfile.ZIP_DEFLATED) |
Doug Zongker | 3c84f56 | 2014-07-31 11:06:30 -0700 | [diff] [blame] | 257 | |
Doug Zongker | fc44a51 | 2014-08-26 13:10:25 -0700 | [diff] [blame] | 258 | def banner(s): |
| 259 | print "\n\n++++ " + s + " ++++\n\n" |
Doug Zongker | 3c84f56 | 2014-07-31 11:06:30 -0700 | [diff] [blame] | 260 | |
Doug Zongker | fc44a51 | 2014-08-26 13:10:25 -0700 | [diff] [blame] | 261 | banner("boot") |
Michael Runge | 2e0d8fc | 2014-11-13 21:41:08 -0800 | [diff] [blame] | 262 | prebuilt_path = os.path.join(OPTIONS.input_tmp, "IMAGES", "boot.img") |
| 263 | boot_image = None |
| 264 | if os.path.exists(prebuilt_path): |
| 265 | print "boot.img already exists in IMAGES/, no need to rebuild..." |
| 266 | if OPTIONS.rebuild_recovery: |
| 267 | boot_image = common.GetBootableImage( |
| 268 | "IMAGES/boot.img", "boot.img", OPTIONS.input_tmp, "BOOT") |
| 269 | else: |
| 270 | boot_image = common.GetBootableImage( |
| 271 | "IMAGES/boot.img", "boot.img", OPTIONS.input_tmp, "BOOT") |
| 272 | if boot_image: |
| 273 | boot_image.AddToZip(output_zip) |
Doug Zongker | 3c84f56 | 2014-07-31 11:06:30 -0700 | [diff] [blame] | 274 | |
Doug Zongker | fc44a51 | 2014-08-26 13:10:25 -0700 | [diff] [blame] | 275 | banner("recovery") |
Michael Runge | 2e0d8fc | 2014-11-13 21:41:08 -0800 | [diff] [blame] | 276 | recovery_image = None |
| 277 | prebuilt_path = os.path.join(OPTIONS.input_tmp, "IMAGES", "recovery.img") |
| 278 | if os.path.exists(prebuilt_path): |
| 279 | print "recovery.img already exists in IMAGES/, no need to rebuild..." |
| 280 | if OPTIONS.rebuild_recovery: |
| 281 | recovery_image = common.GetBootableImage( |
| 282 | "IMAGES/recovery.img", "recovery.img", OPTIONS.input_tmp, "RECOVERY") |
| 283 | else: |
| 284 | recovery_image = common.GetBootableImage( |
| 285 | "IMAGES/recovery.img", "recovery.img", OPTIONS.input_tmp, "RECOVERY") |
| 286 | if recovery_image: |
| 287 | recovery_image.AddToZip(output_zip) |
Doug Zongker | 3c84f56 | 2014-07-31 11:06:30 -0700 | [diff] [blame] | 288 | |
Doug Zongker | fc44a51 | 2014-08-26 13:10:25 -0700 | [diff] [blame] | 289 | banner("system") |
Michael Runge | 2e0d8fc | 2014-11-13 21:41:08 -0800 | [diff] [blame] | 290 | AddSystem(output_zip, recovery_img=recovery_image, boot_img=boot_image) |
Doug Zongker | fc44a51 | 2014-08-26 13:10:25 -0700 | [diff] [blame] | 291 | if has_vendor: |
| 292 | banner("vendor") |
| 293 | AddVendor(output_zip) |
| 294 | banner("userdata") |
| 295 | AddUserdata(output_zip) |
| 296 | banner("cache") |
| 297 | AddCache(output_zip) |
Doug Zongker | 3c84f56 | 2014-07-31 11:06:30 -0700 | [diff] [blame] | 298 | |
Tao Bao | f3282b4 | 2015-04-01 11:21:55 -0700 | [diff] [blame] | 299 | common.ZipClose(output_zip) |
Doug Zongker | 3c84f56 | 2014-07-31 11:06:30 -0700 | [diff] [blame] | 300 | |
Doug Zongker | 3c84f56 | 2014-07-31 11:06:30 -0700 | [diff] [blame] | 301 | def main(argv): |
Baligh Uddin | 59f4ff1 | 2015-09-16 21:20:30 -0700 | [diff] [blame^] | 302 | def option_handler(o, a): |
Michael Runge | 2e0d8fc | 2014-11-13 21:41:08 -0800 | [diff] [blame] | 303 | if o in ("-a", "--add_missing"): |
| 304 | OPTIONS.add_missing = True |
| 305 | elif o in ("-r", "--rebuild_recovery",): |
| 306 | OPTIONS.rebuild_recovery = True |
Baligh Uddin | 59f4ff1 | 2015-09-16 21:20:30 -0700 | [diff] [blame^] | 307 | elif o == "--replace_verity_private_key": |
| 308 | OPTIONS.replace_verity_private_key = (True, a) |
| 309 | elif o == "--replace_verity_public_key": |
| 310 | OPTIONS.replace_verity_public_key = (True, a) |
| 311 | elif o == "--verity_signer_path": |
| 312 | OPTIONS.verity_signer_path = a |
Michael Runge | 2e0d8fc | 2014-11-13 21:41:08 -0800 | [diff] [blame] | 313 | else: |
| 314 | return False |
| 315 | return True |
| 316 | |
Dan Albert | 8b72aef | 2015-03-23 19:13:21 -0700 | [diff] [blame] | 317 | args = common.ParseOptions( |
| 318 | argv, __doc__, extra_opts="ar", |
Baligh Uddin | 59f4ff1 | 2015-09-16 21:20:30 -0700 | [diff] [blame^] | 319 | extra_long_opts=["add_missing", "rebuild_recovery", |
| 320 | "replace_verity_public_key=", |
| 321 | "replace_verity_private_key=", |
| 322 | "verity_signer_path="], |
Dan Albert | 8b72aef | 2015-03-23 19:13:21 -0700 | [diff] [blame] | 323 | extra_option_handler=option_handler) |
Michael Runge | 2e0d8fc | 2014-11-13 21:41:08 -0800 | [diff] [blame] | 324 | |
Doug Zongker | 3c84f56 | 2014-07-31 11:06:30 -0700 | [diff] [blame] | 325 | |
| 326 | if len(args) != 1: |
| 327 | common.Usage(__doc__) |
| 328 | sys.exit(1) |
| 329 | |
| 330 | AddImagesToTargetFiles(args[0]) |
| 331 | print "done." |
| 332 | |
| 333 | if __name__ == '__main__': |
| 334 | try: |
| 335 | common.CloseInheritedPipes() |
| 336 | main(sys.argv[1:]) |
Dan Albert | 8b72aef | 2015-03-23 19:13:21 -0700 | [diff] [blame] | 337 | except common.ExternalError as e: |
Doug Zongker | 3c84f56 | 2014-07-31 11:06:30 -0700 | [diff] [blame] | 338 | print |
| 339 | print " ERROR: %s" % (e,) |
| 340 | print |
| 341 | sys.exit(1) |
Doug Zongker | fc44a51 | 2014-08-26 13:10:25 -0700 | [diff] [blame] | 342 | finally: |
| 343 | common.Cleanup() |