Ejemplo n.º 1
0
def _setup_install_dir(dir, relocatable=False):
    global system_lib_dirs
    global install_dir
    global share_dir
    global bin_dir
    global etc_dir
    global lib_dir
    global libexec_dir

    install_dir = dir
    utils.ensure_dir(install_dir)

    share_dir = os.path.join(install_dir, "share")
    bin_dir = os.path.join(install_dir, "bin")
    etc_dir = os.path.join(install_dir, "etc")
    libexec_dir = os.path.join(install_dir, "libexec")

    distro_info = distro.get_distro_info()

    relative_lib_dir = distro_info.lib_dir
    if relative_lib_dir is None:
        relative_lib_dir = "lib"

    lib_dir = os.path.join(install_dir, relative_lib_dir)

    system_lib_dirs = ["/usr/lib"]
    if distro_info.lib_dir is not None:
        system_lib_dirs.append(os.path.join("/usr", distro_info.lib_dir))
Ejemplo n.º 2
0
def _setup_install_dir(dir, relocatable=False):
    global system_lib_dirs
    global install_dir
    global share_dir
    global bin_dir
    global etc_dir
    global lib_dir
    global libexec_dir

    install_dir = dir
    utils.ensure_dir(install_dir)

    share_dir = os.path.join(install_dir, "share")
    bin_dir = os.path.join(install_dir, "bin")
    etc_dir = os.path.join(install_dir, "etc")
    libexec_dir = os.path.join(install_dir, "libexec")

    distro_info = distro.get_distro_info()

    relative_lib_dir = distro_info.lib_dir
    if relative_lib_dir is None:
        relative_lib_dir = "lib"

    lib_dir = os.path.join(install_dir, relative_lib_dir)

    system_lib_dirs = ["/usr/lib"]
    if distro_info.lib_dir is not None:
        system_lib_dirs.append(os.path.join("/usr", distro_info.lib_dir))
Ejemplo n.º 3
0
def _filter_if(item):
    if "if" not in item:
        return True

    distro_info = distro.get_distro_info()
    globals = {"gnome_version": distro_info.gnome_version,
               "distro": "%s-%s" % (distro_info.name, distro_info.version)}

    return eval(item["if"], globals)
Ejemplo n.º 4
0
def _eval_check_if(check):
    if "check_if" not in check:
        return True

    distro_info = distro.get_distro_info()
    globals = {"distro": "%s-%s" % (distro_info.name, distro_info.version)}

    print(eval(check["check_if"], globals))

    return eval(check["check_if"], globals) == "True"
Ejemplo n.º 5
0
def _eval_check_if(check):
    if "check_if" not in check:
        return True

    distro_info = distro.get_distro_info()
    globals = {"distro": "%s-%s" % (distro_info.name, distro_info.version)}

    print(eval(check["check_if"], globals))

    return eval(check["check_if"], globals) == "True"
Ejemplo n.º 6
0
def _filter_if(item):
    if "if" not in item:
        return True

    distro_info = distro.get_distro_info()
    globals = {
        "gnome_version": distro_info.gnome_version,
        "distro": "%s-%s" % (distro_info.name, distro_info.version)
    }

    return eval(item["if"], globals)
Ejemplo n.º 7
0
def _run_checks(package_manager, checks, packages):
    distro_info = distro.get_distro_info()

    failed_checks = []
    packages_not_found = []
    to_install = []

    for check in checks:
        if not _eval_check_if(check):
            continue

        checker = _checkers[check["checker"]]
        if checker(check["check"]):
            try:
                packages_for_check = packages[check["name"]][distro_info.name]
            except KeyError:
                packages_for_check = []
                packages_not_found.append(check)

            for package in packages_for_check:
                if package not in to_install:
                    to_install.append(package)

            failed_checks.append(check)

    if distro_info.supported:
        if packages_not_found:
            print("\nPackages not found for")
            _print_checks(packages_not_found)
            return False

        if to_install:
            package_manager.install_packages(to_install)
    elif failed_checks:
        print("Failed checks\n")
        _print_checks(failed_checks)

        if to_install:
            print("\nYou might try to install the following packages\n")
            print(" ".join(to_install))

        return False

    return True
Ejemplo n.º 8
0
def _run_checks(package_manager, checks, packages):
    distro_info = distro.get_distro_info()

    failed_checks = []
    packages_not_found = []
    to_install = []

    for check in checks:
        if not _eval_check_if(check):
            continue

        checker = _checkers[check["checker"]]
        if checker(check["check"]):
            try:
                packages_for_check = packages[check["name"]][distro_info.name]
            except KeyError:
                packages_for_check = []
                packages_not_found.append(check)

            for package in packages_for_check:
                if package not in to_install:
                    to_install.append(package)

            failed_checks.append(check)

    if distro_info.supported:
        if packages_not_found:
            print("\nPackages not found for")
            _print_checks(packages_not_found)
            return False

        if to_install:
            package_manager.install_packages(to_install)
    elif failed_checks:
        print("Failed checks\n")
        _print_checks(failed_checks)

        if to_install:
            print("\nYou might try to install the following packages\n")
            print(" ".join(to_install))

        return False

    return True
Ejemplo n.º 9
0
def _remove_packages(package_manager, packages):
    distro_name = distro.get_distro_info().name

    to_keep = []
    for package_info in packages.values():
        if distro_name in package_info:
            for package in package_info[distro_name]:
                if package not in to_keep:
                    to_keep.append(package)

    try:
        to_keep = package_manager.find_with_deps(to_keep)
    except NotImplementedError:
        return

    all = package_manager.find_all()

    to_remove = []
    for package in all:
        if package not in to_keep:
            to_remove.append(package)

    if to_remove:
        package_manager.remove_packages(to_remove)
Ejemplo n.º 10
0
def _remove_packages(package_manager, packages):
    distro_name = distro.get_distro_info().name

    to_keep = []
    for package_info in packages.values():
        if distro_name in package_info:
            for package in package_info[distro_name]:
                if package not in to_keep:
                    to_keep.append(package)

    try:
        to_keep = package_manager.find_with_deps(to_keep)
    except NotImplementedError:
        return

    all = package_manager.find_all()

    to_remove = []
    for package in all:
        if package not in to_keep:
            to_remove.append(package)

    if to_remove:
        package_manager.remove_packages(to_remove)