本文整理汇总了Python中pisi.package.Package.add_to_package方法的典型用法代码示例。如果您正苦于以下问题:Python Package.add_to_package方法的具体用法?Python Package.add_to_package怎么用?Python Package.add_to_package使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pisi.package.Package
的用法示例。
在下文中一共展示了Package.add_to_package方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: build_packages
# 需要导入模块: from pisi.package import Package [as 别名]
# 或者: from pisi.package.Package import add_to_package [as 别名]
def build_packages(self):
"""Build each package defined in PSPEC file. After this process there
will be .pisi files hanging around, AS INTENDED ;)"""
for package in self.spec.packages:
# store additional files
c = os.getcwd()
os.chdir(self.pspecDir)
install_dir = self.bctx.pkg_dir() + ctx.const.install_dir_suffix
for afile in package.additionalFiles:
src = os.path.join(ctx.const.files_dir, afile.filename)
dest = os.path.join(install_dir + os.path.dirname(afile.target), os.path.basename(afile.target))
util.copy_file(src, dest)
if afile.permission:
os.chmod(dest, int(afile.permission) | 0777)
os.chdir(c)
name = util.package_name(package.name,
self.spec.source.version,
self.spec.source.release)
ctx.ui.action(_("** Building package %s") % package.name);
ctx.ui.action(_("Generating %s...") % ctx.const.files_xml)
self.gen_files_xml(package)
ctx.ui.info(_(" done."))
ctx.ui.action(_("Generating %s...") % ctx.const.metadata_xml)
self.gen_metadata_xml(package)
ctx.ui.info(_(" done."))
ctx.ui.action(_("Creating PISI package %s") % name)
pkg = Package(name, 'w')
# add comar files to package
os.chdir(self.pspecDir)
for pcomar in package.providesComar:
fname = os.path.join(ctx.const.comar_dir,
pcomar.script)
pkg.add_to_package(fname)
# add xmls and files
os.chdir(self.bctx.pkg_dir())
pkg.add_to_package(ctx.const.metadata_xml)
pkg.add_to_package(ctx.const.files_xml)
# Now it is time to add files to the packages using newly
# created files.xml
files = Files()
files.read(ctx.const.files_xml)
for finfo in files.list:
pkg.add_to_package("install/" + finfo.path)
pkg.close()
os.chdir(c)
self.set_state("buildpackages")
util.xterm_title_reset()
示例2: build_packages
# 需要导入模块: from pisi.package import Package [as 别名]
# 或者: from pisi.package.Package import add_to_package [as 别名]
def build_packages(self):
"""Build each package defined in PSPEC file. After this process there
will be .pisi files hanging around, AS INTENDED ;)"""
self.fetch_component() # bug 856
# Strip install directory before building .pisi packages.
self.strip_install_dir()
if ctx.get_option('create_static'):
obj = self.generate_static_package_object()
if obj:
self.spec.packages.append(obj)
if ctx.config.values.build.generatedebug:
obj = self.generate_debug_package_object()
if obj:
self.spec.packages.append(obj)
self.new_packages = []
self.old_packages = []
for package in self.spec.packages:
old_package_name = None
# store additional files
c = os.getcwd()
os.chdir(self.specdir)
install_dir = self.pkg_dir() + ctx.const.install_dir_suffix
for afile in package.additionalFiles:
src = os.path.join(ctx.const.files_dir, afile.filename)
dest = os.path.join(install_dir + os.path.dirname(afile.target), os.path.basename(afile.target))
util.copy_file(src, dest)
if afile.permission:
# mode is octal!
os.chmod(dest, int(afile.permission, 8))
os.chdir(c)
ctx.ui.action(_("** Building package %s") % package.name);
ctx.ui.info(_("Generating %s,") % ctx.const.files_xml)
self.gen_files_xml(package)
ctx.ui.info(_("Generating %s,") % ctx.const.metadata_xml)
self.gen_metadata_xml(package)
# build number
if ctx.config.options.ignore_build_no or not ctx.config.values.build.buildno:
build_no = old_build_no = None
ctx.ui.warning(_('Build number is not available. For repo builds you must enable buildno in pisi.conf.'))
else:
build_no, old_build_no = self.calc_build_no(package.name)
self.metadata.package.build = build_no
self.metadata.write(util.join_path(self.pkg_dir(), ctx.const.metadata_xml))
# Calculate new and oldpackage names for buildfarm
name = util.package_name(package.name,
self.spec.source.version,
self.spec.source.release,
self.metadata.package.build)
outdir = ctx.get_option('output_dir')
if outdir:
name = pisi.util.join_path(outdir, name)
self.new_packages.append(name)
ctx.ui.info(_("Creating PISI package %s.") % name)
pkg = Package(name, 'w')
# add comar files to package
os.chdir(self.specdir)
for pcomar in package.providesComar:
fname = util.join_path(ctx.const.comar_dir,
pcomar.script)
pkg.add_to_package(fname)
# add xmls and files
os.chdir(self.pkg_dir())
pkg.add_to_package(ctx.const.metadata_xml)
pkg.add_to_package(ctx.const.files_xml)
# Now it is time to add files to the packages using newly
# created files.xml
files = Files()
files.read(ctx.const.files_xml)
if ctx.get_option('package_format') == "1.0":
for finfo in files.list:
orgname = arcname = join("install", finfo.path)
if package.debug_package:
orgname = join("debug", finfo.path)
pkg.add_to_package(orgname, arcname)
pkg.close()
else: # default package format is 1.1, so make it fallback.
ctx.build_leftover = join(self.pkg_dir(), ctx.const.install_tar_lzma)
tar = archive.ArchiveTar(ctx.const.install_tar_lzma, "tarlzma")
for finfo in files.list:
orgname = arcname = join("install", finfo.path)
#.........这里部分代码省略.........
示例3: build_packages
# 需要导入模块: from pisi.package import Package [as 别名]
# 或者: from pisi.package.Package import add_to_package [as 别名]
def build_packages(self):
"""Build each package defined in PSPEC file. After this process there
will be .pisi files hanging around, AS INTENDED ;)"""
self.fetch_component() # bug 856
# Strip install directory before building .pisi packages.
self.strip_install_dir()
if ctx.get_option('create_static'):
obj = self.generate_static_package_object()
if obj:
self.spec.packages.append(obj)
if not ctx.get_option('no_debug'):
obj = self.generate_debug_package_object()
if obj:
self.spec.packages.append(obj)
package_names = []
old_package_names = []
for package in self.spec.packages:
old_package_name = None
# store additional files
c = os.getcwd()
os.chdir(self.specdir)
install_dir = self.pkg_dir() + ctx.const.install_dir_suffix
for afile in package.additionalFiles:
src = os.path.join(ctx.const.files_dir, afile.filename)
dest = os.path.join(install_dir + os.path.dirname(afile.target), os.path.basename(afile.target))
util.copy_file(src, dest)
if afile.permission:
# mode is octal!
os.chmod(dest, int(afile.permission, 8))
os.chdir(c)
ctx.ui.action(_("** Building package %s") % package.name);
ctx.ui.info(_("Generating %s,") % ctx.const.files_xml)
self.gen_files_xml(package)
ctx.ui.info(_("Generating %s,") % ctx.const.metadata_xml)
build_number, old_build_number = self.gen_metadata_xml(package)
name = util.package_name(package.name,
self.spec.source.version,
self.spec.source.release,
self.metadata.package.build)
outdir = ctx.get_option('output_dir')
if outdir:
name = pisi.util.join_path(outdir, name)
ctx.ui.info(_("Creating PISI package %s.") % name)
# somebody explain to me why this is done here -- exa
if old_build_number:
old_package_name = util.package_name(package.name,
self.spec.source.version,
self.spec.source.release,
old_build_number)
pkg = Package(name, 'w')
package_names.append(name)
old_package_names.append(old_package_name)
# add comar files to package
os.chdir(self.specdir)
for pcomar in package.providesComar:
fname = util.join_path(ctx.const.comar_dir,
pcomar.script)
pkg.add_to_package(fname)
# add xmls and files
os.chdir(self.pkg_dir())
pkg.add_to_package(ctx.const.metadata_xml)
pkg.add_to_package(ctx.const.files_xml)
# Now it is time to add files to the packages using newly
# created files.xml
files = Files()
files.read(ctx.const.files_xml)
if ctx.get_option('package_format') == "1.1":
tar = archive.ArchiveTar("install.tar.lzma", "tarlzma")
for finfo in files.list:
orgname = arcname = join("install", finfo.path)
if package.debug_package:
orgname = join("debug", finfo.path)
tar.add_to_archive(orgname, arcname.lstrip("install"))
tar.close()
pkg.add_to_package("install.tar.lzma")
pkg.close()
os.unlink("install.tar")
os.unlink("install.tar.lzma")
else:
for finfo in files.list:
orgname = arcname = join("install", finfo.path)
#.........这里部分代码省略.........
示例4: build_packages
# 需要导入模块: from pisi.package import Package [as 别名]
# 或者: from pisi.package.Package import add_to_package [as 别名]
def build_packages(self):
"""Build each package defined in PSPEC file. After this process there
will be .pisi files hanging around, AS INTENDED ;)"""
self.fetch_component() # bug 856
# Strip install directory before building .pisi packages.
self.strip_install_dir()
package_names = []
for package in self.spec.packages:
# store additional files
c = os.getcwd()
os.chdir(self.specdir)
install_dir = self.pkg_dir() + ctx.const.install_dir_suffix
for afile in package.additionalFiles:
src = os.path.join(ctx.const.files_dir, afile.filename)
dest = os.path.join(install_dir + os.path.dirname(afile.target), os.path.basename(afile.target))
util.copy_file(src, dest)
if afile.permission:
# mode is octal!
os.chmod(dest, int(afile.permission, 8))
os.chdir(c)
ctx.ui.action(_("** Building package %s") % package.name);
ctx.ui.info(_("Generating %s,") % ctx.const.files_xml)
self.gen_files_xml(package)
ctx.ui.info(_("Generating %s,") % ctx.const.metadata_xml)
self.gen_metadata_xml(package)
ctx.ui.info(_("Creating PISI package %s.") % package.name)
name = util.package_name(package.name,
self.spec.source.version,
self.spec.source.release,
self.metadata.package.build)
pkg = Package(name, 'w')
package_names.append(name)
# add comar files to package
os.chdir(self.specdir)
for pcomar in package.providesComar:
fname = util.join_path(ctx.const.comar_dir,
pcomar.script)
pkg.add_to_package(fname)
# add xmls and files
os.chdir(self.pkg_dir())
pkg.add_to_package(ctx.const.metadata_xml)
pkg.add_to_package(ctx.const.files_xml)
# Now it is time to add files to the packages using newly
# created files.xml
files = Files()
files.read(ctx.const.files_xml)
for finfo in files.list:
pkg.add_to_package(join("install", finfo.path))
pkg.close()
os.chdir(c)
self.set_state("buildpackages")
ctx.ui.info(_("Done."))
if ctx.config.values.general.autoclean is True:
ctx.ui.info(_("Cleaning Build Directory..."))
util.clean_dir(self.pkg_dir())
else:
ctx.ui.info(_("Keeping Build Directory"))
return package_names
示例5: create_delta_package
# 需要导入模块: from pisi.package import Package [as 别名]
# 或者: from pisi.package.Package import add_to_package [as 别名]
def create_delta_package(old_package, new_package):
if old_package == new_package:
ctx.ui.error(_("Cannot create delta for same package!"))
return
oldpkg = Package(old_package, "r")
newpkg = Package(new_package, "r")
newmd = newpkg.get_metadata()
oldmd = oldpkg.get_metadata()
oldfiles = oldpkg.get_files()
newfiles = newpkg.get_files()
files_delta = find_delta(oldfiles, newfiles)
ctx.ui.info(_("Creating delta PiSi package between %s %s") % (old_package, new_package))
# Unpack new package to temp
newpkg_name = util.package_name(newmd.package.name, newmd.package.version, newmd.package.release, newmd.package.build, False)
newpkg_path = util.join_path(ctx.config.tmp_dir(), newpkg_name)
newpkg.extract_to(newpkg_path, True)
tar = archive.ArchiveTar(util.join_path(newpkg_path, ctx.const.install_tar_lzma), "tarlzma", False, False)
tar.unpack_dir(newpkg_path)
# Create delta package
deltaname = "%s-%s-%s%s" % (oldmd.package.name, oldmd.package.build, newmd.package.build, ctx.const.delta_package_suffix)
outdir = ctx.get_option("output_dir")
if outdir:
deltaname = util.join_path(outdir, deltaname)
deltapkg = Package(deltaname, "w")
c = os.getcwd()
os.chdir(newpkg_path)
# add comar files to package
for pcomar in newmd.package.providesComar:
fname = util.join_path(ctx.const.comar_dir, pcomar.script)
deltapkg.add_to_package(fname)
# add xmls and files
deltapkg.add_to_package(ctx.const.metadata_xml)
deltapkg.add_to_package(ctx.const.files_xml)
# only metadata information may change in a package, so no install.tar.lzma added to delta package
if files_delta:
ctx.build_leftover = util.join_path(ctx.config.tmp_dir(), ctx.const.install_tar_lzma)
tar = archive.ArchiveTar(util.join_path(ctx.config.tmp_dir(), ctx.const.install_tar_lzma), "tarlzma")
for file in files_delta:
tar.add_to_archive(file.path)
tar.close()
os.chdir(ctx.config.tmp_dir())
deltapkg.add_to_package(ctx.const.install_tar_lzma)
deltapkg.close()
tmp_file = util.join_path(ctx.config.tmp_dir(), ctx.const.install_tar_lzma)
if os.path.exists(tmp_file):
os.unlink(tmp_file)
ctx.build_leftover = None
os.chdir(c)
ctx.ui.info(_("Done."))