build.py'ye try/except bloğu eklendi ( 4 action betiği ), geri kalan coding standarta uymak adına...

This commit is contained in:
S.Çağlar Onur
2005-06-16 11:31:09 +00:00
parent bf202d8c27
commit 61a54e0933
8 changed files with 52 additions and 48 deletions
+4 -4
View File
@@ -3,7 +3,7 @@
import os import os
def configure( parameters = None): def configure(parameters = None):
''' FIXME: Düzgün hale getirilecek ''' ''' FIXME: Düzgün hale getirilecek '''
''' {EXTRA} = '--with-nls --with-libusb --with-something-usefull ''' ''' {EXTRA} = '--with-nls --with-libusb --with-something-usefull '''
@@ -15,11 +15,11 @@ def configure( parameters = None):
--sysconfdir=/etc \ --sysconfdir=/etc \
--localstatedir=/var/lib {EXTRA}' --localstatedir=/var/lib {EXTRA}'
os.system( configure_string.replace( '{EXTRA}', parameters )) os.system(configure_string.replace('{EXTRA}', parameters))
def make(): def make():
''' FIXME: Düzgün hale getirilecek ''' ''' FIXME: Düzgün hale getirilecek '''
os.system( 'make' ) os.system('make')
def install(): def install():
''' FIXME: Düzgün hale getirilecek ''' ''' FIXME: Düzgün hale getirilecek '''
@@ -34,4 +34,4 @@ def install():
install' install'
# FIXME: need to get install directory from pisi.config... # FIXME: need to get install directory from pisi.config...
os.system( install_string.replace( '{D}', os.path.dirname( os.path.dirname( os.getcwd())) + '/install' )) os.system(install_string.replace('{D}',os.path.dirname(os.path.dirname(os.getcwd())) + '/install'))
+6 -6
View File
@@ -7,18 +7,18 @@ from shell import *
def gnuconfig_findnewest(): def gnuconfig_findnewest():
''' find the newest config.* file according to timestamp and return it ''' ''' find the newest config.* file according to timestamp and return it '''
locations = [ '/usr/share/gnuconfig/config.sub', '/usr/share/automake-1.8/config.sub', '/usr/share/automake-1.7/config.sub', '/usr/share/automake-1.6/config.sub', '/usr/share/automake-1.5/config.sub', '/usr/share/automake-1.4/config.sub' ] locations = ['/usr/share/gnuconfig/config.sub', '/usr/share/automake-1.8/config.sub', '/usr/share/automake-1.7/config.sub', '/usr/share/automake-1.6/config.sub', '/usr/share/automake-1.5/config.sub', '/usr/share/automake-1.4/config.sub']
newer_location = {} newer_location = {}
for i in locations: for i in locations:
newer_location[i] = re.sub( '\'', '', string.split( ( cat( i ) | tr( str.rstrip ) | grep ( '^timestamp' ) | join ), '=')[1] ) newer_location[i] = re.sub( '\'', '', string.split((cat( i ) | tr(str.rstrip) | grep ('^timestamp') | join), '=')[1])
keys = newer_location.keys() keys = newer_location.keys()
keys.sort() keys.sort()
map(newer_location.get, keys ) map(newer_location.get, keys)
return os.path.dirname( newer_location.popitem()[0] ) return os.path.dirname(newer_location.popitem()[0])
def gnuconfig_update(): def gnuconfig_update():
''' copy newest config.* onto source's ''' ''' copy newest config.* onto source's '''
@@ -26,8 +26,8 @@ def gnuconfig_update():
newer_location = gnuconfig_findnewest() newer_location = gnuconfig_findnewest()
try: try:
shutil.copyfile( newer_location + '/config.sub', os.getcwd() + '/config.sub' ) shutil.copyfile(newer_location + '/config.sub', os.getcwd() + '/config.sub')
shutil.copyfile( newer_location + '/config.guess', os.getcwd() + '/config.guess' ) shutil.copyfile(newer_location + '/config.guess', os.getcwd() + '/config.guess')
except IOError: except IOError:
print 'Hata mata...' print 'Hata mata...'
sys.exit() sys.exit()
+2 -2
View File
@@ -12,5 +12,5 @@ def libtoolize():
# no need to create a context for calling static functions # no need to create a context for calling static functions
# currently staticmethods doesn't work in Contex but this function isn't used to ;) # currently staticmethods doesn't work in Contex but this function isn't used to ;)
os.system( 'patch -sN < ' + Context.lib_dir() + '/portage-1.4.1.patch' ) os.system('patch -sN < ' + Context.lib_dir() + '/portage-1.4.1.patch')
os.system( 'patch -sN < ' + Context.lib_dir() + '/sed-1.4.0.patch' ) os.system('patch -sN < ' + Context.lib_dir() + '/sed-1.4.0.patch')
+22 -22
View File
@@ -5,53 +5,53 @@ import sys, re
from itertools import izip, imap, count, ifilter, ifilterfalse from itertools import izip, imap, count, ifilter, ifilterfalse
def cat( filename ): def cat( filename ):
return file( filename ).xreadlines() return file(filename).xreadlines()
class grep: class grep:
"""keep only lines that match the regexp""" """keep only lines that match the regexp"""
def __init__( self,pat, flags = 0 ): def __init__(self,pat, flags = 0):
self.fun = re.compile( pat, flags ).match self.fun = re.compile(pat, flags).match
def __ror__( self, input ): def __ror__(self, input):
return ifilter( self.fun, input ) return ifilter(self.fun, input)
class tr: class tr:
"""apply arbitrary transform to each sequence element""" """apply arbitrary transform to each sequence element"""
def __init__( self, transform ): def __init__(self, transform):
self.tr = transform self.tr = transform
def __ror__( self, input ): def __ror__(self, input):
return imap( self.tr, input ) return imap(self.tr, input)
class printto: class printto:
"""print sequence elements one per line""" """print sequence elements one per line"""
def __init__( self, out = sys.stdout ): def __init__(self, out = sys.stdout):
self.out = out self.out = out
def __ror__( self,input ): def __ror__(self,input):
for l in input: for l in input:
print >> self.out, l print >> self.out, l
printlines = printto( sys.stdout ) printlines = printto(sys.stdout)
class terminator: class terminator:
def __init__( self,method ): def __init__(self,method):
self.process = method self.process = method
def __ror__( self,input ): def __ror__(self,input):
return self.process( input ) return self.process(input)
aslist = terminator( list ) aslist = terminator(list)
asdict = terminator( dict ) asdict = terminator(dict)
astuple = terminator( tuple ) astuple = terminator(tuple)
join = terminator( "".join ) join = terminator("".join)
enum = terminator( enumerate ) enum = terminator(enumerate)
class sort: class sort:
def __ror__( self,input ): def __ror__(self,input):
ll = list( input ) ll = list(input)
ll.sort() ll.sort()
return ll return ll
sort = sort() sort = sort()
class uniq: class uniq:
def __ror__( self,input ): def __ror__(self,input):
for i in input: for i in input:
try: try:
if i == prev: if i == prev:
+2 -2
View File
@@ -4,8 +4,8 @@
import time import time
from tempfile import mkstemp, mkdtemp from tempfile import mkstemp, mkdtemp
def sleep( sleep_time = 5 ): def sleep(sleep_time = 5):
time.sleep( sleep_time ) time.sleep(sleep_time)
def createTmpFile(): def createTmpFile():
handle, path = mkstemp() handle, path = mkstemp()
+10 -6
View File
@@ -48,24 +48,28 @@ class PisiBuild:
# applyPatches() # applyPatches()
self.actionScript = open( os.path.dirname( self.ctx.pspecfile ) + '/' + 'actions' ).read() try:
self.actionScript = open(os.path.dirname(self.ctx.pspecfile ) + '/' + 'actions').read()
except IOError, e:
print "Action Script: %s" % e
return
# FIXME: It's wrong to assume that unpacked archive # FIXME: It's wrong to assume that unpacked archive
# will create a name-version top-level directory. # will create a name-version top-level directory.
# Archive module should give the exact location. # Archive module should give the exact location.
# (from the assumption is evil dept.) # (from the assumption is evil dept.)
os.chdir( self.ctx.build_work_dir() + "/" + self.spec.source.name + "-" + self.spec.source.version) os.chdir(self.ctx.build_work_dir() + "/" + self.spec.source.name + "-" + self.spec.source.version)
locals = globals = {} locals = globals = {}
try: try:
exec compile( self.actionScript , "error", "exec" ) in locals,globals exec compile(self.actionScript , "error", "exec") in locals,globals
except SyntaxError, e: except SyntaxError, e:
print "Error : %s" % e print "Error : %s" % e
return return
self.configureSource( locals ) self.configureSource(locals)
self.buildSource( locals ) self.buildSource(locals)
self.installSource( locals ) self.installSource(locals)
def fetchArchive(self, percentHook=None): def fetchArchive(self, percentHook=None):
"""fetch an archive and store to ctx.archives_dir() """fetch an archive and store to ctx.archives_dir()
+4 -4
View File
@@ -2,13 +2,13 @@
# installation database # installation database
# maintainer: eray and caglar # maintainer: eray and caglar
import config from context import Context
import util import util
import bsddb.dbshelve as shelve import bsddb.dbshelve as shelve
util.check_dir( config.db_dir() ) util.check_dir(Context.db_dir())
d = shelve.open( config.db_dir() + '/install.bdb') d = shelve.open(Context.db_dir() + '/install.bdb')
files_dir = config.archives_dir() + "/files" files_dir = Context.archives_dir() + "/files"
class InstallDBError(Exception): class InstallDBError(Exception):
pass pass
+1 -1
View File
@@ -16,7 +16,7 @@ def info(msg):
# default UI implementation # default UI implementation
class CLI: class CLI:
def info(self, msg): def info(self, msg):
sys.stdout.write( bold( red (msg))) sys.stdout.write(bold(red(msg)))
sys.stdout.flush() sys.stdout.flush()
# default UI is CLI # default UI is CLI