Пример #1
0
def main():
    usage = os.path.basename(__file__) + "--input-type=[json/pkg/who-needs] --pkg=[pkg_name] --file=<JSON_FILE_NAME> --disp=[tree/list/json]"
    parser = OptionParser(usage)
    parser.add_option("-i", "--input-type", dest="input_type", default=DEFAULT_INPUT_TYPE)
    parser.add_option("-p", "--pkg", dest="pkg")
    parser.add_option("-f", "--file", dest="json_file", default="packages_minimal.json")
    parser.add_option("-d", "--disp", dest="display_option", default=DEFAULT_DISPLAY_OPTION) 
    parser.add_option("-s", "--spec-dir", dest="spec_dir", default=SPEC_FILE_DIR)
    parser.add_option("-t", "--stage-dir", dest="stage_dir", default="../../stage")
    parser.add_option("-a", "--input-data-dir", dest="input_data_dir", default="../../common/data/")
    (options,  args) = parser.parse_args() 

    if(False == options.input_data_dir.endswith('/')):
        options.input_data_dir += '/'

    specDeps = SerializedSpecObjects(options.input_data_dir, options.stage_dir)
    displayOption = options.display_option
    abs_path = os.path.abspath(__file__)
    dir_name = os.path.dirname(abs_path)
    os.chdir(dir_name)

    if(options.input_type == "pkg" or options.input_type == "who-needs"): # To display/print package dependencies on console
        targetName = options.pkg
        specDeps.readSpecsAndConvertToSerializableObjects(options.spec_dir, options.input_type, targetName, displayOption)
    elif(options.input_type == "json"):# Generate the expanded package dependencies json file based on package_list_file 
        json_wrapper_option_list = JsonWrapper(options.json_file)
        option_list_json = json_wrapper_option_list.read()
        options_sorted = option_list_json.items()
        for install_option in options_sorted:
            if displayOption == "tree" and install_option[1]["title"] == "ISO Packages":
                continue
            specDeps.readSpecsAndConvertToSerializableObjects(options.spec_dir, options.input_type, install_option[1]["file"], displayOption)

    sys.exit(0)
Пример #2
0
def main():
    usage = os.path.basename(
        __file__
    ) + "--input-type=[json/pkg]    --pkg=[pkg_name]    --file=<JSON_FILE_NAME>    --repo-file=<photon>.repo"
    parser = OptionParser(usage)
    parser.add_option("-i",
                      "--input-type",
                      dest="input_type",
                      default=DEFAULT_INPUT_TYPE)
    parser.add_option("-p", "--pkg", dest="pkg")
    parser.add_option("-f",
                      "--file",
                      dest="json_file",
                      default="packages_full.json")
    parser.add_option("-s",
                      "--spec-dir",
                      dest="spec_dir",
                      default=SPEC_FILE_DIR)
    parser.add_option("-a",
                      "--input-data-dir",
                      dest="input_data_dir",
                      default=INPUT_DATA_DIR)
    parser.add_option("-r", "--repo-file", dest="repo_file", default="")
    excludeList = ["bash", "glibc", "libgcc", "pkg-config", "filesystem"]
    (options, args) = parser.parse_args()

    if (options.repo_file == ""):
        print "Error! repo file not provided"
        print usage
        return

    if (False == options.input_data_dir.endswith('/')):
        options.input_data_dir += '/'

    specDeps = SerializedSpecObjects(options.input_data_dir, "")
    repoDeps = RepoQueryDependency(options.repo_file)
    displayOption = None
    abs_path = os.path.abspath(__file__)
    dir_name = os.path.dirname(abs_path)
    os.chdir(dir_name)

    if (options.input_type == "pkg"):
        targetName = options.pkg
        specDepList = specDeps.readSpecsAndConvertToSerializableObjects(
            options.spec_dir, options.input_type, targetName, displayOption)
        repoDepList = repoDeps.getRequiresList(targetName)
        reportMissing(targetName, specDepList, repoDepList, excludeList)
    elif (options.input_type == "json"):
        filePath = options.input_data_dir + options.json_file
        data = specDeps.get_all_package_names(filePath)
        for pkg in data:
            specDepList = specDeps.readSpecsAndConvertToSerializableObjects(
                options.spec_dir, "pkg", pkg, displayOption)
            repoDepList = repoDeps.getRequiresList(pkg)
            reportMissing(pkg, specDepList, repoDepList, excludeList)
    sys.exit(0)
Пример #3
0
def main():
    usage = "Usage: %prog [options]"
    parser = ArgumentParser(usage)
    parser.add_argument("-i",
                        "--input-type",
                        dest="input_type",
                        default=DEFAULT_INPUT_TYPE)
    parser.add_argument("-p", "--pkg", dest="pkg")
    parser.add_argument("-f",
                        "--file",
                        dest="json_file",
                        default="packages_minimal.json")
    parser.add_argument("-d",
                        "--disp",
                        dest="display_option",
                        default=DEFAULT_DISPLAY_OPTION)
    parser.add_argument("-s",
                        "--spec-dir",
                        dest="spec_dir",
                        default=SPEC_FILE_DIR)
    parser.add_argument("-t",
                        "--stage-dir",
                        dest="stage_dir",
                        default="../../stage")
    parser.add_argument("-a",
                        "--input-data-dir",
                        dest="input_data_dir",
                        default="../../common/data/")
    options = parser.parse_args()

    if not options.input_data_dir.endswith('/'):
        options.input_data_dir += '/'
    try:
        specDeps = SerializedSpecObjects(options.input_data_dir,
                                         options.stage_dir)
        displayOption = options.display_option
        abs_path = os.path.abspath(__file__)
        dir_name = os.path.dirname(abs_path)
        os.chdir(dir_name)

        # To display/print package dependencies on console
        if (options.input_type == "pkg" or options.input_type == "who-needs"
                or options.input_type == "who-needs-build"):
            targetName = options.pkg
            specDeps.readSpecsAndConvertToSerializableObjects(
                options.spec_dir, options.input_type, targetName,
                displayOption)
        elif options.input_type == "json":
            # Generate the expanded package dependencies json file based on package_list_file
            json_wrapper_option_list = JsonWrapper(options.json_file)
            option_list_json = json_wrapper_option_list.read()
            options_sorted = option_list_json.items()
            for install_option in options_sorted:
                if displayOption == "tree" and install_option[1][
                        "title"] == "ISO Packages":
                    continue
                specDeps.readSpecsAndConvertToSerializableObjects(
                    options.spec_dir, options.input_type,
                    install_option[1]["file"], displayOption)
    except Exception as _:
        sys.stderr.write(
            "Failed to generate dependency lists from spec files\n")
        sys.exit(1)

    sys.stderr.write(
        "Successfully generated dependency lists from spec files\n")
    sys.exit(0)