Ejemplo n.º 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
Ejemplo n.º 2
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
Ejemplo n.º 3
0
    def GetBIF(self):
        if self.bif_data_cache:
            if self.bif_data_cache[0] == self.build_branch and \
               self.bif_data_cache[1] == self.cvs_tag and \
               self.bif_data_cache[2] == self.cvs_date:
                return self.bif_data_cache[3]

        filename = self.branch_list.file(self.build_branch)
        if not filename:
            return None

        print 'reading %s file' % (filename)

        import bif
        self.bif_data_cache = (self.build_branch, self.cvs_tag, self.cvs_date,
                               bif.load_bif_data(filename, self.branch_list))

        return self.bif_data_cache[3]
Ejemplo n.º 4
0
    def GetBIF(self):
        if self.bif_data_cache:
            if self.bif_data_cache[0] == self.build_branch and \
               self.bif_data_cache[1] == self.cvs_tag and \
               self.bif_data_cache[2] == self.cvs_date:
                return self.bif_data_cache[3]
        
        filename = self.branch_list.file(self.build_branch)
        if not filename:
            return None

        print 'reading %s file' % (filename)
        
        import bif
        self.bif_data_cache = (
            self.build_branch,
            self.cvs_tag,
            self.cvs_date,
            bif.load_bif_data(filename, self.branch_list) )
        
        return self.bif_data_cache[3]
Ejemplo n.º 5
0
    def __init__(self,
                 module_id,
                 branch_tag,
                 source_branch,
                 source_tag,
                 source_date,
                 default_profile=None,
                 default_options=None,
                 branch_or_tag = "branch",
                 ribosome=None,
                 cvs_flags = '',
                 bif_dir = None):

        self.source_tag = source_tag
        self.source_date = source_date
        self.tag = branch_tag
        
        action=string.upper(branch_or_tag)
        todo={}

        self.cvs_flags=cvs_flags

        if type(module_id) != types.ListType:
            module_id=[ module_id ]

        if branch_or_tag == "branch":
            self.dash_b="-b"
        else:
            self.dash_b=""

        ## find the BIF file for the branch name
        branch_list = branchlist.BranchList(source_tag, source_date)
        old_filename = branch_list.file(source_branch)
        if not old_filename:
            print "[%s] no BIF file for branch=\"%s\"" % (action,source_branch)
            return 0

        
        if bif_dir:
            ## Get this from HEAD
            bif_path = branchlist.BranchList().paths[bif_dir]
        else:
            ## Ugly, but works
            bif_path, old_basename = os.path.split(old_filename)
            

        ## parse old BIF file, and create the new BIF file
        ## Do not include shadows
        print "[%s] parsing file=\"%s\"" % (action,old_filename)
        bdata1 = bif.load_bif_data(old_filename, branch_list, 0)

        ## compute the dependancy list for the target

        if module_id == [ "ALL" ]:
            print "[%s] %sing all modules" % (action, string.capitalize(branch_or_tag))
            deplist1_list = bdata1.module_hash.values()
        else:
            print "[%s] computing dependancy tree for target=%s" % (action,repr(module_id))
            deplist1_list = dependlist.DependList(bdata1, module_id).list()

        ## Create a new BIFData object
        bdata2=bif.BIFData()
        bdata2.set_build_id(branch_tag)
        bdata2.set_default_cvs_root(bdata1.default_cvs_root)
        bdata2.set_default_cvs_tag(branch_tag)
        bdata2.set_default_cvs_tag_type("branch")  ## is it?

        #bdata2.defaults = copy.deepcopy(bdata1.defaults)
        #for d in bdata2.defaults:
        #     d.target = string.join(module_id)
        if module_id == [ "ALL" ]:
            bdata2.defaults = [
                bif.Default(default_profile,
                            string.join(module_id),
                            default_options) ]
        else:
            bdata2.defaults = [
                bif.Default(default_profile,
                            string.join(module_id),
                            default_options) ]
            
        for tmp in deplist1_list:
            # reset the cvs tag
            mod = copy.deepcopy(tmp)
            mod.cvs_tag_flag=0
            mod.cvs_date=""
            mod.cvs_tag_type="branch"
            mod.cvs_tag=branch_tag
            bdata2.add_module(mod)

        self.cmds = []
        if branch_or_tag == "branch":
            ## write out a new XML file for the branch
            basename = "%s.bif" % (branch_tag)
            filename = os.path.join(bif_path, basename)
            print "[%s] writing xml file=\"%s\"" % (action,filename)
            fil = open(filename, "w")
            fil.write(bdata2.write())
            fil.close()

            
            ## cvs commit the new file
            cmd="cvs add %s" % basename
            print "Running: %s" % cmd
            status, output = shell.run(cmd, dir=bif_path)
            print output
            cmd='cvs commit -m "branch script submission" %s' % basename
            print "Running: %s" % cmd
            status, output = shell.run(cmd, dir=bif_path)
            print output

        modules_to_tag = []

        build_module = module.CreateModule("buildsystem","")
        if ribosome:
            build_module.set_cvs_root("helix")
            build_module.name="ribosome/build"
        else:
            build_module.set_cvs_root("real")
            build_module.name="build"

        modules_to_tag.append(build_module)

        ## Tag/Branch BIF files
        ## FIXME: BIF inheritance makes it hard to know which BIF
        ## files to tag/branch, so we tag/branch *all* of them.

        for (prefix, path)  in branch_list.path_list:
            if path[0] == '[':
                tmp=string.split(path[1:],"]")
                repository=tmp[0]
                cvspath=string.join(tmp[1:],"]")

                if cvspath and cvspath[0]=='/':
                    cvspath=cvspath[1:]

                mod=module.CreateModule("%s_bifs" % prefix, cvspath)
                mod.set_cvs_root(repository)

                modules_to_tag.append(mod)

        

        ## compute the dependancy list for the target
        print "[%s] computing dependancy tree for target=%s" % (action, repr(module_id))
        ## print some useful info
        if module_id == [ "ALL" ]:
            deplist2_list = bdata2.module_hash.values()
            print "[%s] targets=\"%d\"" % (action, len(deplist2_list))
        else:
            deplist2 = dependlist.DependList(bdata2, module_id)

            print "[%s] targets=\"%d\"" % (action, len(deplist2.list()))
            print "[%s] cvs targets=\"%d\"" % (action, len(deplist2.checkout_list()))
            print "[%s] dist targets=\"%d\"" % (action, len(deplist2.distribution_list()))


        dists_done={}
        for mod in deplist1_list:

            if mod.type not in ["cvs", "distribution" ]:
                continue

            if mod.type == "distribution":
                if dists_done.has_key(mod.cvs_root):
                    continue
                dists_done[mod.cvs_root]=1

            modules_to_tag.append(mod)

        #print "TAGME: %s" % repr(modules_to_tag)
        chaingang.ProcessModules_anyorder(modules_to_tag, self.process_module)
Ejemplo n.º 6
0
    if len(arg_list) < 2:
        print 'usage: python %s BIF target1 target2 ...' % (sys.argv[0])
        sys.exit(1)

    branch_name = arg_list[0]
    target_list = arg_list[1:]
    if not focus:
        focus = target_list[0]

    import branchlist
    branch_list = branchlist.BranchList()
    bif_filename = branch_list.file(branch_name)

    ## load BIF file
    bif_data = bif.load_bif_data(bif_filename)
    depend_list = DependList(bif_data, target_list)

    print '# TARGET LIST: %s' % (string.join(target_list))
    print '# BIF FILE: %s' % (bif_filename)
    print '# TOTAL TARGETS: %d' % (len(depend_list.list()))
    print '# CHECKOUT TARGETS: %d' % (len(depend_list.checkout_list()))
    print '# DISTRIBUTION TARGETS: %d' % (len(depend_list.distribution_list()))

    def dump(module, ind, xtra=""):
        if xml:
            print module.write()
            print
        else:
            attr=[]
            if module.no_build_flag:
Ejemplo n.º 7
0
    def __init__(self,
                 module_id,
                 source_branch,
                 source_tag,
                 source_date,
                 start_date,
                 end_date):

        if start_date:
            if not re.match("^[-a-zA-Z0-9:/ ]*$",start_date):
                raise "Invalid start date"

        if end_date:
            if not re.match("^[-a-zA-Z0-9:/ ]*$",end_date):
                raise "Invalid start date"

        self.source_tag = source_tag
        self.source_date = source_date

        self.checkins = []

        todo={}

        if type(module_id) != types.ListType:
            module_id=[ module_id ]

        self.module_id = module_id
        self.source_branch = source_branch
        self.start_date = start_date
        self.end_date = end_date

        if self.start_date:
            self.start_date_local=self.start_date
            # FIXME: this was heinously broken. This call converts ticks
            # to gmticks with the date_to_gmticks() call. Then converts that
            # time a second time with the cvs_server_time() call.
            # This will probably require deep investigation to make sure that
            # diff reports are all using the correct times. No surprise that
            # there is an open bug on the diff report timestamps.
            #self.start_date = datelib.cvs_server_time(datelib.date_to_gmticks(self.start_date))
            
            # Notice we are still propagating raw strings here instead of
            # moving Timestamp objects around. Going to take a long time to
            # clean this up completely.
            startTS = timestamp.Timestamp( self.start_date )
            self.start_date = startTS.getUTCString()

        if self.end_date:
            self.end_date_local=self.end_date
            endTS = timestamp.Timestamp( self.end_date )
            self.end_date = endTS.getUTCString()
            #self.end_date = datelib.cvs_server_time(datelib.date_to_gmticks(self.end_date))

        self.date_range = " -d '%s<%s'" % (self.start_date or "",
                                           self.end_date or "")
        if self.date_range == " -d '<'":
            self.date_range = ""

        ## find the BIF file for the branch name
        branch_list = branchlist.BranchList(source_tag, source_date)
        old_filename = branch_list.file(source_branch)
        if not old_filename:
            raise "no BIF file for branch=\"%s\"" % (source_branch)

        ## parse old BIF file, and create the new BIF file
        ## Do not include shadows
        print "parsing file=\"%s\"" % (old_filename)
        bdata1 = bif.load_bif_data(old_filename, branch_list, 0)

        ## compute the dependancy list for the target

        if module_id == [ "ALL" ]:
            print "diffing all modules" % (string.capitalize(branch_or_tag))
            deplist1_list = bdata1.module_hash.values()
        else:
            print "computing dependancy tree for target=%s" % (repr(module_id))
            deplist1_list = dependlist.DependList(bdata1, module_id).list()

        modules_to_diff = []


        dists_done={}
        for mod in deplist1_list:
            if mod.type not in ["cvs", "distribution" ]:
                continue

            if mod.type == "distribution":
                if dists_done.has_key(mod.cvs_root):
                    continue
                dists_done[mod.cvs_root]=1

            modules_to_diff.append(mod)

        self.modules_to_diff = modules_to_diff
Ejemplo n.º 8
0
    if len(arg_list) < 2:
        print 'usage: python %s BIF target1 target2 ...' % (sys.argv[0])
        sys.exit(1)

    branch_name = arg_list[0]
    target_list = arg_list[1:]
    if not focus:
        focus = target_list[0]

    import branchlist
    branch_list = branchlist.BranchList()
    bif_filename = branch_list.file(branch_name)

    ## load BIF file
    bif_data = bif.load_bif_data(bif_filename)
    depend_list = DependList(bif_data, target_list)

    print '# TARGET LIST: %s' % (string.join(target_list))
    print '# BIF FILE: %s' % (bif_filename)
    print '# TOTAL TARGETS: %d' % (len(depend_list.list()))
    print '# CHECKOUT TARGETS: %d' % (len(depend_list.checkout_list()))
    print '# DISTRIBUTION TARGETS: %d' % (len(depend_list.distribution_list()))

    def dump(module, ind, xtra=""):
        if xml:
            print module.write()
            print
        else:
            attr = []
            if module.no_build_flag:
Ejemplo n.º 9
0
 def load(self, branch_tag):
     if self.name_hash.has_key(branch_tag):
         import bif
         return bif.load_bif_data(self.name_hash[branch_tag], self)
     return None
Ejemplo n.º 10
0
 def load(self, branch_tag):
     if self.name_hash.has_key(branch_tag):
         import bif
         return bif.load_bif_data(self.name_hash[branch_tag], self)
     return None