added support for pre- and post-install scripts
This commit is contained in:
parent
582e4ec744
commit
d465617432
@ -22,7 +22,7 @@
|
|||||||
import subprocess
|
import subprocess
|
||||||
import libcalamares
|
import libcalamares
|
||||||
from libcalamares.utils import check_target_env_call, target_env_call
|
from libcalamares.utils import check_target_env_call, target_env_call
|
||||||
from string import Template
|
|
||||||
|
|
||||||
class PackageManager:
|
class PackageManager:
|
||||||
""" Package manager class.
|
""" Package manager class.
|
||||||
@ -109,20 +109,10 @@ class PackageManager:
|
|||||||
elif self.backend == "entropy":
|
elif self.backend == "entropy":
|
||||||
check_target_env_call(["equo", "update"])
|
check_target_env_call(["equo", "update"])
|
||||||
|
|
||||||
|
def run(self, script):
|
||||||
|
if script != "":
|
||||||
|
check_target_env_call(script.split(" "))
|
||||||
|
|
||||||
def subst_locale(list):
|
|
||||||
ret = []
|
|
||||||
locale = libcalamares.globalstorage.value("locale")
|
|
||||||
if locale:
|
|
||||||
for e in list:
|
|
||||||
if locale != "en":
|
|
||||||
entry = Template(e)
|
|
||||||
ret.append(entry.safe_substitute(LOCALE=locale))
|
|
||||||
elif 'LOCALE' not in e:
|
|
||||||
ret.append(e)
|
|
||||||
else:
|
|
||||||
ret = list
|
|
||||||
return ret
|
|
||||||
|
|
||||||
def run_operations(pkgman, entry):
|
def run_operations(pkgman, entry):
|
||||||
""" Call package manager with given parameters.
|
""" Call package manager with given parameters.
|
||||||
@ -131,17 +121,30 @@ def run_operations(pkgman, entry):
|
|||||||
:param entry:
|
:param entry:
|
||||||
"""
|
"""
|
||||||
for key in entry.keys():
|
for key in entry.keys():
|
||||||
entry[key] = subst_locale(entry[key])
|
|
||||||
if key == "install":
|
if key == "install":
|
||||||
|
if isinstance(package, str):
|
||||||
pkgman.install(entry[key])
|
pkgman.install(entry[key])
|
||||||
|
else:
|
||||||
|
for package in entry[key]:
|
||||||
|
pkgman.run(package["pre-script"])
|
||||||
|
pkgman.install([package["package"]])
|
||||||
|
pkgman.run(package["post-script"])
|
||||||
elif key == "try_install":
|
elif key == "try_install":
|
||||||
# we make a separate package manager call for each package so a single
|
# we make a separate package manager call for each package so a single
|
||||||
# failing package won't stop all of them
|
# failing package won't stop all of them
|
||||||
for package in entry[key]:
|
for package in entry[key]:
|
||||||
|
if isinstance(package, str):
|
||||||
try:
|
try:
|
||||||
pkgman.install([package])
|
pkgman.install([package])
|
||||||
except subprocess.CalledProcessError:
|
except subprocess.CalledProcessError:
|
||||||
libcalamares.utils.debug("WARNING: could not install package {}".format(package))
|
libcalamares.utils.debug("WARNING: could not install package {}".format(package))
|
||||||
|
else:
|
||||||
|
try:
|
||||||
|
pkgman.run(package["pre-script"])
|
||||||
|
pkgman.install([package["package"]])
|
||||||
|
pkgman.run(package["post-script"])
|
||||||
|
except subprocess.CalledProcessError:
|
||||||
|
libcalamares.utils.debug("WARNING: could not install packages {}", package["package"])
|
||||||
elif key == "remove":
|
elif key == "remove":
|
||||||
pkgman.remove(entry[key])
|
pkgman.remove(entry[key])
|
||||||
elif key == "try_remove":
|
elif key == "try_remove":
|
||||||
|
Loading…
Reference in New Issue
Block a user