コード例 #1
0
def main():
    global LOG
    LOG = utils.getLogger("pack-tool")
    try:
        usage = "Usage: ./pack.py -t apk -m shared -a x86"
        opts_parser = OptionParser(usage=usage)
        opts_parser.add_option("-c",
                               "--cfg",
                               dest="pkgcfg",
                               help="specify the path of config json file")
        opts_parser.add_option(
            "-t",
            "--type",
            dest="pkgtype",
            help="specify the pkg type, e.g. apk, cordova ...")
        opts_parser.add_option(
            "-m",
            "--mode",
            dest="pkgmode",
            help=
            "specify the apk mode, not for embeddingapi, e.g. shared, embedded"
        )
        opts_parser.add_option(
            "-a",
            "--arch",
            dest="pkgarch",
            help=
            "specify the apk arch, not for embeddingapi, cordova version 3.6, e.g. x86, arm"
        )
        opts_parser.add_option(
            "-d",
            "--dest",
            dest="destdir",
            help="specify the installation folder for packed package")
        opts_parser.add_option(
            "-s",
            "--src",
            dest="srcdir",
            help="specify the path of pkg resource for packing")
        opts_parser.add_option("--tools",
                               dest="pkgpacktools",
                               help="specify the parent folder of pack tools")
        opts_parser.add_option(
            "--notclean",
            dest="bnotclean",
            action="store_true",
            help="disable the build root clean after the packing")
        opts_parser.add_option("-v",
                               "--version",
                               dest="bversion",
                               action="store_true",
                               help="show this tool's version")
        opts_parser.add_option("-u",
                               "--user",
                               dest="user",
                               help="specify the user in inst.py")
        opts_parser.add_option(
            "--sub-version",
            dest="subversion",
            help=
            "specify the embeddingapi, cordova sub version, e.g. v1, v2, v3 ..."
        )
        opts_parser.add_option("--pkg-version",
                               dest="pkgversion",
                               help="specify the pkg version, e.g. 0.0.0.1")
        opts_parser.add_option(
            "--pack-type",
            dest="packtype",
            help="specify the pack type, e.g. gradle, maven")
        opts_parser.add_option("--notdebug",
                               dest="bnotdebug",
                               action="store_true",
                               help="specify the packed pkg is not debug mode")

        if len(sys.argv) == 1:
            sys.argv.append("-h")

        global BUILD_PARAMETERS
        (BUILD_PARAMETERS, args) = opts_parser.parse_args()
    except Exception as e:
        LOG.error("Got wrong options: %s, exit ..." % e)
        sys.exit(1)

    if BUILD_PARAMETERS.bversion:
        print "Version: %s" % TOOL_VERSION
        sys.exit(0)

    if not BUILD_PARAMETERS.srcdir:
        BUILD_PARAMETERS.srcdir = os.getcwd()
    BUILD_PARAMETERS.srcdir = os.path.expanduser(BUILD_PARAMETERS.srcdir)

    if not BUILD_PARAMETERS.user:
        BUILD_PARAMETERS.user = "******"

    if not os.path.exists(
            os.path.join(BUILD_PARAMETERS.srcdir, "..", "..", VERSION_FILE)):
        if not os.path.exists(
                os.path.join(BUILD_PARAMETERS.srcdir, "..", VERSION_FILE)):
            if not os.path.exists(
                    os.path.join(BUILD_PARAMETERS.srcdir, VERSION_FILE)):
                LOG.info(
                    "Not found pkg version file, try to use option --pkg-version"
                )
                pkg_version_file_path = None
            else:
                pkg_version_file_path = os.path.join(BUILD_PARAMETERS.srcdir,
                                                     VERSION_FILE)
        else:
            pkg_version_file_path = os.path.join(BUILD_PARAMETERS.srcdir, "..",
                                                 VERSION_FILE)
    else:
        pkg_version_file_path = os.path.join(BUILD_PARAMETERS.srcdir, "..",
                                             "..", VERSION_FILE)

    try:
        pkg_main_version = 0
        pkg_release_version = 1
        if BUILD_PARAMETERS.pkgversion:
            LOG.info("Using %s as pkg version " % BUILD_PARAMETERS.pkgversion)
            pkg_main_version = BUILD_PARAMETERS.pkgversion
            CROSSWALK_BRANCH = "master"
        else:
            if pkg_version_file_path is not None:
                LOG.info("Using pkg version file: %s" % pkg_version_file_path)
                with open(pkg_version_file_path, "rt") as pkg_version_file:
                    pkg_version_raw = pkg_version_file.read()
                    pkg_version_file.close()
                    pkg_version_json = json.loads(pkg_version_raw)
                    pkg_main_version = pkg_version_json["main-version"]
                    pkg_release_version = pkg_version_json["release-version"]
                    CROSSWALK_BRANCH = pkg_version_json["crosswalk-branch"]
    except Exception as e:
        LOG.error("Fail to read pkg version file: %s, exit ..." % e)
        sys.exit(1)
    CROSSWALK_VERSION = pkg_main_version

    if not BUILD_PARAMETERS.pkgtype:
        LOG.error("No pkg type provided, exit ...")
        sys.exit(1)
    elif not BUILD_PARAMETERS.pkgtype in PKG_TYPES:
        LOG.error("Wrong pkg type, only support: %s, exit ..." % PKG_TYPES)
        sys.exit(1)

    if BUILD_PARAMETERS.pkgtype == "apk" or \
       BUILD_PARAMETERS.pkgtype == "apk-aio":
        if not BUILD_PARAMETERS.pkgmode:
            LOG.error("No pkg mode option provided, exit ...")
            sys.exit(1)
        elif not BUILD_PARAMETERS.pkgmode in PKG_MODES:
            LOG.error(
                "Wrong pkg mode option provided, only support:%s, exit ..." %
                PKG_MODES)
            sys.exit(1)

        if not BUILD_PARAMETERS.pkgarch:
            LOG.error("No pkg arch option provided, exit ...")
            sys.exit(1)
        elif not BUILD_PARAMETERS.pkgarch in PKG_ARCHS:
            LOG.error(
                "Wrong pkg arch option provided, only support:%s, exit ..." %
                PKG_ARCHS)
            sys.exit(1)

    if BUILD_PARAMETERS.pkgtype == "apk-aio" or \
       BUILD_PARAMETERS.pkgtype == "cordova-aio":
        if not BUILD_PARAMETERS.destdir or not os.path.exists(
                BUILD_PARAMETERS.destdir):
            LOG.error("No all-in-one installation dest dir found, exit ...")
            sys.exit(1)

    elif not BUILD_PARAMETERS.destdir:
        BUILD_PARAMETERS.destdir = BUILD_PARAMETERS.srcdir
    BUILD_PARAMETERS.destdir = os.path.expanduser(BUILD_PARAMETERS.destdir)

    if not BUILD_PARAMETERS.pkgpacktools:
        BUILD_PARAMETERS.pkgpacktools = os.path.join(BUILD_PARAMETERS.srcdir,
                                                     "..", "..", "tools")
    BUILD_PARAMETERS.pkgpacktools = os.path.expanduser(
        BUILD_PARAMETERS.pkgpacktools)

    config_json = None
    if BUILD_PARAMETERS.pkgcfg:
        config_json_file_path = BUILD_PARAMETERS.pkgcfg
    else:
        config_json_file_path = os.path.join(BUILD_PARAMETERS.srcdir,
                                             "suite.json")
    try:
        LOG.info("Using config json file: %s" % config_json_file_path)
        with open(config_json_file_path, "rt") as config_json_file:
            config_raw = config_json_file.read()
            config_json_file.close()
            config_json = json.loads(config_raw)
    except Exception as e:
        LOG.error("Fail to read config json file: %s, exit ..." % e)
        sys.exit(1)

    global PKG_NAME
    PKG_NAME = utils.safelyGetValue(config_json, "pkg-name")
    if not PKG_NAME:
        PKG_NAME = os.path.basename(BUILD_PARAMETERS.srcdir)
        LOG.warning("Fail to read pkg name from json, "
                    "using src dir name as pkg name ...")

    LOG.info("================= %s (%s-%s) ================" %
             (PKG_NAME, pkg_main_version, pkg_release_version))

    if not utils.safelyGetValue(config_json, "pkg-list"):
        LOG.error("Fail to read pkg-list, exit ...")
        sys.exit(1)

    pkg_json = None
    global parameters_type
    parameters_type = None
    cordova_subv_list = ['4.x', '3.6']

    if BUILD_PARAMETERS.pkgtype == "cordova" or BUILD_PARAMETERS.pkgtype == "cordova-aio":

        if BUILD_PARAMETERS.pkgarch and not BUILD_PARAMETERS.pkgarch in PKG_ARCHS:
            LOG.error("Wrong pkg-arch, only support: %s, exit ..." % PKG_ARCHS)
            sys.exit(1)

        if BUILD_PARAMETERS.pkgmode and not BUILD_PARAMETERS.pkgmode in PKG_MODES:
            LOG.error("Wrong pkg-mode, only support: %s, exit ..." % PKG_MODES)
            sys.exit(1)

        if BUILD_PARAMETERS.subversion:
            if not str(BUILD_PARAMETERS.subversion) in cordova_subv_list:
                LOG.error(
                    "The argument of cordova --sub-version can only be '3.6' or '4.x' , exit ..."
                )
                sys.exit(1)
            parameters_type = BUILD_PARAMETERS.pkgtype + \
                BUILD_PARAMETERS.subversion

        if (BUILD_PARAMETERS.subversion == '4.x' and BUILD_PARAMETERS.packtype
            ) and not BUILD_PARAMETERS.packtype in CORDOVA_PACK_TYPES:
            LOG.error("cordova packtype can only be npm, local")
            sys.exit(1)

        if (BUILD_PARAMETERS.subversion == '3.6' or
                not BUILD_PARAMETERS.subversion) and BUILD_PARAMETERS.packtype:
            LOG.error("cordova packtype is only for cordova version 4.x")
            sys.exit(1)

        if (BUILD_PARAMETERS.subversion == '3.6' or
                not BUILD_PARAMETERS.subversion) and BUILD_PARAMETERS.pkgarch:
            LOG.error("Command -a is not for cordova version 3.6")
            sys.exit(1)

    if BUILD_PARAMETERS.pkgtype == "embeddingapi":
        if BUILD_PARAMETERS.packtype and not BUILD_PARAMETERS.packtype in PACK_TYPES:
            LOG.error("embeddingapi packtype can only be gradle, maven or ant")
            sys.exit(1)
        if BUILD_PARAMETERS.subversion:
            BUILD_PARAMETERS.pkgtype = BUILD_PARAMETERS.pkgtype + \
                BUILD_PARAMETERS.subversion

    all_pkg_string = "".join(config_json["pkg-list"].keys())
    if parameters_type and parameters_type in all_pkg_string:
        for i_pkg in config_json["pkg-list"].keys():
            i_pkg_list = i_pkg.replace(" ", "").split(",")
            if parameters_type in i_pkg_list:
                pkg_json = config_json["pkg-list"][i_pkg]
                break
    elif BUILD_PARAMETERS.pkgtype in all_pkg_string:
        for i_pkg in config_json["pkg-list"].keys():
            i_pkg_list = i_pkg.replace(" ", "").split(",")
            if BUILD_PARAMETERS.pkgtype in i_pkg_list:
                pkg_json = config_json["pkg-list"][i_pkg]
                break

    if pkg_json == config_json['pkg-list'].get(
            'apk') and BUILD_PARAMETERS.subversion is not None:
        pkg_json = config_json["pkg-list"][BUILD_PARAMETERS.subversion]

    if not pkg_json:
        LOG.error("Fail to read pkg json, exit ...")
        sys.exit(1)

    if not prepareBuildRoot():
        exitHandler(1)

    if "pkg-blacklist" in config_json:
        PKG_BLACK_LIST.extend(config_json["pkg-blacklist"])

    try:
        varshop.setValue("BUILD_PARAMETERS", BUILD_PARAMETERS)
        varshop.setValue("BUILD_ROOT", BUILD_ROOT)
        varshop.setValue("BUILD_ROOT_SRC", BUILD_ROOT_SRC)
        varshop.setValue("BUILD_TIME", BUILD_TIME)
        varshop.setValue("CROSSWALK_BRANCH", CROSSWALK_BRANCH)
        varshop.setValue("CROSSWALK_VERSION", CROSSWALK_VERSION)
        varshop.setValue("DEFAULT_CMD_TIMEOUT", DEFAULT_CMD_TIMEOUT)
        varshop.setValue("PKG_MODES", PKG_MODES)
        varshop.setValue("PKG_ARCHS", PKG_ARCHS)
    except Exception as e:
        LOG.error("Fail to set global vars: %s, exit ..." % e)
        sys.exit(1)

    if not buildPKG(pkg_json):
        exitHandler(1)

    LOG.info("+Building package ...")
    if BUILD_PARAMETERS.pkgtype == "apk-aio" or \
       BUILD_PARAMETERS.pkgtype == "cordova-aio":
        pkg_file_list = os.listdir(os.path.join(BUILD_ROOT, "pkg"))
        for i_file in pkg_file_list:
            if not utils.doCopy(os.path.join(BUILD_ROOT, "pkg", i_file),
                                os.path.join(BUILD_PARAMETERS.destdir,
                                             i_file)):
                exitHandler(1)
    elif BUILD_PARAMETERS.pkgtype == "embeddingapi" and BUILD_PARAMETERS.subversion:
        pkg_file = os.path.join(
            BUILD_PARAMETERS.destdir, "%s-%s-%s-%s.%s.zip" %
            (PKG_NAME, pkg_main_version, pkg_release_version,
             BUILD_PARAMETERS.subversion, BUILD_PARAMETERS.pkgtype))

        LOG.info("pkg_file: %s" % pkg_file)
        if not utils.zipDir(os.path.join(BUILD_ROOT, "pkg"), pkg_file):
            exitHandler(1)
    elif BUILD_PARAMETERS.pkgtype.startswith(
            "embeddingapi") and BUILD_PARAMETERS.packtype:
        pkg_file = os.path.join(
            BUILD_PARAMETERS.destdir, "%s-%s-%s.%s-%s.zip" %
            (PKG_NAME, pkg_main_version, pkg_release_version,
             BUILD_PARAMETERS.pkgtype, BUILD_PARAMETERS.packtype))

        if not utils.zipDir(os.path.join(BUILD_ROOT, "pkg"), pkg_file):
            exitHandler(1)
    else:
        pkg_file = os.path.join(
            BUILD_PARAMETERS.destdir, "%s-%s-%s.%s.zip" %
            (PKG_NAME, pkg_main_version, pkg_release_version,
             BUILD_PARAMETERS.pkgtype))

        if not utils.zipDir(os.path.join(BUILD_ROOT, "pkg"), pkg_file):
            exitHandler(1)
コード例 #2
0
ファイル: pack.py プロジェクト: astojilj/crosswalk-test-suite
def main():
    global LOG
    LOG = utils.getLogger("pack-tool")
    try:
        usage = "Usage: ./pack.py -t apk -m shared -a x86"
        opts_parser = OptionParser(usage=usage)
        opts_parser.add_option("-c", "--cfg", dest="pkgcfg", help="specify the path of config json file")
        opts_parser.add_option("-t", "--type", dest="pkgtype", help="specify the pkg type, e.g. apk, xpk, wgt ...")
        opts_parser.add_option(
            "-m", "--mode", dest="pkgmode", help="specify the apk mode, not for embeddingapi, e.g. shared, embedded"
        )
        opts_parser.add_option(
            "-a",
            "--arch",
            dest="pkgarch",
            help="specify the apk arch, not for embeddingapi, cordova version 3.6, e.g. x86, arm",
        )
        opts_parser.add_option(
            "-d", "--dest", dest="destdir", help="specify the installation folder for packed package"
        )
        opts_parser.add_option("-s", "--src", dest="srcdir", help="specify the path of pkg resource for packing")
        opts_parser.add_option("--tools", dest="pkgpacktools", help="specify the parent folder of pack tools")
        opts_parser.add_option(
            "--notclean", dest="bnotclean", action="store_true", help="disable the build root clean after the packing"
        )
        opts_parser.add_option(
            "--sign", dest="signature", action="store_true", help="signature operation will be done when packing wgt"
        )
        opts_parser.add_option("-v", "--version", dest="bversion", action="store_true", help="show this tool's version")
        opts_parser.add_option("-u", "--user", dest="user", help="specify the user in inst.py")
        opts_parser.add_option(
            "--sub-version",
            dest="subversion",
            help="specify the embeddingapi, cordova sub version, e.g. v1, v2, v3 ...",
        )
        opts_parser.add_option("--pkg-version", dest="pkgversion", help="specify the pkg version, e.g. 0.0.0.1")
        opts_parser.add_option("--pack-type", dest="packtype", help="specify the pack type, e.g. gradle, maven")
        opts_parser.add_option(
            "--notdebug", dest="bnotdebug", action="store_true", help="specify the packed pkg is not debug mode"
        )

        if len(sys.argv) == 1:
            sys.argv.append("-h")

        global BUILD_PARAMETERS
        (BUILD_PARAMETERS, args) = opts_parser.parse_args()
    except Exception as e:
        LOG.error("Got wrong options: %s, exit ..." % e)
        sys.exit(1)

    if BUILD_PARAMETERS.bversion:
        print "Version: %s" % TOOL_VERSION
        sys.exit(0)

    if not BUILD_PARAMETERS.srcdir:
        BUILD_PARAMETERS.srcdir = os.getcwd()
    BUILD_PARAMETERS.srcdir = os.path.expanduser(BUILD_PARAMETERS.srcdir)

    if not BUILD_PARAMETERS.user:
        BUILD_PARAMETERS.user = "******"

    if not os.path.exists(os.path.join(BUILD_PARAMETERS.srcdir, "..", "..", VERSION_FILE)):
        if not os.path.exists(os.path.join(BUILD_PARAMETERS.srcdir, "..", VERSION_FILE)):
            if not os.path.exists(os.path.join(BUILD_PARAMETERS.srcdir, VERSION_FILE)):
                LOG.info("Not found pkg version file, try to use option --pkg-version")
                pkg_version_file_path = None
            else:
                pkg_version_file_path = os.path.join(BUILD_PARAMETERS.srcdir, VERSION_FILE)
        else:
            pkg_version_file_path = os.path.join(BUILD_PARAMETERS.srcdir, "..", VERSION_FILE)
    else:
        pkg_version_file_path = os.path.join(BUILD_PARAMETERS.srcdir, "..", "..", VERSION_FILE)

    try:
        pkg_main_version = 0
        pkg_release_version = 1
        if BUILD_PARAMETERS.pkgversion:
            LOG.info("Using %s as pkg version " % BUILD_PARAMETERS.pkgversion)
            pkg_main_version = BUILD_PARAMETERS.pkgversion
        else:
            if pkg_version_file_path is not None:
                LOG.info("Using pkg version file: %s" % pkg_version_file_path)
                with open(pkg_version_file_path, "rt") as pkg_version_file:
                    pkg_version_raw = pkg_version_file.read()
                    pkg_version_file.close()
                    pkg_version_json = json.loads(pkg_version_raw)
                    pkg_main_version = pkg_version_json["main-version"]
                    pkg_release_version = pkg_version_json["release-version"]
                    CROSSWALK_BRANCH = pkg_version_json["crosswalk-branch"]
    except Exception as e:
        LOG.error("Fail to read pkg version file: %s, exit ..." % e)
        sys.exit(1)
    CROSSWALK_VERSION = pkg_main_version

    if not BUILD_PARAMETERS.pkgtype:
        LOG.error("No pkg type provided, exit ...")
        sys.exit(1)
    elif not BUILD_PARAMETERS.pkgtype in PKG_TYPES:
        LOG.error("Wrong pkg type, only support: %s, exit ..." % PKG_TYPES)
        sys.exit(1)

    if BUILD_PARAMETERS.pkgtype == "apk" or BUILD_PARAMETERS.pkgtype == "apk-aio":
        if not BUILD_PARAMETERS.pkgmode:
            LOG.error("No pkg mode option provided, exit ...")
            sys.exit(1)
        elif not BUILD_PARAMETERS.pkgmode in PKG_MODES:
            LOG.error("Wrong pkg mode option provided, only support:%s, exit ..." % PKG_MODES)
            sys.exit(1)

        if not BUILD_PARAMETERS.pkgarch:
            LOG.error("No pkg arch option provided, exit ...")
            sys.exit(1)
        elif not BUILD_PARAMETERS.pkgarch in PKG_ARCHS:
            LOG.error("Wrong pkg arch option provided, only support:%s, exit ..." % PKG_ARCHS)
            sys.exit(1)

    if BUILD_PARAMETERS.pkgtype == "apk-aio" or BUILD_PARAMETERS.pkgtype == "cordova-aio":
        if not BUILD_PARAMETERS.destdir or not os.path.exists(BUILD_PARAMETERS.destdir):
            LOG.error("No all-in-one installation dest dir found, exit ...")
            sys.exit(1)

    elif not BUILD_PARAMETERS.destdir:
        BUILD_PARAMETERS.destdir = BUILD_PARAMETERS.srcdir
    BUILD_PARAMETERS.destdir = os.path.expanduser(BUILD_PARAMETERS.destdir)

    if not BUILD_PARAMETERS.pkgpacktools:
        BUILD_PARAMETERS.pkgpacktools = os.path.join(BUILD_PARAMETERS.srcdir, "..", "..", "tools")
    BUILD_PARAMETERS.pkgpacktools = os.path.expanduser(BUILD_PARAMETERS.pkgpacktools)

    config_json = None
    if BUILD_PARAMETERS.pkgcfg:
        config_json_file_path = BUILD_PARAMETERS.pkgcfg
    else:
        config_json_file_path = os.path.join(BUILD_PARAMETERS.srcdir, "suite.json")
    try:
        LOG.info("Using config json file: %s" % config_json_file_path)
        with open(config_json_file_path, "rt") as config_json_file:
            config_raw = config_json_file.read()
            config_json_file.close()
            config_json = json.loads(config_raw)
    except Exception as e:
        LOG.error("Fail to read config json file: %s, exit ..." % e)
        sys.exit(1)

    global PKG_NAME
    PKG_NAME = utils.safelyGetValue(config_json, "pkg-name")
    if not PKG_NAME:
        PKG_NAME = os.path.basename(BUILD_PARAMETERS.srcdir)
        LOG.warning("Fail to read pkg name from json, " "using src dir name as pkg name ...")

    LOG.info("================= %s (%s-%s) ================" % (PKG_NAME, pkg_main_version, pkg_release_version))

    if not utils.safelyGetValue(config_json, "pkg-list"):
        LOG.error("Fail to read pkg-list, exit ...")
        sys.exit(1)

    pkg_json = None
    global parameters_type
    parameters_type = None
    cordova_subv_list = ["4.x", "3.6"]

    if BUILD_PARAMETERS.pkgtype == "cordova" or BUILD_PARAMETERS.pkgtype == "cordova-aio":

        if BUILD_PARAMETERS.pkgarch and not BUILD_PARAMETERS.pkgarch in PKG_ARCHS:
            LOG.error("Wrong pkg-arch, only support: %s, exit ..." % PKG_ARCHS)
            sys.exit(1)

        if BUILD_PARAMETERS.pkgmode and not BUILD_PARAMETERS.pkgmode in PKG_MODES:
            LOG.error("Wrong pkg-mode, only support: %s, exit ..." % PKG_MODES)
            sys.exit(1)

        if BUILD_PARAMETERS.subversion:
            if not str(BUILD_PARAMETERS.subversion) in cordova_subv_list:
                LOG.error("The argument of cordova --sub-version can only be '3.6' or '4.x' , exit ...")
                sys.exit(1)
            parameters_type = BUILD_PARAMETERS.pkgtype + BUILD_PARAMETERS.subversion

        if (
            BUILD_PARAMETERS.subversion == "4.x" and BUILD_PARAMETERS.packtype
        ) and not BUILD_PARAMETERS.packtype in CORDOVA_PACK_TYPES:
            LOG.error("cordova packtype can only be npm, local")
            sys.exit(1)

        if (BUILD_PARAMETERS.subversion == "3.6" or not BUILD_PARAMETERS.subversion) and BUILD_PARAMETERS.packtype:
            LOG.error("cordova packtype is only for cordova version 4.x")
            sys.exit(1)

        if (BUILD_PARAMETERS.subversion == "3.6" or not BUILD_PARAMETERS.subversion) and BUILD_PARAMETERS.pkgarch:
            LOG.error("Command -a is not for cordova version 3.6")
            sys.exit(1)

    if BUILD_PARAMETERS.pkgtype == "embeddingapi":
        if BUILD_PARAMETERS.packtype and not BUILD_PARAMETERS.packtype in PACK_TYPES:
            LOG.error("embeddingapi packtype can only be gradle, maven or ant")
            sys.exit(1)
        if BUILD_PARAMETERS.subversion:
            BUILD_PARAMETERS.pkgtype = BUILD_PARAMETERS.pkgtype + BUILD_PARAMETERS.subversion

    all_pkg_string = "".join(config_json["pkg-list"].keys())
    if parameters_type and parameters_type in all_pkg_string:
        for i_pkg in config_json["pkg-list"].keys():
            i_pkg_list = i_pkg.replace(" ", "").split(",")
            if parameters_type in i_pkg_list:
                pkg_json = config_json["pkg-list"][i_pkg]
                break
    elif BUILD_PARAMETERS.pkgtype in all_pkg_string:
        for i_pkg in config_json["pkg-list"].keys():
            i_pkg_list = i_pkg.replace(" ", "").split(",")
            if BUILD_PARAMETERS.pkgtype in i_pkg_list:
                pkg_json = config_json["pkg-list"][i_pkg]
                break

    if pkg_json == config_json["pkg-list"].get("apk") and BUILD_PARAMETERS.subversion is not None:
        pkg_json = config_json["pkg-list"][BUILD_PARAMETERS.subversion]

    if not pkg_json:
        LOG.error("Fail to read pkg json, exit ...")
        sys.exit(1)

    if not prepareBuildRoot():
        exitHandler(1)

    if "pkg-blacklist" in config_json:
        PKG_BLACK_LIST.extend(config_json["pkg-blacklist"])

    try:
        varshop.setValue("BUILD_PARAMETERS", BUILD_PARAMETERS)
        varshop.setValue("BUILD_ROOT", BUILD_ROOT)
        varshop.setValue("BUILD_ROOT_SRC", BUILD_ROOT_SRC)
        varshop.setValue("BUILD_TIME", BUILD_TIME)
        varshop.setValue("CROSSWALK_BRANCH", CROSSWALK_BRANCH)
        varshop.setValue("CROSSWALK_VERSION", CROSSWALK_VERSION)
        varshop.setValue("DEFAULT_CMD_TIMEOUT", DEFAULT_CMD_TIMEOUT)
        varshop.setValue("PKG_MODES", PKG_MODES)
        varshop.setValue("PKG_ARCHS", PKG_ARCHS)
    except Exception as e:
        LOG.error("Fail to set global vars: %s, exit ..." % e)
        sys.exit(1)

    if not buildPKG(pkg_json):
        exitHandler(1)

    LOG.info("+Building package ...")
    if BUILD_PARAMETERS.pkgtype == "apk-aio" or BUILD_PARAMETERS.pkgtype == "cordova-aio":
        pkg_file_list = os.listdir(os.path.join(BUILD_ROOT, "pkg"))
        for i_file in pkg_file_list:
            if not utils.doCopy(
                os.path.join(BUILD_ROOT, "pkg", i_file), os.path.join(BUILD_PARAMETERS.destdir, i_file)
            ):
                exitHandler(1)
    elif BUILD_PARAMETERS.pkgtype == "embeddingapi" and BUILD_PARAMETERS.subversion:
        pkg_file = os.path.join(
            BUILD_PARAMETERS.destdir,
            "%s-%s-%s-%s.%s.zip"
            % (PKG_NAME, pkg_main_version, pkg_release_version, BUILD_PARAMETERS.subversion, BUILD_PARAMETERS.pkgtype),
        )

        LOG.info("pkg_file: %s" % pkg_file)
        if not utils.zipDir(os.path.join(BUILD_ROOT, "pkg"), pkg_file):
            exitHandler(1)
    elif BUILD_PARAMETERS.pkgtype.startswith("embeddingapi") and BUILD_PARAMETERS.packtype:
        pkg_file = os.path.join(
            BUILD_PARAMETERS.destdir,
            "%s-%s-%s.%s-%s.zip"
            % (PKG_NAME, pkg_main_version, pkg_release_version, BUILD_PARAMETERS.pkgtype, BUILD_PARAMETERS.packtype),
        )

        if not utils.zipDir(os.path.join(BUILD_ROOT, "pkg"), pkg_file):
            exitHandler(1)
    else:
        pkg_file = os.path.join(
            BUILD_PARAMETERS.destdir,
            "%s-%s-%s.%s.zip" % (PKG_NAME, pkg_main_version, pkg_release_version, BUILD_PARAMETERS.pkgtype),
        )

        if not utils.zipDir(os.path.join(BUILD_ROOT, "pkg"), pkg_file):
            exitHandler(1)