예제 #1
0
    def SetTag(self):
        print "Current CVS Tag : \"%s\"" % self.cvs_tag
        print "Current CVS Date: \"%s\"" % self.cvs_date
        print ""
        print "You may enter a new tag, branch or date, to enter"
        print "both a branch and a date, put a @ in between."
        print "Example: yourbranch@2002/01/20 05:20:22"
        print "Note that if you are using BIFs and/or profiles"
        print "directly from CVS, then those files will be updated"
        print "using the information you enter here."
        print ""

        tag = raw_input("Enter branch, tag, date or branch@date: ")
        parts = string.split(tag, "@")
        self.cvs_tag = ""
        self.cvs_date = ""
        if len(parts) > 1:
            self.cvs_tag = parts[0]
            self.cvs_date = parts[1]
        elif (" " in tag) or ("/" in tag):
            self.cvs_date = tag
        else:
            self.cvs_tag = tag

        bldreg.set_value('build', 'cvs_date', self.cvs_date)
        bldreg.set_value('build', 'cvs_tag', self.cvs_tag)

        ## Update branchlist and profile_list

        import branchlist
        self.branch_list = branchlist.BranchList(self.cvs_tag, self.cvs_date)
        self.profile_list = None
예제 #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
예제 #3
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)
예제 #4
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
예제 #5
0
        if opt[0] == '-p':
            xml = 1
        if opt[0] == '-a':
            all = 1

    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()
예제 #6
0
    def __init__(self):
        self.bif_data_cache = None

        ## remember the working directory so the build
        ## system doesn't get confused by keyboard interrupts
        self.working_path = os.getcwd()

        self.cvs_tag = bldreg.get_value_default('build', 'cvs_tag', "")
        self.cvs_date = bldreg.get_value_default('build', 'cvs_date', "")

        ## default branch to build
        try:
            build_branch = os.environ["BUILD_BRANCH"]
        except KeyError:
            build_branch = "helix"
        self.build_branch = bldreg.get_value_default("build", "branch",
                                                     build_branch)

        ## get a list of possible build branches
        update = 1

        if (bldreg.get("build", "last_cvs_date", None) == self.cvs_date
                and bldreg.get("build", "last_cvs_tag", None) == self.cvs_tag
                and bldreg.get("build", "last_branch",
                               None) == self.build_branch):
            update = 2

        self.branch_list = branchlist.BranchList(self.cvs_tag, self.cvs_date,
                                                 update)
        self.profile_list = None

        ## Default command line
        self.history = bldreg.get_value_default('build', 'history', [])

        self.flags = bldreg.get_value_default('build', 'arguments', None)
        self.targets = bldreg.get_value_default('build', 'targets', None)
        self.profile = bldreg.get_value_default('build', 'profile', None)

        if not self.profile or not self.targets or self.flags == None:
            bif_data = self.GetBIF()
            if not bif_data:
                ## An old branch
                self.build_branch = "RealMedia"
                bif_data = self.GetBIF()
                if not bif_data:
                    branches = self.branch_list.get_list()
                    if not branches:
                        print "No BIF branches found, please configure your .buildrc!"
                        sys.exit(1)
                    self.build_branch = branches[0]
                    bif_data = self.GetBIF()
                    if not bif_data:
                        print "No BIF files found, please configure your .buildrc!"
                        sys.exit(1)

            if not self.profile:
                self.profile = bif_data.default_profile
                if not self.profile:
                    self.profile = "default"
                bldreg.set_value('build', 'profile', self.profile)

            if not self.targets:
                self.targets = string.split(bif_data.default_target)
                if not self.targets:
                    self.targets = ["splay"]
                bldreg.set_value('build', 'targets', self.targets)

            if self.flags == None:
                self.flags = []
                flags = string.split(bif_data.default_options)
                for flag in flags:
                    flag = "-t" + flag
                    if flag not in self.flags:
                        self.flags.append(flag)

                bldreg.set_value('build', 'arguments', self.flags)

        if not self.profile:
            self.profile = "default"

        self.menu = [
            (self.BIFMenuOption, self.SetBIFBranch),
            (self.TargetMenuOption, self.SetTarget),
            (self.ProfileMenuOption, self.SetProfile),
            (self.BuildMenuOption, self.Build),
            ("Toggle make depend & makefiles (-e -n)", self.Toggle, "-e",
             "-n"), ("Toggle release (-trelease)", self.Toggle, "-trelease"),
            ("Toggle 'make clean'  (-c)", self.Toggle, "-c"),
            ("Toggle clobber (Dangerous!) (-C)", self.Toggle, "-C"),
            ("Toggle halt-on-error (-p green)", self.Toggle, "-p", "green"),
            ("Toggle verbose mode (-v)", self.Toggle, "-v"),
            ("Toggle static build (-tnodll)", self.Toggle, "-tnodll"),
            ("Checkout source for selected target now", self.CheckoutSource),
            (self.TagMenuOption, self.SetTag),
            ("Help Page (full help in build/doc/index.html)", self.Help)
        ]