/usr/lib/python2.3/tabnanny.py build.py
This commit is contained in:
+63
-64
@@ -21,7 +21,7 @@ class PisiBuild:
|
|||||||
"""PisiBuild class, provides the package build and creation routines"""
|
"""PisiBuild class, provides the package build and creation routines"""
|
||||||
def __init__(self, context):
|
def __init__(self, context):
|
||||||
self.ctx = context
|
self.ctx = context
|
||||||
self.work_dir = self.ctx.pkg_work_dir()
|
self.work_dir = self.ctx.pkg_work_dir()
|
||||||
self.spec = self.ctx.spec
|
self.spec = self.ctx.spec
|
||||||
self.sourceArchive = SourceArchive(self.ctx)
|
self.sourceArchive = SourceArchive(self.ctx)
|
||||||
|
|
||||||
@@ -33,45 +33,45 @@ class PisiBuild:
|
|||||||
ui.info("Source archive is stored: %s/%s\n"
|
ui.info("Source archive is stored: %s/%s\n"
|
||||||
%(self.ctx.archives_dir(), self.spec.source.archiveName))
|
%(self.ctx.archives_dir(), self.spec.source.archiveName))
|
||||||
|
|
||||||
self.solveBuildDependencies()
|
self.solveBuildDependencies()
|
||||||
|
|
||||||
ui.info("Unpacking archive...")
|
ui.info("Unpacking archive...")
|
||||||
self.sourceArchive.unpack()
|
self.sourceArchive.unpack()
|
||||||
ui.info(" unpacked (%s)\n" % self.ctx.pkg_work_dir())
|
ui.info(" unpacked (%s)\n" % self.ctx.pkg_work_dir())
|
||||||
|
|
||||||
self.applyPatches()
|
self.applyPatches()
|
||||||
|
|
||||||
try:
|
try:
|
||||||
specdir = os.path.dirname(self.ctx.pspecfile)
|
specdir = os.path.dirname(self.ctx.pspecfile)
|
||||||
self.actionScript = open("/".join([specdir,self.ctx.const.actions_file])).read()
|
self.actionScript = open("/".join([specdir,self.ctx.const.actions_file])).read()
|
||||||
except IOError, e:
|
except IOError, e:
|
||||||
ui.error ("Action Script: %s\n" % e)
|
ui.error ("Action Script: %s\n" % e)
|
||||||
return
|
return
|
||||||
|
|
||||||
#we'll need this our working directory after actionscript
|
#we'll need this our working directory after actionscript
|
||||||
#finished its work in the work_dir
|
#finished its work in the work_dir
|
||||||
curDir = os.getcwd()
|
curDir = os.getcwd()
|
||||||
|
|
||||||
# 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.pkg_work_dir() + "/" + self.spec.source.name + "-" + self.spec.source.version)
|
os.chdir(self.ctx.pkg_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:
|
||||||
ui.error ("Error : %s\n" % e)
|
ui.error ("Error : %s\n" % e)
|
||||||
return
|
return
|
||||||
|
|
||||||
self.configureSource(locals)
|
self.configureSource(locals)
|
||||||
self.buildSource(locals)
|
self.buildSource(locals)
|
||||||
self.installSource(locals)
|
self.installSource(locals)
|
||||||
|
|
||||||
os.chdir(curDir)
|
os.chdir(curDir)
|
||||||
# after all, we are ready to build/prepare the packages
|
# after all, we are ready to build/prepare the packages
|
||||||
self.buildPackages()
|
self.buildPackages()
|
||||||
|
|
||||||
def solveBuildDependencies(self):
|
def solveBuildDependencies(self):
|
||||||
"""pre-alpha: fail if dependencies not satisfied"""
|
"""pre-alpha: fail if dependencies not satisfied"""
|
||||||
@@ -81,55 +81,54 @@ class PisiBuild:
|
|||||||
pass
|
pass
|
||||||
|
|
||||||
def configureSource(self, locals):
|
def configureSource(self, locals):
|
||||||
func = self.ctx.const.setup_func
|
func = self.ctx.const.setup_func
|
||||||
if func in locals:
|
if func in locals:
|
||||||
ui.info("Configuring %s...\n" % self.spec.source.name)
|
ui.info("Configuring %s...\n" % self.spec.source.name)
|
||||||
locals[func]()
|
locals[func]()
|
||||||
|
|
||||||
def buildSource(self, locals):
|
def buildSource(self, locals):
|
||||||
func = self.ctx.const.build_func
|
func = self.ctx.const.build_func
|
||||||
if func in locals:
|
if func in locals:
|
||||||
ui.info("Building %s...\n" % self.spec.source.name)
|
ui.info("Building %s...\n" % self.spec.source.name)
|
||||||
locals[func]()
|
locals[func]()
|
||||||
|
|
||||||
def installSource(self, locals):
|
def installSource(self, locals):
|
||||||
func = self.ctx.const.install_func
|
func = self.ctx.const.install_func
|
||||||
if func in locals:
|
if func in locals:
|
||||||
ui.info("Installing %s...\n" % self.spec.source.name)
|
ui.info("Installing %s...\n" % self.spec.source.name)
|
||||||
locals[func]()
|
locals[func]()
|
||||||
|
|
||||||
def genMetaDataXml(self, package):
|
def genMetaDataXml(self, package):
|
||||||
#test
|
#test
|
||||||
metadata = MetaData()
|
metadata = MetaData()
|
||||||
d = self.ctx.pkg_install_dir()
|
d = self.ctx.pkg_install_dir()
|
||||||
metadata.distribution = "Pardus" # from context?
|
metadata.distribution = "Pardus" # from context?
|
||||||
metadata.distributionRelease = "0.1"
|
metadata.distributionRelease = "0.1"
|
||||||
metadata.architecture = "Any" # FIXME
|
metadata.architecture = "Any" # FIXME
|
||||||
metadata.installSize = util.dir_size(d)
|
metadata.installSize = util.dir_size(d)
|
||||||
print d, metadata.installSize
|
print d, metadata.installSize
|
||||||
metadata.write(os.path.join(self.ctx.pkg_dir(),"metadata.xml"))
|
metadata.write(os.path.join(self.ctx.pkg_dir(),"metadata.xml"))
|
||||||
|
|
||||||
def genFilesXml(self, package):
|
def genFilesXml(self, package):
|
||||||
# the worst function in this project!
|
# the worst function in this project!
|
||||||
# just testing...
|
# just testing...
|
||||||
files = Files()
|
files = Files()
|
||||||
install_dir = self.ctx.pkg_install_dir()
|
install_dir = self.ctx.pkg_install_dir()
|
||||||
for fpath, fhash in util.get_file_hashes(install_dir):
|
for fpath, fhash in util.get_file_hashes(install_dir):
|
||||||
# get the relative path
|
# get the relative path
|
||||||
fpath = fpath[len(install_dir):]
|
fpath = fpath[len(install_dir):]
|
||||||
depth = 0
|
depth = 0
|
||||||
ftype = ""
|
ftype = ""
|
||||||
for path in package.paths:
|
for path in package.paths:
|
||||||
if fpath.startswith(path.pathname):
|
if fpath.startswith(path.pathname):
|
||||||
if depth < len(path.pathname):
|
if depth < len(path.pathname):
|
||||||
depth = len(path.pathname)
|
depth = len(path.pathname)
|
||||||
ftype = path.fileType
|
ftype = path.fileType
|
||||||
files.append(FileInfo(fpath, ftype, fhash))
|
files.append(FileInfo(fpath, ftype, fhash))
|
||||||
files.write(os.path.join(self.ctx.pkg_dir(),"files.xml"))
|
files.write(os.path.join(self.ctx.pkg_dir(),"files.xml"))
|
||||||
|
|
||||||
def buildPackages(self):
|
def buildPackages(self):
|
||||||
for package in self.spec.packages:
|
for package in self.spec.packages:
|
||||||
ui.info("** Building package %s\n" % package.name);
|
ui.info("** Building package %s\n" % package.name);
|
||||||
self.genMetaDataXml(package)
|
self.genMetaDataXml(package)
|
||||||
self.genFilesXml(package)
|
self.genFilesXml(package)
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user