diff --git a/anaconda.spec.in b/anaconda.spec.in index ded52e63d47..f09ab4475ed 100644 --- a/anaconda.spec.in +++ b/anaconda.spec.in @@ -21,7 +21,7 @@ Source0: %{name}-%{version}.tar.bz2 # Also update in AM_GNU_GETTEXT_VERSION in configure.ac %define gettextver 0.18.3 %define intltoolver 0.31.2-3 -%define pykickstartver 2.5 +%define pykickstartver 2.6 %define yumver 3.4.3-91 %define dnfver 0.6.4 %define partedver 1.8.1 diff --git a/pyanaconda/install.py b/pyanaconda/install.py index 937c77896aa..6356b648f05 100644 --- a/pyanaconda/install.py +++ b/pyanaconda/install.py @@ -33,6 +33,7 @@ from pyanaconda.i18n import _ from pyanaconda.threads import threadMgr from pyanaconda.ui.lib.entropy import wait_for_entropy +from pyanaconda.kickstart import runPostScripts, runPreInstallScripts import logging import blivet log = logging.getLogger("anaconda") @@ -55,8 +56,6 @@ def _writeKS(ksdata): iutil.eintr_retry_call(os.chmod, path, 0o600) def doConfiguration(storage, payload, ksdata, instClass): - from pyanaconda.kickstart import runPostScripts - willWriteNetwork = not flags.flags.imageInstall and not flags.flags.dirInstall willRunRealmd = ksdata.realm.discovered @@ -150,7 +149,7 @@ def doInstall(storage, payload, ksdata, instClass): # Update every 10% of packages installed. We don't know how many packages # we are installing until it's too late (see realmd later on) so this is # the best we can do. - steps += 10 + steps += 11 # pre setup phase, post install steps += 2 @@ -199,6 +198,10 @@ def doInstall(storage, payload, ksdata, instClass): if not write_storage_late and not flags.flags.dirInstall: storage.write() + # Run %pre-install scripts with the filesystem mounted and no packages + with progress_report(_("Running pre-installation scripts")): + runPreInstallScripts(ksdata.scripts) + # Do packaging. # Discover information about realms to join, diff --git a/pyanaconda/kickstart.py b/pyanaconda/kickstart.py index b5114dc359a..c7cc7ff2456 100644 --- a/pyanaconda/kickstart.py +++ b/pyanaconda/kickstart.py @@ -65,13 +65,13 @@ from pyanaconda.pwpolicy import F22_PwPolicy, F22_PwPolicyData from pykickstart.constants import CLEARPART_TYPE_NONE, FIRSTBOOT_SKIP, FIRSTBOOT_RECONFIG, KS_SCRIPT_POST, KS_SCRIPT_PRE, \ - KS_SCRIPT_TRACEBACK, SELINUX_DISABLED, SELINUX_ENFORCING, SELINUX_PERMISSIVE + KS_SCRIPT_TRACEBACK, KS_SCRIPT_PREINSTALL, SELINUX_DISABLED, SELINUX_ENFORCING, SELINUX_PERMISSIVE from pykickstart.base import BaseHandler from pykickstart.errors import formatErrorMsg, KickstartError, KickstartValueError from pykickstart.parser import KickstartParser from pykickstart.parser import Script as KSScript from pykickstart.sections import Section -from pykickstart.sections import NullSection, PackageSection, PostScriptSection, PreScriptSection, TracebackScriptSection +from pykickstart.sections import NullSection, PackageSection, PostScriptSection, PreScriptSection, PreInstallScriptSection, TracebackScriptSection from pykickstart.version import returnClassForVersion import logging @@ -2010,6 +2010,7 @@ def handleCommand(self, lineno, args): def setupSections(self): self.registerSection(PreScriptSection(self.handler, dataObj=AnacondaKSScript)) + self.registerSection(NullSection(self.handler, sectionOpen="%pre-install")) self.registerSection(NullSection(self.handler, sectionOpen="%post")) self.registerSection(NullSection(self.handler, sectionOpen="%traceback")) self.registerSection(NullSection(self.handler, sectionOpen="%packages")) @@ -2031,6 +2032,7 @@ def handleCommand(self, lineno, args): def setupSections(self): self.registerSection(PreScriptSection(self.handler, dataObj=self.scriptClass)) + self.registerSection(PreInstallScriptSection(self.handler, dataObj=self.scriptClass)) self.registerSection(PostScriptSection(self.handler, dataObj=self.scriptClass)) self.registerSection(TracebackScriptSection(self.handler, dataObj=self.scriptClass)) self.registerSection(PackageSection(self.handler)) @@ -2121,6 +2123,16 @@ def runPreScripts(scripts): log.info("All kickstart %%pre script(s) have been run") +def runPreInstallScripts(scripts): + preInstallScripts = [s for s in scripts if s.type == KS_SCRIPT_PREINSTALL] + + if len(preInstallScripts) == 0: + return + + log.info("Running kickstart %%pre-install script(s)") + map(lambda s: s.run("/"), preInstallScripts) + log.info("All kickstart %%pre-install script(s) have been run") + def runTracebackScripts(scripts): log.info("Running kickstart %%traceback script(s)") for script in filter(lambda s: s.type == KS_SCRIPT_TRACEBACK, scripts):