コード例 #1
0
    def get_module_path_hash(self, target):
        ## retrieve the branch ID from the registry
        branch = bldreg.get_value('build', 'branch')

        ## find the BIF file for this branch
        branch_list = branchlist.BranchList()
        bif_file = branch_list.file(branch)
        if not bif_file:
            e = err.Error()
            e.Set("Cannot find bif file=\"%s\"." % (bif_file))
            raise err.error, e

        ## parse the BIF/XML file and get information for this build
        bif_data = bif.load_bif_data(bif_file, branch_list)

        ## feed the BIF information to a dependancy list, and set
        ## the dependancy list's targets
        depend = dependlist.DependList(bif_data, target)

        ## this takes it's best shot at returning a list of all the
        ## subdirectory names checked out by this target
        module_list = depend.distribution_list() + depend.checkout_list()

        base_path = ushell.posix_path(bldreg.get_value('build', 'path'))

        module_path_hash = {}
        for module in module_list:
            module_path_hash[module.id] = ushell.join(base_path, module.name)

        return module_path_hash
コード例 #2
0
def system_checks():
    """Check things on the system that could be hosed.  Check to make
    sure the user isn't running the build system in the build directory."""

    reg = bldreg.find_registry_path()
    if reg and reg != os.path.join(os.getcwd(), "build.reg"):
        print "You have previously run builds in '%s'," % os.path.dirname(reg)
        print "running build in this directory will mess up that build."
        print "If you really want to run build in this directory, you must"
        print "delete or rename '%s' or create an" % reg
        print "empty file called 'build.reg' in this directory."

        sys.exit(1)

    if os.path.basename(os.getcwd()) == 'build':
        e = err.Error()
        e.Set("You are trying to run 'build' in the build dir.")
        raise err.error, e

    ## Create an empy registry if it does not already exist
    if not os.path.exists("build.reg"):
        open("build.reg", "a")

    bldreg.clear_section("sdk")
    bldreg.clear_section("extra_dependencies")
    bldreg.clear_section("distribute")
コード例 #3
0
 def set_halt_priority(self, priority):
     if priority not in ["red", "yellow", "green"]:
         e = err.Error()
         e.Set("The module id=\"%s\" with name=\"%s\" in the bif "\
               "file has a incorrect halt_priority setting=\"%s\"." % (
             self.id, self.name, priority))
         raise err.error, e
     self.halt_priority = priority
コード例 #4
0
    def build_common(self):

        if self.stage in [0, 1]:
            if self.settings.get('clean_mode_flag') and \
               not self.settings.get('no_make_depend_flag'):
                status, text = self.make_clean_depend()
            else:
                ## make clean
                ## under fast builds, we don't want to make clean
                ## don't do a make clean when doing a clean build
                if self.settings.get('clean_mode_flag'):
                    status, text = self.make_clean()

                ## make depend -- do not check status, it's okay
                ## if this command fails because makedepend is broken
                ## and too many developers can't figure it out
                if not self.settings.get('no_make_depend_flag'):
                    status, text = self.make_depend()

        ## Only do this when using threads
        if self.stage == 2 and self.isstd():
            self.make_objects()

        if self.stage in [0, 3]:
            ## make all
            if self.isstd() and not self.settings.get('no_make_copy_flag'):
                status, text = self.make_copy()

                if status:
                    e = err.Error()
                    e.Set("Make failed.")
                    self.error(e.text)
                    raise err.error, e
            else:
                status, text = self.make_all()

                if status:
                    e = err.Error()
                    e.Set("Make failed.")
                    self.error(e.text)
                    raise err.error, e

                ## make copy
                if not self.settings.get('no_make_copy_flag'):
                    status, text = self.make_copy()
コード例 #5
0
 def run_cmd(self, cmd):
     outmsg.verbose(cmd)
     t = time.time()
     try:
         ret = shell.run(cmd, self.lcb)
     except shell.error, se:
         e = err.Error()
         e.Set(str(se))
         raise err.error, e
コード例 #6
0
    def __name_check(self):
        """Check the module.name value for invalid charactors."""

        for sep in ['\\', ':', ' ', '#']:
            if sep in self.name or sep in self.id:
                e = err.Error()
                e.Set("The module id=\"%s\" with name=\"%s\" in the bif "\
                      "file has the illegal charactor=\"%s\" in it." % (
                    self.id, self.name, sep))
                raise err.error, e
コード例 #7
0
    def set_type(self, type):
        """Set the module type.  This is usually: cvs(default), or
        distribution."""

        if type not in self.module_type_list:
            e = err.Error()
            e.Set("The module id=\"%s\" in the bif file is set to a "\
                  "unknown type=\"%s\"." % (self.id, type))
            raise err.error, e

        self.type = type
コード例 #8
0
def set_platform_aix4():
    revision = uname_output("-r")

    if revision == "2":
        set_platform("aix-4.2-powerpc")

    elif revision == "3":
        set_platform("aix-4.3-powerpc")

    else:
        e = err.Error()
        e.Set("Unconfigured AIX system.")
        raise err.error, e
コード例 #9
0
    def __init__(self, cvssession, shadow=None, viewcvs=None):
        self.viewcvs = viewcvs
        if os.environ.has_key('MACCVS_PATH'):
            self.cvs_path = os.environ['MACCVS_PATH']
        else:
            e = err.Error()
            e.Set("You need to set the MACCVS_PATH environment variable "\
                  "to the path of MacCVS.")
            raise err.error, e

        if cvssession:
            self.cvs_session_path = cvssession
        else:
            e = err.Error()
            e.Set("You need to set the CVSSESSION_PATH environment variable "\
                  "to the path of the MacCVS session file.")
            raise err.error, e

        if os.environ.has_key('CVSSCRIPT_PATH'):
            self.script_save_path = os.environ['CVSSCRIPT_PATH']
        else:
            self.script_save_path = ''
コード例 #10
0
    def make_objects(self):
        if os.environ.get("BFSERVER"):
            try:
                ret = self.compile_remotely(dir)
                if ret:
                    return ret
            except:
                e = err.Error()
                e.Set("Error in remote compile (non-fatal)")
                e.SetTraceback(sys.exc_info())
                print
                print e.Text()

        return Compile.make_objects(self)
コード例 #11
0
    def circular_dependancy_error(self, mod):
        l = [mod]
        tmp = self.doing[mod]
        while mod != tmp:
            l.append(tmp)
            tmp = self.doing[tmp]
        l.append(mod)

        e = err.Error()
        import bif
        e.Set("A circular module dependancy was detected in the bif "\
              "file while computing the dependancy list for the target "\
              "involving the following modules: %s" %
              string.join(l,"->"))
        raise err.error, e
コード例 #12
0
def set_platform_netbsd1():
    arch = uname_output('-m')

    ## ns1k is the NetBSD/PPC Liberate diskless workstation
    if arch == 'ns1k':
        set_platform('netbsd-1.4-ns1k-powerpc')

    ##  normal NetBSD
    elif arch == 'i386':
        set_platform('netbsd-1.4-i386')

    else:
        e = err.Error()
        e.Set("Unconfigured NetBSD system.")
        raise err.error, e
コード例 #13
0
def set_platform_sunos5():
    version = uname_output('-r')

    if version == '5.5' or version == '5.5.1':
        set_platform('sunos-5.5.1-sparc')

    elif version == '5.6':
        set_platform('sunos-5.6-sparc')

    elif version == '5.7':
        set_platform('sunos-5.7-sparc')

    elif version == '5.8':
        set_platform('sunos-5.8-sparc')

    else:
        e = err.Error()
        e.Set("Unconfigured SunOS system.")
        raise err.error, e
コード例 #14
0
def set_platform_irix6():
    version = uname_output('-r')

    if version == "6.2":
        set_platform("irix-6.2-mips")

    elif version == "6.3":
        set_platform("irix-6.3-mips")

    elif version == "6.4":
        set_platform("irix-6.4-mips")

    elif version == "6.5":
        set_platform("irix-6.5-mips")

    else:
        e = err.Error()
        e.Set("Unconfigured IRIX system.")
        raise err.error, e
コード例 #15
0
def set_platform_linux2():
    arch = uname_output('-m')

    if arch[0] == 'i' and arch != 'ia64':
        if not os.path.exists('/lib/libc.so.6'):
            set_platform('linux-2.0-libc5-i386')
            return

        if uname_output("-r")[:3] == "2.0":
            set_platform('linux-2.0-libc6-i386')
            return

        gcc_version = os.popen("gcc -dumpversion").read()
        gcc_version = string.strip(gcc_version)

        if gcc_version[0] == "3":
            set_platform('linux-2.2-libc6-gcc32-i586')
        else:
            set_platform('linux-2.2-libc6-i586')

    ## Linux PPC Q3
    elif arch == 'ppc':
        set_platform('linux-2.2-libc6-powerpc')

    ## Linux/Redhat SPARC
    elif arch == 'sparc64' or arch == 'sparc':
        set_platform('linux-2.2-libc6-sparc')

    ## Linux Alpha
    elif arch == 'alpha':
        set_platform('linux-2.0-libc6-alpha-gcc2.95')

    elif arch == 'ia64':
        set_platform('linux-2.4-libc6-ia64')

    elif arch == 'x86_64':
        set_platform('linux-2.6-glibc23-amd64')

    else:
        e = err.Error()
        e.Set("System detection failed for unknown Linux system.")
        raise err.error, e
コード例 #16
0
        def worker(self):
            log.trace('entry')
            ## Uncomment this for deadlock debugging!!
            sys.settrace(self.trace)

            self.output_hash[thread.get_ident()] = []
            try:  # release lock
                try:  # error handler
                    ChainGang_nothreads.worker(self)

                except err.error, e:
                    print "***Thread error trapped!"
                    e.SetTraceback(sys.exc_info())
                    self.error = e
                    print e.Text()
                except:
                    print "***Thread error trapped!"
                    e = err.Error()
                    e.Set("Error in threaded call")
                    e.SetTraceback(sys.exc_info())
                    self.error = e
                    print e.Text()
コード例 #17
0
    def __runTool( self ):
        import err
        
        try:
            log.info( 'Running tool: %s' % self.toolName )
            tool = __import__("%s_exe" % self.toolName)
            tool.run()
            
        except KeyboardInterrupt:
            log.info( 'Received keyboard interrupt - aborting.' )
            sys.exit(0)
            
        except SystemExit:
            sys.exit(0)
            
        except:
            e = err.Error()
            e.Set( "You have found a Ribosome bug." )
            e.SetTraceback( sys.exc_info() )
            log.error( e.Text() )
            raise

        else:
            sys.exit(0)            
コード例 #18
0
    def run_umake(self, build_options):
        ## attempt to clear the NS/Working space of Umake
        import umake
        umake.INIT()

        t = time.time()
        try:
            result = umake.Umake(build_options)
        except "NONSTANDARD":
            result = None
        except err.error, e:
            self.error(e.text)
            raise err.error, e
        except:
            e = err.Error()
            e.Set("Error in umake call")
            e.SetTraceback(sys.exc_info())
            self.error(e.text)
            raise err.error, e

        if result and len(result):
            e = err.Error()
            e.Set("umake error=\"%s\"" % (result))
            raise err.error, e

        outmsg.verbose("Time used: %.2f seconds" % (time.time() - t))

    def make(self, arg=""):
        self.error('make needs to be implemented in a subclass')
コード例 #19
0
def update_platform_header(module, build_branch):
    """Write a new include/platform.h header file defining
    TARVER_STR_PLATFORM to the current platform."""

    path = apply(os.path.join,
                 [os.curdir] + string.split(module.name, "/") + ["platform.h"])

    if not os.path.isfile(path):
        e = err.Error()
        e.Set("The required include file=\"%s\" could not be found." % (path))
        raise err.error, e

    ver_path = apply(os.path.join, [os.curdir] +
                     string.split(module.name, "/") + ["PlatformVersion.ini"])

    ## figure out what the platform string should be
    if os.name == 'posix':
        plat_string = sysinfo.id
    else:
        plat_string = sysinfo.platform

    if os.path.isfile(ver_path):
        ## update platform version
        ver_data = open(ver_path, "r").read()
        ver_data = string.split(ver_data, "\n")
        buildtime = time.localtime(time.time())
        build_time = time.strftime("%d %b %Y %H:%M", buildtime)
        plat_string = (ver_data)[0] + " " + build_time
        outmsg.send("Updating Platform Version = %s" % (plat_string))

    outmsg.send("updating file=\"%s\" for platform=\"%s\"" %
                (path, plat_string))

    olddata = open(path, "r").read()
    copyright = ""
    if olddata[:2] == "/*":
        copyright = string.split(olddata, "*/")[0] + "*/\n\n"

    data = """%s#ifndef _PLATFORM_H_
#define _PLATFORM_H_
#define TARVER_STR_PLATFORM "%s"
#define TARVER_STR_BUILD_BRANCH "%s"
#endif
""" % (copyright, plat_string, build_branch)

    ## Don't update the file if it already contains the right stuff
    try:
        if open(path, "r").read() == data:
            return
    except:
        pass

    try:
        fil = open(path, "w")
    except IOError:
        e = err.Error()
        e.Set("Could not write to file=\"%s\"." % (path))
        raise err.error, e

    fil.write(data)

    fil.close()
コード例 #20
0
    def update(self,
               tag,
               module_list,
               az=None,
               timestamp=None,
               nonrecursive=0,
               dir=None):

        ### FIXME:
        ### test this!

        if dir:
            odir = os.getcwd()
            try:
                os.chdir(dir)
                ret = self.checkout(tag, module_list, az, timestamp,
                                    nonrecursive)
            finally:
                os.chdir(odir)

            return ret

        if az:
            odir = os.getcwd()
            shell.mkdir("cvs_temp")
            os.chdir("cvs_temp")
            self.checkout(tag, module_list, None, timestamp, nonrecursive)
            os.chdir(odir)
            for m in module_list:
                shell.cp(os.path.join(odir, "cvs_temp", m),
                         os.path.join(odir, az))

            shell.rm("cvs_temp")
            return

        if nonrecursive:
            e = err.Error()
            e.Set("Nonrecursive not supported by MacCVS")
            raise err.error, e

        session_name = self.cvs_session_path[1:-1]
        session_name = os.path.basename(session_name)

        script = ascript.CreateAppleScript(
            'tell application %s' % (self.cvs_path), '  activate',
            '  open alias %s' % (self.cvs_session_path),
            '  set thesession to session named "%s"' % (session_name),
            '  set local root of thesession to alias "%s"' % (os.getcwd()),
            '  with timeout of 99999 seconds')

        for module in module_list:
            cmd = 'check out thesession module "%s"' % (module)
            if tag:
                cmd = cmd + ' revision "%s"' % (tag)

            if timestamp:
                cmd = cmd + ' date "%s"' % (timestamp)

            script.Append(cmd)

        script.Append('  end timeout', '  quit', 'end tell')

        if self.script_save_path == '':
            result = script.CompileAndExecute()
        else:
            script.CompileAndSave(self.script_save_path)

            launch_script = ascript.CreateAppleScript(
                'set scriptobj to (load script file "%s")' %
                (self.script_save_path), 'tell scriptobj', '  run', 'end tell')

            result = launch_script.CompileAndExecute()

        if result and result != '':
            outmsg.error('cvs checkout error %s' % (result))
コード例 #21
0
    def update_checkout_list(self, tag, module_list, az, dir):
        update_list = []
        checkout_list = []

        if tag == "HEAD":
            tag = ""

        ## separate the modules which need to be checked out
        ## from the modules which need to be updated
        ## and go through the list of modules to be updated, and
        ## check that the current module's CVS/Tag entry is the same
        ## before updating; if it's not, then throw a error and let
        ## the developer handle it
        update_error_list = []
        for module in module_list:
            opath = module

            if dir:
                opath = os.path.join(dir, module)

            if az:
                opath = az

            if (not os.path.isdir(opath)
                    or not os.path.isdir(os.path.join(opath, "CVS"))):
                checkout_list.append(module)
                continue

            tag_path = os.path.join(opath, "CVS", "Tag")
            try:
                current_tag = string.strip(open(tag_path).read())
            except IOError:
                # Special case
                if module == ".":
                    checkout_list.append(module)
                    continue
                current_tag = ""

            update_list.append(module)

            if current_tag in ["HEAD", "THEAD", "NHEAD"]:
                current_tag = ""

            tag_match = 0

            ## some versions of CVS put a "N" or "T" before the actual tag
            if re.match(r'^[NT]?' + tag, current_tag):
                tag_match = 1

            if not tag_match:
                update_error_list.append(
                    "module=\"%s\" current tag=\"%s\" dir=\"%s\"" %
                    (module, current_tag, opath))

        ## now error out if there were conflicts
        if update_error_list:
            e = err.Error()
            e.Set("There are CVS modules in your source tree which "\
                  "were originally checked out from a different CVS "\
                  "branch than the current .bif file is requesting.  "\
                  "This is most likely because of a change in the .bif "\
                  "file.  You will need to remove or move these modules "\
                  "by hand before the build system can continue.\n%s" % (
                string.join(update_error_list, "\n")))
            raise err.error, e

        return update_list, checkout_list
コード例 #22
0
def fatal(text):
    """Raise a fatal exception."""
    e = err.Error()
    e.Set(text)
    raise err.error, e
コード例 #23
0
 def dependancy_error(self, module_id, depmodule_id):
     e = err.Error()
     e.Set("While computing the dependancy list for your target, "\
           "module id=\"%s\" has a dependancy on module=\"%s\" which "\
           "was not found in the bif file." % (module_id, depmodule_id))
     raise err.error, e
コード例 #24
0
def guess_platform():
    ## first, check for the PLATFORM environment variable
    if os.environ.has_key("SYSTEM_ID"):
        id = os.environ['SYSTEM_ID']
        try:
            set_platform(id)
        except KeyError:
            e = err.Error()
            e.Set("Unconfigured SYSTEM_ID=%s.  "\
                  "Valid SYSTEM_ID values are=\"%s\"." % (
                id, string.join(PLATFORM_HASH.keys(), ", ")))
            raise err.error, e
        else:
            return

    if os.name == 'mac':
        set_platform('macos-powerpc')

    elif sys.platform == 'darwin':
        set_platform('macos-carbon-powerpc-darwin-cw7')

    elif os.name == 'nt' or os.name == 'dos':
        set_platform('win32-i386')

    elif sys.platform == 'aix4':
        set_platform_aix4()

    elif sys.platform == 'freebsd2':
        set_platform('freebsd-2.2-i386')

    elif sys.platform == 'freebsd3':
        set_platform('freebsd-3.0-i386')

    elif sys.platform == 'freebsd4':
        set_platform('freebsd-4.0-i386')

    elif sys.platform == 'freebsd5':
        set_platform('freebsd-5.0-i586')

    elif sys.platform == 'freebsd6':
        set_platform('freebsd-6.0-i586')

    elif sys.platform == 'hp-uxB':
        set_platform('hpux-11.0-parisc')

    elif sys.platform == 'irix6':
        set_platform_irix6()

    elif sys.platform == 'irix646':
        set_platform_irix6()

    elif string.find(sys.platform, 'linux') >= 0:
        set_platform_linux2()

    elif sys.platform == 'netbsd1':
        set_platform_netbsd1()

    elif sys.platform == 'osf1V4':
        set_platform('osf-4.0-alpha')

    elif sys.platform == 'osf1V5':
        set_platform('osf-5.1-alpha')

    elif sys.platform == 'sunos5':
        set_platform_sunos5()

    elif sys.platform == 'unixware5':
        set_platform('unixware-7.0-i386')

    elif sys.platform == 'sco_sv3':
        set_platform('openserver-5.0.5-i386')

    elif sys.platform == 'win32':
        set_platform('win32-i386-vc6')

    elif sys.platform == 'openbsd3':
        set_platform('openbsd-3.3-i586')

    else:
        e = err.Error()
        e.Set("Unknown platform, update sysinfo.py for platform=\"%s\"." %
              (sys.platform))
        raise err.error, e