def update_tree(self, item, cmode, ignore_error): if (item == None): h_child_item = self.get_root_item() else: h_child_item = self.get_child_item(item) while(h_child_item != None): if (self.get_child_item(h_child_item) == None): item_text = self.get_item_text(h_child_item) if str(item_text).find("_" + cmode[0:2] + "_") != -1: full_svn_path = self.get_full_path(h_child_item, '|')[0] real_svn_path = str(full_svn_path).replace('|', '/') svn_root_path = full_svn_path[:str(full_svn_path).find('|')] cache_root_path = Glo.get_local_cache_path(svn_root_path, self.__repositories) if cache_root_path == None: print svn_root_path + ' does not exist in .buildc.rc' sys.exit(Errors.conf_item_not_found) full_cache_path = cache_root_path + '|' + full_svn_path[str(full_svn_path).find('|')+1:] real_cache_path = str(full_cache_path).replace('|', '/') real_cache_version_path = real_cache_path[:str(real_cache_path).rfind('/')] real_cache_name_path = real_cache_version_path[:str(real_cache_version_path).rfind('/')] dep_libname = real_cache_name_path[str(real_cache_name_path).rfind('/')+1:] dep_libversion = real_cache_version_path[str(real_cache_version_path).rfind('/')+1:] (trunk_user, trunk_passwd) = self.__get_user_and_passwd_by_url(svn_root_path) svn_revision_code = SvnLocalOper.get_svn_info_revision_code(real_svn_path, True, trunk_user, trunk_passwd) if h_child_item.data == 'none': if os.path.exists(real_cache_path): Util.execute_and_return("rm -rf " + real_cache_path) else: if not os.path.exists(real_cache_path): print 'library [' + dep_libname + ' ' + dep_libversion + '] does not exist!' print 'Checkout [' + real_svn_path + ']...' SvnLocalOper.checkout(real_svn_path, real_cache_path, ignore_error, trunk_user, trunk_passwd) print 'Checkout [' + real_svn_path + '] OK!' else: cache_revision_code = SvnLocalOper.get_svn_info_revision_code(real_cache_path, None) if svn_revision_code != cache_revision_code: print 'Update [' + dep_libname + ' ' + dep_libversion + ']...' SvnLocalOper.update(real_cache_path, ignore_error, trunk_user, trunk_passwd) print 'Update [' + dep_libname + ' ' + dep_libversion + '] OK!' h_child_item.data = svn_revision_code self.update_tree(h_child_item, cmode, ignore_error) h_child_item = self.get_next_sibling_item(h_child_item)
def build_dependent(self, dep_libname, dep_libversion, cmode, force_update = True): lib_flag = False h_child_item = self.get_root_item() while(h_child_item != None): svn_root_path = self.get_item_text(h_child_item) full_svn_path = svn_root_path + '|' + dep_libname + '|' + dep_libversion + '|' + Glo.CPU + '_' + cmode[0:2] + '_' + Glo.SYSTEM real_svn_path = str(full_svn_path).replace('|', '/') leaf_node = self.find_item(full_svn_path, '|', False, 1) if leaf_node != None: lib_flag = True cache_root_path = Glo.get_local_cache_path(svn_root_path, self.__repositories) if cache_root_path == None: print svn_root_path + ' does not exist in .buildc.rc' sys.exit(Errors.conf_item_not_found) full_cache_path = cache_root_path + '|' + dep_libname + '|' + dep_libversion + '|' + Glo.CPU + '_' + cmode[0:2] + '_' + Glo.SYSTEM real_cache_path = str(full_cache_path).replace('|', '/') (trunk_user, trunk_passwd) = self.__get_user_and_passwd_by_url(svn_root_path) svn_revision_code = SvnLocalOper.get_svn_info_revision_code(real_svn_path, True, trunk_user, trunk_passwd) if svn_revision_code == "": return False if leaf_node.data == 'none': if os.path.exists(real_cache_path): Util.execute_and_return("rm -rf " + real_cache_path) print 'library [' + dep_libname + ' ' + dep_libversion + '] does not exist!' print 'Checkout [' + real_svn_path + ']...' result = SvnLocalOper.checkout(real_svn_path, real_cache_path, True, trunk_user, trunk_passwd) if result == False: return False print 'Checkout [' + real_svn_path + '] OK!' leaf_node.data = svn_revision_code else: if not os.path.exists(real_cache_path): print 'library [' + dep_libname + ' ' + dep_libversion + '] does not exist!' print 'Checkout [' + real_svn_path + ']...' result = SvnLocalOper.checkout(real_svn_path, real_cache_path, True, trunk_user, trunk_passwd) if result == False: return False print 'Checkout [' + real_svn_path + '] OK!' leaf_node.data = svn_revision_code else: if force_update: cache_revision_code = SvnLocalOper.get_svn_info_revision_code(real_cache_path, True) if cache_revision_code == "": return False if svn_revision_code != cache_revision_code: print 'Update [' + dep_libname + ' ' + dep_libversion + ']...' result = SvnLocalOper.update(real_cache_path, True, trunk_user, trunk_passwd) if result == False: return False print 'Update [' + dep_libname + ' ' + dep_libversion + '] OK!' leaf_node.data = svn_revision_code else: print "Do not use force_update, skip the update check!" pass break h_child_item = self.get_next_sibling_item(h_child_item) if lib_flag == True: return True else: return False
def build_dependent(self, dep_libname, dep_libversion, cmode, force_update=True): lib_flag = False h_child_item = self.get_root_item() while (h_child_item != None): svn_root_path = self.get_item_text(h_child_item) full_svn_path = svn_root_path + '|' + dep_libname + '|' + dep_libversion + '|' + Glo.CPU + '_' + cmode[ 0:2] + '_' + Glo.SYSTEM real_svn_path = str(full_svn_path).replace('|', '/') leaf_node = self.find_item(full_svn_path, '|', False, 1) if leaf_node != None: lib_flag = True cache_root_path = Glo.get_local_cache_path( svn_root_path, self.__repositories) if cache_root_path == None: print svn_root_path + ' does not exist in .buildc.rc' sys.exit(Errors.conf_item_not_found) full_cache_path = cache_root_path + '|' + dep_libname + '|' + dep_libversion + '|' + Glo.CPU + '_' + cmode[ 0:2] + '_' + Glo.SYSTEM real_cache_path = str(full_cache_path).replace('|', '/') (trunk_user, trunk_passwd ) = self.__get_user_and_passwd_by_url(svn_root_path) svn_revision_code = SvnLocalOper.get_svn_info_revision_code( real_svn_path, True, trunk_user, trunk_passwd) if svn_revision_code == "": return False if leaf_node.data == 'none': if os.path.exists(real_cache_path): Util.execute_and_return("rm -rf " + real_cache_path) print 'library [' + dep_libname + ' ' + dep_libversion + '] does not exist!' print 'Checkout [' + real_svn_path + ']...' result = SvnLocalOper.checkout(real_svn_path, real_cache_path, True, trunk_user, trunk_passwd) if result == False: return False print 'Checkout [' + real_svn_path + '] OK!' leaf_node.data = svn_revision_code else: if not os.path.exists(real_cache_path): print 'library [' + dep_libname + ' ' + dep_libversion + '] does not exist!' print 'Checkout [' + real_svn_path + ']...' result = SvnLocalOper.checkout(real_svn_path, real_cache_path, True, trunk_user, trunk_passwd) if result == False: return False print 'Checkout [' + real_svn_path + '] OK!' leaf_node.data = svn_revision_code else: if force_update: cache_revision_code = SvnLocalOper.get_svn_info_revision_code( real_cache_path, True) if cache_revision_code == "": return False if svn_revision_code != cache_revision_code: print 'Update [' + dep_libname + ' ' + dep_libversion + ']...' result = SvnLocalOper.update( real_cache_path, True, trunk_user, trunk_passwd) if result == False: return False print 'Update [' + dep_libname + ' ' + dep_libversion + '] OK!' leaf_node.data = svn_revision_code else: print "Do not use force_update, skip the update check!" pass break h_child_item = self.get_next_sibling_item(h_child_item) if lib_flag == True: return True else: return False
def update_tree(self, item, cmode, ignore_error): if (item == None): h_child_item = self.get_root_item() else: h_child_item = self.get_child_item(item) while (h_child_item != None): if (self.get_child_item(h_child_item) == None): item_text = self.get_item_text(h_child_item) if str(item_text).find("_" + cmode[0:2] + "_") != -1: full_svn_path = self.get_full_path(h_child_item, '|')[0] real_svn_path = str(full_svn_path).replace('|', '/') svn_root_path = full_svn_path[:str(full_svn_path).find('|' )] cache_root_path = Glo.get_local_cache_path( svn_root_path, self.__repositories) if cache_root_path == None: print svn_root_path + ' does not exist in .buildc.rc' sys.exit(Errors.conf_item_not_found) full_cache_path = cache_root_path + '|' + full_svn_path[ str(full_svn_path).find('|') + 1:] real_cache_path = str(full_cache_path).replace('|', '/') real_cache_version_path = real_cache_path[:str( real_cache_path).rfind('/')] real_cache_name_path = real_cache_version_path[:str( real_cache_version_path).rfind('/')] dep_libname = real_cache_name_path[str(real_cache_name_path ).rfind('/') + 1:] dep_libversion = real_cache_version_path[ str(real_cache_version_path).rfind('/') + 1:] (trunk_user, trunk_passwd ) = self.__get_user_and_passwd_by_url(svn_root_path) svn_revision_code = SvnLocalOper.get_svn_info_revision_code( real_svn_path, True, trunk_user, trunk_passwd) if h_child_item.data == 'none': if os.path.exists(real_cache_path): Util.execute_and_return("rm -rf " + real_cache_path) else: if not os.path.exists(real_cache_path): print 'library [' + dep_libname + ' ' + dep_libversion + '] does not exist!' print 'Checkout [' + real_svn_path + ']...' SvnLocalOper.checkout(real_svn_path, real_cache_path, ignore_error, trunk_user, trunk_passwd) print 'Checkout [' + real_svn_path + '] OK!' else: cache_revision_code = SvnLocalOper.get_svn_info_revision_code( real_cache_path, None) if svn_revision_code != cache_revision_code: print 'Update [' + dep_libname + ' ' + dep_libversion + ']...' SvnLocalOper.update(real_cache_path, ignore_error, trunk_user, trunk_passwd) print 'Update [' + dep_libname + ' ' + dep_libversion + '] OK!' h_child_item.data = svn_revision_code self.update_tree(h_child_item, cmode, ignore_error) h_child_item = self.get_next_sibling_item(h_child_item)