FAQ Search Today's Posts Mark Forums Read
» Video Reviews

» Linux Archive

Linux-archive is a website aiming to archive linux email lists and to make them easily accessible for linux users/developers.


» Sponsor

» Partners

» Sponsor

Go Back   Linux Archive > ArchLinux > ArchLinux Development

 
 
LinkBack Thread Tools
 
Old 10-04-2011, 12:18 AM
"Brian C. Lane"
 
Default copy kickstarts into sysroot (#743135)

From: "Brian C. Lane" <bcl@redhat.com>

The installer no longer has access to the initrd's root. We need to
copy any needed files over to /sysroot before switching root. This
copies *.cfg and *.ks files.
---
src/pylorax/installtree.py | 11 +++++++++++
1 files changed, 11 insertions(+), 0 deletions(-)

diff --git a/src/pylorax/installtree.py b/src/pylorax/installtree.py
index eaea98b..58c1503 100644
--- a/src/pylorax/installtree.py
+++ b/src/pylorax/installtree.py
@@ -546,13 +546,24 @@ class LoraxInstallTree(BaseLoraxClass):
logger.debug("compressing")
rc = compressed.wait()

+ def write_copy_ks(self, fname):
+ """ Write pre-pivot script to copy kickstarts into /sysroot/
+ """
+ with open(fname, "w") as f:
+ f.write("#!/bin/sh
"
+ "cp /*ks /*cfg /sysroot/ 2> /dev/null
")
+
def make_dracut_initramfs(self):
for kernel in self.kernels:
+ copy_ks = "/tmp/99anaconda-copy-ks.sh"
+ self.write_copy_ks(joinpaths(self.root, copy_ks))
+
outfile = "/tmp/initramfs.img" # inside the chroot
logger.debug("chrooting into installtree to create initramfs.img")
subprocess.check_call(["chroot", self.root, "/sbin/dracut",
"--noprefix", "--nomdadmconf", "--nolvmconf",
"--xz", "--modules", "base dmsquash-live",
+ "--include", copy_ks, "/lib/dracut/hooks/pre-pivot",
outfile, kernel.version])
# move output file into installtree workdir
dstdir = joinpaths(self.workdir, "dracut-%s" % kernel.version)
--
1.7.6

_______________________________________________
Anaconda-devel-list mailing list
Anaconda-devel-list@redhat.com
https://www.redhat.com/mailman/listinfo/anaconda-devel-list
 
Old 10-04-2011, 06:45 AM
Martin Gracik
 
Default copy kickstarts into sysroot (#743135)

Hi,

everything looks fine, but wouldn't it be better to have the
99anaconda-copy-ks.sh script somewhere in the share dir, and just copy
it to the installroot, instead of writing it out?

On Mon, 2011-10-03 at 17:18 -0700, Brian C. Lane wrote:
> From: "Brian C. Lane" <bcl@redhat.com>
>
> The installer no longer has access to the initrd's root. We need to
> copy any needed files over to /sysroot before switching root. This
> copies *.cfg and *.ks files.
> ---
> src/pylorax/installtree.py | 11 +++++++++++
> 1 files changed, 11 insertions(+), 0 deletions(-)
>
> diff --git a/src/pylorax/installtree.py b/src/pylorax/installtree.py
> index eaea98b..58c1503 100644
> --- a/src/pylorax/installtree.py
> +++ b/src/pylorax/installtree.py
> @@ -546,13 +546,24 @@ class LoraxInstallTree(BaseLoraxClass):
> logger.debug("compressing")
> rc = compressed.wait()
>
> + def write_copy_ks(self, fname):
> + """ Write pre-pivot script to copy kickstarts into /sysroot/
> + """
> + with open(fname, "w") as f:
> + f.write("#!/bin/sh
"
> + "cp /*ks /*cfg /sysroot/ 2> /dev/null
")
> +
> def make_dracut_initramfs(self):
> for kernel in self.kernels:
> + copy_ks = "/tmp/99anaconda-copy-ks.sh"
> + self.write_copy_ks(joinpaths(self.root, copy_ks))
> +
> outfile = "/tmp/initramfs.img" # inside the chroot
> logger.debug("chrooting into installtree to create initramfs.img")
> subprocess.check_call(["chroot", self.root, "/sbin/dracut",
> "--noprefix", "--nomdadmconf", "--nolvmconf",
> "--xz", "--modules", "base dmsquash-live",
> + "--include", copy_ks, "/lib/dracut/hooks/pre-pivot",
> outfile, kernel.version])
> # move output file into installtree workdir
> dstdir = joinpaths(self.workdir, "dracut-%s" % kernel.version)

--
Martin Gracik <mgracik@redhat.com>

_______________________________________________
Anaconda-devel-list mailing list
Anaconda-devel-list@redhat.com
https://www.redhat.com/mailman/listinfo/anaconda-devel-list
 
Old 10-04-2011, 10:08 PM
"Brian C. Lane"
 
Default copy kickstarts into sysroot (#743135)

From: "Brian C. Lane" <bcl@redhat.com>

The installer no longer has access to the initrd's root. We need to
copy any needed files over to /sysroot before switching root. This
copies *.cfg and *.ks files.

It also adds the ability to add dracut hook scripts to the initramfs
from /usr/share/lorax/dracut_hooks/
---
share/dracut_hooks/99anaconda-copy-ks.sh | 4 ++
src/pylorax/__init__.py | 3 +-
src/pylorax/installtree.py | 46 ++++++++++++++++++++++++++++--
3 files changed, 49 insertions(+), 4 deletions(-)
create mode 100755 share/dracut_hooks/99anaconda-copy-ks.sh

diff --git a/share/dracut_hooks/99anaconda-copy-ks.sh b/share/dracut_hooks/99anaconda-copy-ks.sh
new file mode 100755
index 0000000..ed52088
--- /dev/null
+++ b/share/dracut_hooks/99anaconda-copy-ks.sh
@@ -0,0 +1,4 @@
+#!/bin/sh
+# Copy over kickstart files from the initrd to the sysroot before pivot
+cp /*cfg /*ks /sysroot/ 2> /dev/null
+
diff --git a/src/pylorax/__init__.py b/src/pylorax/__init__.py
index 8eb6c7f..ff14b4f 100644
--- a/src/pylorax/__init__.py
+++ b/src/pylorax/__init__.py
@@ -203,7 +203,8 @@ class Lorax(BaseLoraxClass):
# set up install tree
logger.info("setting up install tree")
self.installtree = LoraxInstallTree(self.yum, self.basearch,
- self.libdir, self.workdir)
+ self.libdir, self.workdir,
+ self.conf)

# set up required build parameters
logger.info("setting up build parameters")
diff --git a/src/pylorax/installtree.py b/src/pylorax/installtree.py
index eaea98b..88fa671 100644
--- a/src/pylorax/installtree.py
+++ b/src/pylorax/installtree.py
@@ -39,7 +39,7 @@ from sysutils import *

class LoraxInstallTree(BaseLoraxClass):

- def __init__(self, yum, basearch, libdir, workdir):
+ def __init__(self, yum, basearch, libdir, workdir, conf=None):
BaseLoraxClass.__init__(self)
self.yum = yum
self.root = self.yum.installroot
@@ -47,9 +47,45 @@ class LoraxInstallTree(BaseLoraxClass):
self.libdir = libdir
self.workdir = workdir
self.initramfs = {}
+ self.conf = conf

self.lcmds = constants.LoraxRequiredCommands()

+ @property
+ def dracut_hooks_path(self):
+ """ Return the path to the lorax dracut hooks scripts
+
+ Use the configured share dir if it is setup,
+ otherwise default to /usr/share/lorax/dracut_hooks
+ """
+ if self.conf:
+ return joinpaths( self.conf.get("lorax", "sharedir"),
+ "dracut_hooks")
+ else:
+ return "/usr/share/lorax/dracut_hooks"
+
+ def copy_dracut_hooks(self, hooks):
+ """ Copy the hook scripts in hooks into the installroot's /tmp/
+ and return a list of commands to pass to dracut when creating the
+ initramfs
+
+ hooks is a list of tuples with the name of the hook script and the
+ target dracut hook directory
+ (eg. [ ("99anaconda-copy-ks.sh", "/lib/dracut/hooks/pre-pivot") ] )
+ """
+ dracut_commands = []
+ for hook_script, dracut_path in hooks:
+ src = joinpaths( self.dracut_hooks_path, hook_script )
+ if not os.path.exists( src ):
+ logger.error( "Missing lorax dracut hook script %s" % (src) )
+ continue
+ dst = joinpaths( self.root, "/tmp/", hook_script )
+ shutil.copy2( src, dst )
+ dracut_commands += ["--include", joinpaths( "/tmp/", hook_script ),
+ dracut_path]
+
+ return dracut_commands
+
def remove_locales(self):
chroot = lambda: os.chroot(self.root)

@@ -548,12 +584,16 @@ class LoraxInstallTree(BaseLoraxClass):

def make_dracut_initramfs(self):
for kernel in self.kernels:
+ hooks = [ ("99anaconda-copy-ks.sh", "/lib/dracut/hooks/pre-pivot") ]
+ hook_commands = self.copy_dracut_hooks(hooks)
+
outfile = "/tmp/initramfs.img" # inside the chroot
logger.debug("chrooting into installtree to create initramfs.img")
subprocess.check_call(["chroot", self.root, "/sbin/dracut",
"--noprefix", "--nomdadmconf", "--nolvmconf",
- "--xz", "--modules", "base dmsquash-live",
- outfile, kernel.version])
+ "--xz", "--modules", "base dmsquash-live"]
+ + hook_commands
+ + [outfile, kernel.version])
# move output file into installtree workdir
dstdir = joinpaths(self.workdir, "dracut-%s" % kernel.version)
os.makedirs(dstdir)
--
1.7.6

_______________________________________________
Anaconda-devel-list mailing list
Anaconda-devel-list@redhat.com
https://www.redhat.com/mailman/listinfo/anaconda-devel-list
 
Old 10-05-2011, 07:13 AM
Martin Gracik
 
Default copy kickstarts into sysroot (#743135)

Hi,

This looks OK, but could you just loose those spaces between braces?

like here:

dst = joinpaths( self.root, "/tmp/", hook_script )

I don't want to be a pain in the ass, just trying to be consistent.

Thanks.


On Tue, 2011-10-04 at 15:08 -0700, Brian C. Lane wrote:
> From: "Brian C. Lane" <bcl@redhat.com>
>
> The installer no longer has access to the initrd's root. We need to
> copy any needed files over to /sysroot before switching root. This
> copies *.cfg and *.ks files.
>
> It also adds the ability to add dracut hook scripts to the initramfs
> from /usr/share/lorax/dracut_hooks/
> ---
> share/dracut_hooks/99anaconda-copy-ks.sh | 4 ++
> src/pylorax/__init__.py | 3 +-
> src/pylorax/installtree.py | 46 ++++++++++++++++++++++++++++--
> 3 files changed, 49 insertions(+), 4 deletions(-)
> create mode 100755 share/dracut_hooks/99anaconda-copy-ks.sh
>
> diff --git a/share/dracut_hooks/99anaconda-copy-ks.sh b/share/dracut_hooks/99anaconda-copy-ks.sh
> new file mode 100755
> index 0000000..ed52088
> --- /dev/null
> +++ b/share/dracut_hooks/99anaconda-copy-ks.sh
> @@ -0,0 +1,4 @@
> +#!/bin/sh
> +# Copy over kickstart files from the initrd to the sysroot before pivot
> +cp /*cfg /*ks /sysroot/ 2> /dev/null
> +
> diff --git a/src/pylorax/__init__.py b/src/pylorax/__init__.py
> index 8eb6c7f..ff14b4f 100644
> --- a/src/pylorax/__init__.py
> +++ b/src/pylorax/__init__.py
> @@ -203,7 +203,8 @@ class Lorax(BaseLoraxClass):
> # set up install tree
> logger.info("setting up install tree")
> self.installtree = LoraxInstallTree(self.yum, self.basearch,
> - self.libdir, self.workdir)
> + self.libdir, self.workdir,
> + self.conf)
>
> # set up required build parameters
> logger.info("setting up build parameters")
> diff --git a/src/pylorax/installtree.py b/src/pylorax/installtree.py
> index eaea98b..88fa671 100644
> --- a/src/pylorax/installtree.py
> +++ b/src/pylorax/installtree.py
> @@ -39,7 +39,7 @@ from sysutils import *
>
> class LoraxInstallTree(BaseLoraxClass):
>
> - def __init__(self, yum, basearch, libdir, workdir):
> + def __init__(self, yum, basearch, libdir, workdir, conf=None):
> BaseLoraxClass.__init__(self)
> self.yum = yum
> self.root = self.yum.installroot
> @@ -47,9 +47,45 @@ class LoraxInstallTree(BaseLoraxClass):
> self.libdir = libdir
> self.workdir = workdir
> self.initramfs = {}
> + self.conf = conf
>
> self.lcmds = constants.LoraxRequiredCommands()
>
> + @property
> + def dracut_hooks_path(self):
> + """ Return the path to the lorax dracut hooks scripts
> +
> + Use the configured share dir if it is setup,
> + otherwise default to /usr/share/lorax/dracut_hooks
> + """
> + if self.conf:
> + return joinpaths( self.conf.get("lorax", "sharedir"),
> + "dracut_hooks")
> + else:
> + return "/usr/share/lorax/dracut_hooks"
> +
> + def copy_dracut_hooks(self, hooks):
> + """ Copy the hook scripts in hooks into the installroot's /tmp/
> + and return a list of commands to pass to dracut when creating the
> + initramfs
> +
> + hooks is a list of tuples with the name of the hook script and the
> + target dracut hook directory
> + (eg. [ ("99anaconda-copy-ks.sh", "/lib/dracut/hooks/pre-pivot") ] )
> + """
> + dracut_commands = []
> + for hook_script, dracut_path in hooks:
> + src = joinpaths( self.dracut_hooks_path, hook_script )
> + if not os.path.exists( src ):
> + logger.error( "Missing lorax dracut hook script %s" % (src) )
> + continue
> + dst = joinpaths( self.root, "/tmp/", hook_script )
> + shutil.copy2( src, dst )
> + dracut_commands += ["--include", joinpaths( "/tmp/", hook_script ),
> + dracut_path]
> +
> + return dracut_commands
> +
> def remove_locales(self):
> chroot = lambda: os.chroot(self.root)
>
> @@ -548,12 +584,16 @@ class LoraxInstallTree(BaseLoraxClass):
>
> def make_dracut_initramfs(self):
> for kernel in self.kernels:
> + hooks = [ ("99anaconda-copy-ks.sh", "/lib/dracut/hooks/pre-pivot") ]
> + hook_commands = self.copy_dracut_hooks(hooks)
> +
> outfile = "/tmp/initramfs.img" # inside the chroot
> logger.debug("chrooting into installtree to create initramfs.img")
> subprocess.check_call(["chroot", self.root, "/sbin/dracut",
> "--noprefix", "--nomdadmconf", "--nolvmconf",
> - "--xz", "--modules", "base dmsquash-live",
> - outfile, kernel.version])
> + "--xz", "--modules", "base dmsquash-live"]
> + + hook_commands
> + + [outfile, kernel.version])
> # move output file into installtree workdir
> dstdir = joinpaths(self.workdir, "dracut-%s" % kernel.version)
> os.makedirs(dstdir)

--
Martin Gracik <mgracik@redhat.com>

_______________________________________________
Anaconda-devel-list mailing list
Anaconda-devel-list@redhat.com
https://www.redhat.com/mailman/listinfo/anaconda-devel-list
 
Old 10-05-2011, 04:11 PM
"Brian C. Lane"
 
Default copy kickstarts into sysroot (#743135)

On Wed, Oct 05, 2011 at 09:13:32AM +0200, Martin Gracik wrote:
> Hi,
>
> This looks OK, but could you just loose those spaces between braces?
>
> like here:
>
> dst = joinpaths( self.root, "/tmp/", hook_script )
>
> I don't want to be a pain in the ass, just trying to be consistent.

Will do.

--
Brian C. Lane | Anaconda Team | IRC: bcl #anaconda | Port Orchard, WA (PST8PDT)
_______________________________________________
Anaconda-devel-list mailing list
Anaconda-devel-list@redhat.com
https://www.redhat.com/mailman/listinfo/anaconda-devel-list
 

Thread Tools




All times are GMT. The time now is 05:12 AM.

VBulletin, Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2007, Crawlability, Inc.
Copyright 2007 - 2008, www.linux-archive.org