ActionsAPI refactor edilmeye başlandı...
This commit is contained in:
@@ -0,0 +1,10 @@
|
||||
ReFactor ActionsAPI:
|
||||
|
||||
pisitools.py - %80
|
||||
autotools.py - %0
|
||||
get.py - %50
|
||||
kde.py - %0
|
||||
libtools.py - %25
|
||||
pisitools_functions.py - %50
|
||||
shelltools.py - %50
|
||||
variables.py - %100
|
||||
@@ -1,62 +0,0 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
# standard python modules
|
||||
from os import getenv, environ
|
||||
|
||||
# pisi modules
|
||||
import pisi.config
|
||||
import pisi.constants
|
||||
|
||||
|
||||
# Set individual information, that are generally needed for actions
|
||||
# api.
|
||||
|
||||
class Env(object):
|
||||
"""General environment variables used in actions API"""
|
||||
def __init__(self):
|
||||
self.__vars = {
|
||||
"pkg_dir": "PKG_DIR",
|
||||
"work_dir": "WORK_DIR",
|
||||
"install_dir": "INSTALL_DIR",
|
||||
"src_name": "SRC_NAME",
|
||||
"src_version": "SRC_VERSION",
|
||||
"src_release": "SRC_RELEASE"
|
||||
}
|
||||
|
||||
def __getattr__(self, attr):
|
||||
|
||||
# Using environment variables is somewhat tricky. Each time
|
||||
# you need them you need to check for their value.
|
||||
if self.__vars.has_key(attr):
|
||||
return getenv(self.__vars[attr])
|
||||
else:
|
||||
return None
|
||||
|
||||
class Dirs:
|
||||
"""General directories used in actions API."""
|
||||
# TODO: Eventually we should consider getting these from a/the
|
||||
# configuration file
|
||||
doc = "usr/share/doc"
|
||||
sbin = "usr/sbin"
|
||||
man = "usr/share/man"
|
||||
info = "usr/share/info"
|
||||
data = "usr/share"
|
||||
conf = "etc"
|
||||
localstate = "var/lib"
|
||||
defaultprefix = "usr"
|
||||
|
||||
class Flags:
|
||||
"""General flags used in actions API"""
|
||||
values = pisi.config.config.values
|
||||
environ["HOST"] = host = values.build.host
|
||||
environ["CFLAGS"] = cflags = values.build.cflags
|
||||
environ["CXXFLAGS"] = cxxflags = values.build.cxxflags
|
||||
ldflags = values.build.ldflags
|
||||
|
||||
class ActionGlobals(pisi.config.Config):
|
||||
const = pisi.constants.const
|
||||
env = Env()
|
||||
dirs = Dirs()
|
||||
flags = Flags()
|
||||
|
||||
glb = ActionGlobals()
|
||||
@@ -5,7 +5,7 @@
|
||||
import os
|
||||
|
||||
# actions api modules
|
||||
from actionglobals import glb
|
||||
from variables import glb
|
||||
|
||||
def configure(parameters = ''):
|
||||
''' FIXME: Düzgün hale getirilecek '''
|
||||
|
||||
@@ -1,36 +0,0 @@
|
||||
#!/usr/bin/python
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
# standard python modules
|
||||
import os
|
||||
|
||||
# actions api modules
|
||||
from actionglobals import glb
|
||||
from pisi.ui import ui
|
||||
|
||||
|
||||
def compile(parameters = ''):
|
||||
compile_string = ("/usr/bin/python2.3 setup.py build %s") % parameters
|
||||
os.system(compile_string)
|
||||
|
||||
def install(parameters = ''):
|
||||
dirs = glb.env
|
||||
|
||||
dir_suffix = os.path.dirname(dirs.work_dir) + \
|
||||
glb.const.install_dir_suffix
|
||||
|
||||
install_string = ("/usr/bin/python2.3 setup.py install --root=%s --no-compile %s") % (dir_suffix, parameters)
|
||||
os.system(install_string)
|
||||
|
||||
def optimize(parameters = ''):
|
||||
ui.info("Byte compiling python modules for python\n")
|
||||
|
||||
dirs = glb.env
|
||||
|
||||
dir_suffix = os.path.dirname(dirs.work_dir) + \
|
||||
glb.const.install_dir_suffix
|
||||
|
||||
optimize_string = ("/usr/bin/python2.3 /usr/lib/python2.3/compileall.py -q %s") % dir_suffix + '/' + parameters
|
||||
os.system(optimize_string)
|
||||
optimize_string = ("/usr/bin/python2.3 -O /usr/lib/python2.3/compileall.py -q %s") % dir_suffix + '/' + parameters
|
||||
os.system(optimize_string)
|
||||
+52
-1
@@ -1,7 +1,11 @@
|
||||
#!/usr/bin/python
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
from actionglobals import glb
|
||||
# Standart Python Modules
|
||||
import os.path
|
||||
|
||||
# ActionsAPI Modules
|
||||
from variables import glb
|
||||
|
||||
env = glb.env
|
||||
dirs = glb.dirs
|
||||
@@ -16,6 +20,12 @@ 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
|
||||
|
||||
@@ -25,6 +35,12 @@ def srcVERSION():
|
||||
def srcRELEASE():
|
||||
return env.src_release
|
||||
|
||||
def srcTAG():
|
||||
return env.src_name + '-' + env.src_version + '-' + env.src_release
|
||||
|
||||
def srcDIR():
|
||||
return env.src_name + '-' + env.src_version
|
||||
|
||||
def HOST():
|
||||
return flags.host
|
||||
|
||||
@@ -36,3 +52,38 @@ def CXXFLAGS():
|
||||
|
||||
def LDFLAGS():
|
||||
return flags.ldflags
|
||||
|
||||
def getBinutilsInfo(needed):
|
||||
process = os.popen("type -p %s-%s" % (HOST(), needed))
|
||||
output = process.readlines()
|
||||
process.close()
|
||||
|
||||
return output[0]
|
||||
|
||||
def AR():
|
||||
return getBinutilsInfo("ar")
|
||||
|
||||
def AS():
|
||||
return getBinutilsInfo("as")
|
||||
|
||||
def CC():
|
||||
return getBinutilsInfo("gcc")
|
||||
|
||||
def CXX():
|
||||
return getBinutilsInfo("g++")
|
||||
|
||||
def LD():
|
||||
return getBinutilsInfo("ld")
|
||||
|
||||
def NM():
|
||||
return getBinutilsInfo("nm")
|
||||
|
||||
def RANLIB():
|
||||
return getBinutilsInfo("ranlib")
|
||||
|
||||
def F77():
|
||||
return getBinutilsInfo("f77")
|
||||
|
||||
def GCJ():
|
||||
return getBinutilsInfo("gcj")
|
||||
|
||||
|
||||
@@ -1,62 +0,0 @@
|
||||
#!/usr/bin/python
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
# standard python modules
|
||||
import os
|
||||
import string
|
||||
import re
|
||||
|
||||
# pisi modules
|
||||
from pisi.ui import ui
|
||||
from pisi.util import copy_file
|
||||
|
||||
# actions api modules
|
||||
from shell import *
|
||||
|
||||
def gnuconfig_findnewest():
|
||||
''' find the newest config.* file according to
|
||||
timestamp and return it'''
|
||||
|
||||
locations = ['/usr/share/gnuconfig/config.sub',
|
||||
'/usr/share/automake-1.9/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',
|
||||
'share/config.sub']
|
||||
|
||||
newer_location = {}
|
||||
|
||||
for i in locations:
|
||||
if not os.path.exists(i):
|
||||
continue
|
||||
newer_location[i] = re.sub('\'', '',
|
||||
string.split((cat(i) | tr(str.rstrip)
|
||||
| grep ('^timestamp')
|
||||
| join), '=')[1])
|
||||
|
||||
keys = newer_location.keys()
|
||||
keys.sort()
|
||||
|
||||
thelist = []
|
||||
for i in keys:
|
||||
thelist.append((i, newer_location[i]))
|
||||
|
||||
return os.path.dirname(thelist[0][0])
|
||||
|
||||
def gnuconfig_update():
|
||||
''' copy newest config.* onto source's '''
|
||||
|
||||
newer_location = gnuconfig_findnewest()
|
||||
|
||||
try:
|
||||
copy_file(newer_location + '/config.sub',
|
||||
os.getcwd() + '/config.sub')
|
||||
copy_file(newer_location + '/config.guess',
|
||||
os.getcwd() + '/config.guess')
|
||||
except IOError, e:
|
||||
ui.error ("Error : %s\n" % e)
|
||||
sys.exit()
|
||||
|
||||
ui.info('GNU Config Update Finished...\n')
|
||||
@@ -1,16 +0,0 @@
|
||||
#!/usr/bin/python
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
import os
|
||||
|
||||
def libtoolize():
|
||||
''' FIXME: Düzgün hale getirilecek '''
|
||||
''' patch source with ltmain patches '''
|
||||
|
||||
# This is wrong! Action files should only operate on the build
|
||||
# directory. And shouldn't depend on external files. If a patch is
|
||||
# need to be applied it is PisiBuild's job to do it!
|
||||
#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('libtoolize --copy --force')
|
||||
@@ -0,0 +1,45 @@
|
||||
#!/usr/bin/python
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
# Standard Python Modules
|
||||
import os
|
||||
import shutil
|
||||
|
||||
# Pisi-Core Modules
|
||||
from pisi.ui import ui
|
||||
|
||||
# ActionsAPI Modules
|
||||
from shelltools import chmod, makedirs
|
||||
import get
|
||||
|
||||
def preplib(sourceDirectory):
|
||||
os.system('/sbin/ldconfig -n -N %s' % get.installDIR() + sourceDirectory)
|
||||
|
||||
def gnuconfig_update():
|
||||
''' copy newest config.* onto source's '''
|
||||
shutil.copyfile('/usr/share/gnuconfig/config.sub', os.getcwd() + '/config.sub')
|
||||
shutil.copyfile('/usr/share/gnuconfig/config.guess',os.getcwd() + '/config.guess')
|
||||
|
||||
ui.info('GNU Config Update Finished...\n')
|
||||
|
||||
def libtoolize():
|
||||
os.system('/usr/bin/libtoolize --copy --force')
|
||||
|
||||
def gen_usr_ldscript(dynamicLib):
|
||||
|
||||
makedirs(get.installDIR() + '/usr/lib')
|
||||
|
||||
destinationFile = open(get.installDIR() + '/usr/lib/' + dynamicLib, 'w')
|
||||
content = '''
|
||||
/* GNU ld script
|
||||
Since Pardus has critical dynamic libraries
|
||||
in /lib, and the static versions in /usr/lib,
|
||||
we need to have a "fake" dynamic lib in /usr/lib,
|
||||
otherwise we run into linking problems.
|
||||
*/
|
||||
GROUP ( /lib/%s )
|
||||
''' % dynamicLib
|
||||
|
||||
destinationFile.write(content)
|
||||
destinationFile.close()
|
||||
chmod(get.installDIR() + '/usr/lib/' + dynamicLib)
|
||||
+160
-145
@@ -1,187 +1,202 @@
|
||||
#!/usr/bin/python
|
||||
# -*- coding: utf-8 -*-
|
||||
#-*- coding: utf-8 -*-
|
||||
|
||||
# standard python modules
|
||||
import os
|
||||
import gzip
|
||||
import glob
|
||||
import sys
|
||||
import shutil
|
||||
import fileinput
|
||||
import re
|
||||
import sys
|
||||
import glob
|
||||
|
||||
from utils import makedirs, unlink, chmod
|
||||
from pisi.util import copy_file, clean_dir
|
||||
import get
|
||||
from pisitools_functions import *
|
||||
from shelltools import *
|
||||
|
||||
# actions api modules
|
||||
from actionglobals import glb
|
||||
def dobin(sourceFile, destinationDirectory = '/usr/bin'):
|
||||
'''insert a executable file into /bin or /usr/bin'''
|
||||
|
||||
env = glb.env
|
||||
dirs = glb.dirs
|
||||
''' example call: pisitools.dobin("bin/xloadimage", "/bin", "xload") '''
|
||||
executable_insinto(sourceFile, get.installDIR() + destinationDirectory)
|
||||
|
||||
def doconfd():
|
||||
#FIXME: AdditionalFiles
|
||||
pass
|
||||
|
||||
def insinto(directory, filename, fileas=''):
|
||||
def dodir(destinationDirectory):
|
||||
'''creates a directory tree'''
|
||||
makedirs(get.installDIR() + 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)
|
||||
|
||||
def doenvd():
|
||||
#FIXME: AdditionalFiles
|
||||
pass
|
||||
|
||||
def doexe(sourceFile, destinationDirectory):
|
||||
'''insert a executable file into destination directory'''
|
||||
|
||||
makedirs(env.install_dir + directory)
|
||||
''' example call: pisitools.doexe("kde-3.4.sh", "/etc/X11/Sessions")'''
|
||||
executable_insinto(sourceFile, get.installDIR() + destinationDirectory)
|
||||
|
||||
if not fileas:
|
||||
for file in glob.glob(filename):
|
||||
if os.access(file, os.F_OK):
|
||||
copy_file(file, env.install_dir +
|
||||
directory + os.path.basename(file))
|
||||
def dohard(sourceFile, destinationFile):
|
||||
'''creates hard link between sourceFile and destinationFile'''
|
||||
#FIXME: How can i use hard-links in Python?
|
||||
pass
|
||||
|
||||
#XXX: toparla burayi..
|
||||
else:
|
||||
if os.access(filename, os.F_OK):
|
||||
copy_file(filename, env.install_dir +
|
||||
directory + fileas)
|
||||
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")
|
||||
|
||||
def dodoc(*documentList):
|
||||
if not can_access_directory(destionationDirectory):
|
||||
makedirs(os.getcwd() + destionationDirectory)
|
||||
|
||||
srcTag = env.src_name + '-' \
|
||||
+ env.src_version + '-' \
|
||||
+ env.src_release
|
||||
|
||||
makedirs(os.path.join(env.install_dir,
|
||||
dirs.doc,
|
||||
srcTag))
|
||||
allowed_extensions = ['.png', '.gif', '.html', '.htm', '.jpg', '.css', '.js']
|
||||
disallowed_directories = ['CVS']
|
||||
|
||||
for item in documentList:
|
||||
for document in glob.glob(item):
|
||||
if os.access(document, os.F_OK):
|
||||
copy_file(document,
|
||||
os.path.join(env.install_dir,
|
||||
dirs.doc,
|
||||
srcTag,
|
||||
os.path.basename(document)))
|
||||
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))
|
||||
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))
|
||||
print "install -m0644 %s %s" % (os.path.join(root, source), destionationDirectory)
|
||||
|
||||
def newdoc(source, destination):
|
||||
def doinfo(*sourceFiles):
|
||||
'''inserts the info files in the list of files into /usr/share/info'''
|
||||
readable_insinto(get.infoDIR(), *sourceFiles)
|
||||
|
||||
srcTag = env.src_name + '-' \
|
||||
+ env.src_version + '-' \
|
||||
+ env.src_release
|
||||
|
||||
makedirs(os.path.join(env.install_dir,
|
||||
dirs.doc,
|
||||
srcTag))
|
||||
def doinitd():
|
||||
#FIXME: AdditionalFiles
|
||||
pass
|
||||
|
||||
if os.access(source, os.F_OK):
|
||||
copy_file(source,
|
||||
os.path.join(env.install_dir,
|
||||
dirs.doc,
|
||||
srcTag,
|
||||
destination))
|
||||
def dojar():
|
||||
'''installs jar files into /usr/share/PACKAGE/lib, and adds to /usr/share/PACKAGE/classpath.env'''
|
||||
pass
|
||||
|
||||
def dosed(filename, searchPattern, replacePattern = ''):
|
||||
for line in fileinput.input(filename, inplace = 1):
|
||||
line = re.sub(searchPattern, replacePattern, line)
|
||||
sys.stdout.write(line)
|
||||
def dolib(sourceFile, destinationDirectory = '/usr/lib'):
|
||||
'''insert the library info /usr/lib'''
|
||||
sourceFile = os.path.join(get.workDIR(), get.srcDIR(), sourceFile)
|
||||
destinationDirectory = get.installDIR() + destinationDirectory
|
||||
print destinationDirectory
|
||||
makedirs(destinationDirectory)
|
||||
os.system("install -m0644 %s %s" % (sourceFile, destinationDirectory))
|
||||
|
||||
def dosbin(filename, destination = glb.dirs.sbin):
|
||||
def dolib_a():
|
||||
'''insert the static library info /usr/lib with permission 0644'''
|
||||
pass
|
||||
|
||||
makedirs(os.path.join(env.install_dir, destination))
|
||||
def dolib_so():
|
||||
'''insert the static library info /usr/lib with permission 0755'''
|
||||
pass
|
||||
|
||||
if os.access(filename, os.F_OK):
|
||||
copy_file(filename,
|
||||
os.path.join(env.install_dir,
|
||||
destination,
|
||||
os.path.basename(filename)))
|
||||
def doman(*sourceFiles):
|
||||
'''inserts the man pages in the list of files into /usr/share/man/'''
|
||||
|
||||
def doman(*filenameList):
|
||||
'''example call: pisitools.doman("man.1", "pardus.*")'''
|
||||
if not can_access_directory(get.manDIR()):
|
||||
makedirs(get.manDIR())
|
||||
|
||||
for item in filenameList:
|
||||
for filename in glob.glob(item):
|
||||
man, postfix = filename.split('.')
|
||||
destDir = os.path.join(env.install_dir, dirs.man, "man" + postfix)
|
||||
|
||||
makedirs(destDir)
|
||||
#FIXME: splitext
|
||||
for sourceFile in sourceFiles:
|
||||
for source in glob.glob(sourceFile):
|
||||
try:
|
||||
pageName, pageDirectory = source.split('.')
|
||||
except ValueError:
|
||||
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))
|
||||
|
||||
gzfile = gzip.GzipFile(filename + '.gz', 'w', 9)
|
||||
gzfile.writelines(file(filename).xreadlines())
|
||||
gzfile.close()
|
||||
|
||||
if os.access(filename + '.gz', os.F_OK):
|
||||
copy_file(filename + '.gz',
|
||||
os.path.join(destDir,
|
||||
os.path.basename(filename + '.gz')))
|
||||
def domo_(*sourceFiles):
|
||||
'''inserts the mo files in the list of files into /usr/share/locale/LOCALE/LC_MESSAGES'''
|
||||
pass
|
||||
|
||||
def domove(source, destination):
|
||||
'''moves sourceFile/Direcroty into destinationFile/Directory'''
|
||||
|
||||
makedirs(env.install_dir + '/' + os.path.dirname(destination))
|
||||
''' example call: pisitools.domove("/usr/bin/bash", "/bin/bash")'''
|
||||
''' example call: pisitools.domove("/usr/bin/", "/usr/sbin")'''
|
||||
makedirs(get.installDIR() + os.path.dirname(destination))
|
||||
shutil.move(get.installDIR() + source, get.installDIR() + destination)
|
||||
|
||||
def dopython():
|
||||
'''FIXME: What the hell is this?'''
|
||||
pass
|
||||
|
||||
def dosed(sourceFile, findPattern, replacePattern = ''):
|
||||
'''replaces patterns in sourceFile'''
|
||||
|
||||
''' example call: pisitools.dosed("/etc/passwd", "caglar", "cem")'''
|
||||
''' example call: pisitools.dosym("/etc/passwd", "caglar")'''
|
||||
''' example call: pisitools.dosym("Makefile", "(?m)^(HAVE_PAM=.*)no", r"\1yes")'''
|
||||
|
||||
if can_access_file(sourceFile):
|
||||
for line in fileinput.input(sourceFile, inplace = 1):
|
||||
line = re.sub(findPattern, replacePattern, line)
|
||||
sys.stdout.write(line)
|
||||
else:
|
||||
raise FileError("File doesn't exists or permission denied...")
|
||||
|
||||
def dosbin(sourceFile, destinationDirectory = '/usr/sbin'):
|
||||
'''insert a executable file into /sbin or /usr/sbin'''
|
||||
|
||||
''' example call: pisitools.dobin("bin/xloadimage", "/sbin") '''
|
||||
executable_insinto(sourceFile, get.installDIR() + destinationDirectory)
|
||||
|
||||
def dosym(sourceFile, destinationFile):
|
||||
'''creates soft link between sourceFile and destinationFile'''
|
||||
|
||||
''' example call: pisitools.dosym("/usr/bin/bash", "/bin/bash")'''
|
||||
makedirs(get.installDIR() + os.path.dirname(destinationFile))
|
||||
|
||||
try:
|
||||
shutil.move(env.install_dir + '/' + source, env.install_dir + '/' + destination)
|
||||
except OSError, e:
|
||||
pass
|
||||
|
||||
def dosym(source, destination):
|
||||
os.symlink(sourceFile, get.installDIR() + destinationFile)
|
||||
except OSError:
|
||||
print "dosym: File exists..."
|
||||
|
||||
makedirs(env.install_dir + '/' + os.path.dirname(destination))
|
||||
|
||||
if not os.path.islink(env.install_dir + destination):
|
||||
os.symlink(source, env.install_dir + destination)
|
||||
''' ************************************************************************** '''
|
||||
|
||||
def dolib(filename, destination = '/lib', srcDir = ''):
|
||||
def insinto(destinationDirectory, sourceFile, destinationFile = ''):
|
||||
'''insert a sourceFile into destinationDirectory as a destinationFile with same uid/guid/permissions'''
|
||||
makedirs(get.installDIR() + destinationDirectory)
|
||||
|
||||
if not srcDir:
|
||||
libFile = os.path.join(env.work_dir, env.src_name + "-" + env.src_version, filename)
|
||||
else:
|
||||
libFile = os.path.join(env.work_dir, srcDir, filename)
|
||||
for file in glob.glob(sourceFile):
|
||||
if can_access_file(file):
|
||||
shutil.copy(sourceFile, get.installDIR() + os.path.join(destinationDirectory, destinationFile))
|
||||
|
||||
makedirs(env.install_dir + destination)
|
||||
''' ************************************************************************** '''
|
||||
|
||||
if os.access(libFile, os.F_OK):
|
||||
copy_file(libFile, env.install_dir + destination + '/' + filename)
|
||||
def newdoc(sourceFile, destinationFile):
|
||||
shutil.move(sourceFile, destinationFile)
|
||||
readable_insinto(get.installDIR() + "/usr/share/doc/" + get.srcTAG(), destinationFile)
|
||||
|
||||
def dodir(parameters = ''):
|
||||
def newman(sourceFile, destinationFile):
|
||||
shutil.move(sourceFile, destinationFile)
|
||||
doman(destinationFile)
|
||||
|
||||
makedirs(env.install_dir + parameters)
|
||||
''' ************************************************************************** '''
|
||||
|
||||
def newman(source, destination, srcDir = ''):
|
||||
def remove(sourceFile):
|
||||
unlink(get.installDIR() + sourceFile)
|
||||
|
||||
man, postfix = destination.split('.')
|
||||
destDir = os.path.join(env.install_dir, dirs.man, "man" + postfix)
|
||||
def removeDir(destinationDirectory):
|
||||
unlinkDir(get.installDIR() + destinationDirectory)
|
||||
|
||||
makedirs(destDir)
|
||||
''' ************************************************************************** '''
|
||||
|
||||
if not srcDir:
|
||||
file = os.path.join(env.work_dir, env.src_name + "-" + env.src_version, source)
|
||||
else:
|
||||
file = os.path.join(env.work_dir, srcDir, source)
|
||||
def preplib():
|
||||
'''prepare all library files for installation'''
|
||||
pass
|
||||
|
||||
if os.access(file, os.F_OK):
|
||||
copy_file(file, os.path.join(destDir, os.path.basename(destination)))
|
||||
|
||||
def remove(filename):
|
||||
|
||||
unlink(env.install_dir + filename)
|
||||
|
||||
def removeDir(dirname):
|
||||
|
||||
clean_dir(env.install_dir + dirname)
|
||||
|
||||
def doecho(content, filename):
|
||||
makedirs(env.install_dir + '/' + os.path.dirname(filename))
|
||||
|
||||
f = open(env.install_dir + '/' + filename, 'w')
|
||||
f.write(content)
|
||||
f.close()
|
||||
|
||||
def gen_usr_ldscript(parameters = ''):
|
||||
|
||||
dodir("/usr/lib")
|
||||
|
||||
f = open(env.install_dir + '/usr/lib/' + parameters, 'w')
|
||||
content = '''
|
||||
/* GNU ld script
|
||||
Since Pardus has critical dynamic libraries
|
||||
in /lib, and the static versions in /usr/lib,
|
||||
we need to have a "fake" dynamic lib in /usr/lib,
|
||||
otherwise we run into linking problems.
|
||||
*/
|
||||
GROUP ( /lib/%s )
|
||||
''' % parameters
|
||||
f.write(content)
|
||||
f.close()
|
||||
chmod(env.install_dir + "/usr/lib/%s" % parameters)
|
||||
|
||||
def preplib(parameters = ''):
|
||||
os.system("/sbin/ldconfig -n -N %s%s" % (env.install_dir, parameters))
|
||||
def preplib_so():
|
||||
'''prepare dynamic library files for installation'''
|
||||
pass
|
||||
|
||||
@@ -0,0 +1,45 @@
|
||||
#!/usr/bin/python
|
||||
#-*- coding: utf-8 -*-
|
||||
|
||||
# Generic functions for common usage of pisitools #
|
||||
|
||||
# Standart Python Modules
|
||||
import os
|
||||
import glob
|
||||
|
||||
# ActionsAPI Modules
|
||||
from shelltools import *
|
||||
|
||||
class FileError(Exception):
|
||||
pass
|
||||
|
||||
class ArgumentError(Exception):
|
||||
pass
|
||||
|
||||
def executable_insinto(sourceFile, destinationDirectory):
|
||||
'''insert a executable file into destinationDirectory'''
|
||||
|
||||
if not sourceFile or not destinationDirectory:
|
||||
raise ArgumentError("Insufficient arguments...")
|
||||
|
||||
if not can_access_file(sourceFile):
|
||||
raise FileError("File doesn't exists or permission denied...")
|
||||
|
||||
if can_access_directory(destinationDirectory) and os.path.isdir(destinationDirectory):
|
||||
os.system("install -m0755 -o caglar -g users %s %s" % (sourceFile, destinationDirectory))
|
||||
else:
|
||||
makedirs(destinationDirectory)
|
||||
os.system("install -m0755 -o caglar -g users %s %s" % (sourceFile, destinationDirectory))
|
||||
|
||||
def readable_insinto(destinationDirectory, *sourceFiles):
|
||||
'''inserts file list into destinationDirectory'''
|
||||
|
||||
if not sourceFiles or not destinationDirectory:
|
||||
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))
|
||||
@@ -1,65 +0,0 @@
|
||||
#!/usr/bin/python
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
# standard python modules
|
||||
import sys
|
||||
import re
|
||||
from itertools import izip, imap, count, ifilter, ifilterfalse
|
||||
|
||||
def cat(filename):
|
||||
return file(filename).xreadlines()
|
||||
|
||||
class grep:
|
||||
"""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"""
|
||||
def __init__(self, transform):
|
||||
self.tr = transform
|
||||
def __ror__(self, input):
|
||||
return imap(self.tr, input)
|
||||
|
||||
class printto:
|
||||
"""print sequence elements one per line"""
|
||||
def __init__(self, out = sys.stdout):
|
||||
self.out = out
|
||||
def __ror__(self,input):
|
||||
for l in input:
|
||||
print >> self.out, l
|
||||
|
||||
printlines = printto(sys.stdout)
|
||||
|
||||
class terminator:
|
||||
def __init__(self,method):
|
||||
self.process = method
|
||||
def __ror__(self,input):
|
||||
return self.process(input)
|
||||
|
||||
aslist = terminator(list)
|
||||
asdict = terminator(dict)
|
||||
astuple = terminator(tuple)
|
||||
join = terminator("".join)
|
||||
enum = terminator(enumerate)
|
||||
|
||||
class sort:
|
||||
def __ror__(self,input):
|
||||
ll = list(input)
|
||||
ll.sort()
|
||||
return ll
|
||||
sort = sort()
|
||||
|
||||
class uniq:
|
||||
def __ror__(self,input):
|
||||
for i in input:
|
||||
try:
|
||||
if i == prev:
|
||||
continue
|
||||
except NameError:
|
||||
pass
|
||||
prev = i
|
||||
yield i
|
||||
uniq = uniq()
|
||||
@@ -0,0 +1,58 @@
|
||||
#!/usr/bin/python
|
||||
#-*- coding: utf-8 -*-
|
||||
|
||||
# Standart Python Modules
|
||||
import os
|
||||
import glob
|
||||
import shutil
|
||||
|
||||
# ActionsAPI Modules
|
||||
import get
|
||||
|
||||
def can_access_file(sourceFile):
|
||||
'''test the existence of file'''
|
||||
return os.access(sourceFile, os.F_OK)
|
||||
|
||||
def can_access_directory(destinationDirectory):
|
||||
'''test readability, writability and executablility of directory'''
|
||||
return os.access(destinationDirectory, os.R_OK | os.W_OK | os.X_OK)
|
||||
|
||||
def makedirs(destinationDirectory):
|
||||
try:
|
||||
os.makedirs(destinationDirectory)
|
||||
except OSError:
|
||||
pass
|
||||
|
||||
def chmod(sourceFile, mode = 0755):
|
||||
for file in glob.glob(sourceFile):
|
||||
os.chmod(file, mode)
|
||||
|
||||
def unlink(sourceFile):
|
||||
os.unlink(sourceFile)
|
||||
|
||||
def unlinkDir(sourceDirectory):
|
||||
if can_access_directory(sourceDirectory):
|
||||
shutil.rmtree(sourceDirectory)
|
||||
else:
|
||||
print "unlinkDir: remove failed..."
|
||||
|
||||
def move(sourceFile, destinationFile):
|
||||
shutil.move(sourceFile, destinationFile)
|
||||
|
||||
def touch(sourceFile):
|
||||
for file in glob.glob(sourceFile):
|
||||
os.utime(file, None)
|
||||
|
||||
def cd(directoryName = ''):
|
||||
current = os.getcwd()
|
||||
if directoryName:
|
||||
os.chdir(directoryName)
|
||||
else:
|
||||
os.chdir(os.path.dirname(current))
|
||||
|
||||
def ls(sourceDirectory):
|
||||
return os.listdir(sourceDirectory)
|
||||
|
||||
def export(key, value):
|
||||
os.environ[key] = value
|
||||
|
||||
@@ -1,53 +0,0 @@
|
||||
#!/usr/bin/python
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
# stadard python modules
|
||||
import os
|
||||
import time
|
||||
import glob
|
||||
import shutil
|
||||
from tempfile import mkstemp, mkdtemp
|
||||
|
||||
def sleep(seconds = 5):
|
||||
time.sleep(seconds)
|
||||
|
||||
def createTmpFile():
|
||||
handle, path = mkstemp()
|
||||
return path
|
||||
|
||||
def createTmpDir():
|
||||
path = mkdtemp()
|
||||
return path
|
||||
|
||||
def chmod(filename, mode = 0755):
|
||||
for file in glob.glob(filename):
|
||||
os.chmod(file, mode)
|
||||
|
||||
def unlink(filename):
|
||||
os.unlink(filename)
|
||||
|
||||
def makedirs(directoryName):
|
||||
try:
|
||||
os.makedirs(directoryName)
|
||||
except OSError:
|
||||
pass
|
||||
|
||||
def touch(filename):
|
||||
for file in glob.glob(filename):
|
||||
os.utime(file, None)
|
||||
|
||||
def changeDir(directoryName = ''):
|
||||
current = os.getcwd()
|
||||
if directoryName:
|
||||
os.chdir(directoryName)
|
||||
else:
|
||||
os.chdir(os.path.dirname(current))
|
||||
|
||||
def ls(directory):
|
||||
return os.listdir(directory)
|
||||
|
||||
def move(source, destination):
|
||||
shutil.move(source, destination)
|
||||
|
||||
def export(key, value):
|
||||
os.environ[key] = value
|
||||
@@ -0,0 +1,61 @@
|
||||
#!/usr/bin/python
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
# Standard Python Modules
|
||||
from os import getenv, environ
|
||||
|
||||
# Pisi-Core Modules
|
||||
import pisi.config
|
||||
import pisi.constants
|
||||
|
||||
# Set individual information, that are generally needed for ActionsAPI
|
||||
|
||||
class Env(object):
|
||||
'''General environment variables used in actions API'''
|
||||
def __init__(self):
|
||||
self.__vars = {
|
||||
'pkg_dir': 'PKG_DIR',
|
||||
'work_dir': 'WORK_DIR',
|
||||
'install_dir': 'INSTALL_DIR',
|
||||
'src_name': 'SRC_NAME',
|
||||
'src_version': 'SRC_VERSION',
|
||||
'src_release': 'SRC_RELEASE'
|
||||
}
|
||||
|
||||
def __getattr__(self, attr):
|
||||
|
||||
# Using environment variables is somewhat tricky. Each time
|
||||
# you need them you need to check for their value.
|
||||
if self.__vars.has_key(attr):
|
||||
return getenv(self.__vars[attr])
|
||||
else:
|
||||
return None
|
||||
|
||||
class Dirs:
|
||||
'''General directories used in actions API.'''
|
||||
# TODO: Eventually we should consider getting these from a/the
|
||||
# configuration file
|
||||
doc = 'usr/share/doc'
|
||||
sbin = 'usr/sbin'
|
||||
man = 'usr/share/man'
|
||||
info = 'usr/share/info'
|
||||
data = 'usr/share'
|
||||
conf = 'etc'
|
||||
localstate = 'var/lib'
|
||||
defaultprefix = 'usr'
|
||||
|
||||
class Flags:
|
||||
'''General flags used in actions API'''
|
||||
values = pisi.config.config.values
|
||||
environ['HOST'] = host = values.build.host
|
||||
environ['CFLAGS'] = cflags = values.build.cflags
|
||||
environ['CXXFLAGS'] = cxxflags = values.build.cxxflags
|
||||
ldflags = values.build.ldflags
|
||||
|
||||
class Variables(pisi.config.Config):
|
||||
const = pisi.constants.const
|
||||
env = Env()
|
||||
dirs = Dirs()
|
||||
flags = Flags()
|
||||
|
||||
glb = Variables()
|
||||
Reference in New Issue
Block a user