Beispiel #1
0
def purge_xfce(component, comp_list):
    """ Delete files and directories of selected components. """
    print(f"Purging the Xfce {component} group...")
    os.chdir(os.path.dirname(os.path.realpath(__file__)))

    def get_path(comp_group):
        # grandparent directory (../../) relative to script.
        installpath = os.path.abspath(os.path.join(os.getcwd(),
                                                   os.pardir,
                                                   os.pardir,
                                                   comp_group))

        return installpath

    repopath = get_path(component)
    success_count = 0

    confirm = query_yes_no(f"Are you sure you want to remove the "
                           f"Xfce '{component}' repositories? ")

    if confirm == 'yes':
        if os.path.isdir(repopath):
            os.chdir(repopath)
            for item in component_list(comp_list):
                if os.path.isdir(item):
                    try:
                        shutil.rmtree(item)
                        success_count += 1
                        print(f"\nThe '{item}' directory has been deleted.\n")
                        print(f"{success_count}"
                              f"/{len(component_list(comp_list))} "
                              f"'{component}' repositories deleted "
                              f"successfully.")
                        print('\u2248' * 16)
                    except FileNotFoundError:
                        print(f"The directory '{item}' does not exist. "
                              f"Skipping...")
                        print('\u2248' * 16)
            os.chdir('..')
            shutil.rmtree(component)
            print(f"\nThe directory '{component}' has been deleted.\n")
            print('\u2248' * 16)
        else:
            print('Nothing to do...\n')
            print(f"The '{component}' repositories do not exist.\n\n"
                  "Perhaps you need to clone the directory first.\n")
            print('\u2248' * 16)

    else:
        print("No repositories have been deleted. Have a nice day.")
Beispiel #2
0
def main(component_group_name):
    """ Build arguments to pass to clone_xfce() with a call to
    cappdata for component name list.
    command format:
            clone_xfce(component='apps',
                       comp_list='apps')
    """
    cgroup_listname = component_list(component_group_name)
    # All cgroup_listnames will return a string, except 'all'
    if isinstance(cgroup_listname, dict):
        for comp, cglist in cgroup_listname.items():
            clone_xfce(component=comp, comp_list=cglist)
    else:
        clone_xfce(component=component_group_name,
                   comp_list=component_group_name)
def install_xfce(component, comp_list):
    """ Run 'make install' or 'sudo make install' on selected components. """
    print(f"Installing the Xfce {component} group...")
    os.chdir(os.path.dirname(os.path.realpath(__file__)))

    def get_path(comp_group):
        # grandparent directory (../../) relative to script.
        installpath = os.path.abspath(
            os.path.join(os.getcwd(), os.pardir, os.pardir, comp_group))

        return installpath

    repopath = get_path(component)

    if os.path.isdir(repopath):
        os.chdir(repopath)
        for item in component_list(comp_list):
            if os.path.isdir(item):
                os.chdir(item)
                confirm = query_yes_no(
                    f"Do you want to install '{item}' to the system? "
                    f"Answer 'No' to install locally. ")
                if confirm == 'yes':
                    print(f"Installing {item} to the system...")
                    os.system('sudo make install')
                    print('\u2248' * 16)
                    os.chdir("..")
                else:
                    print(f"Installing {item} locally...")
                    os.system('make install')
                    print('\u2248' * 16)
                    os.chdir("..")
            else:
                print('\nNothing to do...\n')
                print(f"The '{item}' repository does not exist.\n\n"
                      "Perhaps you need to clone it first.\n")
                print('\u2248' * 16)

    else:
        print('Nothing to do...\n')
        print(f"The '{component}' repositories do not exist.\n\n"
              "Perhaps you need to clone the directory first.\n")
        print('\u2248' * 16)
Beispiel #4
0
def clean_xfce(component, comp_list):
    """ Run make clean on component directories. """
    print(f"Cleaning the Xfce {component} group...")
    os.chdir(os.path.dirname(os.path.realpath(__file__)))

    def get_path(comp_group):
        # grandparent directory (../../) relative to script.
        installpath = os.path.abspath(
            os.path.join(os.getcwd(), os.pardir, os.pardir, comp_group))

        return installpath

    repopath = get_path(component)
    success_count = 0

    if os.path.isdir(repopath):
        os.chdir(repopath)
        for item in component_list(comp_list):
            if os.path.isdir(item):
                os.chdir(item)
                print(f"\nCleaning {item} directory...\n")
                time.sleep(1.5)
                os.system('make -s clean')
                success_count += 1
                print(f"\nExiting {item} directory...\n")
                print(f"{success_count}/{len(component_list(comp_list))} "
                      f"'{component}' repositories cleaned.")
                print('\u2248' * 16)
                os.chdir('..')
            else:
                print('\nNothing to do...\n')
                print(f"The '{item}' repository does not exist.\n\n"
                      "Perhaps you need to clone it first.\n")
                print('\u2248' * 16)

    else:
        print('Nothing to do...\n')
        print(f"The '{component}' repositories do not exist.\n\n"
              "Perhaps you need to clone the directory first.\n")
        print('\u2248' * 16)
def build_xfce(component, comp_list):
    """ Run autogen.sh and make on selected components. """
    print(f"Building the Xfce {component} group...")
    os.chdir(os.path.dirname(os.path.realpath(__file__)))

    def get_path(comp_group):
        # grandparent directory (../../) relative to script.
        installpath = os.path.abspath(
            os.path.join(os.getcwd(), os.pardir, os.pardir, comp_group))

        return installpath

    repopath = get_path(component)
    os.environ["PKG_CONFIG_PATH"] = "/usr/lib/pkgconfig:/usr"

    if os.path.isdir(repopath):
        os.chdir(repopath)
        for item in component_list(comp_list):
            if os.path.isdir(item):
                os.chdir(item)
                print(f"\nRunning autogen.sh for {item} ...\n")
                os.system('./autogen.sh --prefix=/usr')
                print(f"\nRunning make for {item} ...\n")
                time.sleep(1.5)
                os.system('make')
                print('\u2248' * 16)
                os.chdir("..")
            else:
                print('\nNothing to do...\n')
                print(f"The '{item}' repository does not exist.\n\n"
                      "Perhaps you need to clone it first.\n")
                print('\u2248' * 16)

    else:
        print('Nothing to do...\n')
        print(f"The '{component}' repositories do not exist.\n\n"
              "Perhaps you need to clone the directory first.\n")
        print('\u2248' * 16)
Beispiel #6
0
def pull_xfce(component, comp_list):
    """ Run 'git pull' on selected components to update repositories. """
    print(f"Updating the Xfce {component} group...")
    os.chdir(os.path.dirname(os.path.realpath(__file__)))

    def get_path(comp_group):
        # grandparent directory (../../) relative to script.
        installpath = os.path.abspath(
            os.path.join(os.getcwd(), os.pardir, os.pardir, comp_group))

        return installpath

    repopath = get_path(component)
    success_count = 0

    if os.path.isdir(repopath):
        os.chdir(repopath)
        for item in component_list(comp_list):
            if os.path.isdir(item):
                os.chdir(item)
                print(f"Updating {item}...")
                os.system('git pull')
                success_count += 1
                print(f"\n{success_count}/{len(component_list(comp_list))} "
                      f"'{component}' repositories updated successfully.")
                print('\u2248' * 16)
                os.chdir('..')
            else:
                print('\nNothing to do...\n')
                print(f"The '{item}' repository does not exist.\n\n"
                      "Perhaps you need to clone it first.\n")
                print('\u2248' * 16)

    else:
        print('Nothing to do...\n')
        print(f"The '{component}' repositories do not exist.\n\n"
              "Perhaps you need to clone the directory first.\n")
        print('\u2248' * 16)
Beispiel #7
0
def clone_xfce(component, comp_list):
    """ Run 'git clone' for selected components. """
    print(f"Cloning the Xfce {component} group...")
    os.chdir(os.path.dirname(os.path.realpath(__file__)))

    def get_path(comp_group):
        # grandparent directory (../../) relative to script.
        installpath = os.path.abspath(
            os.path.join(os.getcwd(), os.pardir, os.pardir, comp_group))

        return installpath

    repopath = get_path(component)
    success_count = 0

    os.makedirs(repopath, exist_ok=True)
    os.chdir(repopath)

    for item in component_list(comp_list):
        if os.path.isdir(item):
            print(f"\nThe '{item}' directory already exists. Skipping...\n")
            print('\u2248' * 16)
        else:
            try:
                url = f"https://gitlab.xfce.org/{component}/{item}.git"
                subprocess.run(['git', 'clone', url], stdout=None, check=True)
                success_count += 1
                print('\u2248' * 16)
                print(f"{item} repository cloned successfully.")
            except subprocess.CalledProcessError:
                # On error, returns a non-zero exit status 128.
                print('\u2248' * 16)
                print(f"Failed to clone {item} repository.")

            print(f"{success_count}/{len(component_list(comp_list))} "
                  f"'{component}' repositories cloned successfully.")
            print('\u2248' * 16)