Add package installation

This commit is contained in:
ItsDrike 2020-10-22 18:31:20 +02:00
parent 026ab5a354
commit d1ec6091b8
No known key found for this signature in database
GPG key ID: F4E8FF4F6AC7F3B4
2 changed files with 36 additions and 0 deletions

8
packages.yaml Normal file
View file

@ -0,0 +1,8 @@
pacman:
- vim
aur:
- spotify
git:
- https://aur.archlinux.org/yay-git.git

28
src/packages.py Normal file
View file

@ -0,0 +1,28 @@
import yaml
from src.util.package import Package, PackageAlreadyInstalled, InvalidPackage
from src.util import log
with open("packages.yaml") as f:
yaml_file = yaml.safe_load(f)
pacman_packages = yaml_file["pacman"]
aur_packages = yaml_file["aur"]
git_packages = yaml_file["git"]
packages = []
for package in git_packages:
packages.append(Package(package, git=True))
for package in pacman_packages:
packages.append(Package(package))
for package in aur_packages:
packages.append(Package(package, aur=True))
for package in packages:
try:
log.action(f"Installing {package}")
package.install()
except PackageAlreadyInstalled:
log.cancel(f"Package {package} is already installed.")
except InvalidPackage as e:
log.warning(e)