Пример #1
0
def main():
    parser = get_argparser()
    parser.add_argument("--abs-dir", dest="abs_dir", required=True)
    args = parser.parse_args()
    args.mirror_directory = "/mirror"

    dump_build_information(args)

    pkg_dir = os.path.basename(args.abs_dir)

    args.permanent_source_dir = os.path.join(args.sources_directory, pkg_dir)
    args.build_dir = os.path.join("/tmp", pkg_dir)

    sanity_checks(args)

    initialize_repositories(args)

    result = copy_and_build(args)
    if result:
        die(Status.failure)

    paths_to_packages = create_hybrid_packages(args)

    if not paths_to_packages:
        die(Status.failure, "No hybrid packages were created.")

    for path in paths_to_packages:
        add_package_to_toolchain_repo(path, args.toolchain_directory)

    die(Status.success)
Пример #2
0
def main():
    """Create empty local toolchain repository.

    Only one instance of this stage should be run, and it should run
    before any instances of the make_package stage run. We don't want to
    be creating the local repository several times concurrently.
    """
    parser = get_argparser()
    args = parser.parse_args()

    # We can't create an empty database. We need to add a fake package
    # to a new database, then remove it again.

    path = "/tmp/dummy_pack"
    pkg_name = "dummy-pack"

    os.makedirs(path, exist_ok=True)
    pkg_info = (textwrap.dedent("""\
          # Generated by makepkg 4.1.2
          # using fakeroot version 1.20
          # Mon 20 Oct 21 14:19:27 UTC 2013
          pkgname = %s
          pkgver = 1.0.0-0
          url = abc.xyz
          builddate 1382364167
          packager = bog
          size = 1000000
          arch = any
          """) % (pkg_name))

    log("info", "Writing fake package .PKGINFO:",
        pkg_info.splitlines())

    with open(os.path.join(path, ".PKGINFO"), "w") as f:
        print(pkg_info, file=f)

    log("info", "Building fake package")
    pkg = create_package(path, pkg_name, args)
    log("info", "Initializing toolchain repo")
    add_package_to_toolchain_repo(pkg, args.toolchain_directory,
                                  remove_name=pkg_name)
Пример #3
0
def main():
    """Create empty local toolchain repository.

    Only one instance of this stage should be run, and it should run
    before any instances of the make_package stage run. We don't want to
    be creating the local repository several times concurrently.
    """
    parser = get_argparser()
    args = parser.parse_args()

    # We can't create an empty database. We need to add a fake package
    # to a new database, then remove it again.

    path = "/tmp/dummy_pack"
    pkg_name = "dummy-pack"

    os.makedirs(path, exist_ok=True)
    pkg_info = (textwrap.dedent("""\
          # Generated by makepkg 4.1.2
          # using fakeroot version 1.20
          # Mon 20 Oct 21 14:19:27 UTC 2013
          pkgname = %s
          pkgver = 1.0.0-0
          url = abc.xyz
          builddate 1382364167
          packager = bog
          size = 1000000
          arch = any
          """) % (pkg_name))

    log("info", "Writing fake package .PKGINFO:", pkg_info.splitlines())

    with open(os.path.join(path, ".PKGINFO"), "w") as f:
        print(pkg_info, file=f)

    log("info", "Building fake package")
    pkg = create_package(path, pkg_name, args)
    log("info", "Initializing toolchain repo")
    add_package_to_toolchain_repo(pkg,
                                  args.toolchain_directory,
                                  remove_name=pkg_name)
Пример #4
0
def main():
    parser = get_argparser()
    parser.add_argument("--abs-dir", dest="abs_dir", required=True)
    parser.add_argument("--sysroot", default="sysroot")
    args = parser.parse_args()
    args.mirror_directory = "/mirror"

    os.nice(10)

    dump_build_information(args)

    pkg_dir = os.path.basename(args.abs_dir)

    if pkg_dir in os.listdir(args.sources_directory):
        args.permanent_source_dir = os.path.join(args.sources_directory,
                                                 pkg_dir)
    else:
        die(
            Status.failure, "No source directory in source volume: %s" %
            args.sources_directory)

    args.build_dir = os.path.join("/tmp", pkg_dir)

    set_local_repository_location(args.toolchain_directory,
                                  toolchain_repo_name())

    if not os.path.isdir("/sysroot"):
        os.makedirs("/sysroot")

    copied_files = []
    existing_files = []

    for d in os.listdir("/toolchain_root"):
        base = os.path.basename(d)
        src = os.path.join("/toolchain_root", d)
        dst = os.path.join("/sysroot", base)

        # This can happen if we built the toolchain for the first time
        # on this run. If we're using a pre-built toolchain, the file
        # won't exist.
        if os.path.lexists(dst):
            existing_files.append(dst)
            continue

        if os.path.isfile(src):
            copied_files.append((src, dst))
            shutil.copyfile(src, dst)
        elif os.path.isdir(src):
            copied_files.append((src, dst))
            shutil.copytree(src, dst)

    copied_files = ["%s  -->  %s" % (src, dst) for (src, dst) in copied_files]
    if copied_files:
        log("info",
            "Copied permanent toolchain into container-local sysroot",
            output=copied_files)
    if existing_files:
        log("info",
            "There were existing files in /sysroot, using those",
            output=existing_files)

    recursive_chown("/sysroot")

    result = copy_and_build(args)
    if result:
        die(Status.failure)

    paths_to_packages = create_hybrid_packages(args)

    if not paths_to_packages:
        die(Status.failure, "No hybrid packages were created.")

    for path in paths_to_packages:
        add_package_to_toolchain_repo(path, args.toolchain_directory)

    die(Status.success)