Updated with error code exit

This commit is contained in:
Edgar P. Burkhart 2022-02-05 18:02:53 +01:00
parent 043b436ba7
commit 591f4cb1f0
Signed by: edpibu
GPG key ID: 9833D3C5A25BD227
4 changed files with 28 additions and 7 deletions

View file

@ -7,6 +7,7 @@ import pathlib
import os
import getpass
import tempfile
import sys
# CLI Args Parsing
@ -35,17 +36,34 @@ log.setLevel(min(
# Pacman
if config.getboolean('pacman', 'install_yay', fallback=False):
log.info('Installing yay')
log.info('Installing git and base-devel')
proc = subprocess.run(('sudo', 'pacman', '-Syu', '--needed',
'git', 'base-devel'))
if proc.returncode != 0:
log.error('Installation of git and base-devel failed')
sys.exit(proc.returncode)
with tempfile.TemporaryDirectory() as yay_folder:
log.info('Cloning yay')
subprocess.run(('git', 'clone', 'https://aur.archlinux.org/yay', yay_folder))
subprocess.run(('makepkg', '-rcsi'), cwd=yay_folder)
proc = subprocess.run(('git', 'clone',
'https://aur.archlinux.org/yay', yay_folder))
if proc.returncode != 0:
log.error('Cloning of yay failed')
sys.exit(proc.returncode)
log.info('Compiling and installing yay')
proc = subprocess.run(('makepkg', '-rcsi'), cwd=yay_folder)
if proc.returncode != 0:
log.error('Yay compile and install failed')
sys.exit(proc.returncode)
if config.getboolean('pacman', 'install_pkg', fallback=False):
with open(config.get('pacman', 'pkg_list', fallback=''), 'r') as pkg_file:
pkg_list = pkg_file.read().splitlines()
log.info('Installing packages')
subprocess.run(('yay', '-Syu', *pkg_list))
proc = subprocess.run(('yay', '-Syu', '--needed', *pkg_list))
if proc.returncode != 0:
log.error('Package install failed')
sys.exit(proc.returncode)
# Config files
if 'config' in config:
@ -58,3 +76,5 @@ if 'config' in config:
log.debug(f'Copying {src} -> {dst}')
dst.parent.mkdir(exist_ok=True)
shutil.copy2(src, dst)
log.info('Autoconfig ended successfully')

View file

@ -1,12 +1,12 @@
[pacman]
install_yay = True
install_yay = False
install_pkg = False
pkg_list = pacman.list
[config]
root = config
kitty = kitty.conf:~/.config/kitty/kitty.conf
kitty-theme = kitty-theme.conf:~/.config/kitty/theme.conf
#kitty-theme = kitty-theme.conf:~/.config/kitty/theme.conf
neovim = init.vim:~/.config/nvim/init.vim
git = gitconfig:~/.gitconfig

View file

@ -1,6 +1,6 @@
font_family Fira Code
font_size 12
include ./theme.conf
#include ./theme.conf
map ctrl+f2 detach_window
map ctrl+f3 detach_window new-tab

View file

@ -1,2 +1,3 @@
git
fish
sudo