示例#1
0
def do(args):
    """
    Add a package to a toolchain
    - Check that there is a current toolchain
    - Add the package to the cache
    - Add the package from cache to toolchain
    """
    toolchain = qitoolchain.parsers.get_toolchain(args)
    package_path = args.package_path
    legacy = False
    try:
        if urlparse.urlparse(package_path).scheme:
            package_path = qisys.remote.download(package_path, ".")
        archive = zipfile.ZipFile(package_path, allowZip64=True)
        archive.read("package.xml")
    except KeyError:
        legacy = True
    if legacy and not args.name:
        raise Exception("Must specify --name when using legacy format")
    if args.name and not legacy:
        ui.warning("--name ignored when using modern format")
    package = None
    if legacy:
        package = qitoolchain.qipackage.QiPackage(args.name)
    else:
        package = qitoolchain.qipackage.from_archive(package_path)
    # extract it to the default packages path of the toolchain
    tc_name = toolchain.name
    tc_packages_path = qitoolchain.toolchain.get_default_packages_path(tc_name)
    dest = os.path.join(tc_packages_path, package.name)
    qisys.sh.rm(dest)
    qitoolchain.qipackage.extract(package_path, dest)
    package.path = dest
    # add the package to the toolchain
    toolchain.add_package(package)
示例#2
0
def do(args):
    """
    Add a package to a toolchain
    - Check that there is a current toolchain
    - Add the package to the cache
    - Add the package from cache to toolchain
    """
    toolchain = qitoolchain.parsers.get_toolchain(args)
    package_path = args.package_path
    legacy = False
    try:
        if urlparse.urlparse(package_path).scheme:
            package_path = qisys.remote.download(package_path, ".")
        archive = zipfile.ZipFile(package_path, allowZip64=True)
        archive.read("package.xml")
    except KeyError:
        legacy = True
    if legacy and not args.name:
        raise Exception("Must specify --name when using legacy format")
    if args.name and not legacy:
        ui.warning("--name ignored when using modern format")
    package = None
    if legacy:
        package = qitoolchain.qipackage.QiPackage(args.name)
    else:
        package = qitoolchain.qipackage.from_archive(package_path)
    # extract it to the default packages path of the toolchain
    tc_name = toolchain.name
    tc_packages_path = qitoolchain.toolchain.get_default_packages_path(tc_name)
    dest = os.path.join(tc_packages_path, package.name)
    qisys.sh.rm(dest)
    qitoolchain.qipackage.extract(package_path, dest)
    package.path = dest
    # add the package to the toolchain
    toolchain.add_package(package)
示例#3
0
def do(args):
    """ Add a package to a toolchain

    - Check that there is a current toolchain
    - Add the package to the cache
    - Add the package from cache to toolchain

    """
    toolchain = qitoolchain.parsers.get_toolchain(args)
    name = args.name
    package_path = args.package_path
    legacy = False
    try:
        archive = zipfile.ZipFile(package_path)
        archive.read("package.xml")
    except:
        legacy = True
    if legacy and not args.name:
        raise Exception("Must specify --name when using legacy format")

    package = None
    if legacy:
        package = qitoolchain.qipackage.QiPackage(args.name)
    else:
        package = qitoolchain.qipackage.from_archive(package_path)

    # extract it to the default packages path of the toolchain
    tc_name = toolchain.name
    tc_packages_path = qitoolchain.toolchain.get_default_packages_path(tc_name)
    dest = os.path.join(tc_packages_path, package.name)
    qisys.sh.rm(dest)
    qitoolchain.qipackage.extract(package_path, dest)
    package.path = dest

    # add the package to the toolchain
    toolchain.add_package(package)
示例#4
0
def do(args):
    """ Add a package to a toolchain

    - Check that there is a current toolchain
    - Add the package to the cache
    - Add the package from cache to toolchain

    """
    toolchain = qitoolchain.parsers.get_toolchain(args)
    name = args.name
    package_path = args.package_path
    legacy = False
    try:
        archive = zipfile.ZipFile(package_path)
        archive.read("package.xml")
    except:
        legacy = True
    if legacy and not args.name:
        raise Exception("Must specify --name when using legacy format")

    package = None
    if legacy:
        package = qitoolchain.qipackage.QiPackage(args.name)
    else:
        package = qitoolchain.qipackage.from_archive(package_path)

    # extract it to the default packages path of the toolchain
    tc_name = toolchain.name
    tc_packages_path = qitoolchain.toolchain.get_default_packages_path(tc_name)
    dest = os.path.join(tc_packages_path, package.name)
    qisys.sh.rm(dest)
    qitoolchain.qipackage.extract(package_path, dest)
    package.path = dest

    # add the package to the toolchain
    toolchain.add_package(package)