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:
+3
-1
@@ -48,7 +48,9 @@
|
||||
<!-- FIXME: should be oneOrMore -->
|
||||
<ref name="Description"/>
|
||||
</zeroOrMore>
|
||||
<ref name="Archive"/>
|
||||
<oneOrMore>
|
||||
<ref name="Archive"/>
|
||||
</oneOrMore>
|
||||
<optional>
|
||||
<ref name="AdditionalFiles"/>
|
||||
</optional>
|
||||
|
||||
+5
-3
@@ -47,10 +47,12 @@ class ArchiveBase(object):
|
||||
def unpack(self, target_dir, clean_dir = False):
|
||||
self.target_dir = target_dir
|
||||
# first we check if we need to clean-up our working env.
|
||||
if os.path.exists(self.target_dir) and clean_dir:
|
||||
util.clean_dir(self.target_dir)
|
||||
if os.path.exists(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):
|
||||
|
||||
+10
-13
@@ -192,7 +192,7 @@ class Builder:
|
||||
|
||||
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()
|
||||
|
||||
@@ -259,8 +259,8 @@ class Builder:
|
||||
|
||||
self.check_build_dependencies()
|
||||
self.fetch_component()
|
||||
self.fetch_source_archive()
|
||||
self.unpack_source_archive()
|
||||
self.fetch_source_archives()
|
||||
self.unpack_source_archives()
|
||||
|
||||
# Grab AdditionalFiles
|
||||
self.copy_additional_source_files()
|
||||
@@ -392,15 +392,12 @@ class Builder:
|
||||
ctx.ui.info(_('Source is part of %s component') % comp.name)
|
||||
self.spec.source.partOf = comp.name
|
||||
|
||||
def fetch_source_archive(self):
|
||||
ctx.ui.info(_("Fetching source from: %s") % self.spec.source.archive.uri)
|
||||
self.sourceArchive.fetch()
|
||||
ctx.ui.info(_("Source archive is stored: %s/%s")
|
||||
%(ctx.config.archives_dir(), self.spec.source.archive.name))
|
||||
def fetch_source_archives(self):
|
||||
self.sourceArchives.fetch()
|
||||
|
||||
def unpack_source_archive(self):
|
||||
ctx.ui.info(_("Unpacking archive..."))
|
||||
self.sourceArchive.unpack()
|
||||
def unpack_source_archives(self):
|
||||
ctx.ui.info(_("Unpacking archive(s)..."))
|
||||
self.sourceArchives.unpack()
|
||||
# apply the patches and prepare a source directory for build.
|
||||
if self.apply_patches():
|
||||
ctx.ui.info(_(" unpacked (%s)") % self.pkg_work_dir())
|
||||
@@ -1094,12 +1091,12 @@ order = {"none": 0,
|
||||
def __buildState_fetch(pb):
|
||||
# fetch is the first state to run.
|
||||
pb.patch_exists()
|
||||
pb.fetch_source_archive()
|
||||
pb.fetch_source_archives()
|
||||
|
||||
def __buildState_unpack(pb, last):
|
||||
if order[last] < order["fetch"]:
|
||||
__buildState_fetch(pb)
|
||||
pb.unpack_source_archive()
|
||||
pb.unpack_source_archives()
|
||||
|
||||
def __buildState_setupaction(pb, last):
|
||||
if order[last] < order["unpack"]:
|
||||
|
||||
+22
-3
@@ -28,14 +28,29 @@ import pisi.mirrors
|
||||
class Error(pisi.Error):
|
||||
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:
|
||||
"""source archive. this is a class responsible for fetching
|
||||
and unpacking a source archive"""
|
||||
def __init__(self, spec, pkg_work_dir):
|
||||
self.url = pisi.uri.URI(spec.source.archive.uri)
|
||||
def __init__(self, archive, pkg_work_dir):
|
||||
self.url = pisi.uri.URI(archive.uri)
|
||||
self.pkg_work_dir = pkg_work_dir
|
||||
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):
|
||||
if not self.is_cached(interactive):
|
||||
@@ -45,6 +60,7 @@ class SourceArchive:
|
||||
self.progress = None
|
||||
|
||||
try:
|
||||
ctx.ui.info(_("Fetching source from: %s") % self.url.uri)
|
||||
if self.url.get_uri().startswith("mirrors://"):
|
||||
self.fetch_from_mirror()
|
||||
else:
|
||||
@@ -55,6 +71,9 @@ class SourceArchive:
|
||||
else:
|
||||
raise
|
||||
|
||||
ctx.ui.info(_("Source archive is stored: %s/%s")
|
||||
% (ctx.config.archives_dir(), self.uri.filename()))
|
||||
|
||||
def fetch_from_fallback(self):
|
||||
archive = os.path.basename(self.url.get_uri())
|
||||
src = os.path.join(ctx.config.values.build.fallback, archive)
|
||||
|
||||
+1
-1
@@ -171,7 +171,7 @@ class Source:
|
||||
t_Summary = [autoxml.LocalText, autoxml.mandatory]
|
||||
t_Description = [autoxml.LocalText, 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_BuildDependencies = [ [pisi.dependency.Dependency], autoxml.optional]
|
||||
t_Patches = [ [Patch], autoxml.optional]
|
||||
|
||||
Reference in New Issue
Block a user