2020-10-22 16:43:51 +00:00
|
|
|
import typing as t
|
2020-10-22 16:31:20 +00:00
|
|
|
import yaml
|
|
|
|
|
|
|
|
from src.util.package import Package, PackageAlreadyInstalled, InvalidPackage
|
2021-01-14 13:55:21 +00:00
|
|
|
from src.util import install
|
2020-10-22 18:06:48 +00:00
|
|
|
from src.util.user import Print, Input
|
2020-10-22 16:31:20 +00:00
|
|
|
|
2020-10-22 16:43:51 +00:00
|
|
|
|
|
|
|
def obtain_packages() -> t.List[Package]:
|
|
|
|
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 = []
|
2020-10-22 19:50:52 +00:00
|
|
|
packages += Package.safe_load(pacman_packages)
|
|
|
|
packages += Package.safe_load(aur_packages, aur=True)
|
|
|
|
packages += Package.safe_load(git_packages, git=True)
|
2020-10-22 16:43:51 +00:00
|
|
|
|
|
|
|
return packages
|
|
|
|
|
|
|
|
|
|
|
|
def install_packages() -> None:
|
|
|
|
packages = obtain_packages()
|
2020-10-22 18:06:48 +00:00
|
|
|
if Input.yes_no("Do you wish to perform system upgrade first? (Recommended)"):
|
2021-01-14 13:55:21 +00:00
|
|
|
install.upgrade_pacman()
|
2020-10-22 16:43:51 +00:00
|
|
|
for package in packages:
|
|
|
|
try:
|
2020-10-22 17:02:23 +00:00
|
|
|
Print.action(f"Installing {package}")
|
2020-10-22 16:43:51 +00:00
|
|
|
package.install()
|
|
|
|
except PackageAlreadyInstalled:
|
2020-10-22 17:02:23 +00:00
|
|
|
Print.cancel(f"Package {package} is already installed.")
|
2020-10-22 16:43:51 +00:00
|
|
|
except InvalidPackage as e:
|
2020-10-22 17:02:23 +00:00
|
|
|
Print.warning(e)
|
|
|
|
|
|
|
|
|
|
|
|
if __name__ == "__main__":
|
|
|
|
install_packages()
|