Feature: Add ability to use multiple <Archive> tags for a source package

You can now use 1 or more <Archive> tags in source packages to download more than 1
tarballs in workDir. This is especially useful for packages like thunderbird where
we're currently creating our own tarball to contain the source code + l10n files.

This will also be useful on some binary drivers which has different tarballs for
every architecture.

pisi will automatically chdir into the directory which matches pkgname-pkgversion. If
no directory matches this, you should provide WorkDir in actions.py as usually.

If you'd like to apply your patches to every subarchive directory, you'll have to
modify the patch levels and set WorkDir to "." (very very very rare case)

Example:

<Source>
  ..
  ..
  ..
  <Archive sha1sum=".." type="tarbz2">http://nvidia.com/driver_x86.tar.bz2</Archive>
  <Archive sha1sum=".." type="tarbz2">http://nvidia.com/driver_x86_64.tar.bz2</Archive>
</Source>
This commit is contained in:
Ozan Çağlayan
2010-02-20 10:36:40 +00:00
parent 8adab008cd
commit 674dd8ea4e
5 changed files with 41 additions and 21 deletions
+3 -1
View File
@@ -48,7 +48,9 @@
<!-- FIXME: should be oneOrMore --> <!-- FIXME: should be oneOrMore -->
<ref name="Description"/> <ref name="Description"/>
</zeroOrMore> </zeroOrMore>
<ref name="Archive"/> <oneOrMore>
<ref name="Archive"/>
</oneOrMore>
<optional> <optional>
<ref name="AdditionalFiles"/> <ref name="AdditionalFiles"/>
</optional> </optional>
+5 -3
View File
@@ -47,10 +47,12 @@ class ArchiveBase(object):
def unpack(self, target_dir, clean_dir = False): def unpack(self, target_dir, clean_dir = False):
self.target_dir = target_dir self.target_dir = target_dir
# first we check if we need to clean-up our working env. # first we check if we need to clean-up our working env.
if os.path.exists(self.target_dir) and clean_dir: if os.path.exists(self.target_dir):
util.clean_dir(self.target_dir) if clean_dir:
util.clean_dir(self.target_dir)
os.makedirs(self.target_dir) if not os.path.exists(self.target_dir):
os.makedirs(self.target_dir)
class ArchiveBinary(ArchiveBase): class ArchiveBinary(ArchiveBase):
+10 -13
View File
@@ -192,7 +192,7 @@ class Builder:
self.read_translations(self.specdir) self.read_translations(self.specdir)
self.sourceArchive = pisi.sourcearchive.SourceArchive(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()
@@ -259,8 +259,8 @@ class Builder:
self.check_build_dependencies() self.check_build_dependencies()
self.fetch_component() self.fetch_component()
self.fetch_source_archive() self.fetch_source_archives()
self.unpack_source_archive() self.unpack_source_archives()
# Grab AdditionalFiles # Grab AdditionalFiles
self.copy_additional_source_files() self.copy_additional_source_files()
@@ -392,15 +392,12 @@ class Builder:
ctx.ui.info(_('Source is part of %s component') % comp.name) ctx.ui.info(_('Source is part of %s component') % comp.name)
self.spec.source.partOf = comp.name self.spec.source.partOf = comp.name
def fetch_source_archive(self): def fetch_source_archives(self):
ctx.ui.info(_("Fetching source from: %s") % self.spec.source.archive.uri) self.sourceArchives.fetch()
self.sourceArchive.fetch()
ctx.ui.info(_("Source archive is stored: %s/%s")
%(ctx.config.archives_dir(), self.spec.source.archive.name))
def unpack_source_archive(self): def unpack_source_archives(self):
ctx.ui.info(_("Unpacking archive...")) ctx.ui.info(_("Unpacking archive(s)..."))
self.sourceArchive.unpack() self.sourceArchives.unpack()
# apply the patches and prepare a source directory for build. # apply the patches and prepare a source directory for build.
if self.apply_patches(): if self.apply_patches():
ctx.ui.info(_(" unpacked (%s)") % self.pkg_work_dir()) ctx.ui.info(_(" unpacked (%s)") % self.pkg_work_dir())
@@ -1094,12 +1091,12 @@ order = {"none": 0,
def __buildState_fetch(pb): def __buildState_fetch(pb):
# fetch is the first state to run. # fetch is the first state to run.
pb.patch_exists() pb.patch_exists()
pb.fetch_source_archive() pb.fetch_source_archives()
def __buildState_unpack(pb, last): def __buildState_unpack(pb, last):
if order[last] < order["fetch"]: if order[last] < order["fetch"]:
__buildState_fetch(pb) __buildState_fetch(pb)
pb.unpack_source_archive() pb.unpack_source_archives()
def __buildState_setupaction(pb, last): def __buildState_setupaction(pb, last):
if order[last] < order["unpack"]: if order[last] < order["unpack"]:
+22 -3
View File
@@ -28,14 +28,29 @@ import pisi.mirrors
class Error(pisi.Error): class Error(pisi.Error):
pass pass
class SourceArchives:
"""This is a wrapper for supporting multiple SourceArchive objects."""
def __init__(self, spec, pkg_work_dir):
self.sourceArchives = [SourceArchive(a, pkg_work_dir) for a in spec.source.archive]
def fetch(self, interactive=True):
for archive in self.sourceArchives:
archive.fetch(interactive)
def unpack(self, clean_dir=True):
self.sourceArchives[0].unpack(clean_dir)
for archive in self.sourceArchives[1:]:
archive.unpack(clean_dir=False)
class SourceArchive: class SourceArchive:
"""source archive. this is a class responsible for fetching """source archive. this is a class responsible for fetching
and unpacking a source archive""" and unpacking a source archive"""
def __init__(self, spec, pkg_work_dir): def __init__(self, archive, pkg_work_dir):
self.url = pisi.uri.URI(spec.source.archive.uri) self.url = pisi.uri.URI(archive.uri)
self.pkg_work_dir = pkg_work_dir self.pkg_work_dir = pkg_work_dir
self.archiveFile = os.path.join(ctx.config.archives_dir(), self.url.filename()) self.archiveFile = os.path.join(ctx.config.archives_dir(), self.url.filename())
self.archive = spec.source.archive self.archive = archive
def fetch(self, interactive=True): def fetch(self, interactive=True):
if not self.is_cached(interactive): if not self.is_cached(interactive):
@@ -45,6 +60,7 @@ class SourceArchive:
self.progress = None self.progress = None
try: try:
ctx.ui.info(_("Fetching source from: %s") % self.url.uri)
if self.url.get_uri().startswith("mirrors://"): if self.url.get_uri().startswith("mirrors://"):
self.fetch_from_mirror() self.fetch_from_mirror()
else: else:
@@ -55,6 +71,9 @@ class SourceArchive:
else: else:
raise raise
ctx.ui.info(_("Source archive is stored: %s/%s")
% (ctx.config.archives_dir(), self.uri.filename()))
def fetch_from_fallback(self): def fetch_from_fallback(self):
archive = os.path.basename(self.url.get_uri()) archive = os.path.basename(self.url.get_uri())
src = os.path.join(ctx.config.values.build.fallback, archive) src = os.path.join(ctx.config.values.build.fallback, archive)
+1 -1
View File
@@ -171,7 +171,7 @@ class Source:
t_Summary = [autoxml.LocalText, autoxml.mandatory] t_Summary = [autoxml.LocalText, autoxml.mandatory]
t_Description = [autoxml.LocalText, autoxml.optional] t_Description = [autoxml.LocalText, autoxml.optional]
t_Icon = [ autoxml.String, autoxml.optional] t_Icon = [ autoxml.String, autoxml.optional]
t_Archive = [Archive, autoxml.mandatory ] t_Archive = [ [Archive], autoxml.mandatory, "Archive" ]
t_AdditionalFiles = [ [AdditionalFile], autoxml.optional] t_AdditionalFiles = [ [AdditionalFile], autoxml.optional]
t_BuildDependencies = [ [pisi.dependency.Dependency], autoxml.optional] t_BuildDependencies = [ [pisi.dependency.Dependency], autoxml.optional]
t_Patches = [ [Patch], autoxml.optional] t_Patches = [ [Patch], autoxml.optional]