mirror of
				https://github.com/ItsDrike/dotfiles.git
				synced 2025-11-04 01:16:35 +00:00 
			
		
		
		
	Installation complete
This commit is contained in:
		
							parent
							
								
									961e5430fd
								
							
						
					
					
						commit
						ea51b5e7ae
					
				
					 2 changed files with 88 additions and 18 deletions
				
			
		
							
								
								
									
										95
									
								
								lib.py
									
										
									
									
									
								
							
							
						
						
									
										95
									
								
								lib.py
									
										
									
									
									
								
							| 
						 | 
				
			
			@ -1,19 +1,28 @@
 | 
			
		|||
#!/bin/python3
 | 
			
		||||
import subprocess
 | 
			
		||||
import os
 | 
			
		||||
import shutil
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
class Command:
 | 
			
		||||
    def execute(command):
 | 
			
		||||
    def execute(command, use_os=False):
 | 
			
		||||
        '''Execute bash command
 | 
			
		||||
 | 
			
		||||
        Arguments:
 | 
			
		||||
            command {str} -- full command
 | 
			
		||||
 | 
			
		||||
        Keyword Arguments:
 | 
			
		||||
            os {bool} -- should the os module be used instead of subprocess (default: {False})
 | 
			
		||||
 | 
			
		||||
        Returns:
 | 
			
		||||
            int -- returncode
 | 
			
		||||
            int/bool -- returncode/True if os is used
 | 
			
		||||
        '''
 | 
			
		||||
        command = command.split(' ')
 | 
			
		||||
        return subprocess.call(command)
 | 
			
		||||
        if not use_os:
 | 
			
		||||
            command = command.split(' ')
 | 
			
		||||
            return subprocess.call(command)
 | 
			
		||||
        else:
 | 
			
		||||
            os.system(command)
 | 
			
		||||
            return True
 | 
			
		||||
 | 
			
		||||
    def get_output(command):
 | 
			
		||||
        '''Get standard output of command
 | 
			
		||||
| 
						 | 
				
			
			@ -189,6 +198,18 @@ class Input:
 | 
			
		|||
 | 
			
		||||
 | 
			
		||||
class Install:
 | 
			
		||||
 | 
			
		||||
    def _generate_install_text(install_text, package_name, yay=False, git=False):
 | 
			
		||||
        if install_text == 'default':
 | 
			
		||||
            install_text = f'Do you wish to install {package_name}?'
 | 
			
		||||
        if install_text[:10] == 'default + ':
 | 
			
		||||
            install_text = f'Do you wish to install {package_name}? {install_text[10:]}'
 | 
			
		||||
        if yay:
 | 
			
		||||
            install_text += '[AUR (YAY) Package]'
 | 
			
		||||
        if git:
 | 
			
		||||
            install_text += '[AUR (GIT) Package]'
 | 
			
		||||
        return install_text
 | 
			
		||||
 | 
			
		||||
    def check_not_installed(package_name):
 | 
			
		||||
        '''Check if specified package is currently not installed
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -217,23 +238,69 @@ class Install:
 | 
			
		|||
            raise TypeError(
 | 
			
		||||
                'check_not_installed() only takes string or list inputs')
 | 
			
		||||
 | 
			
		||||
    def package(package_name, install_text='default', reinstall=False):
 | 
			
		||||
        '''Installation of package
 | 
			
		||||
    def git_aur(repository, install_text='default', force=False):
 | 
			
		||||
        '''Install package directly from AUR using only git and makepkg
 | 
			
		||||
 | 
			
		||||
        Arguments:
 | 
			
		||||
            package_name {str} -- name of package to be installed
 | 
			
		||||
            install_text {str} -- text presented to user before installing
 | 
			
		||||
            repository {string} -- repository name
 | 
			
		||||
 | 
			
		||||
        Keyword Arguments:
 | 
			
		||||
            install_text {str} -- text presented to the user before installing (default: {'default' -> 'Do you wish to install [repository]'})
 | 
			
		||||
            force {bool} -- should the repository be installed even if detected as installed (default: {False})
 | 
			
		||||
 | 
			
		||||
        Returns:
 | 
			
		||||
            bool -- installed
 | 
			
		||||
        '''
 | 
			
		||||
        if Install.check_not_installed(package_name) or reinstall:
 | 
			
		||||
            if install_text == 'default':
 | 
			
		||||
                install_text = f'Do you wish to install {package_name}?'
 | 
			
		||||
            if install_text[:10] == 'default + ':
 | 
			
		||||
                install_text = f'Do you wish to install {package_name}? {install_text[10:]}'
 | 
			
		||||
 | 
			
		||||
        if Install.check_not_installed('git'):
 | 
			
		||||
            Print.warning(
 | 
			
		||||
                f'Unable to install github repository: {repository}, git is not installed')
 | 
			
		||||
            return False
 | 
			
		||||
 | 
			
		||||
        if Install.check_not_installed(repository) or force:
 | 
			
		||||
            install_text = Install._generate_install_text(
 | 
			
		||||
                install_text, repository, git=True)
 | 
			
		||||
            if Input.yes_no(install_text):
 | 
			
		||||
                Command.execute(f'sudo pacman -S {package_name}')
 | 
			
		||||
                url = f'https://aur.archlinux.org/{repository}.git'
 | 
			
		||||
                Command.execute(f'git clone {url}')
 | 
			
		||||
                Command.execute(f'cd {repository}', use_os=True)
 | 
			
		||||
                Command.execute('makepkg -si')
 | 
			
		||||
                Command.execute('cd ..', use_os=True)
 | 
			
		||||
                shutil.rmtree(repository)
 | 
			
		||||
                return True
 | 
			
		||||
            else:
 | 
			
		||||
                Print.cancel('Skipping...')
 | 
			
		||||
        else:
 | 
			
		||||
            Print.cancel(
 | 
			
		||||
                f'assuming {repository} already installed ({repository} is installed)')
 | 
			
		||||
 | 
			
		||||
    def package(package_name, install_text='default', use_yay=False, reinstall=False):
 | 
			
		||||
        '''Installation of package
 | 
			
		||||
 | 
			
		||||
        Arguments:
 | 
			
		||||
            package_name {str} -- name of package to be installed
 | 
			
		||||
 | 
			
		||||
        Keyword Arguments:
 | 
			
		||||
            install_text {str} -- text presented to user before installing (default: {'default' -> 'Do you wish to install [package_name]'})
 | 
			
		||||
            use_yay {bool} -- use yay for package installation (default: {False})
 | 
			
		||||
            reinstall {bool} -- should the package be reinstalled (default {False})
 | 
			
		||||
 | 
			
		||||
        Returns:
 | 
			
		||||
            bool -- installed
 | 
			
		||||
        '''
 | 
			
		||||
        if use_yay:
 | 
			
		||||
            if Install.check_not_installed('yay'):
 | 
			
		||||
                Print.warning(
 | 
			
		||||
                    f'Unable to install AUR package: {package_name}, yay is not installed')
 | 
			
		||||
                return False
 | 
			
		||||
        if Install.check_not_installed(package_name) or reinstall:
 | 
			
		||||
            install_text = Install._generate_install_text(
 | 
			
		||||
                install_text, package_name, yay=use_yay)
 | 
			
		||||
            if Input.yes_no(install_text):
 | 
			
		||||
                if use_yay:
 | 
			
		||||
                    Command.execute(f'yay -S {package_name}')
 | 
			
		||||
                else:
 | 
			
		||||
                    Command.execute(f'sudo pacman -S {package_name}')
 | 
			
		||||
                return True
 | 
			
		||||
            else:
 | 
			
		||||
                Print.cancel('Skipping...')
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -19,20 +19,23 @@ Install.multiple_packages(['plasma', 'plasma-desktop', 'gnome'], 'Do you wish to
 | 
			
		|||
Install.multiple_packages(['sddm', 'gdm', 'lightdm'], 'Do you wish to install DM (Display Manager)?', [
 | 
			
		||||
    'SDDM (KDE)', 'GDM (Gnome)', 'LightDM'])
 | 
			
		||||
 | 
			
		||||
# TODO: YAY install
 | 
			
		||||
Install.git_aur(
 | 
			
		||||
    'yay', 'default + (Required for some installations, otherwise they\'ll be skipped)')
 | 
			
		||||
Install.package('exa', 'default + (Better ls tool)')
 | 
			
		||||
Install.package('terminator', 'default + (advanced terminal)')
 | 
			
		||||
Install.package('konsole', 'default + (KDE terminal emulator)')
 | 
			
		||||
Install.package(
 | 
			
		||||
    'ark', 'default + (Managing various archive formats such as tar, gzip, zip, rar, etc.)')
 | 
			
		||||
Install.package('cron', '(Task scheduling)')
 | 
			
		||||
Install.package('cron', 'default + (Task scheduling)')
 | 
			
		||||
Install.package('dolphin', 'default + (File Manager)')
 | 
			
		||||
Install.package('nomacs', 'default + (Photo viewer & editor)')
 | 
			
		||||
Install.package('discord', 'default + (Chat App)')
 | 
			
		||||
# TODO: Spotify (YAY)
 | 
			
		||||
Install.package(
 | 
			
		||||
    'spotify', 'default + (Online Music Player)', use_yay=True)
 | 
			
		||||
Install.package(
 | 
			
		||||
    'spectacle', 'default + (Screenshot tool)')
 | 
			
		||||
# TODO: Qualculate (YAY)
 | 
			
		||||
Install.package('qalculate-gtk-nognome',
 | 
			
		||||
                'Do you wish to install Qalculate! (Complex Calculator)?', use_yay=True)
 | 
			
		||||
Install.package('gnome-system-monitor',
 | 
			
		||||
                'Do you wish to install gnome system monitor?')
 | 
			
		||||
Install.package(
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue