Exemplo n.º 1
0
    def create_runtime(self,
                       outfile="/var/tmp/squashfs.img",
                       compression="xz",
                       compressargs=[],
                       size=2):
        # make live rootfs image - must be named "LiveOS/rootfs.img" for dracut
        workdir = joinpaths(os.path.dirname(outfile), "runtime-workdir")
        if size:
            fssize = size * (1024 * 1024 * 1024
                             )  # 2GB sparse file compresses down to nothin'
        else:
            fssize = None  # Let mkext4img figure out the needed size
        os.makedirs(joinpaths(workdir, "LiveOS"))
        imgutils.mkext4img(self.vars.root,
                           joinpaths(workdir, "LiveOS/rootfs.img"),
                           label="Anaconda",
                           size=fssize)

        # Reset selinux context on new rootfs
        with imgutils.LoopDev(joinpaths(workdir,
                                        "LiveOS/rootfs.img")) as loopdev:
            with imgutils.Mount(loopdev) as mnt:
                cmd = [
                    "setfiles", "-e", "/proc", "-e", "/sys", "-e", "/dev",
                    "/etc/selinux/targeted/contexts/files/file_contexts", "/"
                ]
                runcmd(cmd, root=mnt)

        # squash the live rootfs and clean up workdir
        imgutils.mksquashfs(workdir, outfile, compression, compressargs)
        remove(workdir)
Exemplo n.º 2
0
 def postinstall(self):
     '''Do some post-install setup work with runtime-postinstall.tmpl'''
     # copy configdir into runtime root beforehand
     configdir = joinpaths(self._runner.templatedir,"config_files")
     configdir_path = "tmp/config_files"
     fullpath = joinpaths(self.vars.root, configdir_path)
     if os.path.exists(fullpath):
         remove(fullpath)
     copytree(configdir, fullpath)
     self._runner.run("runtime-postinstall.tmpl", configdir=configdir_path)
Exemplo n.º 3
0
 def postinstall(self):
     '''Do some post-install setup work with runtime-postinstall.tmpl'''
     # copy configdir into runtime root beforehand
     configdir = joinpaths(self._runner.templatedir, "config_files")
     configdir_path = "tmp/config_files"
     fullpath = joinpaths(self.vars.root, configdir_path)
     if os.path.exists(fullpath):
         remove(fullpath)
     copytree(configdir, fullpath)
     self._runner.run("runtime-postinstall.tmpl", configdir=configdir_path)
Exemplo n.º 4
0
Arquivo: ltmpl.py Projeto: joy01/clip
 def remove(self, *fileglobs):
     '''
     remove FILEGLOB [FILEGLOB ...]
       Remove all the named files or directories.
       Will *not* raise exceptions if the file(s) are not found.
     '''
     for g in fileglobs:
         for f in rglob(self._out(g)):
             remove(f)
             logger.debug("removed %s", f)
Exemplo n.º 5
0
 def remove(self, *fileglobs):
     '''
     remove FILEGLOB [FILEGLOB ...]
       Remove all the named files or directories.
       Will *not* raise exceptions if the file(s) are not found.
     '''
     for g in fileglobs:
         for f in rglob(self._out(g)):
             remove(f)
             logger.debug("removed %s", f)
Exemplo n.º 6
0
    def create_runtime(self, outfile="/var/tmp/squashfs.img", compression="xz", compressargs=[], size=2):
        # make live rootfs image - must be named "LiveOS/rootfs.img" for dracut
        workdir = joinpaths(os.path.dirname(outfile), "runtime-workdir")
        os.makedirs(joinpaths(workdir, "LiveOS"))

        imgutils.mkrootfsimg(self.vars.root, joinpaths(workdir, "LiveOS/rootfs.img"),
                             "Anaconda", size=size)

        # squash the live rootfs and clean up workdir
        imgutils.mksquashfs(workdir, outfile, compression, compressargs)
        remove(workdir)
Exemplo n.º 7
0
    def create_runtime(self, outfile="/var/tmp/squashfs.img", compression="xz", compressargs=[], size=2):
        # make live rootfs image - must be named "LiveOS/rootfs.img" for dracut
        workdir = joinpaths(os.path.dirname(outfile), "runtime-workdir")
        os.makedirs(joinpaths(workdir, "LiveOS"))

        imgutils.mkrootfsimg(self.vars.root, joinpaths(workdir, "LiveOS/rootfs.img"),
                             "Anaconda", size=size)

        # squash the live rootfs and clean up workdir
        imgutils.mksquashfs(workdir, outfile, compression, compressargs)
        remove(workdir)
Exemplo n.º 8
0
    def create_runtime(self, outfile="/var/tmp/squashfs.img", compression="xz", compressargs=[], size=2):
        # make live rootfs image - must be named "LiveOS/rootfs.img" for dracut
        workdir = joinpaths(os.path.dirname(outfile), "runtime-workdir")
        if size:
            fssize = size * (1024*1024*1024) # 2GB sparse file compresses down to nothin'
        else:
            fssize = None       # Let mkext4img figure out the needed size
        os.makedirs(joinpaths(workdir, "LiveOS"))
        imgutils.mkext4img(self.vars.root, joinpaths(workdir, "LiveOS/rootfs.img"),
                           label="Anaconda", size=fssize)

        # Reset selinux context on new rootfs
        with imgutils.LoopDev( joinpaths(workdir, "LiveOS/rootfs.img") ) as loopdev:
            with imgutils.Mount(loopdev) as mnt:
                cmd = [ "setfiles", "-e", "/proc", "-e", "/sys", "-e", "/dev",  "/etc/selinux/targeted/contexts/files/file_contexts", "/"]
                runcmd(cmd, root=mnt)

        # squash the live rootfs and clean up workdir
        imgutils.mksquashfs(workdir, outfile, compression, compressargs)
        remove(workdir)