Ejemplo n.º 1
0
    def post_conf(self, inhibitor_state):
        if self.conf.has('seed'):
            self.seed = self.conf.seed

        if self.conf.has('fs_add'):
            self.conf.fs_add.keep = True
            self.conf.fs_add.dest = util.Path('/')
            self.stage_sources.append(self.conf.fs_add)

        baselayout     = source.create_source(
            src = 'file://%s/early-userspace/root' % inhibitor_state.paths.share,
            keep = True,
            dest = util.Path('/')
        )
        self.stage_sources.append(baselayout)

        for src in self.stage_sources:
            src.post_conf(inhibitor_state)
            src.init()

        super(EmbeddedStage, self).post_conf(inhibitor_state)
        self.moduledir      = self.istate.paths.share.pjoin('early-userspace/modules')
        self.tarpath        = self.istate.paths.stages.pjoin('%s/image.tar.bz2' % (self.build_name,))
        self.cpiopath       = self.istate.paths.stages.pjoin('%s/initramfs.gz' % (self.build_name,))
        self.kernlinkpath   = self.istate.paths.stages.pjoin('%s/kernel' % (self.build_name,))

        if self.conf.has('files'):
            self.files = util.strlist_to_list(self.conf.files)

        if self.conf.has('package_list'):
            self.package_list = util.strlist_to_list(self.conf.package_list)

        if self.conf.has('modules'):
            self.modules = self.conf.modules

        for m in self.modules:
            need_file   = self.moduledir.pjoin('%s.files' % m)
            pkg_file    = self.moduledir.pjoin('%s.pkgs' % m)
            if os.path.lexists(need_file):
                f = open(need_file)
                for l in f.readlines():
                    self.files.append(l.strip())
                    util.dbg('Adding path %s for %s' % (l.strip(), m))
                f.close()
            if os.path.lexists(pkg_file):
                f = open(pkg_file)
                for l in f.readlines():
                    self.package_list.append(l.strip())
                    util.dbg('Adding package %s for %s' % (l.strip(), m))
                f.close()
Ejemplo n.º 2
0
    def post_conf_begin(self, inhibitor_state):
        super(BaseStage, self).post_conf(inhibitor_state)
        self.target_root = self.istate.paths.build.pjoin(self.build_name)
        self.tarpath = self.istate.paths.stages.pjoin(self.build_name + ".tar.bz2")
        util.mkdir(self.target_root)
        if self.seed:
            self.seed = self.istate.paths.stages.pjoin(self.seed)

        self.aux_mounts = {
            "proc": util.Mount("/proc", "/proc", self.target_root),
            "sys": util.Mount("/sys", "/sys", self.target_root),
            "dev": util.Mount("/dev", "/dev", self.target_root),
            "devpts": util.Mount("/dev/pts", "/dev/pts", self.target_root),
        }
        self.aux_sources = {
            "resolv.conf": source.create_source("file://etc/resolv.conf", keep=True, dest="/etc/resolv.conf"),
            "hosts": source.create_source("file://etc/hosts", keep=True, dest="/etc/hosts"),
        }

        for i in glob.iglob(self.istate.paths.share.pjoin("*.sh")):
            j = source.create_source(
                "file://%s" % i, keep=False, dest=self.env["INHIBITOR_SCRIPT_ROOT"] + "/" + os.path.basename(i)
            )
            self.sources.append(j)

        if self.conf.has("fs_sources"):
            if not type(self.conf.fs_sources) in (types.ListType, types.TupleType):
                self.conf.fs_sources = [self.conf.fs_sources]

            for src in self.conf.fs_sources:
                if not src.dest:
                    util.warn("Setting dest for %s to '/'" % (src.src,))
                    src.dest = util.Path("/")
                if src.mountable and src.dest == util.Path("/"):
                    util.warn("Setting mountable=False on %s" % (src.src,))
                    src.mountable = False
                self.sources.append(src)
Ejemplo n.º 3
0
    def post_conf(self, inhibitor_state):
        super(BaseGentooStage, self).post_conf(inhibitor_state, run_finish=False)
        if not self.pkgcache:
            self.pkgcache = source.create_source(
                "file://%s" % util.mkdir(self.istate.paths.pkgs.pjoin(self.build_name))
            )
        self.pkgcache.keep = False
        self.pkgcache.dest = self.env["PKGDIR"]
        self.sources.append(self.pkgcache)

        distcache = source.create_source(
            "file://%s" % util.mkdir(self.istate.paths.dist), keep=False, dest=self.env["DISTDIR"]
        )
        self.sources.append(distcache)

        if self.conf.has("kernel"):
            self.kernel = self.conf.kernel
            if not self.kernel.has("kconfig"):
                raise util.InhibitorError("No kernel config (kconfig) specified.")
            else:
                self.kernel.kconfig.keep = False
                self.kernel.kconfig.dest = util.Path("/tmp/inhibitor/kconfig")
                self.kernel.kconfig.post_conf(inhibitor_state)
                self.sources.append(self.kernel.kconfig)
            if not self.kernel.has("kernel_pkg"):
                raise util.InhibitorError("No kernel package (kernel_pkg) specified.")

            kerncache = source.create_source(
                "file://%s" % util.mkdir(inhibitor_state.paths.kernel.pjoin(self.build_name)),
                keep=False,
                dest="/tmp/inhibitor/kerncache",
            )
            self.sources.append(kerncache)

        if self.conf.has("snapshot"):
            self.conf.snapshot.keep = False
            self.conf.snapshot.dest = util.Path(self.env["PORTDIR"])
            self.sources.append(self.conf.snapshot)
        else:
            _, portdir = util.cmd_out("portageq portdir", raise_exception=True)
            self.sources.append(
                source.create_source("file://" + portdir, keep=False, dest=util.Path(self.env["PORTDIR"]))
            )

        if self.conf.has("overlays"):
            i = 0
            for overlay in self.conf.overlays:
                overlay.keep = False
                overlay.dest = util.Path("/tmp/inhibitor/overlays/%d" % i)
                self.sources.append(overlay)
                self.env["PORTDIR_OVERLAY"] += " /tmp/inhibitor/overlays/%d" % i
                i += 1

        if self.conf.has("profile"):
            self.profile = self.conf.profile
        else:
            self.profile = os.readlink("/etc/make.profile")
            self.profile = re.sub(".*/profiles/", "", self.profile)

        if self.conf.has("make_conf"):
            mc = self.conf.make_conf
        else:
            mc = source.create_source(make_conf_source, source="/etc/make.conf")
        mc.dest = self.portage_cr.pjoin("etc/make.conf")
        mc.keep = True
        self.sources.append(mc)

        if self.conf.has("portage_conf"):
            self.conf.portage_conf.dest = self.portage_cr.pjoin("etc/portage")
            self.conf.portage_conf.keep = True
            self.sources.append(self.conf.portage_conf)

        self.post_conf_finish()