* a bit of refactoring
* and make bug 368 explicit: relative thingie does not work yet
This commit is contained in:
+47
-46
@@ -34,7 +34,7 @@ class PisiBuildError(pisi.Error):
|
|||||||
|
|
||||||
|
|
||||||
# Helper Functions
|
# Helper Functions
|
||||||
def getFileType(path, pinfoList):
|
def get_file_type(path, pinfoList):
|
||||||
"""Return the file type of a path according to the given PathInfo
|
"""Return the file type of a path according to the given PathInfo
|
||||||
list"""
|
list"""
|
||||||
# The usage of depth is somewhat confusing. It is used for finding
|
# The usage of depth is somewhat confusing. It is used for finding
|
||||||
@@ -53,7 +53,7 @@ def getFileType(path, pinfoList):
|
|||||||
ftype = pinfo.fileType
|
ftype = pinfo.fileType
|
||||||
return ftype
|
return ftype
|
||||||
|
|
||||||
def checkPathCollision(package, pkgList):
|
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."""
|
||||||
@@ -81,7 +81,7 @@ class PisiBuild:
|
|||||||
self.spec = self.ctx.spec
|
self.spec = self.ctx.spec
|
||||||
self.sourceArchive = SourceArchive(self.ctx)
|
self.sourceArchive = SourceArchive(self.ctx)
|
||||||
|
|
||||||
self.setEnvorinmentVars()
|
self.set_environment_vars()
|
||||||
|
|
||||||
self.actionLocals = None
|
self.actionLocals = None
|
||||||
self.actionGlobals = None
|
self.actionGlobals = None
|
||||||
@@ -94,11 +94,11 @@ class PisiBuild:
|
|||||||
ui.error(e + '\n')
|
ui.error(e + '\n')
|
||||||
raise PisiBuildError, "invalid PSPEC file %s" % self.ctx.pspecfile
|
raise PisiBuildError, "invalid PSPEC file %s" % self.ctx.pspecfile
|
||||||
|
|
||||||
def setState(self, state):
|
def set_state(self, state):
|
||||||
stateFile = os.path.join(self.srcDir, "pisiBuildState")
|
stateFile = os.path.join(self.srcDir, "pisiBuildState")
|
||||||
open(stateFile, "w").write(state)
|
open(stateFile, "w").write(state)
|
||||||
|
|
||||||
def getState(self):
|
def get_state(self):
|
||||||
stateFile = os.path.join(self.srcDir, "pisiBuildState")
|
stateFile = os.path.join(self.srcDir, "pisiBuildState")
|
||||||
if not os.path.exists(stateFile): # no state
|
if not os.path.exists(stateFile): # no state
|
||||||
return None
|
return None
|
||||||
@@ -110,25 +110,25 @@ class PisiBuild:
|
|||||||
ui.info("Building PISI source package: %s\n" % self.spec.source.name)
|
ui.info("Building PISI source package: %s\n" % self.spec.source.name)
|
||||||
util.xtermTitle("Building PISI source package: %s\n" % self.spec.source.name)
|
util.xtermTitle("Building PISI source package: %s\n" % self.spec.source.name)
|
||||||
|
|
||||||
self.compileActionScript()
|
self.compile_action_script()
|
||||||
|
|
||||||
self.fetchSourceArchive()
|
self.fetch_source_archive()
|
||||||
|
|
||||||
self.unpackSourceArchive()
|
self.unpack_source_archive()
|
||||||
|
|
||||||
self.solveBuildDependencies()
|
self.solve_build_dependencies()
|
||||||
|
|
||||||
# apply the patches and prepare a source directory for build.
|
# apply the patches and prepare a source directory for build.
|
||||||
self.applyPatches()
|
self.apply_patches()
|
||||||
|
|
||||||
self.runSetupAction()
|
self.run_setup_action()
|
||||||
self.runBuildAction()
|
self.run_build_action()
|
||||||
self.runInstallAction()
|
self.run_install_action()
|
||||||
|
|
||||||
# after all, we are ready to build/prepare the packages
|
# after all, we are ready to build/prepare the packages
|
||||||
self.buildPackages()
|
self.build_packages()
|
||||||
|
|
||||||
def setEnvorinmentVars(self):
|
def set_environment_vars(self):
|
||||||
"""Sets the environment variables for actions API to use"""
|
"""Sets the environment variables for actions API to use"""
|
||||||
evn = {
|
evn = {
|
||||||
"PKG_DIR": self.ctx.pkg_dir(),
|
"PKG_DIR": self.ctx.pkg_dir(),
|
||||||
@@ -140,30 +140,30 @@ class PisiBuild:
|
|||||||
}
|
}
|
||||||
os.environ.update(evn)
|
os.environ.update(evn)
|
||||||
|
|
||||||
def fetchSourceArchive(self):
|
def fetch_source_archive(self):
|
||||||
ui.info("Fetching source from: %s\n" % self.spec.source.archiveUri)
|
ui.info("Fetching source from: %s\n" % self.spec.source.archiveUri)
|
||||||
self.sourceArchive.fetch()
|
self.sourceArchive.fetch()
|
||||||
ui.info("Source archive is stored: %s/%s\n"
|
ui.info("Source archive is stored: %s/%s\n"
|
||||||
%(config.archives_dir(), self.spec.source.archiveName))
|
%(config.archives_dir(), self.spec.source.archiveName))
|
||||||
|
|
||||||
def unpackSourceArchive(self):
|
def unpack_source_archive(self):
|
||||||
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.setState("unpacked")
|
self.set_state("unpacked")
|
||||||
|
|
||||||
def runSetupAction(self):
|
def run_setup_action(self):
|
||||||
# Run configure, build and install phase
|
# Run configure, build and install phase
|
||||||
ui.action("Setting up source...\n")
|
ui.action("Setting up source...\n")
|
||||||
self.runActionFunction(const.setup_func)
|
self.run_action_function(const.setup_func)
|
||||||
self.setState("setupaction")
|
self.set_state("setupaction")
|
||||||
|
|
||||||
def runBuildAction(self):
|
def run_build_action(self):
|
||||||
ui.action("Building source...\n")
|
ui.action("Building source...\n")
|
||||||
self.runActionFunction(const.build_func)
|
self.run_action_function(const.build_func)
|
||||||
self.setState("buildaction")
|
self.set_state("buildaction")
|
||||||
|
|
||||||
def runInstallAction(self):
|
def run_install_action(self):
|
||||||
ui.action("Installing...\n")
|
ui.action("Installing...\n")
|
||||||
|
|
||||||
# Before install make sure install_dir is clean
|
# Before install make sure install_dir is clean
|
||||||
@@ -171,10 +171,10 @@ class PisiBuild:
|
|||||||
util.clean_dir(self.ctx.pkg_install_dir())
|
util.clean_dir(self.ctx.pkg_install_dir())
|
||||||
|
|
||||||
# install function is mandatory!
|
# install function is mandatory!
|
||||||
self.runActionFunction(const.install_func, True)
|
self.run_action_function(const.install_func, True)
|
||||||
self.setState("installaction")
|
self.set_state("installaction")
|
||||||
|
|
||||||
def compileActionScript(self):
|
def compile_action_script(self):
|
||||||
"""Compiles actions.py and sets the actionLocals and actionGlobals"""
|
"""Compiles actions.py and sets the actionLocals and actionGlobals"""
|
||||||
specdir = os.path.dirname(self.ctx.pspecfile)
|
specdir = os.path.dirname(self.ctx.pspecfile)
|
||||||
scriptfile = os.path.join(specdir, const.actions_file)
|
scriptfile = os.path.join(specdir, const.actions_file)
|
||||||
@@ -191,9 +191,9 @@ class PisiBuild:
|
|||||||
|
|
||||||
self.actionLocals = localSymbols
|
self.actionLocals = localSymbols
|
||||||
self.actionGlobals = globalSymbols
|
self.actionGlobals = globalSymbols
|
||||||
self.srcDir = self.pkgSrcDir()
|
self.srcDir = self.pkg_src_dir()
|
||||||
|
|
||||||
def pkgSrcDir(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']
|
||||||
@@ -202,7 +202,7 @@ class PisiBuild:
|
|||||||
|
|
||||||
return os.path.join(self.ctx.pkg_work_dir(), workdir)
|
return os.path.join(self.ctx.pkg_work_dir(), workdir)
|
||||||
|
|
||||||
def runActionFunction(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.
|
||||||
|
|
||||||
If mandatory parameter is True, and function is not present in
|
If mandatory parameter is True, and function is not present in
|
||||||
@@ -221,11 +221,12 @@ class PisiBuild:
|
|||||||
|
|
||||||
os.chdir(curDir)
|
os.chdir(curDir)
|
||||||
|
|
||||||
def solveBuildDependencies(self):
|
def solve_build_dependencies(self):
|
||||||
"""pre-alpha: fail if dependencies not satisfied"""
|
"""fail if dependencies not satisfied"""
|
||||||
|
#TODO: we'll have to do better than plugging a fxn here
|
||||||
pass
|
pass
|
||||||
|
|
||||||
def applyPatches(self):
|
def apply_patches(self):
|
||||||
files_dir = os.path.abspath(os.path.join(self.pspecDir,
|
files_dir = os.path.abspath(os.path.join(self.pspecDir,
|
||||||
const.files_dir))
|
const.files_dir))
|
||||||
|
|
||||||
@@ -239,13 +240,13 @@ class PisiBuild:
|
|||||||
ui.action("* Applying patch: %s\n" % patch.filename)
|
ui.action("* Applying patch: %s\n" % patch.filename)
|
||||||
util.do_patch(self.srcDir, patchFile, level=patch.level, target=patch.target)
|
util.do_patch(self.srcDir, patchFile, level=patch.level, target=patch.target)
|
||||||
|
|
||||||
def genMetaDataXml(self, package):
|
def gen_metadata_xml(self, package):
|
||||||
"""Generate the metadata.xml file for build source.
|
"""Generate the metadata.xml file for build source.
|
||||||
|
|
||||||
metadata.xml is composed of the information from specfile plus
|
metadata.xml is composed of the information from specfile plus
|
||||||
some additional information."""
|
some additional information."""
|
||||||
metadata = MetaData()
|
metadata = MetaData()
|
||||||
metadata.fromSpec(self.spec.source, package)
|
metadata.from_spec(self.spec.source, package)
|
||||||
|
|
||||||
# FIXME: MEREEEEEN :)
|
# FIXME: MEREEEEEN :)
|
||||||
metadata.package.build = 0 # BOGUS. WRONG.
|
metadata.package.build = 0 # BOGUS. WRONG.
|
||||||
@@ -263,18 +264,18 @@ class PisiBuild:
|
|||||||
metadata.package.installedSize = str(size)
|
metadata.package.installedSize = str(size)
|
||||||
metadata.write(os.path.join(self.ctx.pkg_dir(), const.metadata_xml))
|
metadata.write(os.path.join(self.ctx.pkg_dir(), const.metadata_xml))
|
||||||
|
|
||||||
def genFilesXml(self, package):
|
def gen_files_xml(self, package):
|
||||||
"""Generetes files.xml using the path definitions in specfile and
|
"""Generetes files.xml using the path definitions in specfile and
|
||||||
generated files by the build system."""
|
generated files by the build system."""
|
||||||
files = Files()
|
files = Files()
|
||||||
install_dir = self.ctx.pkg_install_dir()
|
install_dir = self.ctx.pkg_install_dir()
|
||||||
collisions = checkPathCollision(package,
|
collisions = check_path_collision(package,
|
||||||
self.spec.packages)
|
self.spec.packages)
|
||||||
for pinfo in package.paths:
|
for pinfo in package.paths:
|
||||||
path = install_dir + pinfo.pathname
|
path = install_dir + pinfo.pathname
|
||||||
for fpath, fhash in util.get_file_hashes(path, collisions, install_dir):
|
for fpath, fhash in util.get_file_hashes(path, collisions, install_dir):
|
||||||
frpath = util.removepathprefix(install_dir, fpath) # relative path
|
frpath = util.removepathprefix(install_dir, fpath) # relative path
|
||||||
ftype = getFileType(frpath, package.paths)
|
ftype = get_file_type(frpath, package.paths)
|
||||||
try: # broken links can cause problem
|
try: # broken links can cause problem
|
||||||
fsize = str(os.path.getsize(fpath))
|
fsize = str(os.path.getsize(fpath))
|
||||||
except OSError:
|
except OSError:
|
||||||
@@ -283,7 +284,7 @@ class PisiBuild:
|
|||||||
|
|
||||||
files.write(os.path.join(self.ctx.pkg_dir(), const.files_xml))
|
files.write(os.path.join(self.ctx.pkg_dir(), const.files_xml))
|
||||||
|
|
||||||
def buildPackages(self):
|
def build_packages(self):
|
||||||
"""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 ;)"""
|
||||||
for package in self.spec.packages:
|
for package in self.spec.packages:
|
||||||
@@ -294,7 +295,7 @@ class PisiBuild:
|
|||||||
|
|
||||||
pkg = Package(name, 'w')
|
pkg = Package(name, 'w')
|
||||||
c = os.getcwd()
|
c = os.getcwd()
|
||||||
|
|
||||||
# add comar files to package
|
# add comar files to package
|
||||||
os.chdir(self.pspecDir)
|
os.chdir(self.pspecDir)
|
||||||
for pcomar in package.providesComar:
|
for pcomar in package.providesComar:
|
||||||
@@ -310,24 +311,24 @@ class PisiBuild:
|
|||||||
util.copy_file(src, dest)
|
util.copy_file(src, dest)
|
||||||
if afile.permission:
|
if afile.permission:
|
||||||
os.chmod(dest, int(afile.permission) | 0777)
|
os.chmod(dest, int(afile.permission) | 0777)
|
||||||
|
|
||||||
os.chdir(c)
|
os.chdir(c)
|
||||||
|
|
||||||
ui.action("** Building package %s\n" % package.name);
|
ui.action("** Building package %s\n" % package.name);
|
||||||
|
|
||||||
ui.action("Generating %s..." % const.metadata_xml)
|
ui.action("Generating %s..." % const.metadata_xml)
|
||||||
self.genMetaDataXml(package)
|
self.gen_metadata_xml(package)
|
||||||
ui.info(" done.\n")
|
ui.info(" done.\n")
|
||||||
|
|
||||||
ui.action("Generating %s..." % const.files_xml)
|
ui.action("Generating %s..." % const.files_xml)
|
||||||
self.genFilesXml(package)
|
self.gen_files_xml(package)
|
||||||
ui.info(" done.\n")
|
ui.info(" done.\n")
|
||||||
|
|
||||||
ui.action("Creating PISI package %s\n" % name)
|
ui.action("Creating PISI package %s\n" % name)
|
||||||
|
|
||||||
# add xmls and files
|
# add xmls and files
|
||||||
os.chdir(self.ctx.pkg_dir())
|
os.chdir(self.ctx.pkg_dir())
|
||||||
|
|
||||||
pkg.add_to_package(const.metadata_xml)
|
pkg.add_to_package(const.metadata_xml)
|
||||||
pkg.add_to_package(const.files_xml)
|
pkg.add_to_package(const.files_xml)
|
||||||
|
|
||||||
@@ -340,5 +341,5 @@ class PisiBuild:
|
|||||||
|
|
||||||
pkg.close()
|
pkg.close()
|
||||||
os.chdir(c)
|
os.chdir(c)
|
||||||
self.setState("buildpackages")
|
self.set_state("buildpackages")
|
||||||
util.xtermTitleReset()
|
util.xtermTitleReset()
|
||||||
|
|||||||
@@ -471,7 +471,7 @@ Remove all repository information from the system.
|
|||||||
if len(self.args)>=1:
|
if len(self.args)>=1:
|
||||||
self.init()
|
self.init()
|
||||||
for repo in self.args:
|
for repo in self.args:
|
||||||
toplevel.remove_repo(repo)
|
pisi.toplevel.remove_repo(repo)
|
||||||
self.finalize()
|
self.finalize()
|
||||||
else:
|
else:
|
||||||
self.help()
|
self.help()
|
||||||
|
|||||||
+2
-2
@@ -24,9 +24,9 @@ class BuildContext(object):
|
|||||||
|
|
||||||
def __init__(self, pspecfile):
|
def __init__(self, pspecfile):
|
||||||
super(BuildContext, self).__init__()
|
super(BuildContext, self).__init__()
|
||||||
self.setSpecFile(pspecfile)
|
self.set_spec_file(pspecfile)
|
||||||
|
|
||||||
def setSpecFile(self, pspecfile):
|
def set_spec_file(self, pspecfile):
|
||||||
self.pspecfile = pspecfile
|
self.pspecfile = pspecfile
|
||||||
spec = SpecFile()
|
spec = SpecFile()
|
||||||
spec.read(pspecfile)
|
spec.read(pspecfile)
|
||||||
|
|||||||
+7
-7
@@ -76,7 +76,7 @@ class DepInfo:
|
|||||||
s += 'rel <= ' + self.releaseTo
|
s += 'rel <= ' + self.releaseTo
|
||||||
return s
|
return s
|
||||||
|
|
||||||
def dictSatisfiesDep(dict, depinfo):
|
def dict_satisfies_dep(dict, depinfo):
|
||||||
"""determine if a package in a dictionary satisfies given dependency spec"""
|
"""determine if a package in a dictionary satisfies given dependency spec"""
|
||||||
pkg_name = depinfo.package
|
pkg_name = depinfo.package
|
||||||
if not dict.has_key(pkg_name):
|
if not dict.has_key(pkg_name):
|
||||||
@@ -86,7 +86,7 @@ def dictSatisfiesDep(dict, depinfo):
|
|||||||
(version, release) = (pkg.version, pkg.release)
|
(version, release) = (pkg.version, pkg.release)
|
||||||
return depinfo.satisfies(pkg_name, version, release)
|
return depinfo.satisfies(pkg_name, version, release)
|
||||||
|
|
||||||
def installedSatisfiesDep(depinfo):
|
def installed_satisfies_dep(depinfo):
|
||||||
"""determine if a package in *repository* satisfies given
|
"""determine if a package in *repository* satisfies given
|
||||||
dependency spec"""
|
dependency spec"""
|
||||||
pkg_name = depinfo.package
|
pkg_name = depinfo.package
|
||||||
@@ -97,7 +97,7 @@ dependency spec"""
|
|||||||
(version, release) = (pkg.version, pkg.release)
|
(version, release) = (pkg.version, pkg.release)
|
||||||
return depinfo.satisfies(pkg_name, version, release)
|
return depinfo.satisfies(pkg_name, version, release)
|
||||||
|
|
||||||
def repoSatisfiesDep(depinfo):
|
def repo_satisfies_dep(depinfo):
|
||||||
"""determine if a package in *repository* satisfies given
|
"""determine if a package in *repository* satisfies given
|
||||||
dependency spec"""
|
dependency spec"""
|
||||||
pkg_name = depinfo.package
|
pkg_name = depinfo.package
|
||||||
@@ -108,7 +108,7 @@ dependency spec"""
|
|||||||
(version, release) = (pkg.version, pkg.release)
|
(version, release) = (pkg.version, pkg.release)
|
||||||
return depinfo.satisfies(pkg_name, version, release)
|
return depinfo.satisfies(pkg_name, version, release)
|
||||||
|
|
||||||
def satisfiesDeps(pkg, deps, sat = installedSatisfiesDep):
|
def satisfies_dependencies(pkg, deps, sat = installed_satisfies_dep):
|
||||||
for dep in deps:
|
for dep in deps:
|
||||||
if not sat(dep):
|
if not sat(dep):
|
||||||
ui.error('Package %s does not satisfy dependency %s\n' %
|
ui.error('Package %s does not satisfy dependency %s\n' %
|
||||||
@@ -116,9 +116,9 @@ def satisfiesDeps(pkg, deps, sat = installedSatisfiesDep):
|
|||||||
return False
|
return False
|
||||||
return True
|
return True
|
||||||
|
|
||||||
def satisfiesRuntimeDeps(pkg):
|
def satisfies_runtime_deps(pkg):
|
||||||
deps = packagedb.get_package(pkg).runtimeDeps
|
deps = packagedb.get_package(pkg).runtimeDeps
|
||||||
return satisfiesDeps(pkg, deps)
|
return satisfies_dependencies(pkg, deps)
|
||||||
|
|
||||||
def installable(pkg):
|
def installable(pkg):
|
||||||
"""calculate if pkg is installable currently
|
"""calculate if pkg is installable currently
|
||||||
@@ -126,7 +126,7 @@ def installable(pkg):
|
|||||||
if not packagedb.has_package(pkg):
|
if not packagedb.has_package(pkg):
|
||||||
ui.info("Package " + pkg + " is not present in the package database\n");
|
ui.info("Package " + pkg + " is not present in the package database\n");
|
||||||
return False
|
return False
|
||||||
elif satisfiesRuntimeDeps(pkg):
|
elif satisfies_runtime_deps(pkg):
|
||||||
return True
|
return True
|
||||||
else:
|
else:
|
||||||
#ui.info("package " + pkg + " does not satisfy dependencies\n");
|
#ui.info("package " + pkg + " does not satisfy dependencies\n");
|
||||||
|
|||||||
+5
-5
@@ -32,7 +32,7 @@ class FetchError(pisi.Error):
|
|||||||
|
|
||||||
|
|
||||||
# helper functions
|
# helper functions
|
||||||
def fetchUrl(url, dest, progress=None):
|
def fetch_url(url, dest, progress=None):
|
||||||
fetch = Fetcher(url, dest)
|
fetch = Fetcher(url, dest)
|
||||||
fetch.progress = progress
|
fetch.progress = progress
|
||||||
fetch.fetch()
|
fetch.fetch()
|
||||||
@@ -70,7 +70,7 @@ class Fetcher:
|
|||||||
|
|
||||||
return os.path.join(self.filedest, self.url.filename())
|
return os.path.join(self.filedest, self.url.filename())
|
||||||
|
|
||||||
def doGrab(self, fileURI, dest, totalsize):
|
def _do_grab(self, fileURI, dest, totalsize):
|
||||||
symbols = [' B/s', 'KB/s', 'MB/s', 'GB/s']
|
symbols = [' B/s', 'KB/s', 'MB/s', 'GB/s']
|
||||||
from time import time
|
from time import time
|
||||||
tt, oldsize = int(time()), 0
|
tt, oldsize = int(time()), 0
|
||||||
@@ -101,7 +101,7 @@ class Fetcher:
|
|||||||
'percent' : self.percent,
|
'percent' : self.percent,
|
||||||
'rate': self.rate,
|
'rate': self.rate,
|
||||||
'symbol': symbol}
|
'symbol': symbol}
|
||||||
ui.displayProgress(retval)
|
ui.display_progress(retval)
|
||||||
|
|
||||||
dest.close()
|
dest.close()
|
||||||
|
|
||||||
@@ -114,7 +114,7 @@ class Fetcher:
|
|||||||
dest = open(os.path.join(self.filedest, url.filename()) , "w")
|
dest = open(os.path.join(self.filedest, url.filename()) , "w")
|
||||||
totalsize = os.path.getsize(url.path())
|
totalsize = os.path.getsize(url.path())
|
||||||
fileObj = open(url.path())
|
fileObj = open(url.path())
|
||||||
self.doGrab(fileObj, dest, totalsize)
|
self._do_grab(fileObj, dest, totalsize)
|
||||||
|
|
||||||
def fetchRemoteFile (self):
|
def fetchRemoteFile (self):
|
||||||
from httplib import HTTPException
|
from httplib import HTTPException
|
||||||
@@ -138,7 +138,7 @@ class Fetcher:
|
|||||||
else: totalsize = int(headers['Content-Length'])
|
else: totalsize = int(headers['Content-Length'])
|
||||||
|
|
||||||
dest = open(os.path.join(self.filedest, self.url.filename()) , "w")
|
dest = open(os.path.join(self.filedest, self.url.filename()) , "w")
|
||||||
self.doGrab(fileObj, dest, totalsize)
|
self._do_grab(fileObj, dest, totalsize)
|
||||||
|
|
||||||
def formatRequest(self, request):
|
def formatRequest(self, request):
|
||||||
authinfo = self.url.auth_info()
|
authinfo = self.url.auth_info()
|
||||||
|
|||||||
+1
-1
@@ -23,7 +23,7 @@ import pisi
|
|||||||
class CycleException(pisi.Exception):
|
class CycleException(pisi.Exception):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
class digraph(object):
|
class Digraph(object):
|
||||||
|
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
self.__v = set()
|
self.__v = set()
|
||||||
|
|||||||
+2
-2
@@ -39,12 +39,12 @@ class Index(XmlFile):
|
|||||||
self.filepath = filename
|
self.filepath = filename
|
||||||
url = URI(filename)
|
url = URI(filename)
|
||||||
if url.is_remote_file():
|
if url.is_remote_file():
|
||||||
from fetcher import fetchUrl
|
from fetcher import fetch_url
|
||||||
|
|
||||||
dest = os.path.join(config.index_dir(), repo)
|
dest = os.path.join(config.index_dir(), repo)
|
||||||
if not os.path.exists(dest):
|
if not os.path.exists(dest):
|
||||||
os.makedirs(dest)
|
os.makedirs(dest)
|
||||||
fetchUrl(url, dest, ui.Progress)
|
fetch_url(url, dest, ui.Progress)
|
||||||
|
|
||||||
self.filepath = os.path.join(dest, url.filename())
|
self.filepath = os.path.join(dest, url.filename())
|
||||||
|
|
||||||
|
|||||||
+6
-6
@@ -54,9 +54,9 @@ class Installer:
|
|||||||
self.check_requirements()
|
self.check_requirements()
|
||||||
self.check_relations()
|
self.check_relations()
|
||||||
self.reinstall()
|
self.reinstall()
|
||||||
self.extractInstall()
|
self.extract_install()
|
||||||
self.storePisiFiles()
|
self.store_pisi_files()
|
||||||
self.registerCOMARScripts()
|
self.register_comar_scripts()
|
||||||
self.update_databases()
|
self.update_databases()
|
||||||
|
|
||||||
def check_requirements(self):
|
def check_requirements(self):
|
||||||
@@ -119,13 +119,13 @@ class Installer:
|
|||||||
# remove old package then
|
# remove old package then
|
||||||
operations.remove_single(pkg.name)
|
operations.remove_single(pkg.name)
|
||||||
|
|
||||||
def extractInstall(self):
|
def extract_install(self):
|
||||||
"unzip package in place"
|
"unzip package in place"
|
||||||
|
|
||||||
ui.info('Extracting files,\n')
|
ui.info('Extracting files,\n')
|
||||||
self.package.extract_dir_flat('install', config.destdir)
|
self.package.extract_dir_flat('install', config.destdir)
|
||||||
|
|
||||||
def storePisiFiles(self):
|
def store_pisi_files(self):
|
||||||
"""put files.xml, metadata.xml, actions.py and COMAR scripts
|
"""put files.xml, metadata.xml, actions.py and COMAR scripts
|
||||||
somewhere in the file system. We'll need these in future..."""
|
somewhere in the file system. We'll need these in future..."""
|
||||||
|
|
||||||
@@ -142,7 +142,7 @@ class Installer:
|
|||||||
ui.info('Storing %s\n' % fpath)
|
ui.info('Storing %s\n' % fpath)
|
||||||
self.package.extract_file(fpath, self.package.pkg_dir())
|
self.package.extract_file(fpath, self.package.pkg_dir())
|
||||||
|
|
||||||
def registerCOMARScripts(self):
|
def register_comar_scripts(self):
|
||||||
"register COMAR scripts"
|
"register COMAR scripts"
|
||||||
|
|
||||||
for pcomar in self.metadata.package.providesComar:
|
for pcomar in self.metadata.package.providesComar:
|
||||||
|
|||||||
+1
-1
@@ -95,7 +95,7 @@ class MetaData(XmlFile):
|
|||||||
def __init__(self):
|
def __init__(self):
|
||||||
XmlFile.__init__(self, "PISI")
|
XmlFile.__init__(self, "PISI")
|
||||||
|
|
||||||
def fromSpec(self, src, pkg):
|
def from_spec(self, src, pkg):
|
||||||
self.source = SourceInfo()
|
self.source = SourceInfo()
|
||||||
self.source.name = src.name
|
self.source.name = src.name
|
||||||
self.source.homepage = src.homepage
|
self.source.homepage = src.homepage
|
||||||
|
|||||||
+1
-1
@@ -77,7 +77,7 @@ def install_single_name(name, upgrade = False):
|
|||||||
pkg = packagedb.get_package(name)
|
pkg = packagedb.get_package(name)
|
||||||
|
|
||||||
if repo.indexuri.is_local_file():
|
if repo.indexuri.is_local_file():
|
||||||
pkg_path = pkg.packageURI
|
pkg_path = str(pkg.packageURI)
|
||||||
else:
|
else:
|
||||||
# FIXME: determine if we have relative paths in the index
|
# FIXME: determine if we have relative paths in the index
|
||||||
# rather than doing this. Requires the index to know about
|
# rather than doing this. Requires the index to know about
|
||||||
|
|||||||
+2
-2
@@ -37,10 +37,10 @@ class Package:
|
|||||||
url = URI(packagefn)
|
url = URI(packagefn)
|
||||||
|
|
||||||
if url.is_remote_file():
|
if url.is_remote_file():
|
||||||
from fetcher import fetchUrl
|
from fetcher import fetch_url
|
||||||
from ui import ui
|
from ui import ui
|
||||||
dest = config.packages_dir()
|
dest = config.packages_dir()
|
||||||
fetchUrl(url, dest, ui.Progress)
|
fetch_url(url, dest, ui.Progress)
|
||||||
self.filepath = join(dest, url.filename())
|
self.filepath = join(dest, url.filename())
|
||||||
|
|
||||||
self.impl = archive.ArchiveZip(self.filepath, 'zip', mode)
|
self.impl = archive.ArchiveZip(self.filepath, 'zip', mode)
|
||||||
|
|||||||
+1
-1
@@ -14,7 +14,7 @@ from graph import *
|
|||||||
|
|
||||||
# Cache the results from packagedb queries in a graph
|
# Cache the results from packagedb queries in a graph
|
||||||
|
|
||||||
class PGraph(digraph):
|
class PGraph(Digraph):
|
||||||
|
|
||||||
def __init__(self, packagedb):
|
def __init__(self, packagedb):
|
||||||
super(PGraph, self).__init__()
|
super(PGraph, self).__init__()
|
||||||
|
|||||||
@@ -25,7 +25,7 @@ from pisi.archive import Archive
|
|||||||
from pisi.uri import URI
|
from pisi.uri import URI
|
||||||
from pisi.ui import ui
|
from pisi.ui import ui
|
||||||
from pisi.config import config
|
from pisi.config import config
|
||||||
from pisi.fetcher import fetchUrl
|
from pisi.fetcher import fetch_url
|
||||||
import pisi.util as util
|
import pisi.util as util
|
||||||
|
|
||||||
class SourceArchiveError(pisi.Error):
|
class SourceArchiveError(pisi.Error):
|
||||||
@@ -42,13 +42,13 @@ class SourceArchive:
|
|||||||
self.archiveSHA1 = self.ctx.spec.source.archiveSHA1
|
self.archiveSHA1 = self.ctx.spec.source.archiveSHA1
|
||||||
|
|
||||||
def fetch(self, interactive=True):
|
def fetch(self, interactive=True):
|
||||||
if not self.isCached(interactive):
|
if not self.is_cached(interactive):
|
||||||
if interactive:
|
if interactive:
|
||||||
progress = ui.Progress
|
progress = ui.Progress
|
||||||
else: progress = None
|
else: progress = None
|
||||||
fetchUrl(self.url, config.archives_dir(), progress)
|
fetch_url(self.url, config.archives_dir(), progress)
|
||||||
|
|
||||||
def isCached(self, interactive=True):
|
def is_cached(self, interactive=True):
|
||||||
if not access(self.archiveFile, R_OK):
|
if not access(self.archiveFile, R_OK):
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
|||||||
@@ -74,9 +74,9 @@ class SourceFetcher(object):
|
|||||||
self.fetch(const.files_dir)
|
self.fetch(const.files_dir)
|
||||||
|
|
||||||
def fetch(self, appendDest=""):
|
def fetch(self, appendDest=""):
|
||||||
from fetcher import fetchUrl
|
from fetcher import fetch_url
|
||||||
|
|
||||||
ui.info("Fetching %s\n" % self.url.uri)
|
ui.info("Fetching %s\n" % self.url.uri)
|
||||||
dest = join(self.dest, appendDest)
|
dest = join(self.dest, appendDest)
|
||||||
fetchUrl(self.url, dest)
|
fetch_url(self.url, dest)
|
||||||
|
|
||||||
|
|||||||
+4
-4
@@ -371,12 +371,12 @@ class SpecFile(XmlFile):
|
|||||||
packageElts = self.getAllNodes("Package")
|
packageElts = self.getAllNodes("Package")
|
||||||
self.packages = [PackageInfo(p) for p in packageElts]
|
self.packages = [PackageInfo(p) for p in packageElts]
|
||||||
|
|
||||||
self.doMerges()
|
self.merge_tags()
|
||||||
self.doOverrides()
|
self.override_tags()
|
||||||
|
|
||||||
self.unlink()
|
self.unlink()
|
||||||
|
|
||||||
def doOverrides(self):
|
def override_tags(self):
|
||||||
"""Override tags from Source in Packages. Some tags in Packages
|
"""Override tags from Source in Packages. Some tags in Packages
|
||||||
overrides the tags from Source. There is a more detailed
|
overrides the tags from Source. There is a more detailed
|
||||||
description in documents."""
|
description in documents."""
|
||||||
@@ -395,7 +395,7 @@ class SpecFile(XmlFile):
|
|||||||
if not pkg.license:
|
if not pkg.license:
|
||||||
pkg.license = self.source.license
|
pkg.license = self.source.license
|
||||||
|
|
||||||
def doMerges(self):
|
def merge_tags(self):
|
||||||
"""Merge tags from Source in Packages. Some tags in Packages merged
|
"""Merge tags from Source in Packages. Some tags in Packages merged
|
||||||
with the tags from Source. There is a more detailed
|
with the tags from Source. There is a more detailed
|
||||||
description in documents."""
|
description in documents."""
|
||||||
|
|||||||
+15
-15
@@ -82,8 +82,8 @@ def install_pkg_files(package_URIs):
|
|||||||
dfn[name] = x
|
dfn[name] = x
|
||||||
|
|
||||||
def satisfiesDep(dep):
|
def satisfiesDep(dep):
|
||||||
return dependency.installedSatisfiesDep(dep) \
|
return dependency.installed_satisfies_dep(dep) \
|
||||||
or dependency.dictSatisfiesDep(d_t, dep)
|
or dependency.dict_satisfies_dep(d_t, dep)
|
||||||
|
|
||||||
# for this case, we have to determine the dependencies
|
# for this case, we have to determine the dependencies
|
||||||
# that aren't already satisfied and try to install them
|
# that aren't already satisfied and try to install them
|
||||||
@@ -140,7 +140,7 @@ def install_pkg_files(package_URIs):
|
|||||||
print pkg
|
print pkg
|
||||||
for dep in pkg.runtimeDeps:
|
for dep in pkg.runtimeDeps:
|
||||||
print 'checking ', dep
|
print 'checking ', dep
|
||||||
if dependency.dictSatisfiesDep(d_t, dep):
|
if dependency.dict_satisfies_dep(d_t, dep):
|
||||||
if not dep.package in G_f.vertices():
|
if not dep.package in G_f.vertices():
|
||||||
Bp.add(str(dep.package))
|
Bp.add(str(dep.package))
|
||||||
G_f.add_dep(x, dep)
|
G_f.add_dep(x, dep)
|
||||||
@@ -188,7 +188,7 @@ def install_pkg_names(A):
|
|||||||
for dep in pkg.runtimeDeps:
|
for dep in pkg.runtimeDeps:
|
||||||
print 'checking ', dep
|
print 'checking ', dep
|
||||||
# we don't deal with already *satisfied* dependencies
|
# we don't deal with already *satisfied* dependencies
|
||||||
if not dependency.installedSatisfiesDep(dep):
|
if not dependency.installed_satisfies_dep(dep):
|
||||||
if not dep.package in G_f.vertices():
|
if not dep.package in G_f.vertices():
|
||||||
Bp.add(str(dep.package))
|
Bp.add(str(dep.package))
|
||||||
G_f.add_dep(x, dep)
|
G_f.add_dep(x, dep)
|
||||||
@@ -256,7 +256,7 @@ def upgrade_pkg_names(A):
|
|||||||
for dep in pkg.runtimeDeps:
|
for dep in pkg.runtimeDeps:
|
||||||
print 'checking ', dep
|
print 'checking ', dep
|
||||||
# add packages that can be upgraded
|
# add packages that can be upgraded
|
||||||
if dependency.repoSatisfiesDep(dep):
|
if dependency.repo_satisfies_dep(dep):
|
||||||
if installdb.is_installed(dep.package):
|
if installdb.is_installed(dep.package):
|
||||||
#FIXME: use build no
|
#FIXME: use build no
|
||||||
(v,r) = installdb.get_version(dep.package)
|
(v,r) = installdb.get_version(dep.package)
|
||||||
@@ -314,7 +314,7 @@ def remove(A):
|
|||||||
for (rev_dep, depinfo) in rev_deps:
|
for (rev_dep, depinfo) in rev_deps:
|
||||||
print 'checking ', rev_dep
|
print 'checking ', rev_dep
|
||||||
# we don't deal with unsatisfied dependencies
|
# we don't deal with unsatisfied dependencies
|
||||||
if dependency.installedSatisfiesDep(depinfo):
|
if dependency.installed_satisfies_dep(depinfo):
|
||||||
if not rev_dep in G_f.vertices():
|
if not rev_dep in G_f.vertices():
|
||||||
Bp.add(rev_dep)
|
Bp.add(rev_dep)
|
||||||
G_f.add_plain_dep(rev_dep, x)
|
G_f.add_plain_dep(rev_dep, x)
|
||||||
@@ -406,39 +406,39 @@ order = {"none": 0,
|
|||||||
|
|
||||||
def __buildState_unpack(pb):
|
def __buildState_unpack(pb):
|
||||||
# unpack is the first state to run.
|
# unpack is the first state to run.
|
||||||
pb.fetchSourceArchive()
|
pb.fetch_source_archive()
|
||||||
pb.unpackSourceArchive()
|
pb.unpack_source_archive()
|
||||||
pb.applyPatches()
|
pb.apply_patches()
|
||||||
|
|
||||||
def __buildState_setupaction(pb, last):
|
def __buildState_setupaction(pb, last):
|
||||||
|
|
||||||
if order[last] < order["unpack"]:
|
if order[last] < order["unpack"]:
|
||||||
__buildState_unpack(pb)
|
__buildState_unpack(pb)
|
||||||
pb.runSetupAction()
|
pb.run_setup_action()
|
||||||
|
|
||||||
def __buildState_buildaction(pb, last):
|
def __buildState_buildaction(pb, last):
|
||||||
|
|
||||||
if order[last] < order["setupaction"]:
|
if order[last] < order["setupaction"]:
|
||||||
__buildState_setupaction(pb, last)
|
__buildState_setupaction(pb, last)
|
||||||
pb.runBuildAction()
|
pb.run_build_action()
|
||||||
|
|
||||||
def __buildState_installaction(pb, last):
|
def __buildState_installaction(pb, last):
|
||||||
|
|
||||||
if order[last] < order["buildaction"]:
|
if order[last] < order["buildaction"]:
|
||||||
__buildState_buildaction(pb, last)
|
__buildState_buildaction(pb, last)
|
||||||
pb.runInstallAction()
|
pb.run_install_action()
|
||||||
|
|
||||||
def __buildState_buildpackages(pb, last):
|
def __buildState_buildpackages(pb, last):
|
||||||
|
|
||||||
if order[last] < order["installaction"]:
|
if order[last] < order["installaction"]:
|
||||||
__buildState_installaction(pb, last)
|
__buildState_installaction(pb, last)
|
||||||
pb.buildPackages()
|
pb.build_packages()
|
||||||
|
|
||||||
def build_until(pspecfile, state, authInfo=None):
|
def build_until(pspecfile, state, authInfo=None):
|
||||||
pb = prepare_for_build(pspecfile, authInfo)
|
pb = prepare_for_build(pspecfile, authInfo)
|
||||||
pb.compileActionScript()
|
pb.compile_action_script()
|
||||||
|
|
||||||
last = pb.getState()
|
last = pb.get_state()
|
||||||
ui.info("Last state was %s\n"%last)
|
ui.info("Last state was %s\n"%last)
|
||||||
|
|
||||||
if not last: last = "none"
|
if not last: last = "none"
|
||||||
|
|||||||
+1
-1
@@ -81,7 +81,7 @@ class CLI:
|
|||||||
else:
|
else:
|
||||||
return 0
|
return 0
|
||||||
|
|
||||||
def displayProgress(self, pd):
|
def display_progress(self, pd):
|
||||||
out = '\r%-30.30s %3d%% %12.2f %s' % \
|
out = '\r%-30.30s %3d%% %12.2f %s' % \
|
||||||
(pd['filename'], pd['percent'], pd['rate'], pd['symbol'])
|
(pd['filename'], pd['percent'], pd['rate'], pd['symbol'])
|
||||||
self.info(out)
|
self.info(out)
|
||||||
|
|||||||
+2
-1
@@ -9,9 +9,10 @@
|
|||||||
#
|
#
|
||||||
# Please read the COPYING file.
|
# Please read the COPYING file.
|
||||||
#
|
#
|
||||||
|
|
||||||
# some helper functions for using minidom
|
# some helper functions for using minidom
|
||||||
# works well enough for now... :/
|
# works well enough for now... :/
|
||||||
|
# function names are mixedCase for compatibility with minidom,
|
||||||
|
# an old library
|
||||||
|
|
||||||
# Authors: Eray Ozkural <eray@uludag.org.tr>
|
# Authors: Eray Ozkural <eray@uludag.org.tr>
|
||||||
# Baris Metin <baris@uludag.org.tr
|
# Baris Metin <baris@uludag.org.tr
|
||||||
|
|||||||
+3
-1
@@ -9,13 +9,15 @@
|
|||||||
#
|
#
|
||||||
# Please read the COPYING file.
|
# Please read the COPYING file.
|
||||||
#
|
#
|
||||||
|
|
||||||
# XmlFile is a halper module for accessing XML files using
|
# XmlFile is a halper module for accessing XML files using
|
||||||
# xml.dom.minidom.
|
# xml.dom.minidom.
|
||||||
#
|
#
|
||||||
# XmlFile class that further abstracts a dom object using the
|
# XmlFile class that further abstracts a dom object using the
|
||||||
# high-level dom functions provided in xml module (and sorely lacking
|
# high-level dom functions provided in xml module (and sorely lacking
|
||||||
# in xml.dom :( )
|
# in xml.dom :( )
|
||||||
|
#
|
||||||
|
# method names are mixedCase for compatibility with minidom,
|
||||||
|
# an old library
|
||||||
|
|
||||||
# Authors: Eray Ozkural <eray@uludag.org.tr>
|
# Authors: Eray Ozkural <eray@uludag.org.tr>
|
||||||
# Baris Metin <baris@uludag.org.tr
|
# Baris Metin <baris@uludag.org.tr
|
||||||
|
|||||||
Reference in New Issue
Block a user