本文整理汇总了Python中pisi.sourcearchive.SourceArchive.fetch方法的典型用法代码示例。如果您正苦于以下问题:Python SourceArchive.fetch方法的具体用法?Python SourceArchive.fetch怎么用?Python SourceArchive.fetch使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pisi.sourcearchive.SourceArchive
的用法示例。
在下文中一共展示了SourceArchive.fetch方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
# 需要导入模块: from pisi.sourcearchive import SourceArchive [as 别名]
# 或者: from pisi.sourcearchive.SourceArchive import fetch [as 别名]
class PisiBuild:
"""PisiBuild class, provides the package build and creation routines"""
def __init__(self, pspec):
self.bctx = BuildContext(pspec)
self.pspecDir = os.path.dirname(os.path.realpath(self.bctx.pspecfile))
self.spec = self.bctx.spec
self.sourceArchive = SourceArchive(self.bctx)
self.set_environment_vars()
self.actionLocals = None
self.actionGlobals = None
self.srcDir = None
def set_state(self, state):
stateFile = os.path.join(self.bctx.pkg_work_dir(), "pisiBuildState")
open(stateFile, "w").write(state)
def get_state(self):
stateFile = os.path.join(self.bctx.pkg_work_dir(), "pisiBuildState")
if not os.path.exists(stateFile): # no state
return None
return open(stateFile, "r").read()
def build(self):
"""Build the package in one shot."""
ctx.ui.info(_("Building PISI source package: %s") % self.spec.source.name)
util.xterm_title(_("Building PISI source package: %s\n") % self.spec.source.name)
self.compile_action_script()
# check if all patch files exists, if there are missing no need to unpack!
self.patch_exists()
self.fetch_source_archive()
self.unpack_source_archive()
self.solve_build_dependencies()
# apply the patches and prepare a source directory for build.
self.apply_patches()
self.run_setup_action()
self.run_build_action()
self.run_install_action()
self.strip_install_dir()
# after all, we are ready to build/prepare the packages
self.build_packages()
def set_environment_vars(self):
"""Sets the environment variables for actions API to use"""
evn = {
"PKG_DIR": self.bctx.pkg_dir(),
"WORK_DIR": self.bctx.pkg_work_dir(),
"INSTALL_DIR": self.bctx.pkg_install_dir(),
"SRC_NAME": self.spec.source.name,
"SRC_VERSION": self.spec.source.version,
"SRC_RELEASE": self.spec.source.release
}
os.environ.update(evn)
def fetch_source_archive(self):
ctx.ui.info(_("Fetching source from: %s") % self.spec.source.archiveUri)
self.sourceArchive.fetch()
ctx.ui.info(_("Source archive is stored: %s/%s")
%(ctx.config.archives_dir(), self.spec.source.archiveName))
def unpack_source_archive(self):
ctx.ui.info(_("Unpacking archive..."))
self.sourceArchive.unpack()
ctx.ui.info(_(" unpacked (%s)") % self.bctx.pkg_work_dir())
self.set_state("unpack")
def run_setup_action(self):
# Run configure, build and install phase
ctx.ui.action(_("Setting up source..."))
self.run_action_function(ctx.const.setup_func)
self.set_state("setupaction")
def run_build_action(self):
ctx.ui.action(_("Building source..."))
self.run_action_function(ctx.const.build_func)
self.set_state("buildaction")
def run_install_action(self):
ctx.ui.action(_("Installing..."))
# Before install make sure install_dir is clean
if os.path.exists(self.bctx.pkg_install_dir()):
util.clean_dir(self.bctx.pkg_install_dir())
# install function is mandatory!
self.run_action_function(ctx.const.install_func, True)
self.set_state("installaction")
def compile_action_script(self):
#.........这里部分代码省略.........
示例2: from_name
# 需要导入模块: from pisi.sourcearchive import SourceArchive [as 别名]
# 或者: from pisi.sourcearchive.SourceArchive import fetch [as 别名]
class Builder:
"""Provides the package build and creation routines"""
#FIXME: this class and every other class must use URLs as paths!
@staticmethod
def from_name(name):
# download package and return an installer object
# find package in repository
sf, reponame = ctx.sourcedb.get_spec_repo(name)
src = sf.source
if src:
src_uri = URI(src.sourceURI)
if src_uri.is_absolute_path():
src_path = str(src_uri)
else:
repo = ctx.repodb.get_repo(reponame)
#FIXME: don't use dirname to work on URLs
src_path = os.path.join(os.path.dirname(repo.indexuri.get_uri()),
str(src_uri.path()))
ctx.ui.debug(_("Source URI: %s") % src_path)
return Builder(src_path)
else:
raise Error(_("Source %s not found in any active repository.") % name)
def __init__(self, specuri):
# process args
if not isinstance(specuri, URI):
specuri = URI(specuri)
# read spec file, we'll need it :)
self.set_spec_file(specuri)
if specuri.is_remote_file():
#make local here and fuck up
self.specdir = self.fetch_files()
else:
self.specdir = dirname(self.specuri.get_uri())
self.sourceArchive = SourceArchive(self.spec, self.pkg_work_dir())
self.set_environment_vars()
self.actionLocals = None
self.actionGlobals = None
self.srcDir = None
def set_spec_file(self, specuri):
if not specuri.is_remote_file():
specuri = URI(os.path.realpath(specuri.get_uri())) # FIXME: doesn't work for file://
self.specuri = specuri
spec = SpecFile()
spec.read(specuri, ctx.config.tmp_dir())
self.spec = spec
# directory accessor functions
# pkg_x_dir: per package directory for storing info type x
def pkg_dir(self):
"package build directory"
packageDir = self.spec.source.name + '-' + \
self.spec.source.version + '-' + self.spec.source.release
return util.join_path(ctx.config.dest_dir(), ctx.config.values.dirs.tmp_dir,
packageDir)
def pkg_work_dir(self):
return self.pkg_dir() + ctx.const.work_dir_suffix
def pkg_debug_dir(self):
return self.pkg_dir() + ctx.const.debug_dir_suffix
def pkg_install_dir(self):
return self.pkg_dir() + ctx.const.install_dir_suffix
def set_state(self, state):
stateFile = util.join_path(self.pkg_work_dir(), "pisiBuildState")
open(stateFile, "w").write(state)
def get_state(self):
stateFile = util.join_path(self.pkg_work_dir(), "pisiBuildState")
if not os.path.exists(stateFile): # no state
return None
return open(stateFile, "r").read()
def build(self):
"""Build the package in one shot."""
ctx.ui.status(_("Building PISI source package: %s") % self.spec.source.name)
self.compile_action_script()
# check if all patch files exists, if there are missing no need to unpack!
self.patch_exists()
self.check_build_dependencies()
self.fetch_component()
#.........这里部分代码省略.........