Esempio n. 1
0
 def __init__(self, product_device):
     self.__android_top = os.path.abspath(os.getcwd())
     self.__otp = "out/target/product"
     self.__android_out = pjoin(self.__android_top, self.__otp,
                                product_device)
     self.__armgcc = "prebuilts/gcc/linux-x86/arm/arm-eabi-4.6/bin/arm-eabi-"
     self.__cross_compile = pjoin(self.__android_top, self.__armgcc)
     self.__host_bin = "out/host/linux-x86/bin"
     self.__host_utils_dir = pjoin(self.__android_top, self.__host_bin)
     self.__build_target = get_config_file("bt")
     build_target = parse_kv_file(self.__build_target)
     self.envd = {
         "android_top": self.__android_top,
         "otp": self.__otp,
         "armgcc": self.__armgcc,
         "host_bin": self.__host_bin,
         "android_out": self.__android_out,
         "uboot_out": pjoin(self.__android_out, "obj", "UBOOT"),
         "kernel_out": pjoin(self.__android_out, "obj", "KERNEL"),
         "cross_compile": self.__cross_compile,
         "host_utils_dir": self.__host_utils_dir,
         "uboot_src": pjoin(self.__android_top, "u-boot"),
         "kernel_src": pjoin(self.__android_top, "kernel"),
         "env_setup": pjoin(self.__android_top, "build/envsetup.sh"),
         "gendroid": get_config_file("gendroid"),
         "kernel_config_file": build_target.get("KERNEL_CONFIG_FILE"),
         "kernel_target_image": build_target.get("KERNEL_TARGET_IMAGE"),
         "uboot_config": build_target.get("UBOOT_CONFIG_FILE"),
         "ota_script": "build/tools/releasetools/ota_from_target_files",
         "ota_key": "build/target/product/security/testkey"
     }
Esempio n. 2
0
def vendor_xxx(pabObj):
    """
    xxx is specific vendor name
    """
    vendor_suffix, passwd, vendor_tag = get_vendor_xxx_info()
    pab_package_prefix = pabObj.product_device[7:] + vendor_tag
    vendor_package_name = pab_package_prefix + \
        pabObj.time_stamp + "." + vendor_suffix

    # pack file list below under metadata
    vendor_file = get_config_file("vendor")
    pack_list = []
    with open(vendor_file) as f:
        pack_list = f.read().splitlines()

    # Found no file to pack? exit
    if pack_list == []:
        pabObj.goto_exit("check your %s" % vendor_file)

    # rar a -ep -hpxxx package file
    # xxx is passwd
    # exclude path from name
    pack_cmd = "/usr/bin/rar a -ep -hp%s" % passwd
    pack_cmd += " metadata/%s" % vendor_package_name
    for pimages in pack_list:
        pack_cmd += " metadata/%s" % pimages

    pabObj.run_command(pack_cmd)
    pabObj.print_success("===> metadata/" + vendor_package_name)
Esempio n. 3
0
def get_vendor_xxx_info():
    pabrc = get_config_file("pabrc")
    brc = parse_kv_file(pabrc)
    version_nb = brc.get('VERSION_NUMBER')
    android_version = brc.get('VENDOR_ANDROID_VERSION')
    platform_name = brc.get('VENDOR_PLATFORM_NAME')
    platform_id = brc.get('VENDOR_PLATFORM_ID')
    vendor_tag = brc.get('VENDOR_TAG')
    vendor_suffix = brc.get('VENDOR_SUFFIX')
    passwd = brc.get('VENDOR_PASSWD')
    vendor_tag = "_%s_%s_%s_V%s.%s_" % (vendor_tag, android_version,
                                        platform_name, platform_id, version_nb)
    return vendor_suffix, passwd, vendor_tag
Esempio n. 4
0
    def __init__(self):
        parser = argparse.ArgumentParser(
            formatter_class=argparse.RawDescriptionHelpFormatter,
            description=textwrap.dedent('''\
                     Python Android Builder
                     --------------------------------------------------
                     Build the whole android world if no argument given
                     --------------------------------------------------
                     '''))

        parser.add_argument("-j", "--jobs", help="running jobs", type=int)
        parser.add_argument("-a",
                            "--droid",
                            help="build android",
                            action="store_true")
        parser.add_argument("-p",
                            "--package",
                            help="build vendor package",
                            action="store_true")
        parser.add_argument("-k",
                            "--kernel",
                            help="build kernel",
                            action="store_true")
        parser.add_argument("--kmodule",
                            help="build kernel modules only",
                            action="store_true")
        parser.add_argument("-c",
                            "--menuconfig",
                            help="kernel config",
                            action="store_true")
        parser.add_argument("-u",
                            "--uboot",
                            help="build uboot",
                            action="store_true")
        parser.add_argument("-s",
                            "--system",
                            help="pack system image",
                            action="store_true")
        parser.add_argument("-O",
                            "--buildota",
                            help="build Android OTA package",
                            action="store_true")
        parser.add_argument("-t",
                            "--target_product",
                            help="target_product for android",
                            type=str)
        parser.add_argument("--diffota",
                            help="build android diff OTA package",
                            action="store_true")
        parser.add_argument("--source", help="OTA source package", type=str)
        parser.add_argument("--target", help="OTA target package", type=str)
        parser.add_argument("--module",
                            help="Alternative for make submodule",
                            type=str)
        parser.add_argument("-C",
                            "--clean",
                            help="Clean build images",
                            type=str,
                            choices=["android", "kernel", "uboot"])
        parser.add_argument("-v",
                            "--build_varient",
                            help="userdebug or user",
                            type=str,
                            choices=["userdebug", "user"])
        parser.add_argument("--pack",
                            help="pack images",
                            type=str,
                            choices=["boot"])

        # auto complete the argument with TAB
        argcomplete.autocomplete(parser)
        # 1. put the line below in ~/.bashrc
        #   eval "$(register-python-argcomplete pab)"
        # 2. install the complete function
        # activate-global-python-argcomplete [--user]

        # parse the args
        args = parser.parse_args()

        # run this tool on android top dir
        self.__buildconfig = get_config_file("pabrc")
        try:
            assert os.path.exists(self.__buildconfig)
        except AssertionError:
            print 'Error : Not on android source tree'
            os.sys.exit()

        prj_info = parse_kv_file(self.__buildconfig)

        self.__build_droid = True if args.droid else False
        self.__build_vendor_package = True if args.package else False
        self.__build_kernel = True if args.kernel else False
        self.__build_kmodule_only = True if args.kmodule else False
        self.__build_uboot = True if args.uboot else False
        self.__diff_ota = True if args.diffota else False

        self.__source = args.source if args.source else False
        self.__target = args.target if args.target else False

        # for submodule
        self.__module = args.module if args.module else False

        # clean what build?
        self.__clean_kernel = True if args.clean == "kernel" else False
        self.__clean_android = True if args.clean == "android" else False
        self.__clean_uboot = True if args.clean == "uboot" else False
        # pack x images
        self.__pack_boot = True if args.pack == "boot" else False

        self.__kernel_config = True if args.menuconfig else False
        self.__pack_system = True if args.system else False
        self.__build_ota = True if args.buildota else False

        self.__jobs_nr = args.jobs if args.jobs else 16

        # TARGET_PRODUCT = AAA_BBB
        # PRODUCT_DEVICE = AAA-BBB
        self.__target_product = args.target_product if args.target_product else prj_info[
            "TARGET_PRODUCT"]
        target_product_aaa = self.__target_product.split('_')[0]
        target_product_bbb = self.__target_product.split('_')[1]
        self.__product_device = target_product_aaa + '-' + target_product_bbb
        self.__build_varient = args.build_varient if args.build_varient else prj_info[
            "TARGET_BUILD_VARIANT"]
        self.argsd = {
            "build_kernel": self.__build_kernel,
            "build_kmodule": self.__build_kmodule_only,
            "build_uboot": self.__build_uboot,
            "build_droid": self.__build_droid,
            "build_vendor": self.__build_vendor_package,
            "clean_kernel": self.__clean_kernel,
            "clean_android": self.__clean_android,
            "clean_uboot": self.__clean_uboot,
            "pack_boot": self.__pack_boot,
            "kernel_config": self.__kernel_config,
            "pack_system": self.__pack_system,
            "build_ota": self.__build_ota,
            "diff_ota": self.__diff_ota,
            "source_package": self.__source,
            "target_package": self.__target,
            "submodule": self.__module,
            "target_product": self.__target_product,  # PRODUCT_NAME
            "product_device": self.__product_device,  # PRODUCT_DEVICE
            "build_varient": self.__build_varient,
            "jobs_nr": self.__jobs_nr
        }
Esempio n. 5
0
File: pab.py Progetto: 54shady/pab
    def pab_genk(self):
        """ build kernel """
        # copy necessary file or dir
        prev_copy_filename = get_config_file("prevcp")
        with open(prev_copy_filename) as f:
            cp_list = f.read().splitlines()
        nicecopy.copy_stuffs(self.kernel_src, self.kernel_out, cp_list)

        # all the target cmd
        make_cmds = []

        # config cmd
        make_config = self.pab_make_target(self.kernel_src, self.kernel_out,
                                           self.kernel_config_file)

        # not config file? make one
        if not os.path.exists(pjoin(self.kernel_out, ".config")):
            make_cmds.append(make_config)

        # kernel cmd
        make_kernel = self.pab_make_target(self.kernel_src, self.kernel_out,
                                           self.kernel_target_image)
        make_cmds.append(make_kernel)

        # dtb cmd
        dtb_file = get_config_file("dtbs")
        with open(dtb_file) as f:
            dtb_list = f.read().splitlines()

        # dtb file not empty
        if not dtb_list == []:
            for dtb in dtb_list:
                make_dtb = self.pab_make_target(self.kernel_src,
                                                self.kernel_out, dtb)
                make_cmds.append(make_dtb)

        # modules cmd
        self.append_modules_target(make_cmds)

        # start make things we need
        self.run_cmdlist(make_cmds)

        # dtb file not empty
        if not dtb_list == []:
            # pack resource image
            # multi dtb supported
            fdt_res_dir = pjoin(self.android_top, "fdt_res")
            if not os.path.exists(fdt_res_dir):
                os.mkdir(fdt_res_dir)

            # copy dtbs to fdt_res_dir
            dtbs_dir = pjoin(self.kernel_out, "arch/arm/boot/dts/")

            for i in range(len(dtb_list)):
                nicecopy.ncopy(dtbs_dir + dtb_list[i], fdt_res_dir)

            fdt_res = pjoin(self.android_top, "fdt_res")
            res_in = pjoin(self.kernel_out, "resource.img")
            res_out = pjoin(fdt_res, "resource_fdt.img")
            self.pab_packres(fdt_res, res_in, res_out)
            shutil.rmtree(fdt_res_dir)

        # Misc stuff
        post_copy_filename = get_config_file("postcp")
        with open(post_copy_filename) as f:
            misc_stuff = f.read().splitlines()
        nicecopy.copy_stuffs(self.kernel_out, self.kernel_src, misc_stuff)

        # final copy
        final_copy = ["kernel.img", "resource.img"]
        nicecopy.copy_stuffs(self.kernel_out, self.final_images, final_copy)