[Cvsshell-devel] CVS: cvsshell build.py,NONE,1.1
Status: Beta
Brought to you by:
stefanheimann
From: Stefan H. <ste...@us...> - 2002-03-16 13:26:09
|
Update of /cvsroot/cvsshell/cvsshell In directory usw-pr-cvs1:/tmp/cvs-serv11072 Added Files: build.py Log Message: initial checkin of buildscript --- NEW FILE: build.py --- #!/usr/bin/env python ############################################################################### # This file is part of CvsShell # # CvsShell is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. # # CvsShell is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with CvsShell; if not, write to the Free Software # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA # # Copyright 2002 by Stefan Heimann # Website: http://cvsshell.sourceforge.net/ ############################################################################### # Note: This script requires GNU tar and GNU find to be installed on your system. ############################## # Constants ############################## # all files in these directories will be included in the distribution # Note: subdirectories are NOT included. DIST_DIRS = ['', 'src', 'images', 'etc'] ############################## # Initialization ############################## import sys, os, string thisDir = os.path.join(os.getcwd(), sys.path[0]) sys.path.insert(1, os.path.join(thisDir, 'src')) from app import App from cvs_shell import NAME, VERSION, COPYRIGHT, BUG_ADDRESS class BuildApp(App): def __init__(self): App.__init__(self) self.setName(NAME + " Build Procedure") self.setVersion(VERSION) self.setCopyright(COPYRIGHT) self.setBugAddress(BUG_ADDRESS) self.initOptions() def run(self): os.chdir(thisDir) targets = [] for t in self.restargs(): try: fun = eval('self.' + t) except NameError, msg: self.printErr("Target %s does not exist in this project." % t) else: targets.append(fun) if len(targets) == 0: self.printMsg('No targets given.') for fun in targets: self.printMsg("Target " + fun.__name__) fun() def clean(self): cmd = "find . -name 'build' -o -name '*.pyc' -o -name '*~' -o -name '#*' -o -name '.#*'| xargs rm -r" self.printMsg(cmd) os.system(cmd) def pack(self): self.clean() distname = NAME.lower() + '-' + VERSION destdir = os.path.join('build', distname) try: os.makedirs(destdir, 0755) except: pass def collect(destdir, dirname, filenames): import shutil dirname = dirname.replace(thisDir, '') if len(dirname) > 0 and dirname[0] == os.sep: dirname = dirname[1:] if dirname in DIST_DIRS: for name in filenames: if os.path.isdir(name): continue src = os.path.join(dirname, name) dest = os.path.join(destdir, dirname, name) try: os.makedirs(os.path.join(destdir, dirname), 0755) except: pass shutil.copy(src, dest) os.path.walk(thisDir, collect, destdir) os.chdir('build') tarname = distname + ".tar.gz" os.system('tar cfz %s %s' % (tarname, distname)) os.system('tar tfz %s' % tarname) os.chdir(thisDir) if __name__ == '__main__': app = BuildApp() app.main() |