예제 #1
0
파일: creator.py 프로젝트: linearlog1/poky
    def postoptparse(self, options):
        abspath = lambda pth: os.path.abspath(os.path.expanduser(pth))

        if options.verbose:
            msger.set_loglevel('verbose')
        if options.debug:
            msger.set_loglevel('debug')

        if options.logfile:
            logfile_abs_path = abspath(options.logfile)
            if os.path.isdir(logfile_abs_path):
                raise errors.Usage("logfile's path %s should be file" %
                                   options.logfile)
            if not os.path.exists(os.path.dirname(logfile_abs_path)):
                os.makedirs(os.path.dirname(logfile_abs_path))
            msger.set_interactive(False)
            msger.set_logfile(logfile_abs_path)
            configmgr.create['logfile'] = options.logfile

        if options.config:
            configmgr.reset()
            configmgr._siteconf = options.config

        if options.outdir is not None:
            configmgr.create['outdir'] = abspath(options.outdir)

        cdir = 'outdir'
        if os.path.exists(configmgr.create[cdir]) \
           and not os.path.isdir(configmgr.create[cdir]):
            msger.error('Invalid directory specified: %s' \
                        % configmgr.create[cdir])

        if options.enabletmpfs:
            configmgr.create['enabletmpfs'] = options.enabletmpfs
예제 #2
0
    def do_create(cls, opts, *args):
        """
        Create direct image, called from creator as 'direct' cmd
        """
        if len(args) != 8:
            raise errors.Usage("Extra arguments given")

        native_sysroot = args[0]
        kernel_dir = args[1]
        bootimg_dir = args[2]
        rootfs_dir = args[3]

        creatoropts = configmgr.create
        ksconf = args[4]

        image_output_dir = args[5]
        oe_builddir = args[6]
        compressor = args[7]

        krootfs_dir = cls.__rootfs_dir_to_dict(rootfs_dir)

        configmgr._ksconf = ksconf

        creator = direct.DirectImageCreator(oe_builddir,
                                            image_output_dir,
                                            krootfs_dir,
                                            bootimg_dir,
                                            kernel_dir,
                                            native_sysroot,
                                            compressor,
                                            creatoropts,
                                            opts.bmap)

        try:
            creator.create()
            creator.assemble()
            creator.finalize()
            creator.print_outimage_info()

        except errors.CreatorError:
            raise
        finally:
            creator.cleanup()

        return 0
예제 #3
0
    def do_create(self, subcmd, opts, *args):
        """
        Create direct image, called from creator as 'direct' cmd
        """
        if len(args) != 9:
            raise errors.Usage("Extra arguments given")

        staging_data_dir = args[0]
        hdddir = args[1]
        native_sysroot = args[2]
        kernel_dir = args[3]
        bootimg_dir = args[4]
        rootfs_dir = args[5]

        creatoropts = configmgr.create
        ksconf = args[6]

        image_output_dir = args[7]
        oe_builddir = args[8]

        krootfs_dir = self.__rootfs_dir_to_dict(rootfs_dir)

        configmgr._ksconf = ksconf

        creator = direct.DirectImageCreator(oe_builddir, image_output_dir,
                                            krootfs_dir, bootimg_dir,
                                            kernel_dir, native_sysroot, hdddir,
                                            staging_data_dir, creatoropts)

        try:
            creator.create()
            creator.assemble()
            creator.finalize()
            creator.print_outimage_info()

        except errors.CreatorError:
            raise
        finally:
            creator.cleanup()

        return 0
예제 #4
0
    def preoptparse(self, argv):
        optparser = self.get_optparser()

        largs = []
        rargs = []
        while argv:
            arg = argv.pop(0)

            if arg in ('-h', '--help'):
                rargs.append(arg)

            elif optparser.has_option(arg):
                largs.append(arg)

                if optparser.get_option(arg).takes_value():
                    try:
                        largs.append(argv.pop(0))
                    except IndexError:
                        raise errors.Usage("option %s requires arguments" %
                                           arg)

            else:
                if arg.startswith("--"):
                    if "=" in arg:
                        opt = arg.split("=")[0]
                    else:
                        opt = None
                elif arg.startswith("-") and len(arg) > 2:
                    opt = arg[0:2]
                else:
                    opt = None

                if opt and optparser.has_option(opt):
                    largs.append(arg)
                else:
                    rargs.append(arg)

        return largs + rargs