Exemple #1
0
    "--list-projects",
    help="List all valid projects in 'projects_manifest.yaml' and exit.",
    action='store_true')
parser.add_argument(
    "--clone-only",
    help="Clone the specified projects but don't attempt a build.",
    action='store_true')
parser.add_argument(
    "--web-target",
    help="For supported projects, the jellyfin-web branch/tag to use.",
    default=['master'],
    nargs=1)
args = parser.parse_args()

# Parse out the manifest sections
cfg = manifest.load_manifest('{}/projects_manifest.yaml'.format(cwd))
jellyfin_projects = cfg['jellyfin-manifest']

full_projects_list = list()
full_types_list = list()
for project in jellyfin_projects:
    full_projects_list.append(project['name'])
    full_types_list.append(project['type'])

if args.list_projects:
    print("Project types:")
    print(" > " + " \n > ".join(set(full_types_list)))
    print("All projects:")
    print("   {name: <40} {ptype: <10}".format(name='Name', ptype='Type'))
    for project in jellyfin_projects:
        print(" > {name: <40} {ptype: <10}".format(name=project['name'],
Exemple #2
0
def load_manifest():
  global LOADED_MANIFEST
  if not LOADED_MANIFEST:
    LOADED_MANIFEST = manifest.load_manifest("manifest.json")
  return LOADED_MANIFEST
def build_plugin(project):
    # Schema:
    # build_type: dotnet|docker|script
    # dotnet_runtime: the runtime for dotnet builds
    # dotnet_configuration: the configuration for dotnet builds
    # dotnet_framework: the framework for dotnet builds
    # docker_file: the Dockerfile for docker builds
    # script_path: the path for script builds

    # Extract our name and type
    project_name = project['name']
    project_type = project['type']
    # Set out the directories
    type_dir = "{}/projects/{}".format(cwd, project_type)
    project_dir = "{}/projects/{}/{}".format(cwd, project_type, project_name)
    # Check if a build configuration exists and load it
    manifest_file = '{}/build.yaml'.format(project_dir)
    if not os.path.exists(manifest_file):
        print("ERROR: Project {} does not contain a valid 'build.yaml' file.".
              format(project['name']))
        return False
    build_cfg = manifest.load_manifest(manifest_file)

    project_version = build_cfg['version']

    # move into the project directory
    revdir = os.getcwd()
    os.chdir(project_dir)

    if build_cfg['build_type'] == 'dotnet':
        build_command = "dotnet publish --configuration {} --framework {} --output ../bin/".format(
            build_cfg['dotnet_configuration'], build_cfg['dotnet_framework'])
        run_os_command(build_command)
    elif build_cfg['build_type'] == 'build.py':
        build_command = "python3 build.py"
        run_os_command(build_command)
    else:
        print("ERROR: Unsupported build type.")
        return False

    raw_bin_dir = "{}/bin".format(project_dir)
    os.chdir(raw_bin_dir)

    # Get a sensible name
    new_name = "{}_{}.zip".format(project_name, project_version)
    # Move out the artifacts
    artifacts_list = list()
    for artifact in build_cfg['artifacts']:
        artifacts_list.append("{}".format(artifact))
    stdout, stderr, retcode = run_os_command("zip {} {}".format(
        new_name, ' '.join(artifacts_list)))
    if retcode:
        print('Could not archive artifacts: {}'.format(stderr))
        return False

    # Move back to the previous directory
    os.chdir(revdir)

    # Collect artifacts
    src_dir = "{}/bin".format(project_dir)
    target_dir = "./bin/{}".format(project_name)
    # Make the type dir if it doesn't exist
    if not os.path.isdir(target_dir):
        os.makedirs(target_dir)

    stdout, stderr, retcode = run_os_command("mv {}/{} {}/".format(
        src_dir, new_name, target_dir))
    if retcode:
        print('Could not move archive: {}'.format(stderr))
        return False

    # Remove build junk
    run_os_command("rm -rf {}".format(src_dir))

    bin_md5sum = run_os_command("md5sum {}/{}".format(target_dir,
                                                      new_name))[0].split()[0]

    generate_plugin_manifest(project, build_cfg, bin_md5sum)

    return True
Exemple #4
0
def load_manifest():
    return manifest.load_manifest("manifest.json")
def build_client(project, package):
    # Extract our name and type
    project_name = project['name']
    project_type = project['type']

    # Set out the directories
    type_dir = "{}/projects/{}".format(cwd, project_type)
    project_dir = "{}/projects/{}/{}".format(cwd, project_type, project_name)

    # Check if a build configuration exists and load it
    manifest_file = '{}/build.yaml'.format(project_dir)
    if not os.path.exists(manifest_file):
        print("ERROR: Project {} does not contain a valid 'build.yaml' file.".
              format(project['name']))
        return False
    build_cfg = manifest.load_manifest(manifest_file)

    project_version = build_cfg['version']
    project_packages = build_cfg['packages']

    packages_list = list()
    if package == 'all':
        packages_list = project_packages
    else:
        if package in project_packages:
            packages_list.append(package)
        else:
            print('ERROR: Package type {} is not valid. Valid packages are:'.
                  format(package))
            print('\n > '.join(project_packages))
            return False

    # move into the project directory
    revdir = os.getcwd()
    # Build each package type
    for package in packages_list:
        os.chdir(project_dir)

        # We wrap `build` so we expect it to be sane and like what we send it
        subprocess.call('./build -r {} -b master'.format(package), shell=True)

        # Move back to the previous directory
        os.chdir(revdir)

        # Collect artifacts
        src_dir = "{}/bin".format(type_dir)
        target_dir = "./bin/{}".format(project_name)
        # Make the type dir if it doesn't exist
        if not os.path.isdir(target_dir):
            os.makedirs(target_dir)
        # Clean out the old target dir
        stdout, stderr, retcode = run_os_command("rm -rf {}/{}".format(
            target_dir, package))
        if retcode:
            print('Could not remove old archive: {}'.format(stderr))
            return False
        # Move the artifacts
        stdout, stderr, retcode = run_os_command("mv {}/* {}/".format(
            src_dir, target_dir),
                                                 shell=True)
        if retcode:
            print('Could not move archive: {}'.format(stderr))
            return False

        # Remove build junk
        run_os_command("rm -rf {}".format(src_dir))

    return True
Exemple #6
0
def load_manifest():
  return manifest.load_manifest("manifest.json")