㈡ 下面我们分析ota_from_target_files这个python脚本是怎样生成最终zip包的。先讲这个脚本的代码贴出来如下:
import sys if sys.hexversion < 0x02040000: PRint >> sys.stderr, "Python 2.4 or newer is required." sys.exit(1) import copy import errno import os import re import sha import subprocess import tempfile import time import zipfile import common import edify_generator OPTIONS = common.OPTIONS OPTIONS.package_key = "build/target/product/security/testkey" OPTIONS.incremental_source = None OPTIONS.require_verbatim = set() OPTIONS.prohibit_verbatim = set(("system/build.prop",)) OPTIONS.patch_threshold = 0.95 OPTIONS.wipe_user_data = False OPTIONS.omit_prereq = False OPTIONS.extra_script = None OPTIONS.worker_threads = 3 def MostPopularKey(d, default): """Given a dict, return the key corresponding to the largest value. Returns 'default' if the dict is empty.""" x = [(v, k) for (k, v) in d.iteritems()] if not x: return default x.sort() return x[-1][1] def IsSymlink(info): """Return true if the zipfile.ZipInfo object passed in represents a symlink.""" return (info.external_attr >> 16) == 0120777 class Item: """Items represent the metadata (user, group, mode) of files and directories in the system image.""" ITEMS = {} def __init__(self, name, dir=False): self.name = name self.uid = None