Ejemplo n.º 1
0
def prePackage():
	# extra other files
	for item in gv.EXTRA_FILES:
		file = os.path.basename(item)
		if not os.path.exists(gv.EXTRA_PATH + '/' + file):
			func.errorReport(gv.EXTRA_PATH + '/' + file + ' not exists')
	
	# build number check
	cfg = ConfigParser.ConfigParser();
	cfg.read(gv.BUILD_INI_FILE)
	currentNum = cfg.get(gv.BUILD_INI_SEC, gv.CURRENT_BUILDNUM)
	revision = cfg.get(gv.BUILD_INI_SEC, gv.CURRENT_REVISION)
	
	lastRevision = cfg.get(gv.BUILD_INI_SEC, 'build' + currentNum)
	if int(lastRevision) > int(revision):
		func.errorReport('No need to package\nNow Revison: ' + revision + ', Last:' +lastRevision + '(Build' + currentNum + ')')
	
	# conf / files / package
	outputs = [gv.PACK_CONF_PATH, gv.PACK_FILE_PATH, gv.PACK_PACK_PATH]
	for item in outputs:
		if os.path.exists(item):
			shutil.rmtree(item)
		os.makedirs(item)
	
	# delete old package
	if os.path.exists(gv.ITM_PACKAGE_NAME):
		os.remove(gv.ITM_PACKAGE_NAME)
	
	func.tip('Prepare for Package Finish.', '32');
	func.tip('-------------------------------------');
Ejemplo n.º 2
0
def generateCfgIni():
	for branch in gv.SVN_EACH_BRANCH:
		if os.path.exists(gv.FILE_INI_PATH + '/' + branch + '.ini'):
			_getSvnList(branch);
			_updateCfgIni(branch);
			func.tip('++++ update ini ' + branch + ' \t++++');
		else:
			func.errorReport(item + " origin ini miss")
	func.tip('Generate Latest Ini Config', '32');
Ejemplo n.º 3
0
def _combineBaseCfg(info):
	tmp = [ info['act'], info['typ'], info['dst'][1:], info['dst'], info['grp'], info['own'], info['mod'] ]
	ret = ' '.join(tmp) + '\n'
	
	if gv.DEBUG_SWITCH == 1:
		if info['act'] == 'm':
			func.tip('\n[SRC]: ' + info['src'] + '\n[DST]: ' + info['dst'] + '\n[MSG]: ' + ret.strip(), '33')
		else:
			func.tip('\n[SRC]: ' + info['src'] + '\n[DST]: ' + info['dst'] + '\n[MSG]: ' + ret.strip(), '37')
	
	return ret
Ejemplo n.º 4
0
def tarItmPkg():
	current_path = os.getcwd()
	tar = tarfile.open(gv.ITM_PACKAGE_NAME, 'w:gz')
	os.chdir(gv.PACK_PACK_PATH)
	for root,dir,files in os.walk("./"):
		for file in files:
			fullpath = os.path.join(root, file)
			tar.add(fullpath)
	tar.close()
	os.chdir(current_path)
	func.tip('Create TGZ Patch Finish', '32');
	func.tip('-------------------------------------');
Ejemplo n.º 5
0
def checkUninited():
	for branch in gv.SVN_EACH_BRANCH:
		_checkByAct(branch, 'add');
		func.tip('++++ check uninited ' + branch + ' \t++++');
	
	if uninit_items > 0:
		func.tip('\033[40;32mUninitialied Files: ' + str(uninit_items));
		func.tip('Go to ' + gv.FILE_INI_PATH + ' REWRITE INI Files', '32');
		func.tip('Run\'./make_patch.py uninited\' to check after rewrite', '32');
		func.errorReport();
	
	func.tip('No-Uninited Sections Exists', '32');
Ejemplo n.º 6
0
def releasePkg():
	if not os.path.exists(gv.RELEASE_PATH):
		os.makedirs(gv.RELEASE_PATH)
	
	cfg = ConfigParser.ConfigParser()
	cfg.read(gv.BUILD_INI_FILE)
	lastBuild = gv.RELEASE_PATH + '/build' + cfg.get(gv.BUILD_INI_SEC, gv.CURRENT_BUILDNUM)
	if os.path.exists(lastBuild):
		shutil.rmtree(lastBuild)
	os.mkdir(lastBuild)
	shutil.move(gv.ITM_PACKAGE_NAME, lastBuild + '/' + gv.ITM_PACKAGE_NAME)
	func.tip('Release Build  Done', '32');
	func.tip('-------------------------------------');
Ejemplo n.º 7
0
def pkgFiles(branch):
	ins_cfg = gv.PACK_CONF_PATH + '/' + branch + '.cfg'
	cfgcontent = ''
	# whether need add ignore??
	
	ini = gv.FILE_INI_PATH + '/' + branch + '.ini'
	cfgPsr = ConfigParser.ConfigParser()
	cfgPsr.read(ini)
	
	difflist = gv.DIFF_LIST_PATH + '/' + branch + '.txt'
	fileAdapter = open(difflist)
	for line in fileAdapter:
		line = line.strip()
		if line.find('#') == 0 or line.strip() == '':
			continue;
		
		(svnAct, svnpath) = line.split(' ')
		svnAct = svnAct.lower()
		
		if not cfgPsr.has_section(svnpath):
			if cfgPsr.has_section(svnpath + '/'):
				svnpath += '/'
		
		dictIni = _infoParser(cfgPsr.items(svnpath))
		if dictIni['act'] == 'i':
			if gv.DEBUG_SWITCH == 1:
				if dictIni['typ'] == 'f':
					_sec_type = 'FILE'
				elif dictIni['typ'] == 'd':
					_sec_type = 'DIRS'
				else:
					_sec_type = 'null'
				func.tip('[SEC]: ' + svnpath + '\n[IGN]: ' + _sec_type + '\n[PTH]: ' + svnpath, '35')
			continue;
		
		
		if svnAct == 'd':
			dictIni['act'] = 'm'
			dictIni['mod'] = '0'
			dictIni['own'] = '0'
			dictIni['grp'] = '0'
			cfgcontent += _combineBaseCfg(dictIni)
		elif svnAct == 'm' or svnAct == 'a':
			dictIni['sec'] = svnpath
			dictIni['act'] = 'a'
			tmp = _combineAddCfg(dictIni)
			# if tmp == '':
			# 	func.errorReport('[' + svnpath + '] combine:\n' + str(dictIni))
			cfgcontent += tmp
		
	func.writeFile(ins_cfg, cfgcontent)
Ejemplo n.º 8
0
def _checkByAct(branch, act='add'):
	config = ConfigParser.ConfigParser();
	ini = gv.FILE_INI_PATH + '/' + branch + '.ini'
	
	config.read(ini)
	sections = config.sections();
	
	_secUni = ''
	_secIgn = ''
	_countUni = 0
	_countIgn = 0
	for item in sections:
		action = config.get(item, 'act')
		if action == 'Z':
			_countUni += 1
			_secUni += '\n  [UnInit-' + str(_countUni).zfill(4) + ']: ' + item
		elif action == 'I':
			_countIgn += 1
			_secIgn += '\n  [Ignore-' + str(_countIgn).zfill(4) + ']: ' + item
	global uninit_items;
	uninit_items += _countUni;
	
	if act == 'all':
		if not _secIgn == '':
			func.tip('  ====[Ignore files/dirs]====' + _secIgn, '34')
		if not _secUni == '':
			func.tip('  ====[UnInit files/dirs]====' + _secUni, '33')
	elif act == 'ign':
		if not _secIgn == '':
			func.tip('  ====[Ignore files/dirs]====' + _secIgn, '34')
	elif act == 'add':
		if not _secUni == '':
			func.tip('  ====[UnInit files/dirs]====' + _secUni, '33')
Ejemplo n.º 9
0
def copyToPack():
	# 0. clear dir
	if os.path.exists(gv.PACK_PACK_PATH):
		shutil.rmtree(gv.PACK_PACK_PATH)
	os.makedirs(gv.PACK_PACK_PATH)
	
	# 1. conf
	conf = gv.PACK_PACK_PATH + '/conf'
	os.makedirs(conf)
	shutil.copyfile(gv.PACK_CONF_PATH + '/files.cfg', conf + '/files.cfg')
	shutil.copyfile(gv.PACK_CONF_PATH + '/version', conf + '/version')
	shutil.copyfile(gv.PACK_CONF_PATH + '/revision', conf + '/revision')
	
	# 2. misc/update
	updir = gv.LOCAL_CODE_PATH + '/misc/update'
	tree = [os.path.join(updir, file) for file in os.listdir(updir)]
	for item in tree:
		if os.path.isfile(item):
			shutil.copy(item, gv.PACK_PACK_PATH)
		if os.path.isdir(item):
			src = os.path.split(item)[1]
			if src == '.svn' or src == 'conf' or src == 'files':
				continue;
			dst = os.path.join(gv.PACK_PACK_PATH,src)
			shutil.copytree(item, dst)
	tree = [os.path.join(gv.PACK_PACK_PATH, file) for file in os.listdir(gv.PACK_PACK_PATH)]
	for item in tree:
		if item.split('.')[-1] == 'sh':
			os.chmod(item, 0755)
	
	os.path.walk(gv.PACK_PACK_PATH, _excludeSvn, None)
	
	# 3. files
	tmpdir = gv.PACK_PACK_PATH + '/' + os.path.split(gv.PACK_FILE_PATH)[1]
	if os.path.exists(tmpdir):
		shutil.rmtree(tmpdir)
	shutil.copytree(gv.PACK_FILE_PATH, tmpdir)
	func.tip('Copy All Files To ' + gv.PACK_PACK_PATH, '32');
	func.tip('-------------------------------------');
Ejemplo n.º 10
0
def arrangeCfg():
	ret = ''
	for item in gv.SVN_EACH_BRANCH:
		cfg = gv.PACK_CONF_PATH + '/' + item + '.cfg'
		ret = ret + open(cfg).read()
	
	cfgall = gv.PACK_CONF_PATH + '/files.cfg'
	if os.path.exists(cfgall):
		os.remove(cfgall)
	
	for item in gv.EXTRA_FILES:
		src = item[1:]
		tmp = 'a f ' + src + ' ' + item + ' root root 0644\n'
		ret += tmp
		
		# copy extra to files
		if os.path.basename(item) == 'version':
			cfgPsr = ConfigParser.ConfigParser()
			cfgPsr.read(gv.BUILD_INI_FILE)
			last = int(cfgPsr.get(gv.BUILD_INI_SEC, gv.CURRENT_BUILDNUM))
			revision = cfgPsr.get(gv.BUILD_INI_SEC, gv.CURRENT_REVISION)
			
			latest = str(last + 1)
			cfgPsr.set(gv.BUILD_INI_SEC, 'build' + latest, revision)
			cfgPsr.set(gv.BUILD_INI_SEC, gv.CURRENT_BUILDNUM, latest)
			cfgPsr.write(open(gv.BUILD_INI_FILE, 'w'))
			func.tip('[Build]:' + latest + '\t[Revision]:' + revision, '31')
			
			verCfg = gv.ITM_VERSION + '-' + latest
			func.writeFile(gv.PACK_CONF_PATH + '/version', verCfg + '\n')
			func.writeFile(gv.PACK_CONF_PATH + '/revision', revision + '\n')
			
			verFile = gv.PACK_FILE_PATH + item
			if not os.path.exists(os.path.dirname(verFile)):
				os.makedirs(os.path.dirname(verFile))
			
			cmd = 'sed \'s/^Last_Build_SN.*/Last_Build_SN=' + latest + '/\' ' + gv.EXTRA_PATH + '/' + os.path.basename(item) +' > ' + verFile
			os.system(cmd)
		else:
			srcExtra = gv.EXTRA_PATH + '/' + os.path.basename(item)
			dstExtra = gv.PACK_FILE_PATH + item
			if not os.path.exists(os.path.dirname(dstExtra)):
				os.makedirs(os.path.dirname(dstExtra))
			shutil.copyfile(srcExtra, dstExtra)
	
	# sort -u
	listRet1 = ret.split('\n')
	listRet2 = list(set(listRet1))
	listRet2.sort(key = listRet1.index)
	ret = '\n'.join(listRet2)
	
	func.writeFile(cfgall, ret)
	func.tip('Update Files.cfg Finish', '32');
	func.tip('-------------------------------------');
Ejemplo n.º 11
0
def updateSvnCode():
	#for branch in gv.SVN_EACH_BRANCH:
	#	updateBranch();
	updateBranch();
	func.tip('...Update Svn Code to Local...', '32');
Ejemplo n.º 12
0
def mainPackage():
	for item in gv.SVN_EACH_BRANCH:
		pkgFiles(item)
	func.tip('Copy Files Finish', '32');
	func.tip('-------------------------------------');
Ejemplo n.º 13
0
def checkCfgIni():
	illegals = 0;
	if os.path.exists(gv.CHECK_CONF_PATH):
		os.system('rm -rf ' + gv.CHECK_CONF_PATH)
	os.makedirs(gv.CHECK_CONF_PATH)
	
	for branch in gv.SVN_EACH_BRANCH:
		# diff list
		file_diff = gv.DIFF_LIST_PATH + '/' + branch + '.txt'
		file_inis = gv.FILE_INI_PATH + '/' + branch + '.ini'
		
		cfgPsr = ConfigParser.ConfigParser()
		cfgPsr.read(file_inis)
		
		_cfgStr = ''
		_errStr = ''
		# read each line Of diff.txt
		file_reader = open(file_diff)
		for line in file_reader:
			line = line.strip();
			# comment line & null line, skip;
			if line.find('#') == 0 or line.strip() == '':
				continue;
			(act, codepath) = line.split(' ');
			if _checkInSkipDirs(codepath) == 1:
				_cfgStr += codepath + '\n  [action]: IGNORE  [reason]: belong to SVN_SKIP_DIRS\n';
				continue;
			
			
			# errorReport
			if not cfgPsr.has_section(codepath):
				if cfgPsr.has_section(codepath + '/'):
					codepath += '/';
				else:
					_errStr += codepath + '\n  [reason]: NOT EXSITS\n'
					continue;
			
			dictIni = _parserInfo(cfgPsr.items(codepath));
			if dictIni['typ'] == '' and dictIni['act'] == '' and dictIni['src'] == '' and dictIni['dst'] == '' and dictIni['mod'] == '' and dictIni['own'] == '' and dictIni['grp'] == '':
				_errStr += codepath + '\n  [reason]: PROPERTIES UNDEFINED\n';
				continue;
			
			# Dirs, src & dst not allow multi
			if dictIni['typ'] == 'd':
				if (len(dictIni['src'].strip()) > 1) or (len(dictIni['dst'].strip()) > 1):
					_errStr += codepath + '\n  [reason]: Dirs src/dst UnALLOWED MULTI';
					continue;
			
			if dictIni['act'] == 'i':
				_cfgStr += codepath + '\n  [act]: IGNORE\n  [reason]: defined by '+ branch +'.ini\n';
				continue;
			elif dictIni['act'] == 'z':
				_errStr += codepath + '\n  [reason]: UNINITIALIEZED\n'
				continue;
			
			# check srcNums & dstNums
			_srcNums = str.count(dictIni['src'], '|')
			_dstNums = str.count(dictIni['dst'], '|')
			if not _srcNums == _dstNums:
				_errStr += codepath + '\n  [reason]: SRC & DST NUMBERS NOT EQUAL\n'
				continue;
			
			# check src whether exist or not
			# exist 1 at least!!
			_srcCount = 0;
			_srcS = dictIni['src'].split('|');
			for each in _srcS:
				if os.path.exists(gv.LOCAL_CODE_PATH + '/' + each):
					_srcCount += 1;
			if _srcCount == 0:
				if not act == 'D':
					_errStr += codepath + '\n  [reason]: NOT FOUND SRC, BUT CHANGED\n'
					continue;
			
			# check dst, if not start with '/', error
			_dstCount = 0;
			_dstS = dictIni['dst'].split('|');
			for each in _dstS:
				if not each.find('/') == 0:
					_errStr += codepath + '\n  [reason]: DST PATH NOT START WITH \'/\'\n'
			
			# check finish
			_cfgStr += codepath + '\n  [act]: ' + dictIni['act'] + '  \t[type]:  ' + dictIni['typ'] + '\n'
			_cfgStr += '  [src]: ' + dictIni['src'] + '\n  [dst]: ' + dictIni['dst'] + '\n'
			_cfgStr += '  [mod]: ' + dictIni['mod'] + '  \t[own]: ' + dictIni['own'] + '  \t[grp]: ' + dictIni['grp'] + '\n'
		
		func.writeFile(gv.CHECK_CONF_PATH + '/' + branch + '-cfg.txt', _cfgStr, 'w');
		func.writeFile(gv.CHECK_CONF_PATH + '/' + branch + '-err.txt', _errStr, 'w');
		
		if not len(_errStr) == 0:
			illegals += 1;
			func.tip(branch + '.ini EXISTS ERRORS', '31')
		
		if gv.DEBUG_SWITCH == 1:
			if not len(_errStr) == 0:
				func.tip(_errStr, '31');
		
		func.tip('++++ check ini ' + branch + ' \t++++');
	
	if not illegals == 0:
		func.errorReport('INI Config Illegal, Go "' + gv.CHECK_CONF_PATH + '" to check')
	
	func.tip('INI Config Check Finished.', '32')
Ejemplo n.º 14
0
def updateDifflist():
	for branch in gv.SVN_EACH_BRANCH:
		_getDifflist(branch)
		func.tip('++++ diff list ' + branch + ' \t++++');
	func.tip('Different List To: ' + gv.DIFF_LIST_PATH, '32')