Some cleanups to update_patches, should run properly on any system now.

This commit is contained in:
LexManos 2012-04-02 01:09:00 -07:00
parent 719e436caa
commit 21afe2a2aa
3 changed files with 65 additions and 97 deletions

View file

@ -1,21 +1,3 @@
@setlocal enabledelayedexpansion
@echo off @echo off
set PATH=.\bin;%PATH% set PATH=.\bin;%PATH%
..\runtime\bin\python\python_mcp update_patches.py
python update_patches.py
echo Grabbing copy of conf folder
for /f %%i in ('find conf -type f') do (
set file=%%i
if %%i NEQ ".gitignore" (
del !file:/=\!
)
)
xcopy ..\conf conf /E /I /Y
tr -d \r < ../conf/mcp.cfg > conf/mcp.cfg
tr -d \r < ../conf/patches/Start.java > conf/patches/Start.java
echo Finished
pause

View file

@ -2,7 +2,7 @@ import os
import commands import commands
import fnmatch import fnmatch
import re import re
import subprocess, shlex import subprocess, shlex, shutil
def cmdsplit(args): def cmdsplit(args):
if os.sep == '\\': if os.sep == '\\':
@ -25,16 +25,15 @@ def cleanDirs(path):
os.rmdir(path) os.rmdir(path)
def main(): def main():
print Creating patches print 'Creating patches'
base = os.path.normpath(os.path.join('..', 'src_base')) base = os.path.normpath(os.path.join('..', 'src_base'))
work = os.path.normpath(os.path.join('..', 'src_work')) work = os.path.normpath(os.path.join('..', 'src_work'))
timestamp = re.compile(r'[0-9-]* [0-9:\.]* [+-][0-9]*\r?\n') timestamp = re.compile(r'[0-9-]* [0-9:\.]* [+-][0-9]*\r?\n')
for path, _, filelist in os.walk(work, followlinks=True): for path, _, filelist in os.walk(work, followlinks=True):
for cur_file in fnmatch.filter(filelist, '*.java'): for cur_file in fnmatch.filter(filelist, '*.java'):
#print cur_file + " " + path[12:] file_base = os.path.normpath(os.path.join(base, path[12:], cur_file)).replace(os.path.sep, '/')
file_base = os.path.normpath(os.path.join(base, path[12:], cur_file)) file_work = os.path.normpath(os.path.join(work, path[12:], cur_file)).replace(os.path.sep, '/')
file_work = os.path.normpath(os.path.join(work, path[12:], cur_file))
patch = '' patch = ''
cmd = 'diff -u %s %s -r --strip-trailing-cr --new-file' % (file_base, file_work) cmd = 'diff -u %s %s -r --strip-trailing-cr --new-file' % (file_base, file_work)
process = subprocess.Popen(cmdsplit(cmd), stdout=subprocess.PIPE, stderr=subprocess.STDOUT, bufsize=-1) process = subprocess.Popen(cmdsplit(cmd), stdout=subprocess.PIPE, stderr=subprocess.STDOUT, bufsize=-1)
@ -49,15 +48,18 @@ def main():
if not os.path.exists(patch_dir): if not os.path.exists(patch_dir):
os.makedirs(patch_dir) os.makedirs(patch_dir)
with open(patch_file, 'w') as fh: with open(patch_file, 'wb') as fh:
fh.write(patch) fh.write(patch)
else: else:
if os.path.isfile(patch_file): if os.path.isfile(patch_file):
print 'Deleting empty patch: ' + patch_file print 'Deleting empty patch: ' + patch_file
os.remove(patch_file) os.remove(patch_file)
cleanDirs('patches') cleanDirs('patches')
print 'Grabing copy of Conf'
if os.path.exists('conf'):
shutil.rmtree('conf')
shutil.copytree('../conf', './conf/')
if __name__ == '__main__': if __name__ == '__main__':
main() main()

View file

@ -1,17 +1 @@
fdir=$PWD
python update_patches.py python update_patches.py
echo Grabbing copy of conf folder
for i in `find $fdir/conf -type f | grep -a -v ".gitignore"`
do
rm $i
done
for i in `find $fdir/conf -depth -empty -type d | grep -a -v ".git"`
do
rmdir "$i"
done
mkdir -p $fdir/conf
cp -r conf/* $fdir/conf
echo Finished