re-factor continues and some cosmetic changes for our coding standarts
This commit is contained in:
@@ -1,10 +1,11 @@
|
||||
ReFactor ActionsAPI:
|
||||
|
||||
pisitools.py - %80
|
||||
autotools.py - %0
|
||||
get.py - %50
|
||||
autotools.py - %50
|
||||
get.py - %75
|
||||
kde.py - %0
|
||||
libtools.py - %25
|
||||
pisitools_functions.py - %50
|
||||
shelltools.py - %50
|
||||
variables.py - %100
|
||||
coreutils.py - %100
|
||||
|
||||
@@ -9,4 +9,4 @@
|
||||
#
|
||||
|
||||
# pisi.actionsapi version
|
||||
__version__ = "0.1"
|
||||
__version__ = '0.1'
|
||||
|
||||
@@ -11,59 +11,41 @@
|
||||
# Please read the COPYING file.
|
||||
#
|
||||
|
||||
# standard python modules
|
||||
# Standard Python Modules
|
||||
import os
|
||||
|
||||
# actions api modules
|
||||
from variables import glb
|
||||
# ActionsAPI Modules
|
||||
import get
|
||||
from shelltools import system
|
||||
|
||||
def configure(parameters = ''):
|
||||
''' FIXME: Düzgün hale getirilecek '''
|
||||
''' parameters = '--with-nls --with-libusb --with-something-usefull '''
|
||||
dirs = glb.dirs
|
||||
env = glb.env
|
||||
''' configure source with given parameters = "--with-nls --with-libusb --with-something-usefull"'''
|
||||
|
||||
configure_string = './configure --prefix=/%s \
|
||||
--host=%s \
|
||||
--mandir=/%s \
|
||||
--infodir=/%s \
|
||||
--datadir=/%s \
|
||||
--sysconfdir=/%s \
|
||||
--localstatedir=/%s \
|
||||
%s' % (dirs.defaultprefix,
|
||||
env.host,
|
||||
dirs.man,
|
||||
dirs.info,
|
||||
dirs.data,
|
||||
dirs.conf,
|
||||
dirs.localstate,
|
||||
parameters)
|
||||
configure_string = './configure --prefix=/%s --host=%s --mandir=/%s \
|
||||
--infodir=/%s --datadir=/%s --sysconfdir=/%s \
|
||||
--localstatedir=/%s %s' \
|
||||
% (get.defaultprefixDIR(), get.HOST(), get.manDIR(),
|
||||
get.infoDIR(), get.dataDIR(), get.confDIR(),
|
||||
get.localstateDIR(), parameters)
|
||||
|
||||
system(configure_string)
|
||||
|
||||
os.system(configure_string)
|
||||
|
||||
def rawConfigure(parameters = ''):
|
||||
os.system('./configure ' + parameters)
|
||||
''' configure source with given parameters = " --prefix=/usr --libdir=/usr/lib --with-nls"'''
|
||||
system('./configure %s' % parameters)
|
||||
|
||||
#FIXME: Find another way!
|
||||
def rawConfigureWithPrefix(prefix='', parameters = ''):
|
||||
os.system(prefix + ' ./configure ' + parameters)
|
||||
system('%s ./configure %s' % ( prefix, parameters))
|
||||
|
||||
def compile(parameters = ''):
|
||||
compile_string = 'gcc ${CFLAGS} %s' % parameters
|
||||
os.system(compile_string)
|
||||
system('%s %s %s' % (get.GCC(), get.CFLAGS(), parameters))
|
||||
|
||||
def make(parameters = ''):
|
||||
''' FIXME: Düzgün hale getirilecek '''
|
||||
make_string = 'make %s' % parameters
|
||||
os.system(make_string)
|
||||
make_string = ('make %s' % parameters)
|
||||
system(make_string)
|
||||
|
||||
def install(parameters = ''):
|
||||
''' FIXME: Düzgün hale getirilecek '''
|
||||
''' dir_suffix = /var/tmp/pisi/ _paket_adı_ /image/ '''
|
||||
dirs = glb.dirs
|
||||
|
||||
dir_suffix = os.path.dirname(os.path.dirname(os.getcwd())) + \
|
||||
glb.const.install_dir_suffix
|
||||
|
||||
install_string = 'make prefix=%(prefix)s/%(defaultprefix)s \
|
||||
datadir=%(prefix)s/%(data)s \
|
||||
infodir=%(prefix)s/%(info)s \
|
||||
@@ -71,65 +53,25 @@ def install(parameters = ''):
|
||||
mandir=%(prefix)s/%(man)s \
|
||||
sysconfdir=%(prefix)s/%(conf)s \
|
||||
%(parameters)s \
|
||||
install' % {'prefix': dir_suffix,
|
||||
'defaultprefix': dirs.defaultprefix,
|
||||
'man': dirs.man,
|
||||
'info': dirs.info,
|
||||
'localstate': dirs.localstate,
|
||||
'conf': dirs.conf,
|
||||
'data': dirs.data,
|
||||
install' % {'prefix': get.installDIR(),
|
||||
'defaultprefix': get.defaultprefixDIR(),
|
||||
'man': get.manDIR(),
|
||||
'info': get.infoDIR(),
|
||||
'localstate': get.localstateDIR(),
|
||||
'conf': get.confDIR(),
|
||||
'data': get.dataDIR(),
|
||||
'parameters': parameters}
|
||||
|
||||
os.system(install_string)
|
||||
|
||||
def installWithPrefix(parameters = ''):
|
||||
dirs = glb.dirs
|
||||
|
||||
dir_suffix = os.path.dirname(os.path.dirname(os.getcwd())) + \
|
||||
glb.const.install_dir_suffix
|
||||
|
||||
install_string = 'make PREFIX=%s%s install' % (dir_suffix, parameters)
|
||||
|
||||
os.system(install_string)
|
||||
|
||||
def installWithDestdir(parameters = ''):
|
||||
dirs = glb.dirs
|
||||
|
||||
dir_suffix = os.path.dirname(os.path.dirname(os.getcwd())) + \
|
||||
glb.const.install_dir_suffix
|
||||
|
||||
install_string = 'make install DESTDIR=%s %s' % (dir_suffix, parameters)
|
||||
|
||||
os.system(install_string)
|
||||
|
||||
def installWithBasedir():
|
||||
dirs = glb.dirs
|
||||
|
||||
dir_suffix = os.path.dirname(os.path.dirname(os.getcwd())) + \
|
||||
glb.const.install_dir_suffix
|
||||
|
||||
install_string = 'make BASEDIR=%s install' % dir_suffix
|
||||
|
||||
os.system(install_string)
|
||||
|
||||
def installWithInstallRootdir():
|
||||
dirs = glb.dirs
|
||||
|
||||
dir_suffix = os.path.dirname(os.path.dirname(os.getcwd())) + \
|
||||
glb.const.install_dir_suffix
|
||||
|
||||
install_string = 'make INSTALL_ROOT=%s install' % dir_suffix
|
||||
|
||||
os.system(install_string)
|
||||
system(install_string)
|
||||
|
||||
def rawInstall(parameters = ''):
|
||||
os.system("make %s install" % parameters)
|
||||
system('make %s install' % parameters)
|
||||
|
||||
def aclocal(parameters = ''):
|
||||
os.system("aclocal %s" % parameters)
|
||||
system('aclocal %s' % parameters)
|
||||
|
||||
def autoconf(parameters = ''):
|
||||
os.system("autoconf %s" % parameters)
|
||||
system('autoconf %s' % parameters)
|
||||
|
||||
def automake(parameters = ''):
|
||||
os.system("automake %s" % parameters)
|
||||
system('automake %s' % parameters)
|
||||
|
||||
@@ -20,21 +20,21 @@ def cat(filename):
|
||||
return file(filename).xreadlines()
|
||||
|
||||
class grep:
|
||||
"""keep only lines that match the regexp"""
|
||||
'''keep only lines that match the regexp'''
|
||||
def __init__(self, pat, flags = 0):
|
||||
self.fun = re.compile(pat, flags).match
|
||||
def __ror__(self, input):
|
||||
return ifilter(self.fun, input)
|
||||
|
||||
class tr:
|
||||
"""apply arbitrary transform to each sequence element"""
|
||||
'''apply arbitrary transform to each sequence element'''
|
||||
def __init__(self, transform):
|
||||
self.tr = transform
|
||||
def __ror__(self, input):
|
||||
return imap(self.tr, input)
|
||||
|
||||
class printto:
|
||||
"""print sequence elements one per line"""
|
||||
'''print sequence elements one per line'''
|
||||
def __init__(self, out = sys.stdout):
|
||||
self.out = out
|
||||
def __ror__(self,input):
|
||||
@@ -52,7 +52,7 @@ class terminator:
|
||||
aslist = terminator(list)
|
||||
asdict = terminator(dict)
|
||||
astuple = terminator(tuple)
|
||||
join = terminator("".join)
|
||||
join = terminator(''.join)
|
||||
enum = terminator(enumerate)
|
||||
|
||||
class sort:
|
||||
|
||||
+40
-17
@@ -20,6 +20,8 @@ from variables import glb
|
||||
env = glb.env
|
||||
dirs = glb.dirs
|
||||
|
||||
# variables.Env
|
||||
|
||||
def pkgDIR():
|
||||
return env.pkg_dir
|
||||
|
||||
@@ -29,12 +31,6 @@ def workDIR():
|
||||
def installDIR():
|
||||
return env.install_dir
|
||||
|
||||
def infoDIR():
|
||||
return os.path.join(installDIR(), dirs.info)
|
||||
|
||||
def manDIR():
|
||||
return os.path.join(installDIR(), dirs.man)
|
||||
|
||||
def srcNAME():
|
||||
return env.src_name
|
||||
|
||||
@@ -62,33 +58,60 @@ def CXXFLAGS():
|
||||
def LDFLAGS():
|
||||
return env.ldflags
|
||||
|
||||
# variables.Dirs
|
||||
|
||||
def docDIR():
|
||||
return dirs.doc
|
||||
|
||||
def sbinDIR():
|
||||
return dirs.sbin
|
||||
|
||||
def infoDIR():
|
||||
return dirs.info
|
||||
|
||||
def manDIR():
|
||||
return dirs.man
|
||||
|
||||
def dataDIR():
|
||||
return dirs.data
|
||||
|
||||
def confDIR():
|
||||
return dirs.conf
|
||||
|
||||
def localstateDIR():
|
||||
return dirs.localstate
|
||||
|
||||
def defaultprefixDIR():
|
||||
return dirs.defaultprefix
|
||||
|
||||
# Binutils Variables
|
||||
|
||||
def getBinutilsInfo(needed):
|
||||
return "%s-%s" % (HOST(), needed)
|
||||
return '%s-%s' % (HOST(), needed)
|
||||
|
||||
def AR():
|
||||
return getBinutilsInfo("ar")
|
||||
return getBinutilsInfo('ar')
|
||||
|
||||
def AS():
|
||||
return getBinutilsInfo("as")
|
||||
return getBinutilsInfo('as')
|
||||
|
||||
def CC():
|
||||
return getBinutilsInfo("gcc")
|
||||
return getBinutilsInfo('gcc')
|
||||
|
||||
def CXX():
|
||||
return getBinutilsInfo("g++")
|
||||
return getBinutilsInfo('g++')
|
||||
|
||||
def LD():
|
||||
return getBinutilsInfo("ld")
|
||||
return getBinutilsInfo('ld')
|
||||
|
||||
def NM():
|
||||
return getBinutilsInfo("nm")
|
||||
return getBinutilsInfo('nm')
|
||||
|
||||
def RANLIB():
|
||||
return getBinutilsInfo("ranlib")
|
||||
return getBinutilsInfo('ranlib')
|
||||
|
||||
def F77():
|
||||
return getBinutilsInfo("f77")
|
||||
return getBinutilsInfo('f77')
|
||||
|
||||
def GCJ():
|
||||
return getBinutilsInfo("gcj")
|
||||
|
||||
return getBinutilsInfo('gcj')
|
||||
|
||||
@@ -40,7 +40,7 @@ def dodir(destinationDirectory):
|
||||
|
||||
def dodoc(*sourceFiles):
|
||||
'''inserts the files in the list of files into /usr/share/doc/PACKAGE'''
|
||||
readable_insinto(get.installDIR() + "/usr/share/doc/" + get.srcTAG(), *sourceFiles)
|
||||
readable_insinto(get.installDIR() + os.path.join('/usr/share/doc', get.srcTAG()), *sourceFiles)
|
||||
|
||||
def doenvd():
|
||||
#FIXME: AdditionalFiles
|
||||
@@ -61,7 +61,7 @@ def dohtml(*sourceFiles):
|
||||
'''inserts the files in the list of files into /usr/share/doc/PACKAGE/html'''
|
||||
|
||||
''' example call: pisitools.dohtml("doc/doxygen/html/*")'''
|
||||
destionationDirectory = os.path.join(get.installDIR(), "usr/share/doc" ,get.srcTAG(), "html")
|
||||
destionationDirectory = os.path.join(get.installDIR(), 'usr/share/doc' ,get.srcTAG(), 'html')
|
||||
|
||||
if not can_access_directory(destionationDirectory):
|
||||
makedirs(os.getcwd() + destionationDirectory)
|
||||
@@ -72,17 +72,17 @@ def dohtml(*sourceFiles):
|
||||
for sourceFile in sourceFiles:
|
||||
for source in glob.glob(sourceFile):
|
||||
if os.path.isfile(source) and os.path.splitext(source)[1] in allowed_extensions:
|
||||
os.system("install -m0644 %s %s" % (source, destionationDirectory))
|
||||
os.system('install -m0644 %s %s' % (source, destionationDirectory))
|
||||
if os.path.isdir(source) and os.path.basename(source) not in disallowed_directories:
|
||||
for root, dirs, files in os.walk(source):
|
||||
for source in files:
|
||||
if os.path.splitext(source)[1] in allowed_extensions:
|
||||
makedirs(destionationDirectory)
|
||||
os.system("install -m0644 %s %s" % (os.path.join(root, source), destionationDirectory))
|
||||
os.system('install -m0644 %s %s' % (os.path.join(root, source), destionationDirectory))
|
||||
|
||||
def doinfo(*sourceFiles):
|
||||
'''inserts the into files in the list of files into /usr/share/info'''
|
||||
readable_insinto(get.infoDIR(), *sourceFiles)
|
||||
readable_insinto(os.path.join(get.installDIR(), get.infoDIR()), *sourceFiles)
|
||||
|
||||
def doinitd():
|
||||
#FIXME: AdditionalFiles
|
||||
@@ -127,8 +127,9 @@ def doman(*sourceFiles):
|
||||
'''inserts the man pages in the list of files into /usr/share/man/'''
|
||||
|
||||
'''example call: pisitools.doman("man.1", "pardus.*")'''
|
||||
if not can_access_directory(get.manDIR()):
|
||||
makedirs(get.manDIR())
|
||||
manDIR = os.path.join(get.installDIR(), get.manDIR())
|
||||
if not can_access_directory(manDIR):
|
||||
makedirs(manDIR)
|
||||
|
||||
for sourceFile in sourceFiles:
|
||||
for source in glob.glob(sourceFile):
|
||||
@@ -136,11 +137,11 @@ def doman(*sourceFiles):
|
||||
#FIXME: splitext
|
||||
pageName, pageDirectory = source.split('.')
|
||||
except ValueError:
|
||||
print "doman: Wrong man page file"
|
||||
print 'doman: Wrong man page file'
|
||||
sys.exit(1)
|
||||
|
||||
makedirs(get.manDIR() + '/man%s' % pageDirectory)
|
||||
os.system("install -m0644 %s %s" % (source, get.manDIR() + '/man%s' % pageDirectory))
|
||||
makedirs(manDIR + '/man%s' % pageDirectory)
|
||||
os.system('install -m0644 %s %s' % (source, manDIR + '/man%s' % pageDirectory))
|
||||
|
||||
def domo_(*sourceFiles):
|
||||
'''inserts the mo files in the list of files into /usr/share/locale/LOCALE/LC_MESSAGES'''
|
||||
@@ -175,7 +176,7 @@ def dosed(sourceFile, findPattern, replacePattern = ''):
|
||||
line = re.sub(findPattern, replacePattern, line)
|
||||
sys.stdout.write(line)
|
||||
else:
|
||||
raise FileError("File doesn't exists or permission denied...")
|
||||
raise FileError('File doesn\'t exists or permission denied...')
|
||||
|
||||
def dosbin(sourceFile, destinationDirectory = '/usr/sbin'):
|
||||
'''insert a executable file into /sbin or /usr/sbin'''
|
||||
@@ -192,7 +193,7 @@ def dosym(sourceFile, destinationFile):
|
||||
try:
|
||||
os.symlink(sourceFile, get.installDIR() + destinationFile)
|
||||
except OSError:
|
||||
print "dosym: File exists..."
|
||||
print 'dosym: File exists...'
|
||||
|
||||
''' ************************************************************************** '''
|
||||
|
||||
@@ -209,7 +210,7 @@ def insinto(destinationDirectory, sourceFile, destinationFile = ''):
|
||||
def newdoc(sourceFile, destinationFile):
|
||||
'''inserts a sourceFile into /usr/share/doc/PACKAGE/ directory as a destinationFile'''
|
||||
shutil.move(sourceFile, destinationFile)
|
||||
readable_insinto(get.installDIR() + "/usr/share/doc/" + get.srcTAG(), destinationFile)
|
||||
readable_insinto(os.path.join(get.installDIR(), 'usr/share/doc', get.srcTAG()), destinationFile)
|
||||
|
||||
def newman(sourceFile, destinationFile):
|
||||
'''inserts a sourceFile into /usr/share/man/manPREFIX/ directory as a destinationFile'''
|
||||
|
||||
@@ -30,35 +30,35 @@ def executable_insinto(sourceFile, destinationDirectory):
|
||||
'''insert a executable file into destinationDirectory'''
|
||||
|
||||
if not sourceFile or not destinationDirectory:
|
||||
raise ArgumentError("Insufficient arguments...")
|
||||
raise ArgumentError('Insufficient arguments...')
|
||||
|
||||
if not can_access_file(sourceFile):
|
||||
raise FileError("File doesn't exists or permission denied...")
|
||||
raise FileError('File doesn\'t exists or permission denied...')
|
||||
|
||||
if can_access_directory(destinationDirectory) and os.path.isdir(destinationDirectory):
|
||||
os.system("install -m0755 -o root -g root %s %s" % (sourceFile, destinationDirectory))
|
||||
os.system('install -m0755 -o root -g root %s %s' % (sourceFile, destinationDirectory))
|
||||
else:
|
||||
makedirs(destinationDirectory)
|
||||
os.system("install -m0755 -o root -g root %s %s" % (sourceFile, destinationDirectory))
|
||||
os.system('install -m0755 -o root -g root %s %s' % (sourceFile, destinationDirectory))
|
||||
|
||||
def readable_insinto(destinationDirectory, *sourceFiles):
|
||||
'''inserts file list into destinationDirectory'''
|
||||
|
||||
if not sourceFiles or not destinationDirectory:
|
||||
raise ArgumentError("Insufficient arguments...")
|
||||
raise ArgumentError('Insufficient arguments...')
|
||||
|
||||
if not can_access_directory(destinationDirectory):
|
||||
makedirs(destinationDirectory)
|
||||
|
||||
for sourceFile in sourceFiles:
|
||||
for source in glob.glob(sourceFile):
|
||||
os.system("install -m0644 %s %s" % (source, destinationDirectory))
|
||||
os.system('install -m0644 %s %s' % (source, destinationDirectory))
|
||||
|
||||
def lib_insinto(sourceFile, destinationDirectory, permission = 0644):
|
||||
'''inserts a library fileinto destinationDirectory with given permission'''
|
||||
|
||||
if not sourceFiles or not destinationDirectory:
|
||||
raise ArgumentError("Insufficient arguments...")
|
||||
if not sourceFile or not destinationDirectory:
|
||||
raise ArgumentError('Insufficient arguments...')
|
||||
|
||||
if not can_access_directory(destinationDirectory):
|
||||
makedirs(destinationDirectory)
|
||||
@@ -66,4 +66,4 @@ def lib_insinto(sourceFile, destinationDirectory, permission = 0644):
|
||||
if os.path.islink(sourceFile):
|
||||
os.symlink(os.path.realpath(sourceFile), os.path.join(destinationDirectory, sourceFile))
|
||||
else:
|
||||
os.system("install -m%s %s %s" % (permission, sourceFile, destinationDirectory))
|
||||
os.system('install -m%s %s %s' % (permission, sourceFile, destinationDirectory))
|
||||
|
||||
@@ -16,6 +16,9 @@ import os
|
||||
import glob
|
||||
import shutil
|
||||
|
||||
# Pisi Modules
|
||||
from pisi.ui import ui
|
||||
|
||||
# ActionsAPI Modules
|
||||
import get
|
||||
|
||||
@@ -46,7 +49,7 @@ def unlinkDir(sourceDirectory):
|
||||
if can_access_directory(sourceDirectory):
|
||||
shutil.rmtree(sourceDirectory)
|
||||
else:
|
||||
print "unlinkDir: remove failed..."
|
||||
ui.error('unlinkDir: remove failed...')
|
||||
|
||||
def move(sourceFile, destinationFile):
|
||||
'''recursively move a sourceFile or directory to destinationFile'''
|
||||
@@ -77,4 +80,13 @@ def ls(source):
|
||||
|
||||
def export(key, value):
|
||||
os.environ[key] = value
|
||||
|
||||
|
||||
def system(command):
|
||||
p = os.popen(command)
|
||||
while 1:
|
||||
line = p.readline()
|
||||
if not line:
|
||||
break
|
||||
ui.debug(line)
|
||||
|
||||
p.close()
|
||||
|
||||
Reference in New Issue
Block a user