Added packages
This commit is contained in:
parent
92cab96c85
commit
8e641c0f97
1 changed files with 39 additions and 0 deletions
39
pastafariutils/packages.py
Normal file
39
pastafariutils/packages.py
Normal file
|
|
@ -0,0 +1,39 @@
|
||||||
|
#!/usr/bin/env python3
|
||||||
|
|
||||||
|
import distro
|
||||||
|
from subprocess import call, DEVNULL
|
||||||
|
|
||||||
|
def install_package(package: dict, extra_configurations={}):
|
||||||
|
|
||||||
|
"""A function for install packages for different distros. Now support, debian, ubuntu, rocky, almalinux, fedora, archlinux.
|
||||||
|
|
||||||
|
Args:
|
||||||
|
package (dict): A dict with all packages names for every distro.
|
||||||
|
|
||||||
|
Returns
|
||||||
|
|
||||||
|
result_package_manager (bool): return false if install fail, if install is finished, return true.
|
||||||
|
"""
|
||||||
|
|
||||||
|
linux_distro=distro.id()
|
||||||
|
|
||||||
|
if linux_distro=='debian' or linux_distro=='ubuntu':
|
||||||
|
|
||||||
|
if call('sudo DEBIAN_FRONTEND="noninteractive" apt-get install -y {}'.format(package[linux_distro]), shell=True) > 0:
|
||||||
|
print('Error, cannot install {}...'.format(package[linux_distro]))
|
||||||
|
return False
|
||||||
|
|
||||||
|
elif linux_distro=='rocky' or linux_distro=='fedora' or linux_distro=='almalinux':
|
||||||
|
|
||||||
|
if call("sudo dnf install -y {}", shell=True) > 0:
|
||||||
|
print('Error, cannot install {}...'.format(package[linux_distro]))
|
||||||
|
return False
|
||||||
|
if linux_distro=='arch':
|
||||||
|
|
||||||
|
if call("sudo pacman -S --noconfirm {}".format(package[linux_distro]), shell=True) > 0:
|
||||||
|
print('Error, cannot install {}...'.format(package[linux_distro]))
|
||||||
|
exit(1)
|
||||||
|
|
||||||
|
def change_config_file(config_file: dict):
|
||||||
|
|
||||||
|
pass
|
||||||
Loading…
Add table
Add a link
Reference in a new issue