[Fedora-livecd-list] pre-install scripts and syslinux
David Straub
dms5074 at psu.edu
Thu Nov 13 14:15:45 UTC 2008
On Wed, Nov 12, 2008 10:34 PM Jeremy Katz <katzj at redhat.com> wrote:
>The main reason has been that there are ... interesting questions about
>the environment it should run in. What are you using them for and maybe
>that's enough to talk me into it :-)
Since pykickstart already handles pre-install scripts, I pretty much just
copied the imgcreate functions that deal with the post-install scripts for
consistency. I suppose this is the important function:
> def __run_pre_scripts(self):
> for s in kickstart.get_pre_scripts(self.ks):
> (fd, path) = tempfile.mkstemp(prefix = "ks-script-",
> dir = "/tmp")
>
> os.write(fd, s.script)
> os.close(fd)
> os.chmod(path, 0700)
>
> env = self._get_pre_scripts_env(s.inChroot)
>
> env["INSTALL_ROOT"] = self._instroot
> preexec = None
> script = path
>
> try:
> subprocess.call([s.interp, script],
> preexec_fn = preexec, env = env)
> except OSError, (err, msg):
> raise CreatorError("Failed to execute %%pre script "
> "with '%s' : %s" % (s.interp, msg))
> finally:
> os.unlink(path)
>
I have this called as the first action in the install function, just before
yum runs. I think the only changes I made to this from the post function are
that I removed the chroot conditional (since %pre is always --nochroot), and
that it writes the temporary script files to the system's /tmp rather than the
image's /tmp (since it doesn't exist at this point).
What were the concerns regarding the environment? All I needed was the
ability to get at a shell in the install image before yum is called, which is
all that does.
Thanks,
Dave
More information about the Fedora-livecd-list
mailing list