mirror of
https://github.com/ItsDrike/dotfiles.git
synced 2025-04-28 05:02:26 +00:00
Installation complete
This commit is contained in:
parent
961e5430fd
commit
ea51b5e7ae
2 changed files with 88 additions and 18 deletions
89
lib.py
89
lib.py
|
@ -1,19 +1,28 @@
|
||||||
#!/bin/python3
|
#!/bin/python3
|
||||||
import subprocess
|
import subprocess
|
||||||
|
import os
|
||||||
|
import shutil
|
||||||
|
|
||||||
|
|
||||||
class Command:
|
class Command:
|
||||||
def execute(command):
|
def execute(command, use_os=False):
|
||||||
'''Execute bash command
|
'''Execute bash command
|
||||||
|
|
||||||
Arguments:
|
Arguments:
|
||||||
command {str} -- full command
|
command {str} -- full command
|
||||||
|
|
||||||
|
Keyword Arguments:
|
||||||
|
os {bool} -- should the os module be used instead of subprocess (default: {False})
|
||||||
|
|
||||||
Returns:
|
Returns:
|
||||||
int -- returncode
|
int/bool -- returncode/True if os is used
|
||||||
'''
|
'''
|
||||||
|
if not use_os:
|
||||||
command = command.split(' ')
|
command = command.split(' ')
|
||||||
return subprocess.call(command)
|
return subprocess.call(command)
|
||||||
|
else:
|
||||||
|
os.system(command)
|
||||||
|
return True
|
||||||
|
|
||||||
def get_output(command):
|
def get_output(command):
|
||||||
'''Get standard output of command
|
'''Get standard output of command
|
||||||
|
@ -189,6 +198,18 @@ class Input:
|
||||||
|
|
||||||
|
|
||||||
class Install:
|
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):
|
def check_not_installed(package_name):
|
||||||
'''Check if specified package is currently not installed
|
'''Check if specified package is currently not installed
|
||||||
|
|
||||||
|
@ -217,22 +238,68 @@ class Install:
|
||||||
raise TypeError(
|
raise TypeError(
|
||||||
'check_not_installed() only takes string or list inputs')
|
'check_not_installed() only takes string or list inputs')
|
||||||
|
|
||||||
def package(package_name, install_text='default', reinstall=False):
|
def git_aur(repository, install_text='default', force=False):
|
||||||
'''Installation of package
|
'''Install package directly from AUR using only git and makepkg
|
||||||
|
|
||||||
Arguments:
|
Arguments:
|
||||||
package_name {str} -- name of package to be installed
|
repository {string} -- repository name
|
||||||
install_text {str} -- text presented to user before installing
|
|
||||||
|
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:
|
Returns:
|
||||||
bool -- installed
|
bool -- installed
|
||||||
'''
|
'''
|
||||||
if Install.check_not_installed(package_name) or reinstall:
|
|
||||||
if install_text == 'default':
|
if Install.check_not_installed('git'):
|
||||||
install_text = f'Do you wish to install {package_name}?'
|
Print.warning(
|
||||||
if install_text[:10] == 'default + ':
|
f'Unable to install github repository: {repository}, git is not installed')
|
||||||
install_text = f'Do you wish to install {package_name}? {install_text[10:]}'
|
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):
|
if Input.yes_no(install_text):
|
||||||
|
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}')
|
Command.execute(f'sudo pacman -S {package_name}')
|
||||||
return True
|
return True
|
||||||
else:
|
else:
|
||||||
|
|
|
@ -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)?', [
|
Install.multiple_packages(['sddm', 'gdm', 'lightdm'], 'Do you wish to install DM (Display Manager)?', [
|
||||||
'SDDM (KDE)', 'GDM (Gnome)', 'LightDM'])
|
'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('exa', 'default + (Better ls tool)')
|
||||||
Install.package('terminator', 'default + (advanced terminal)')
|
Install.package('terminator', 'default + (advanced terminal)')
|
||||||
Install.package('konsole', 'default + (KDE terminal emulator)')
|
Install.package('konsole', 'default + (KDE terminal emulator)')
|
||||||
Install.package(
|
Install.package(
|
||||||
'ark', 'default + (Managing various archive formats such as tar, gzip, zip, rar, etc.)')
|
'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('dolphin', 'default + (File Manager)')
|
||||||
Install.package('nomacs', 'default + (Photo viewer & editor)')
|
Install.package('nomacs', 'default + (Photo viewer & editor)')
|
||||||
Install.package('discord', 'default + (Chat App)')
|
Install.package('discord', 'default + (Chat App)')
|
||||||
# TODO: Spotify (YAY)
|
Install.package(
|
||||||
|
'spotify', 'default + (Online Music Player)', use_yay=True)
|
||||||
Install.package(
|
Install.package(
|
||||||
'spectacle', 'default + (Screenshot tool)')
|
'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',
|
Install.package('gnome-system-monitor',
|
||||||
'Do you wish to install gnome system monitor?')
|
'Do you wish to install gnome system monitor?')
|
||||||
Install.package(
|
Install.package(
|
||||||
|
|
Loading…
Add table
Reference in a new issue