예제 #1
0
def exec_func_shell(function, d, runfile, logfile, cwd=None, fakeroot=False):
    """Execute a shell function from the metadata

    Note on directory behavior.  The 'dirs' varflag should contain a list
    of the directories you need created prior to execution.  The last
    item in the list is where we will chdir/cd to.
    """

    # Don't let the emitted shell script override PWD
    d.delVarFlag('PWD', 'export')

    with open(runfile, 'w') as script:
        script.write('#!/bin/sh -e\n')
        data.emit_func(function, script, d)

        script.write("set -x\n")
        script.write("%s\n" % function)
        os.fchmod(script.fileno(), 0775)

    if fakeroot:
        cmd = ['fakeroot', runfile]
    else:
        cmd = runfile

    if logger.isEnabledFor(logging.DEBUG):
        logfile = LogTee(logger, logfile)

    try:
        bb.process.run(cmd, cwd=cwd, shell=False, stdin=NULL, log=logfile)
    except bb.process.CmdError:
        raise FuncFailed(function, logfile.name)
예제 #2
0
파일: build.py 프로젝트: opencalc/poky
def exec_func_shell(function, d, runfile, cwd=None):
    """Execute a shell function from the metadata

    Note on directory behavior.  The 'dirs' varflag should contain a list
    of the directories you need created prior to execution.  The last
    item in the list is where we will chdir/cd to.
    """

    # Don't let the emitted shell script override PWD
    d.delVarFlag('PWD', 'export')

    with open(runfile, 'w') as script:
        script.write('#!/bin/sh -e\n')
        if logger.isEnabledFor(logging.DEBUG):
            script.write("set -x\n")
        data.emit_func(function, script, d)
        if cwd:
            script.write("cd %s\n" % cwd)
        script.write("%s\n" % function)

    os.chmod(runfile, 0775)

    cmd = runfile

    if logger.isEnabledFor(logging.DEBUG):
        logfile = LogTee(logger, sys.stdout)
    else:
        logfile = sys.stdout

    try:
        bb.process.run(cmd, shell=False, stdin=NULL, log=logfile)
    except bb.process.CmdError:
        logfn = d.getVar('BB_LOGFILE', True)
        raise FuncFailed(function, logfn)
예제 #3
0
def exec_func_shell(function, d, runfile, cwd=None):
    """Execute a shell function from the metadata

    Note on directory behavior.  The 'dirs' varflag should contain a list
    of the directories you need created prior to execution.  The last
    item in the list is where we will chdir/cd to.
    """

    # Don't let the emitted shell script override PWD
    d.delVarFlag("PWD", "export")

    with open(runfile, "w") as script:
        script.write("#!/bin/sh -e\n")
        if bb.msg.loggerDefaultVerbose:
            script.write("set -x\n")
        data.emit_func(function, script, d)
        if cwd:
            script.write("cd %s\n" % cwd)
        script.write("%s\n" % function)

    os.chmod(runfile, 0775)

    cmd = runfile

    if bb.msg.loggerDefaultVerbose:
        logfile = LogTee(logger, sys.stdout)
    else:
        logfile = sys.stdout

    try:
        bb.process.run(cmd, shell=False, stdin=NULL, log=logfile)
    except bb.process.CmdError:
        logfn = d.getVar("BB_LOGFILE", True)
        raise FuncFailed(function, logfn)
예제 #4
0
def exec_func_shell(function, d, runfile, logfile, cwd=None, fakeroot=False):
    """Execute a shell function from the metadata

    Note on directory behavior.  The 'dirs' varflag should contain a list
    of the directories you need created prior to execution.  The last
    item in the list is where we will chdir/cd to.
    """

    # Don't let the emitted shell script override PWD
    d.delVarFlag('PWD', 'export')

    with open(runfile, 'w') as script:
        script.write('#!/bin/sh -e\n')
        data.emit_func(function, script, d)

        script.write("set -x\n")
        script.write("%s\n" % function)
        os.fchmod(script.fileno(), 0775)

    if fakeroot:
        cmd = ['fakeroot', runfile]
    else:
        cmd = runfile

    if logger.isEnabledFor(logging.DEBUG):
        logfile = LogTee(logger, logfile)

    try:
        bb.process.run(cmd, cwd=cwd, shell=False, stdin=NULL, log=logfile)
    except bb.process.CmdError:
        raise FuncFailed(function, logfile.name)
예제 #5
0
파일: build.py 프로젝트: luozhenhua/poky
def exec_func_shell(func, d, runfile, cwd=None):
    """Execute a shell function from the metadata

    Note on directory behavior.  The 'dirs' varflag should contain a list
    of the directories you need created prior to execution.  The last
    item in the list is where we will chdir/cd to.
    """

    # Don't let the emitted shell script override PWD
    d.delVarFlag('PWD', 'export')

    with open(runfile, 'w') as script:
        script.write('#!/bin/sh -e\n')
        data.emit_func(func, script, d)

        if bb.msg.loggerVerboseLogs:
            script.write("set -x\n")
        if cwd:
            script.write("cd %s\n" % cwd)
        script.write("%s\n" % func)

    os.chmod(runfile, 0775)

    cmd = runfile
    if d.getVarFlag(func, 'fakeroot'):
        fakerootcmd = d.getVar('FAKEROOT', True)
        if fakerootcmd:
            cmd = [fakerootcmd, runfile]

    if bb.msg.loggerDefaultVerbose:
        logfile = LogTee(logger, sys.stdout)
    else:
        logfile = sys.stdout

    bb.debug(2, "Executing shell function %s" % func)

    try:
        with open(os.devnull, 'r+') as stdin:
            bb.process.run(cmd, shell=False, stdin=stdin, log=logfile)
    except bb.process.CmdError:
        logfn = d.getVar('BB_LOGFILE', True)
        raise FuncFailed(func, logfn)

    bb.debug(2, "Shell function %s finished" % func)
예제 #6
0
def exec_func_shell(func, d, runfile, cwd=None):
    """Execute a shell function from the metadata

    Note on directory behavior.  The 'dirs' varflag should contain a list
    of the directories you need created prior to execution.  The last
    item in the list is where we will chdir/cd to.
    """

    # Don't let the emitted shell script override PWD
    d.delVarFlag('PWD', 'export')

    with open(runfile, 'w') as script:
        script.write('#!/bin/sh -e\n')
        data.emit_func(func, script, d)

        if bb.msg.loggerVerboseLogs:
            script.write("set -x\n")
        if cwd:
            script.write("cd %s\n" % cwd)
        script.write("%s\n" % func)

    os.chmod(runfile, 0775)

    cmd = runfile
    if d.getVarFlag(func, 'fakeroot'):
        fakerootcmd = d.getVar('FAKEROOT', True)
        if fakerootcmd:
            cmd = [fakerootcmd, runfile]

    if bb.msg.loggerDefaultVerbose:
        logfile = LogTee(logger, sys.stdout)
    else:
        logfile = sys.stdout

    bb.debug(2, "Executing shell function %s" % func)

    try:
        bb.process.run(cmd, shell=False, stdin=NULL, log=logfile)
    except bb.process.CmdError:
        logfn = d.getVar('BB_LOGFILE', True)
        raise FuncFailed(func, logfn)

    bb.debug(2, "Shell function %s finished" % func)
예제 #7
0
파일: build.py 프로젝트: folkien/poky-fork
def exec_func_shell(function, d, runfile, cwd=None):
    """Execute a shell function from the metadata

    Note on directory behavior.  The 'dirs' varflag should contain a list
    of the directories you need created prior to execution.  The last
    item in the list is where we will chdir/cd to.
    """

    # Don't let the emitted shell script override PWD
    d.delVarFlag('PWD', 'export')

    with open(runfile, 'w') as script:
        script.write('#!/bin/sh -e\n')
        if logger.isEnabledFor(logging.DEBUG):
            script.write("set -x\n")
        data.emit_func(function, script, d)

        script.write("%s\n" % function)
        os.fchmod(script.fileno(), 0775)

    env = {
        'PATH': d.getVar('PATH', True),
        'LC_ALL': 'C',
    }

    cmd = runfile

    if logger.isEnabledFor(logging.DEBUG):
        logfile = LogTee(logger, sys.stdout)
    else:
        logfile = sys.stdout

    try:
        bb.process.run(cmd, env=env, cwd=cwd, shell=False, stdin=NULL,
                       log=logfile)
    except bb.process.CmdError:
        logfn = d.getVar('BB_LOGFILE', True)
        raise FuncFailed(function, logfn)