Integrate package installation into __main__

This commit is contained in:
ItsDrike 2020-10-22 18:43:51 +02:00
parent d1ec6091b8
commit 555a2d0599
No known key found for this signature in database
GPG key ID: F4E8FF4F6AC7F3B4
2 changed files with 35 additions and 20 deletions

View file

@ -1,5 +1,10 @@
import os
import sys
from src.packages import install_packages
if os.geteuid() != 0:
sys.exit("Please run this program as root user")
install_packages()

View file

@ -1,8 +1,12 @@
import typing as t
import yaml
from src.util.package import Package, PackageAlreadyInstalled, InvalidPackage
from src.util.install import Install
from src.util import log
def obtain_packages() -> t.List[Package]:
with open("packages.yaml") as f:
yaml_file = yaml.safe_load(f)
@ -18,6 +22,12 @@ for package in pacman_packages:
for package in aur_packages:
packages.append(Package(package, aur=True))
return packages
def install_packages() -> None:
packages = obtain_packages()
Install.upgrade_pacman()
for package in packages:
try:
log.action(f"Installing {package}")