build: Lots of code style fixes
This commit is contained in:
+196
-143
@@ -27,7 +27,7 @@ _ = __trans.ugettext
|
|||||||
|
|
||||||
import pisi
|
import pisi
|
||||||
import pisi.specfile
|
import pisi.specfile
|
||||||
import pisi.util
|
import pisi.util as util
|
||||||
import pisi.file
|
import pisi.file
|
||||||
import pisi.context as ctx
|
import pisi.context as ctx
|
||||||
import pisi.dependency as dependency
|
import pisi.dependency as dependency
|
||||||
@@ -43,6 +43,7 @@ import pisi.archive as archive
|
|||||||
import pisi.actionsapi.variables
|
import pisi.actionsapi.variables
|
||||||
import pisi.db
|
import pisi.db
|
||||||
|
|
||||||
|
|
||||||
class Error(pisi.Error):
|
class Error(pisi.Error):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
@@ -55,6 +56,7 @@ class AbandonedFilesException(pisi.Error):
|
|||||||
class ExcludedArchitectureException(Error):
|
class ExcludedArchitectureException(Error):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
||||||
# Helper Functions
|
# Helper Functions
|
||||||
def get_file_type(path, pinfo_list):
|
def get_file_type(path, pinfo_list):
|
||||||
"""Return the file type of a path according to the given PathInfo
|
"""Return the file type of a path according to the given PathInfo
|
||||||
@@ -72,7 +74,7 @@ def get_file_type(path, pinfo_list):
|
|||||||
elif fnmatch.fnmatch(path, pinfo.path):
|
elif fnmatch.fnmatch(path, pinfo.path):
|
||||||
glob_match = pinfo
|
glob_match = pinfo
|
||||||
|
|
||||||
elif fnmatch.fnmatch(path, pisi.util.join_path(pinfo.path, "*")):
|
elif fnmatch.fnmatch(path, util.join_path(pinfo.path, "*")):
|
||||||
if parent_match is None or parent_match.path < pinfo.path:
|
if parent_match is None or parent_match.path < pinfo.path:
|
||||||
parent_match = pinfo
|
parent_match = pinfo
|
||||||
|
|
||||||
@@ -85,6 +87,11 @@ def check_path_collision(package, pkgList):
|
|||||||
"""This function will check for collision of paths in a package with
|
"""This function will check for collision of paths in a package with
|
||||||
the paths of packages in pkgList. The return value will be the
|
the paths of packages in pkgList. The return value will be the
|
||||||
list containing the paths that collide."""
|
list containing the paths that collide."""
|
||||||
|
create_static = ctx.get_option("create_static")
|
||||||
|
create_debug = ctx.config.values.build.generatedebug
|
||||||
|
ar_suffix = ctx.const.ar_file_suffix
|
||||||
|
debug_suffix = ctx.const.debug_file_suffix
|
||||||
|
|
||||||
collisions = []
|
collisions = []
|
||||||
for pinfo in package.files:
|
for pinfo in package.files:
|
||||||
for pkg in pkgList:
|
for pkg in pkgList:
|
||||||
@@ -96,12 +103,14 @@ def check_path_collision(package, pkgList):
|
|||||||
# collide. Exp:
|
# collide. Exp:
|
||||||
# pinfo.path: /usr/share
|
# pinfo.path: /usr/share
|
||||||
# path.path: /usr/share/doc
|
# path.path: /usr/share/doc
|
||||||
if (path.path.endswith(ctx.const.ar_file_suffix) and ctx.get_option('create_static')) or \
|
|
||||||
(path.path.endswith(ctx.const.debug_file_suffix) and ctx.config.values.build.generatedebug):
|
if (create_static and path.path.endswith(ar_suffix)) or \
|
||||||
|
(create_static and path.path.endswith(debug_suffix)):
|
||||||
# don't throw collision error for these files.
|
# don't throw collision error for these files.
|
||||||
# we'll handle this in gen_files_xml..
|
# we'll handle this in gen_files_xml..
|
||||||
continue
|
continue
|
||||||
if pisi.util.subpath(pinfo.path, path.path):
|
|
||||||
|
if util.subpath(pinfo.path, path.path):
|
||||||
collisions.append(path.path.rstrip("/"))
|
collisions.append(path.path.rstrip("/"))
|
||||||
ctx.ui.debug(_('Path %s belongs in multiple packages') %
|
ctx.ui.debug(_('Path %s belongs in multiple packages') %
|
||||||
path.path)
|
path.path)
|
||||||
@@ -109,22 +118,22 @@ def check_path_collision(package, pkgList):
|
|||||||
|
|
||||||
def exclude_special_files(filepath, fileinfo, ag):
|
def exclude_special_files(filepath, fileinfo, ag):
|
||||||
keeplist = [] if not ag.has_key('KeepSpecial') else ag['KeepSpecial']
|
keeplist = [] if not ag.has_key('KeepSpecial') else ag['KeepSpecial']
|
||||||
patterns = {
|
patterns = {"libtool": "libtool library file",
|
||||||
"libtool": "libtool library file",
|
"python": "python.*byte-compiled",
|
||||||
"python": "python.*byte-compiled",
|
"perl": "Perl POD document text"}
|
||||||
"perl": "Perl POD document text"
|
|
||||||
}
|
|
||||||
|
|
||||||
if "libtool" in keeplist:
|
if "libtool" in keeplist:
|
||||||
# Some upstream sources have buggy libtool and ltmain.sh with them,
|
# Some upstream sources have buggy libtool and ltmain.sh with them,
|
||||||
# which causes wrong path entries in *.la files. And these wrong path
|
# which causes wrong path entries in *.la files. And these wrong path
|
||||||
# entries sometimes triggers compile-time errors or linkage problems.
|
# entries sometimes triggers compile-time errors or linkage problems.
|
||||||
# Instead of patching all these buggy sources and maintain these patches,
|
# Instead of patching all these buggy sources and maintain these
|
||||||
# PiSi removes wrong paths...
|
# patches, PiSi removes wrong paths...
|
||||||
if re.match(patterns["libtool"], fileinfo) and not os.path.islink(filepath):
|
if re.match(patterns["libtool"], fileinfo) and \
|
||||||
|
not os.path.islink(filepath):
|
||||||
ladata = file(filepath).read()
|
ladata = file(filepath).read()
|
||||||
new_ladata = re.sub("-L%s/\S*" % ctx.config.tmp_dir(), "", ladata)
|
new_ladata = re.sub("-L%s/\S*" % ctx.config.tmp_dir(), "", ladata)
|
||||||
new_ladata = re.sub("%s/\S*/install/" % ctx.config.tmp_dir(), "/", new_ladata)
|
new_ladata = re.sub("%s/\S*/install/" % ctx.config.tmp_dir(), "/",
|
||||||
|
new_ladata)
|
||||||
if new_ladata != ladata:
|
if new_ladata != ladata:
|
||||||
file(filepath, "w").write(new_ladata)
|
file(filepath, "w").write(new_ladata)
|
||||||
|
|
||||||
@@ -133,25 +142,25 @@ def exclude_special_files(filepath, fileinfo, ag):
|
|||||||
ctx.ui.debug("Removing special %s file: %s" % (pattern, filepath))
|
ctx.ui.debug("Removing special %s file: %s" % (pattern, filepath))
|
||||||
os.unlink(filepath)
|
os.unlink(filepath)
|
||||||
# Remove dir if it becomes empty (Bug #11588)
|
# Remove dir if it becomes empty (Bug #11588)
|
||||||
pisi.util.rmdirs(os.path.dirname(filepath))
|
util.rmdirs(os.path.dirname(filepath))
|
||||||
|
|
||||||
def strip_debug_action(filepath, fileinfo, install_dir, ag):
|
def strip_debug_action(filepath, fileinfo, install_dir, ag):
|
||||||
excludelist = [] if not ag.has_key('NoStrip') else ag['NoStrip']
|
excludelist = [] if not ag.has_key('NoStrip') else ag['NoStrip']
|
||||||
outputpath = pisi.util.join_path(os.path.dirname(install_dir),
|
outputpath = util.join_path(os.path.dirname(install_dir),
|
||||||
ctx.const.debug_dir_suffix,
|
ctx.const.debug_dir_suffix,
|
||||||
ctx.const.debug_files_suffix,
|
ctx.const.debug_files_suffix,
|
||||||
pisi.util.remove_prefix(install_dir, filepath))
|
util.remove_prefix(install_dir, filepath))
|
||||||
|
|
||||||
# real path in .pisi package
|
# real path in .pisi package
|
||||||
p = '/' + pisi.util.removepathprefix(install_dir, filepath)
|
p = '/' + util.removepathprefix(install_dir, filepath)
|
||||||
strip = True
|
strip = True
|
||||||
for exclude in excludelist:
|
for exclude in excludelist:
|
||||||
if p.startswith(exclude):
|
if p.startswith(exclude):
|
||||||
strip = False
|
strip = False
|
||||||
|
|
||||||
if strip:
|
if strip:
|
||||||
if pisi.util.strip_file(filepath, fileinfo, outputpath):
|
if util.strip_file(filepath, fileinfo, outputpath):
|
||||||
ctx.ui.debug("%s [%s]" %(p, "stripped"))
|
ctx.ui.debug("%s [%s]" % (p, "stripped"))
|
||||||
|
|
||||||
class Builder:
|
class Builder:
|
||||||
"""Provides the package build and creation routines"""
|
"""Provides the package build and creation routines"""
|
||||||
@@ -173,14 +182,16 @@ class Builder:
|
|||||||
else:
|
else:
|
||||||
repo = repodb.get_repo(reponame)
|
repo = repodb.get_repo(reponame)
|
||||||
#FIXME: don't use dirname to work on URLs
|
#FIXME: don't use dirname to work on URLs
|
||||||
src_path = os.path.join(os.path.dirname(repo.indexuri.get_uri()),
|
src_path = os.path.join(
|
||||||
str(src_uri.path()))
|
os.path.dirname(repo.indexuri.get_uri()),
|
||||||
|
str(src_uri.path()))
|
||||||
|
|
||||||
ctx.ui.debug(_("Source URI: %s") % src_path)
|
ctx.ui.debug(_("Source URI: %s") % src_path)
|
||||||
|
|
||||||
return Builder(src_path)
|
return Builder(src_path)
|
||||||
else:
|
else:
|
||||||
raise Error(_("Source %s not found in any active repository.") % name)
|
raise Error(_("Source %s not found in any active repository.")
|
||||||
|
% name)
|
||||||
|
|
||||||
def __init__(self, specuri):
|
def __init__(self, specuri):
|
||||||
|
|
||||||
@@ -199,12 +210,16 @@ class Builder:
|
|||||||
else:
|
else:
|
||||||
self.specdir = os.path.dirname(self.specuri.get_uri())
|
self.specdir = os.path.dirname(self.specuri.get_uri())
|
||||||
|
|
||||||
# Don't wait until creating .pisi file for complaining about versioning scheme errors
|
# Don't wait until creating .pisi file for complaining about versioning
|
||||||
self.check_versioning(self.spec.getSourceVersion(), self.spec.getSourceRelease())
|
# scheme errors
|
||||||
|
self.check_versioning(self.spec.getSourceVersion(),
|
||||||
|
self.spec.getSourceRelease())
|
||||||
|
|
||||||
self.read_translations(self.specdir)
|
self.read_translations(self.specdir)
|
||||||
|
|
||||||
self.sourceArchives = pisi.sourcearchive.SourceArchives(self.spec, self.pkg_work_dir())
|
self.sourceArchives = pisi.sourcearchive.SourceArchives(
|
||||||
|
self.spec,
|
||||||
|
self.pkg_work_dir())
|
||||||
|
|
||||||
self.set_environment_vars()
|
self.set_environment_vars()
|
||||||
|
|
||||||
@@ -214,14 +229,16 @@ class Builder:
|
|||||||
|
|
||||||
def set_spec_file(self, specuri):
|
def set_spec_file(self, specuri):
|
||||||
if not specuri.is_remote_file():
|
if not specuri.is_remote_file():
|
||||||
specuri = pisi.uri.URI(os.path.realpath(specuri.get_uri())) # FIXME: doesn't work for file://
|
# FIXME: doesn't work for file://
|
||||||
|
specuri = pisi.uri.URI(os.path.realpath(specuri.get_uri()))
|
||||||
self.specuri = specuri
|
self.specuri = specuri
|
||||||
spec = pisi.specfile.SpecFile()
|
spec = pisi.specfile.SpecFile()
|
||||||
spec.read(self.specuri, ctx.config.tmp_dir())
|
spec.read(self.specuri, ctx.config.tmp_dir())
|
||||||
self.spec = spec
|
self.spec = spec
|
||||||
|
|
||||||
def read_translations(self, specdir):
|
def read_translations(self, specdir):
|
||||||
self.spec.read_translations(pisi.util.join_path(specdir, ctx.const.translations_file))
|
self.spec.read_translations(util.join_path(specdir,
|
||||||
|
ctx.const.translations_file))
|
||||||
|
|
||||||
# directory accessor functions
|
# directory accessor functions
|
||||||
|
|
||||||
@@ -230,9 +247,11 @@ class Builder:
|
|||||||
def pkg_dir(self):
|
def pkg_dir(self):
|
||||||
"package build directory"
|
"package build directory"
|
||||||
packageDir = self.spec.source.name + '-' + \
|
packageDir = self.spec.source.name + '-' + \
|
||||||
self.spec.getSourceVersion() + '-' + self.spec.getSourceRelease()
|
self.spec.getSourceVersion() + '-' + \
|
||||||
return pisi.util.join_path(ctx.config.dest_dir(), ctx.config.values.dirs.tmp_dir,
|
self.spec.getSourceRelease()
|
||||||
packageDir)
|
return util.join_path(ctx.config.dest_dir(),
|
||||||
|
ctx.config.values.dirs.tmp_dir,
|
||||||
|
packageDir)
|
||||||
|
|
||||||
def pkg_work_dir(self):
|
def pkg_work_dir(self):
|
||||||
return self.pkg_dir() + ctx.const.work_dir_suffix
|
return self.pkg_dir() + ctx.const.work_dir_suffix
|
||||||
@@ -244,12 +263,12 @@ class Builder:
|
|||||||
return self.pkg_dir() + ctx.const.install_dir_suffix
|
return self.pkg_dir() + ctx.const.install_dir_suffix
|
||||||
|
|
||||||
def set_state(self, state):
|
def set_state(self, state):
|
||||||
stateFile = pisi.util.join_path(self.pkg_work_dir(), "pisiBuildState")
|
stateFile = util.join_path(self.pkg_work_dir(), "pisiBuildState")
|
||||||
open(stateFile, "w").write(state)
|
open(stateFile, "w").write(state)
|
||||||
|
|
||||||
def get_state(self):
|
def get_state(self):
|
||||||
stateFile = pisi.util.join_path(self.pkg_work_dir(), "pisiBuildState")
|
stateFile = util.join_path(self.pkg_work_dir(), "pisiBuildState")
|
||||||
if not os.path.exists(stateFile): # no state
|
if not os.path.exists(stateFile): # no state
|
||||||
return None
|
return None
|
||||||
return open(stateFile, "r").read()
|
return open(stateFile, "r").read()
|
||||||
|
|
||||||
@@ -258,15 +277,18 @@ class Builder:
|
|||||||
|
|
||||||
architecture = ctx.config.values.general.architecture
|
architecture = ctx.config.values.general.architecture
|
||||||
if architecture in self.spec.source.excludeArch:
|
if architecture in self.spec.source.excludeArch:
|
||||||
raise ExcludedArchitectureException(_("pspec.xml avoids this package from building for '%s'") % architecture)
|
raise ExcludedArchitectureException(
|
||||||
|
_("pspec.xml avoids this package from building for '%s'")
|
||||||
|
% architecture)
|
||||||
|
|
||||||
|
ctx.ui.status(_("Building PiSi source package: %s")
|
||||||
ctx.ui.status(_("Building PiSi source package: %s") % self.spec.source.name)
|
% self.spec.source.name)
|
||||||
|
|
||||||
self.compile_action_script()
|
self.compile_action_script()
|
||||||
self.compile_comar_script()
|
self.compile_comar_script()
|
||||||
|
|
||||||
# check if all patch files exists, if there are missing no need to unpack!
|
# check if all patch files exists, if there are missing no need
|
||||||
|
# to unpack!
|
||||||
self.patch_exists()
|
self.patch_exists()
|
||||||
|
|
||||||
self.check_build_dependencies()
|
self.check_build_dependencies()
|
||||||
@@ -290,14 +312,12 @@ class Builder:
|
|||||||
# environment. See bug #2575
|
# environment. See bug #2575
|
||||||
pisi.actionsapi.variables.initVariables()
|
pisi.actionsapi.variables.initVariables()
|
||||||
|
|
||||||
env = {
|
env = {"PKG_DIR": self.pkg_dir(),
|
||||||
"PKG_DIR": self.pkg_dir(),
|
"WORK_DIR": self.pkg_work_dir(),
|
||||||
"WORK_DIR": self.pkg_work_dir(),
|
"INSTALL_DIR": self.pkg_install_dir(),
|
||||||
"INSTALL_DIR": self.pkg_install_dir(),
|
"SRC_NAME": self.spec.source.name,
|
||||||
"SRC_NAME": self.spec.source.name,
|
"SRC_VERSION": self.spec.getSourceVersion(),
|
||||||
"SRC_VERSION": self.spec.getSourceVersion(),
|
"SRC_RELEASE": self.spec.getSourceRelease()}
|
||||||
"SRC_RELEASE": self.spec.getSourceRelease()
|
|
||||||
}
|
|
||||||
os.environ.update(env)
|
os.environ.update(env)
|
||||||
|
|
||||||
# First check icecream, if not found use ccache, no need to use both
|
# First check icecream, if not found use ccache, no need to use both
|
||||||
@@ -305,21 +325,23 @@ class Builder:
|
|||||||
if ctx.config.values.build.buildhelper == "icecream":
|
if ctx.config.values.build.buildhelper == "icecream":
|
||||||
if os.path.exists("/opt/icecream/bin/gcc"):
|
if os.path.exists("/opt/icecream/bin/gcc"):
|
||||||
# Add icecream directory for support distributed compiling :)
|
# Add icecream directory for support distributed compiling :)
|
||||||
os.environ["PATH"] = "/opt/icecream/bin/:%s" % os.environ["PATH"]
|
os.environ["PATH"] = "/opt/icecream/bin:%(PATH)s" % os.environ
|
||||||
ctx.ui.info(_("IceCream detected. Make sure your daemon is up and running..."))
|
ctx.ui.info(_("IceCream detected. Make sure your daemon "
|
||||||
|
"is up and running..."))
|
||||||
elif ctx.config.values.build.buildhelper == "ccache":
|
elif ctx.config.values.build.buildhelper == "ccache":
|
||||||
if os.path.exists("/usr/lib/ccache/bin/gcc"):
|
if os.path.exists("/usr/lib/ccache/bin/gcc"):
|
||||||
# Add ccache directory for support Compiler Cache :)
|
# Add ccache directory for support Compiler Cache :)
|
||||||
os.environ["PATH"] = "/usr/lib/ccache/bin/:%s" % os.environ["PATH"]
|
os.environ["PATH"] = "/usr/lib/ccache/bin:%(PATH)s" \
|
||||||
# Force ccache to use /root/.ccache instead of $HOME/.ccache which can be modified
|
% os.environ
|
||||||
# through actions.py
|
# Force ccache to use /root/.ccache instead of $HOME/.ccache
|
||||||
|
# which can be modified through actions.py
|
||||||
os.environ["CCACHE_DIR"] = "/root/.ccache"
|
os.environ["CCACHE_DIR"] = "/root/.ccache"
|
||||||
ctx.ui.info(_("CCache detected..."))
|
ctx.ui.info(_("CCache detected..."))
|
||||||
|
|
||||||
def fetch_files(self):
|
def fetch_files(self):
|
||||||
self.specdiruri = os.path.dirname(self.specuri.get_uri())
|
self.specdiruri = os.path.dirname(self.specuri.get_uri())
|
||||||
pkgname = os.path.basename(self.specdiruri)
|
pkgname = os.path.basename(self.specdiruri)
|
||||||
self.destdir = pisi.util.join_path(ctx.config.tmp_dir(), pkgname)
|
self.destdir = util.join_path(ctx.config.tmp_dir(), pkgname)
|
||||||
#self.location = os.path.dirname(self.url.uri)
|
#self.location = os.path.dirname(self.url.uri)
|
||||||
|
|
||||||
self.fetch_actionsfile()
|
self.fetch_actionsfile()
|
||||||
@@ -332,15 +354,16 @@ class Builder:
|
|||||||
return self.destdir
|
return self.destdir
|
||||||
|
|
||||||
def fetch_pspecfile(self):
|
def fetch_pspecfile(self):
|
||||||
pspecuri = pisi.util.join_path(self.specdiruri, ctx.const.pspec_file)
|
pspecuri = util.join_path(self.specdiruri, ctx.const.pspec_file)
|
||||||
self.download(pspecuri, self.destdir)
|
self.download(pspecuri, self.destdir)
|
||||||
|
|
||||||
def fetch_actionsfile(self):
|
def fetch_actionsfile(self):
|
||||||
actionsuri = pisi.util.join_path(self.specdiruri, ctx.const.actions_file)
|
actionsuri = util.join_path(self.specdiruri, ctx.const.actions_file)
|
||||||
self.download(actionsuri, self.destdir)
|
self.download(actionsuri, self.destdir)
|
||||||
|
|
||||||
def fetch_translationsfile(self):
|
def fetch_translationsfile(self):
|
||||||
translationsuri = pisi.util.join_path(self.specdiruri, ctx.const.translations_file)
|
translationsuri = util.join_path(self.specdiruri,
|
||||||
|
ctx.const.translations_file)
|
||||||
try:
|
try:
|
||||||
self.download(translationsuri, self.destdir)
|
self.download(translationsuri, self.destdir)
|
||||||
except pisi.fetcher.FetchError:
|
except pisi.fetcher.FetchError:
|
||||||
@@ -352,26 +375,31 @@ class Builder:
|
|||||||
for patch in spec.source.patches:
|
for patch in spec.source.patches:
|
||||||
file_name = os.path.basename(patch.filename)
|
file_name = os.path.basename(patch.filename)
|
||||||
dir_name = os.path.dirname(patch.filename)
|
dir_name = os.path.dirname(patch.filename)
|
||||||
patchuri = pisi.util.join_path(self.specdiruri,
|
patchuri = util.join_path(self.specdiruri,
|
||||||
ctx.const.files_dir, dir_name, file_name)
|
ctx.const.files_dir, dir_name, file_name)
|
||||||
self.download(patchuri, pisi.util.join_path(self.destdir, ctx.const.files_dir, dir_name))
|
self.download(patchuri, util.join_path(self.destdir,
|
||||||
|
ctx.const.files_dir,
|
||||||
|
dir_name))
|
||||||
|
|
||||||
def fetch_comarfiles(self):
|
def fetch_comarfiles(self):
|
||||||
spec = self.spec
|
spec = self.spec
|
||||||
for package in spec.packages:
|
for package in spec.packages:
|
||||||
for pcomar in package.providesComar:
|
for pcomar in package.providesComar:
|
||||||
comaruri = pisi.util.join_path(self.specdiruri,
|
comaruri = util.join_path(self.specdiruri,
|
||||||
ctx.const.comar_dir, pcomar.script)
|
ctx.const.comar_dir, pcomar.script)
|
||||||
self.download(comaruri, pisi.util.join_path(self.destdir, ctx.const.comar_dir))
|
self.download(comaruri, util.join_path(self.destdir,
|
||||||
|
ctx.const.comar_dir))
|
||||||
|
|
||||||
def fetch_additionalFiles(self):
|
def fetch_additionalFiles(self):
|
||||||
for pkg in self.spec.packages + [self.spec.source]:
|
for pkg in self.spec.packages + [self.spec.source]:
|
||||||
for afile in pkg.additionalFiles:
|
for afile in pkg.additionalFiles:
|
||||||
file_name = os.path.basename(afile.filename)
|
file_name = os.path.basename(afile.filename)
|
||||||
dir_name = os.path.dirname(afile.filename)
|
dir_name = os.path.dirname(afile.filename)
|
||||||
afileuri = pisi.util.join_path(self.specdiruri,
|
afileuri = util.join_path(self.specdiruri,
|
||||||
ctx.const.files_dir, dir_name, file_name)
|
ctx.const.files_dir, dir_name, file_name)
|
||||||
self.download(afileuri, pisi.util.join_path(self.destdir, ctx.const.files_dir, dir_name))
|
self.download(afileuri, util.join_path(self.destdir,
|
||||||
|
ctx.const.files_dir,
|
||||||
|
dir_name))
|
||||||
|
|
||||||
def download(self, uri, transferdir):
|
def download(self, uri, transferdir):
|
||||||
# fix auth info and download
|
# fix auth info and download
|
||||||
@@ -381,21 +409,25 @@ class Builder:
|
|||||||
def fetch_component(self):
|
def fetch_component(self):
|
||||||
if not self.spec.source.partOf:
|
if not self.spec.source.partOf:
|
||||||
ctx.ui.info(_('PartOf tag not defined, looking for component'))
|
ctx.ui.info(_('PartOf tag not defined, looking for component'))
|
||||||
diruri = pisi.util.parenturi(self.specuri.get_uri())
|
diruri = util.parenturi(self.specuri.get_uri())
|
||||||
parentdir = pisi.util.parenturi(diruri)
|
parentdir = util.parenturi(diruri)
|
||||||
url = pisi.util.join_path(parentdir, 'component.xml')
|
url = util.join_path(parentdir, 'component.xml')
|
||||||
progress = ctx.ui.Progress
|
progress = ctx.ui.Progress
|
||||||
if pisi.uri.URI(url).is_remote_file():
|
if pisi.uri.URI(url).is_remote_file():
|
||||||
try:
|
try:
|
||||||
pisi.fetcher.fetch_url(url, self.pkg_work_dir(), progress)
|
pisi.fetcher.fetch_url(url, self.pkg_work_dir(), progress)
|
||||||
except pisi.fetcher.FetchError:
|
except pisi.fetcher.FetchError:
|
||||||
ctx.ui.warning(_('Cannot find component.xml in remote directory, Source is now part of unknown component'))
|
ctx.ui.warning(_("Cannot find component.xml in remote "
|
||||||
|
"directory, Source is now part of "
|
||||||
|
"unknown component"))
|
||||||
self.spec.source.partOf = 'unknown'
|
self.spec.source.partOf = 'unknown'
|
||||||
return
|
return
|
||||||
path = pisi.util.join_path(self.pkg_work_dir(), 'component.xml')
|
path = util.join_path(self.pkg_work_dir(), 'component.xml')
|
||||||
else:
|
else:
|
||||||
if not os.path.exists(url):
|
if not os.path.exists(url):
|
||||||
ctx.ui.warning(_('Cannot find component.xml in upper directory, Source is now part of unknown component'))
|
ctx.ui.warning(_("Cannot find component.xml in upper "
|
||||||
|
"directory, Source is now part of "
|
||||||
|
"unknown component"))
|
||||||
self.spec.source.partOf = 'unknown'
|
self.spec.source.partOf = 'unknown'
|
||||||
return
|
return
|
||||||
path = url
|
path = url
|
||||||
@@ -437,7 +469,7 @@ class Builder:
|
|||||||
|
|
||||||
# Before install make sure install_dir is clean
|
# Before install make sure install_dir is clean
|
||||||
if os.path.exists(self.pkg_install_dir()):
|
if os.path.exists(self.pkg_install_dir()):
|
||||||
pisi.util.clean_dir(self.pkg_install_dir())
|
util.clean_dir(self.pkg_install_dir())
|
||||||
|
|
||||||
# install function is mandatory!
|
# install function is mandatory!
|
||||||
if self.run_action_function(ctx.const.install_func, True):
|
if self.run_action_function(ctx.const.install_func, True):
|
||||||
@@ -450,17 +482,16 @@ class Builder:
|
|||||||
abandoned_files = []
|
abandoned_files = []
|
||||||
all_paths_in_packages = []
|
all_paths_in_packages = []
|
||||||
|
|
||||||
|
|
||||||
for package in self.spec.packages:
|
for package in self.spec.packages:
|
||||||
for path in package.files:
|
for path in package.files:
|
||||||
path = pisi.util.join_path(install_dir, path.path)
|
path = util.join_path(install_dir, path.path)
|
||||||
all_paths_in_packages.append(path)
|
all_paths_in_packages.append(path)
|
||||||
|
|
||||||
def is_included(path1, path2):
|
def is_included(path1, path2):
|
||||||
"Return True if path2 includes path1"
|
"Return True if path2 includes path1"
|
||||||
return path1 == path2 \
|
return path1 == path2 \
|
||||||
or fnmatch.fnmatch(path1, path2) \
|
or fnmatch.fnmatch(path1, path2) \
|
||||||
or fnmatch.fnmatch(path1, pisi.util.join_path(path2, "*"))
|
or fnmatch.fnmatch(path1, util.join_path(path2, "*"))
|
||||||
|
|
||||||
for root, dirs, files in os.walk(install_dir):
|
for root, dirs, files in os.walk(install_dir):
|
||||||
if not dirs and not files:
|
if not dirs and not files:
|
||||||
@@ -471,7 +502,7 @@ class Builder:
|
|||||||
abandoned_files.append(root)
|
abandoned_files.append(root)
|
||||||
|
|
||||||
for file_ in files:
|
for file_ in files:
|
||||||
fpath = pisi.util.join_path(root, file_)
|
fpath = util.join_path(root, file_)
|
||||||
for _path in all_paths_in_packages:
|
for _path in all_paths_in_packages:
|
||||||
if is_included(fpath, _path):
|
if is_included(fpath, _path):
|
||||||
break
|
break
|
||||||
@@ -487,22 +518,25 @@ class Builder:
|
|||||||
for afile in self.spec.source.additionalFiles:
|
for afile in self.spec.source.additionalFiles:
|
||||||
src = os.path.join(self.specdir, ctx.const.files_dir, afile.filename)
|
src = os.path.join(self.specdir, ctx.const.files_dir, afile.filename)
|
||||||
dest = os.path.join(self.srcDir, afile.target)
|
dest = os.path.join(self.srcDir, afile.target)
|
||||||
pisi.util.copy_file(src, dest)
|
util.copy_file(src, dest)
|
||||||
if afile.permission:
|
if afile.permission:
|
||||||
# mode is octal!
|
# mode is octal!
|
||||||
os.chmod(dest, int(afile.permission, 8))
|
os.chmod(dest, int(afile.permission, 8))
|
||||||
|
|
||||||
def compile_action_script(self):
|
def compile_action_script(self):
|
||||||
"""Compiles given actions.py to check syntax error in it and sets the actionLocals and actionGlobals"""
|
"""Compiles given actions.py to check syntax error in it and
|
||||||
fname = pisi.util.join_path(self.specdir, ctx.const.actions_file)
|
sets the actionLocals and actionGlobals"""
|
||||||
|
fname = util.join_path(self.specdir, ctx.const.actions_file)
|
||||||
try:
|
try:
|
||||||
localSymbols = globalSymbols = {}
|
localSymbols = globalSymbols = {}
|
||||||
buf = open(fname).read()
|
buf = open(fname).read()
|
||||||
exec compile(buf, "error", "exec") in localSymbols, globalSymbols
|
exec compile(buf, "error", "exec") in localSymbols, globalSymbols
|
||||||
except IOError, e:
|
except IOError, e:
|
||||||
raise Error(_("Unable to read Actions Script (%s): %s") %(fname,e))
|
raise Error(_("Unable to read Actions Script (%s): %s")
|
||||||
|
% (fname, e))
|
||||||
except SyntaxError, e:
|
except SyntaxError, e:
|
||||||
raise Error(_("SyntaxError in Actions Script (%s): %s") %(fname,e))
|
raise Error(_("SyntaxError in Actions Script (%s): %s")
|
||||||
|
% (fname, e))
|
||||||
|
|
||||||
self.actionLocals = localSymbols
|
self.actionLocals = localSymbols
|
||||||
self.actionGlobals = globalSymbols
|
self.actionGlobals = globalSymbols
|
||||||
@@ -512,28 +546,33 @@ class Builder:
|
|||||||
"""Compiles comar scripts to check syntax errors"""
|
"""Compiles comar scripts to check syntax errors"""
|
||||||
for package in self.spec.packages:
|
for package in self.spec.packages:
|
||||||
for pcomar in package.providesComar:
|
for pcomar in package.providesComar:
|
||||||
fname = pisi.util.join_path(self.specdir, ctx.const.comar_dir,
|
fname = util.join_path(self.specdir, ctx.const.comar_dir,
|
||||||
pcomar.script)
|
pcomar.script)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
buf = open(fname).read()
|
buf = open(fname).read()
|
||||||
compile(buf, "error", "exec")
|
compile(buf, "error", "exec")
|
||||||
except IOError, e:
|
except IOError, e:
|
||||||
raise Error(_("Unable to read COMAR script (%s): %s") %(fname,e))
|
raise Error(_("Unable to read COMAR script (%s): %s")
|
||||||
|
% (fname, e))
|
||||||
except SyntaxError, e:
|
except SyntaxError, e:
|
||||||
raise Error(_("SyntaxError in COMAR file (%s): %s") %(fname,e))
|
raise Error(_("SyntaxError in COMAR file (%s): %s")
|
||||||
|
% (fname, e))
|
||||||
|
|
||||||
def pkg_src_dir(self):
|
def pkg_src_dir(self):
|
||||||
"""Returns the real path of WorkDir for an unpacked archive."""
|
"""Returns the real path of WorkDir for an unpacked archive."""
|
||||||
try:
|
try:
|
||||||
workdir = self.actionGlobals['WorkDir']
|
workdir = self.actionGlobals['WorkDir']
|
||||||
except KeyError:
|
except KeyError:
|
||||||
workdir = self.spec.source.name + "-" + self.spec.getSourceVersion()
|
workdir = self.spec.source.name + "-" + \
|
||||||
|
self.spec.getSourceVersion()
|
||||||
|
|
||||||
return pisi.util.join_path(self.pkg_work_dir(), workdir)
|
return util.join_path(self.pkg_work_dir(), workdir)
|
||||||
|
|
||||||
def log_sandbox_violation(self, operation, path, canonical_path):
|
def log_sandbox_violation(self, operation, path, canonical_path):
|
||||||
ctx.ui.error(_("Sandbox violation: %s (%s -> %s)") % (operation, path, canonical_path))
|
ctx.ui.error(_("Sandbox violation: %s (%s -> %s)") % (operation,
|
||||||
|
path,
|
||||||
|
canonical_path))
|
||||||
|
|
||||||
def run_action_function(self, func, mandatory=False):
|
def run_action_function(self, func, mandatory=False):
|
||||||
"""Calls the corresponding function in actions.py.
|
"""Calls the corresponding function in actions.py.
|
||||||
@@ -546,10 +585,12 @@ class Builder:
|
|||||||
if os.path.exists(self.srcDir):
|
if os.path.exists(self.srcDir):
|
||||||
os.chdir(self.srcDir)
|
os.chdir(self.srcDir)
|
||||||
else:
|
else:
|
||||||
raise Error(_("ERROR: WorkDir (%s) does not exist\n") % (self.srcDir))
|
raise Error(_("ERROR: WorkDir (%s) does not exist\n")
|
||||||
|
% (self.srcDir))
|
||||||
|
|
||||||
if func in self.actionLocals:
|
if func in self.actionLocals:
|
||||||
if ctx.get_option('ignore_sandbox') or not ctx.config.values.build.enablesandbox:
|
if ctx.get_option('ignore_sandbox') or \
|
||||||
|
not ctx.config.values.build.enablesandbox:
|
||||||
self.actionLocals[func]()
|
self.actionLocals[func]()
|
||||||
else:
|
else:
|
||||||
import catbox
|
import catbox
|
||||||
@@ -557,7 +598,7 @@ class Builder:
|
|||||||
ctx.ui.info(_("Sandbox enabled build..."))
|
ctx.ui.info(_("Sandbox enabled build..."))
|
||||||
|
|
||||||
# Configure allowed paths from sandbox.conf
|
# Configure allowed paths from sandbox.conf
|
||||||
valid_paths = [ self.pkg_dir() ]
|
valid_paths = [self.pkg_dir()]
|
||||||
conf_file = ctx.const.sandbox_conf
|
conf_file = ctx.const.sandbox_conf
|
||||||
if os.path.exists(conf_file):
|
if os.path.exists(conf_file):
|
||||||
for line in file(conf_file):
|
for line in file(conf_file):
|
||||||
@@ -569,21 +610,28 @@ class Builder:
|
|||||||
|
|
||||||
# Extra path for ccache when needed
|
# Extra path for ccache when needed
|
||||||
if ctx.config.values.build.buildhelper == "ccache":
|
if ctx.config.values.build.buildhelper == "ccache":
|
||||||
valid_paths.append(os.environ.get("CCACHE_DIR", "/root/.ccache"))
|
valid_paths.append(os.environ.get("CCACHE_DIR",
|
||||||
|
"/root/.ccache"))
|
||||||
|
|
||||||
ret = catbox.run(self.actionLocals[func], valid_paths, logger=self.log_sandbox_violation)
|
ret = catbox.run(self.actionLocals[func],
|
||||||
# Retcode can be 0 while there is a sanbox violation, so only look for violations to correctly handle it
|
valid_paths,
|
||||||
|
logger=self.log_sandbox_violation)
|
||||||
|
# Retcode can be 0 while there is a sanbox violation, so only
|
||||||
|
# look for violations to correctly handle it
|
||||||
if ret.violations != []:
|
if ret.violations != []:
|
||||||
ctx.ui.error(_("Sandbox violation result:"))
|
ctx.ui.error(_("Sandbox violation result:"))
|
||||||
for result in ret.violations:
|
for result in ret.violations:
|
||||||
ctx.ui.error("* %s (%s -> %s)" % (result[0], result[1], result[2]))
|
ctx.ui.error("* %s (%s -> %s)" % (result[0],
|
||||||
|
result[1],
|
||||||
|
result[2]))
|
||||||
raise Error(_("Sandbox violations!"))
|
raise Error(_("Sandbox violations!"))
|
||||||
|
|
||||||
if ret.code == 1:
|
if ret.code == 1:
|
||||||
raise ActionScriptException
|
raise ActionScriptException
|
||||||
else:
|
else:
|
||||||
if mandatory:
|
if mandatory:
|
||||||
raise Error(_("unable to call function from actions: %s") % func)
|
raise Error(_("unable to call function from actions: %s")
|
||||||
|
% func)
|
||||||
|
|
||||||
os.chdir(curDir)
|
os.chdir(curDir)
|
||||||
return True
|
return True
|
||||||
@@ -593,14 +641,16 @@ class Builder:
|
|||||||
int(release)
|
int(release)
|
||||||
pisi.version.make_version(version)
|
pisi.version.make_version(version)
|
||||||
except (ValueError, pisi.version.InvalidVersionError):
|
except (ValueError, pisi.version.InvalidVersionError):
|
||||||
raise Error(_("%s-%s is not a valid PiSi version format") % (version, release))
|
raise Error(_("%s-%s is not a valid PiSi version format")
|
||||||
|
% (version, release))
|
||||||
|
|
||||||
def check_build_dependencies(self):
|
def check_build_dependencies(self):
|
||||||
"""check and try to install build dependencies, otherwise fail."""
|
"""check and try to install build dependencies, otherwise fail."""
|
||||||
|
|
||||||
build_deps = self.spec.source.buildDependencies
|
build_deps = self.spec.source.buildDependencies
|
||||||
|
|
||||||
if not ctx.config.values.general.ignore_safety and not ctx.get_option('ignore_safety'):
|
if not ctx.config.values.general.ignore_safety and \
|
||||||
|
not ctx.get_option('ignore_safety'):
|
||||||
if self.componentdb.has_component('system.devel'):
|
if self.componentdb.has_component('system.devel'):
|
||||||
build_deps_names = set([x.package for x in build_deps])
|
build_deps_names = set([x.package for x in build_deps])
|
||||||
devel_deps_names = set(self.componentdb.get_component('system.devel').packages)
|
devel_deps_names = set(self.componentdb.get_component('system.devel').packages)
|
||||||
@@ -608,8 +658,8 @@ class Builder:
|
|||||||
extra_names = filter(lambda x: not self.installdb.has_package(x), extra_names)
|
extra_names = filter(lambda x: not self.installdb.has_package(x), extra_names)
|
||||||
if extra_names:
|
if extra_names:
|
||||||
ctx.ui.warning(_('Safety switch: following extra packages in system.devel will be installed: ') +
|
ctx.ui.warning(_('Safety switch: following extra packages in system.devel will be installed: ') +
|
||||||
pisi.util.strlist(extra_names))
|
util.strlist(extra_names))
|
||||||
extra_deps = [dependency.Dependency(package = x) for x in extra_names]
|
extra_deps = [dependency.Dependency(package=x) for x in extra_names]
|
||||||
build_deps.extend(extra_deps)
|
build_deps.extend(extra_deps)
|
||||||
else:
|
else:
|
||||||
ctx.ui.info(_('Safety switch: system.devel is already installed'))
|
ctx.ui.info(_('Safety switch: system.devel is already installed'))
|
||||||
@@ -624,7 +674,7 @@ class Builder:
|
|||||||
|
|
||||||
if dep_unsatis:
|
if dep_unsatis:
|
||||||
ctx.ui.info(_("Unsatisfied Build Dependencies:") + ' '
|
ctx.ui.info(_("Unsatisfied Build Dependencies:") + ' '
|
||||||
+ pisi.util.strlist([str(x) for x in dep_unsatis]) )
|
+ util.strlist([str(x) for x in dep_unsatis]))
|
||||||
|
|
||||||
def fail():
|
def fail():
|
||||||
raise Error(_('Cannot build package due to unsatisfied build dependencies'))
|
raise Error(_('Cannot build package due to unsatisfied build dependencies'))
|
||||||
@@ -646,37 +696,37 @@ class Builder:
|
|||||||
def patch_exists(self):
|
def patch_exists(self):
|
||||||
"""check existence of patch files declared in PSPEC"""
|
"""check existence of patch files declared in PSPEC"""
|
||||||
|
|
||||||
files_dir = os.path.abspath(pisi.util.join_path(self.specdir,
|
files_dir = os.path.abspath(util.join_path(self.specdir,
|
||||||
ctx.const.files_dir))
|
ctx.const.files_dir))
|
||||||
for patch in self.spec.source.patches:
|
for patch in self.spec.source.patches:
|
||||||
patchFile = pisi.util.join_path(files_dir, patch.filename)
|
patchFile = util.join_path(files_dir, patch.filename)
|
||||||
if not os.access(patchFile, os.F_OK):
|
if not os.access(patchFile, os.F_OK):
|
||||||
raise Error(_("Patch file is missing: %s\n") % patch.filename)
|
raise Error(_("Patch file is missing: %s\n") % patch.filename)
|
||||||
|
|
||||||
def apply_patches(self):
|
def apply_patches(self):
|
||||||
files_dir = os.path.abspath(pisi.util.join_path(self.specdir,
|
files_dir = os.path.abspath(util.join_path(self.specdir,
|
||||||
ctx.const.files_dir))
|
ctx.const.files_dir))
|
||||||
|
|
||||||
for patch in self.spec.source.patches:
|
for patch in self.spec.source.patches:
|
||||||
patchFile = pisi.util.join_path(files_dir, patch.filename)
|
patchFile = util.join_path(files_dir, patch.filename)
|
||||||
relativePath = patch.filename
|
relativePath = patch.filename
|
||||||
reverseApply = patch.reverse and patch.reverse.lower() == "true"
|
reverseApply = patch.reverse and patch.reverse.lower() == "true"
|
||||||
if patch.compressionType:
|
if patch.compressionType:
|
||||||
patchFile = pisi.util.uncompress(patchFile,
|
patchFile = util.uncompress(patchFile,
|
||||||
compressType=patch.compressionType,
|
compressType=patch.compressionType,
|
||||||
targetDir=ctx.config.tmp_dir())
|
targetDir=ctx.config.tmp_dir())
|
||||||
relativePath = relativePath.rsplit(".%s" % patch.compressionType, 1)[0]
|
relativePath = relativePath.rsplit(".%s" % patch.compressionType, 1)[0]
|
||||||
|
|
||||||
ctx.ui.action(_("* Applying patch: %s") % patch.filename)
|
ctx.ui.action(_("* Applying patch: %s") % patch.filename)
|
||||||
pisi.util.do_patch(self.srcDir, patchFile, level=patch.level, name=relativePath, reverse=reverseApply)
|
util.do_patch(self.srcDir, patchFile, level=patch.level, name=relativePath, reverse=reverseApply)
|
||||||
return True
|
return True
|
||||||
|
|
||||||
def generate_static_package_object(self):
|
def generate_static_package_object(self):
|
||||||
ar_files = []
|
ar_files = []
|
||||||
for root, dirs, files in os.walk(self.pkg_install_dir()):
|
for root, dirs, files in os.walk(self.pkg_install_dir()):
|
||||||
for f in files:
|
for f in files:
|
||||||
if f.endswith(ctx.const.ar_file_suffix) and pisi.util.is_ar_file(pisi.util.join_path(root, f)):
|
if f.endswith(ctx.const.ar_file_suffix) and util.is_ar_file(util.join_path(root, f)):
|
||||||
ar_files.append(pisi.util.join_path(root, f))
|
ar_files.append(util.join_path(root, f))
|
||||||
|
|
||||||
if not len(ar_files):
|
if not len(ar_files):
|
||||||
return None
|
return None
|
||||||
@@ -688,12 +738,12 @@ class Builder:
|
|||||||
static_package_obj.description['en'] = u'Ar files for %s' % (self.spec.source.name)
|
static_package_obj.description['en'] = u'Ar files for %s' % (self.spec.source.name)
|
||||||
static_package_obj.partOf = self.spec.source.partOf
|
static_package_obj.partOf = self.spec.source.partOf
|
||||||
for f in ar_files:
|
for f in ar_files:
|
||||||
static_package_obj.files.append(pisi.specfile.Path(path = f[len(self.pkg_install_dir()):], fileType = "library"))
|
static_package_obj.files.append(pisi.specfile.Path(path=f[len(self.pkg_install_dir()):], fileType="library"))
|
||||||
|
|
||||||
# append all generated packages to dependencies
|
# append all generated packages to dependencies
|
||||||
for p in self.spec.packages:
|
for p in self.spec.packages:
|
||||||
static_package_obj.packageDependencies.append(
|
static_package_obj.packageDependencies.append(
|
||||||
pisi.dependency.Dependency(package = p.name))
|
pisi.dependency.Dependency(package=p.name))
|
||||||
|
|
||||||
return static_package_obj
|
return static_package_obj
|
||||||
|
|
||||||
@@ -702,7 +752,7 @@ class Builder:
|
|||||||
for root, dirs, files in os.walk(self.pkg_debug_dir()):
|
for root, dirs, files in os.walk(self.pkg_debug_dir()):
|
||||||
for f in files:
|
for f in files:
|
||||||
if f.endswith(ctx.const.debug_file_suffix):
|
if f.endswith(ctx.const.debug_file_suffix):
|
||||||
debug_files.append(pisi.util.join_path(root, f))
|
debug_files.append(util.join_path(root, f))
|
||||||
|
|
||||||
if not len(debug_files):
|
if not len(debug_files):
|
||||||
return None
|
return None
|
||||||
@@ -715,7 +765,7 @@ class Builder:
|
|||||||
debug_package_obj.description['en'] = u'Debug files for %s' % (self.spec.source.name)
|
debug_package_obj.description['en'] = u'Debug files for %s' % (self.spec.source.name)
|
||||||
debug_package_obj.partOf = self.spec.source.partOf
|
debug_package_obj.partOf = self.spec.source.partOf
|
||||||
for f in debug_files:
|
for f in debug_files:
|
||||||
debug_package_obj.files.append(pisi.specfile.Path(path = f[len(self.pkg_debug_dir()):], fileType = "debug"))
|
debug_package_obj.files.append(pisi.specfile.Path(path=f[len(self.pkg_debug_dir()):], fileType="debug"))
|
||||||
|
|
||||||
return debug_package_obj
|
return debug_package_obj
|
||||||
|
|
||||||
@@ -760,19 +810,20 @@ class Builder:
|
|||||||
# reported as errors
|
# reported as errors
|
||||||
|
|
||||||
d = {}
|
d = {}
|
||||||
|
|
||||||
def add_path(path):
|
def add_path(path):
|
||||||
# add the files under material path
|
# add the files under material path
|
||||||
for fpath, fhash in pisi.util.get_file_hashes(path, collisions, install_dir):
|
for fpath, fhash in util.get_file_hashes(path, collisions, install_dir):
|
||||||
if ctx.get_option('create_static') \
|
if ctx.get_option('create_static') \
|
||||||
and fpath.endswith(ctx.const.ar_file_suffix) \
|
and fpath.endswith(ctx.const.ar_file_suffix) \
|
||||||
and not package.name.endswith(ctx.const.static_name_suffix) \
|
and not package.name.endswith(ctx.const.static_name_suffix) \
|
||||||
and pisi.util.is_ar_file(fpath):
|
and util.is_ar_file(fpath):
|
||||||
# if this is an ar file, and this package is not a static package,
|
# if this is an ar file, and this package is not a static package,
|
||||||
# don't include this file into the package.
|
# don't include this file into the package.
|
||||||
continue
|
continue
|
||||||
frpath = pisi.util.removepathprefix(install_dir, fpath) # relative path
|
frpath = util.removepathprefix(install_dir, fpath) # relative path
|
||||||
ftype, permanent = get_file_type(frpath, package.files)
|
ftype, permanent = get_file_type(frpath, package.files)
|
||||||
fsize = long(pisi.util.dir_size(fpath))
|
fsize = long(util.dir_size(fpath))
|
||||||
if not os.path.islink(fpath):
|
if not os.path.islink(fpath):
|
||||||
st = os.stat(fpath)
|
st = os.stat(fpath)
|
||||||
else:
|
else:
|
||||||
@@ -784,14 +835,14 @@ class Builder:
|
|||||||
ctx.ui.warning(_("/%s has suid bit set") % frpath)
|
ctx.ui.warning(_("/%s has suid bit set") % frpath)
|
||||||
|
|
||||||
for pinfo in package.files:
|
for pinfo in package.files:
|
||||||
wildcard_path = pisi.util.join_path(install_dir, pinfo.path)
|
wildcard_path = util.join_path(install_dir, pinfo.path)
|
||||||
for path in glob.glob(wildcard_path):
|
for path in glob.glob(wildcard_path):
|
||||||
add_path(path)
|
add_path(path)
|
||||||
|
|
||||||
for (p, fileinfo) in d.iteritems():
|
for (p, fileinfo) in d.iteritems():
|
||||||
files.append(fileinfo)
|
files.append(fileinfo)
|
||||||
|
|
||||||
files_xml_path = pisi.util.join_path(self.pkg_dir(), ctx.const.files_xml)
|
files_xml_path = util.join_path(self.pkg_dir(), ctx.const.files_xml)
|
||||||
files.write(files_xml_path)
|
files.write(files_xml_path)
|
||||||
self.files = files
|
self.files = files
|
||||||
|
|
||||||
@@ -808,19 +859,20 @@ class Builder:
|
|||||||
|
|
||||||
# find previous build in packages dir
|
# find previous build in packages dir
|
||||||
found = set()
|
found = set()
|
||||||
|
|
||||||
def locate_old_package(old_package_fn):
|
def locate_old_package(old_package_fn):
|
||||||
if not old_package_fn.endswith(ctx.const.package_suffix) or \
|
if not old_package_fn.endswith(ctx.const.package_suffix) or \
|
||||||
old_package_fn.endswith(ctx.const.delta_package_suffix):
|
old_package_fn.endswith(ctx.const.delta_package_suffix):
|
||||||
return
|
return
|
||||||
|
|
||||||
if pisi.util.is_package_name(os.path.basename(old_package_fn), package_name):
|
if util.is_package_name(os.path.basename(old_package_fn), package_name):
|
||||||
try:
|
try:
|
||||||
pkg = os.path.basename(old_package_fn)
|
pkg = os.path.basename(old_package_fn)
|
||||||
name, version = pisi.util.parse_package_name(pkg[:-5])
|
name, version = util.parse_package_name(pkg[:-5])
|
||||||
ctx.ui.info(_('(found old version %s)') % old_package_fn)
|
ctx.ui.info(_('(found old version %s)') % old_package_fn)
|
||||||
ver, rel, build = pisi.util.split_version(version)
|
ver, rel, build = util.split_version(version)
|
||||||
old_build = int(build) if build else 0
|
old_build = int(build) if build else 0
|
||||||
found.add( (old_package_fn, old_build) )
|
found.add((old_package_fn, old_build))
|
||||||
except Error:
|
except Error:
|
||||||
ctx.ui.warning('Package file %s may be corrupt. Skipping.' % old_package_fn)
|
ctx.ui.warning('Package file %s may be corrupt. Skipping.' % old_package_fn)
|
||||||
|
|
||||||
@@ -828,15 +880,15 @@ class Builder:
|
|||||||
for path in paths:
|
for path in paths:
|
||||||
for root, dirs, files in os.walk(path):
|
for root, dirs, files in os.walk(path):
|
||||||
for f in files:
|
for f in files:
|
||||||
locate_old_package(pisi.util.join_path(root,f))
|
locate_old_package(util.join_path(root, f))
|
||||||
|
|
||||||
search_old_packages_in([ctx.config.compiled_packages_dir(),
|
search_old_packages_in([ctx.config.compiled_packages_dir(),
|
||||||
ctx.config.debug_packages_dir()])
|
ctx.config.debug_packages_dir()])
|
||||||
|
|
||||||
outdir=ctx.get_option('output_dir')
|
outdir = ctx.get_option('output_dir')
|
||||||
if not outdir:
|
if not outdir:
|
||||||
outdir = '.'
|
outdir = '.'
|
||||||
for f in [pisi.util.join_path(outdir,entry) for entry in os.listdir(outdir)]:
|
for f in [util.join_path(outdir, entry) for entry in os.listdir(outdir)]:
|
||||||
if os.path.isfile(f):
|
if os.path.isfile(f):
|
||||||
locate_old_package(f)
|
locate_old_package(f)
|
||||||
|
|
||||||
@@ -844,11 +896,11 @@ class Builder:
|
|||||||
return (1, None)
|
return (1, None)
|
||||||
ctx.ui.warning(_('(no previous build found, setting build no to 1.)'))
|
ctx.ui.warning(_('(no previous build found, setting build no to 1.)'))
|
||||||
else:
|
else:
|
||||||
a = filter(lambda (x,y): y != 0, found)
|
a = filter(lambda (x, y): y != 0, found)
|
||||||
ctx.ui.debug(str(a))
|
ctx.ui.debug(str(a))
|
||||||
if a:
|
if a:
|
||||||
# sort in order of increasing build number
|
# sort in order of increasing build number
|
||||||
a.sort(lambda x,y : cmp(x[1],y[1]))
|
a.sort(lambda x, y: cmp(x[1], y[1]))
|
||||||
old_package_fn = a[-1][0] # get the last one
|
old_package_fn = a[-1][0] # get the last one
|
||||||
old_build = a[-1][1]
|
old_build = a[-1][1]
|
||||||
|
|
||||||
@@ -859,8 +911,8 @@ class Builder:
|
|||||||
changed = False
|
changed = False
|
||||||
fnew = self.files.list
|
fnew = self.files.list
|
||||||
fold = old_pkg.files.list
|
fold = old_pkg.files.list
|
||||||
fold.sort(lambda x,y : cmp(x.path,y.path))
|
fold.sort(lambda x, y: cmp(x.path, y.path))
|
||||||
fnew.sort(lambda x,y : cmp(x.path,y.path))
|
fnew.sort(lambda x, y: cmp(x.path, y.path))
|
||||||
|
|
||||||
if len(fnew) != len(fold):
|
if len(fnew) != len(fold):
|
||||||
changed = True
|
changed = True
|
||||||
@@ -880,7 +932,7 @@ class Builder:
|
|||||||
changed = True
|
changed = True
|
||||||
|
|
||||||
self.old_packages.append(os.path.basename(old_package_fn))
|
self.old_packages.append(os.path.basename(old_package_fn))
|
||||||
else: # no old build had a build number
|
else: # no old build had a build number
|
||||||
old_build = None
|
old_build = None
|
||||||
|
|
||||||
ctx.ui.debug('old build number: %s' % old_build)
|
ctx.ui.debug('old build number: %s' % old_build)
|
||||||
@@ -906,7 +958,7 @@ class Builder:
|
|||||||
|
|
||||||
for root, dirs, files in os.walk(install_dir):
|
for root, dirs, files in os.walk(install_dir):
|
||||||
for fn in files:
|
for fn in files:
|
||||||
filepath = pisi.util.join_path(root, fn)
|
filepath = util.join_path(root, fn)
|
||||||
fileinfo = ms.file(filepath)
|
fileinfo = ms.file(filepath)
|
||||||
strip_debug_action(filepath, fileinfo, install_dir, self.actionGlobals)
|
strip_debug_action(filepath, fileinfo, install_dir, self.actionGlobals)
|
||||||
exclude_special_files(filepath, fileinfo, self.actionGlobals)
|
exclude_special_files(filepath, fileinfo, self.actionGlobals)
|
||||||
@@ -918,7 +970,7 @@ class Builder:
|
|||||||
"""Build each package defined in PSPEC file. After this process there
|
"""Build each package defined in PSPEC file. After this process there
|
||||||
will be .pisi files hanging around, AS INTENDED ;)"""
|
will be .pisi files hanging around, AS INTENDED ;)"""
|
||||||
|
|
||||||
self.fetch_component() # bug 856
|
self.fetch_component() # bug 856
|
||||||
|
|
||||||
# Operations and filters for package files
|
# Operations and filters for package files
|
||||||
self.file_actions()
|
self.file_actions()
|
||||||
@@ -947,7 +999,7 @@ class Builder:
|
|||||||
dest = os.path.join(
|
dest = os.path.join(
|
||||||
install_dir + os.path.dirname(afile.target),
|
install_dir + os.path.dirname(afile.target),
|
||||||
os.path.basename(afile.target))
|
os.path.basename(afile.target))
|
||||||
pisi.util.copy_file(src, dest)
|
util.copy_file(src, dest)
|
||||||
if afile.permission:
|
if afile.permission:
|
||||||
# mode is octal!
|
# mode is octal!
|
||||||
os.chmod(dest, int(afile.permission, 8))
|
os.chmod(dest, int(afile.permission, 8))
|
||||||
@@ -1013,17 +1065,17 @@ class Builder:
|
|||||||
build_no, old_build_no = self.calc_build_no(package.name)
|
build_no, old_build_no = self.calc_build_no(package.name)
|
||||||
|
|
||||||
self.metadata.package.build = build_no
|
self.metadata.package.build = build_no
|
||||||
self.metadata.write(pisi.util.join_path(self.pkg_dir(), ctx.const.metadata_xml))
|
self.metadata.write(util.join_path(self.pkg_dir(), ctx.const.metadata_xml))
|
||||||
|
|
||||||
# Calculate new and oldpackage names for buildfarm
|
# Calculate new and oldpackage names for buildfarm
|
||||||
name = pisi.util.package_name(package.name,
|
name = util.package_name(package.name,
|
||||||
self.spec.getSourceVersion(),
|
self.spec.getSourceVersion(),
|
||||||
self.spec.getSourceRelease(),
|
self.spec.getSourceRelease(),
|
||||||
self.metadata.package.build)
|
self.metadata.package.build)
|
||||||
|
|
||||||
outdir = ctx.get_option('output_dir')
|
outdir = ctx.get_option('output_dir')
|
||||||
if outdir:
|
if outdir:
|
||||||
name = pisi.util.join_path(outdir, name)
|
name = util.join_path(outdir, name)
|
||||||
self.new_packages.append(name)
|
self.new_packages.append(name)
|
||||||
|
|
||||||
ctx.ui.info(_("Creating PiSi package %s.") % name)
|
ctx.ui.info(_("Creating PiSi package %s.") % name)
|
||||||
@@ -1033,7 +1085,7 @@ class Builder:
|
|||||||
# add comar files to package
|
# add comar files to package
|
||||||
os.chdir(self.specdir)
|
os.chdir(self.specdir)
|
||||||
for pcomar in package.providesComar:
|
for pcomar in package.providesComar:
|
||||||
fname = pisi.util.join_path(ctx.const.comar_dir,
|
fname = util.join_path(ctx.const.comar_dir,
|
||||||
pcomar.script)
|
pcomar.script)
|
||||||
pkg.add_to_package(fname)
|
pkg.add_to_package(fname)
|
||||||
|
|
||||||
@@ -1049,24 +1101,25 @@ class Builder:
|
|||||||
files.read(ctx.const.files_xml)
|
files.read(ctx.const.files_xml)
|
||||||
|
|
||||||
# Sort the files in-place according to their path for an ordered
|
# Sort the files in-place according to their path for an ordered
|
||||||
# tarfile layout which dramatically improves the compression performance
|
# tarfile layout which dramatically improves the compression
|
||||||
# of lzma.
|
# performance of lzma.
|
||||||
files.list.sort(key=lambda x: x.path)
|
files.list.sort(key=lambda x: x.path)
|
||||||
|
|
||||||
if ctx.get_option('package_format') == "1.0":
|
if ctx.get_option('package_format') == "1.0":
|
||||||
for finfo in files.list:
|
for finfo in files.list:
|
||||||
orgname = arcname = pisi.util.join_path("install", finfo.path)
|
orgname = arcname = util.join_path("install", finfo.path)
|
||||||
if package.debug_package:
|
if package.debug_package:
|
||||||
orgname = pisi.util.join_path("debug", finfo.path)
|
orgname = util.join_path("debug", finfo.path)
|
||||||
pkg.add_to_package(orgname, arcname)
|
pkg.add_to_package(orgname, arcname)
|
||||||
pkg.close()
|
pkg.close()
|
||||||
else: # default package format is 1.1, so make it fallback.
|
else: # default package format is 1.1, so make it fallback.
|
||||||
ctx.build_leftover = pisi.util.join_path(self.pkg_dir(), ctx.const.install_tar_lzma)
|
ctx.build_leftover = util.join_path(self.pkg_dir(),
|
||||||
|
ctx.const.install_tar_lzma)
|
||||||
tar = archive.ArchiveTar(ctx.const.install_tar_lzma, "tarlzma")
|
tar = archive.ArchiveTar(ctx.const.install_tar_lzma, "tarlzma")
|
||||||
for finfo in files.list:
|
for finfo in files.list:
|
||||||
orgname = pisi.util.join_path("install", finfo.path)
|
orgname = util.join_path("install", finfo.path)
|
||||||
if package.debug_package:
|
if package.debug_package:
|
||||||
orgname = pisi.util.join_path("debug", finfo.path)
|
orgname = util.join_path("debug", finfo.path)
|
||||||
tar.add_to_archive(orgname, finfo.path)
|
tar.add_to_archive(orgname, finfo.path)
|
||||||
tar.close()
|
tar.close()
|
||||||
pkg.add_to_package(ctx.const.install_tar_lzma)
|
pkg.add_to_package(ctx.const.install_tar_lzma)
|
||||||
@@ -1083,7 +1136,7 @@ class Builder:
|
|||||||
|
|
||||||
if ctx.config.values.general.autoclean is True:
|
if ctx.config.values.general.autoclean is True:
|
||||||
ctx.ui.info(_("Cleaning Build Directory..."))
|
ctx.ui.info(_("Cleaning Build Directory..."))
|
||||||
pisi.util.clean_dir(self.pkg_dir())
|
util.clean_dir(self.pkg_dir())
|
||||||
else:
|
else:
|
||||||
ctx.ui.info(_("Keeping Build Directory"))
|
ctx.ui.info(_("Keeping Build Directory"))
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user