mirror of
https://github.com/ItsDrike/dotfiles.git
synced 2024-12-26 13:14:35 +00:00
Integrate package installation into __main__
This commit is contained in:
parent
d1ec6091b8
commit
555a2d0599
|
@ -1,5 +1,10 @@
|
||||||
import os
|
import os
|
||||||
import sys
|
import sys
|
||||||
|
|
||||||
|
from src.packages import install_packages
|
||||||
|
|
||||||
|
|
||||||
if os.geteuid() != 0:
|
if os.geteuid() != 0:
|
||||||
sys.exit("Please run this program as root user")
|
sys.exit("Please run this program as root user")
|
||||||
|
|
||||||
|
install_packages()
|
||||||
|
|
|
@ -1,28 +1,38 @@
|
||||||
|
import typing as t
|
||||||
import yaml
|
import yaml
|
||||||
|
|
||||||
from src.util.package import Package, PackageAlreadyInstalled, InvalidPackage
|
from src.util.package import Package, PackageAlreadyInstalled, InvalidPackage
|
||||||
|
from src.util.install import Install
|
||||||
from src.util import log
|
from src.util import log
|
||||||
|
|
||||||
with open("packages.yaml") as f:
|
|
||||||
yaml_file = yaml.safe_load(f)
|
|
||||||
|
|
||||||
pacman_packages = yaml_file["pacman"]
|
def obtain_packages() -> t.List[Package]:
|
||||||
aur_packages = yaml_file["aur"]
|
with open("packages.yaml") as f:
|
||||||
git_packages = yaml_file["git"]
|
yaml_file = yaml.safe_load(f)
|
||||||
|
|
||||||
packages = []
|
pacman_packages = yaml_file["pacman"]
|
||||||
for package in git_packages:
|
aur_packages = yaml_file["aur"]
|
||||||
packages.append(Package(package, git=True))
|
git_packages = yaml_file["git"]
|
||||||
for package in pacman_packages:
|
|
||||||
packages.append(Package(package))
|
|
||||||
for package in aur_packages:
|
|
||||||
packages.append(Package(package, aur=True))
|
|
||||||
|
|
||||||
for package in packages:
|
packages = []
|
||||||
try:
|
for package in git_packages:
|
||||||
log.action(f"Installing {package}")
|
packages.append(Package(package, git=True))
|
||||||
package.install()
|
for package in pacman_packages:
|
||||||
except PackageAlreadyInstalled:
|
packages.append(Package(package))
|
||||||
log.cancel(f"Package {package} is already installed.")
|
for package in aur_packages:
|
||||||
except InvalidPackage as e:
|
packages.append(Package(package, aur=True))
|
||||||
log.warning(e)
|
|
||||||
|
return packages
|
||||||
|
|
||||||
|
|
||||||
|
def install_packages() -> None:
|
||||||
|
packages = obtain_packages()
|
||||||
|
Install.upgrade_pacman()
|
||||||
|
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)
|
||||||
|
|
Loading…
Reference in a new issue