mirror of
				https://github.com/ItsDrike/dotfiles.git
				synced 2025-11-04 01:16:35 +00:00 
			
		
		
		
	Add package installation
This commit is contained in:
		
							parent
							
								
									026ab5a354
								
							
						
					
					
						commit
						d1ec6091b8
					
				
					 2 changed files with 36 additions and 0 deletions
				
			
		
							
								
								
									
										8
									
								
								packages.yaml
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										8
									
								
								packages.yaml
									
										
									
									
									
										Normal file
									
								
							| 
						 | 
					@ -0,0 +1,8 @@
 | 
				
			||||||
 | 
					pacman:
 | 
				
			||||||
 | 
					    - vim
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					aur:
 | 
				
			||||||
 | 
					    - spotify
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					git:
 | 
				
			||||||
 | 
					    - https://aur.archlinux.org/yay-git.git
 | 
				
			||||||
							
								
								
									
										28
									
								
								src/packages.py
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										28
									
								
								src/packages.py
									
										
									
									
									
										Normal 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)
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue