[elbe-devel] [PATCH v4 5/5] Unpack the archives depending on volume attribute
Akash Satamkar
akash at linutronix.de
Wed Sep 18 12:17:22 CEST 2019
The volume attribute can be used to specify the volume
number in which the archive is added.
When volume attribute is not specified,
the archive is added to each volume.
Signed-off-by: Akash Satamkar <akash at linutronix.de>
---
elbepack/cdroms.py | 18 ++++++++++++++++++
elbepack/repomanager.py | 13 +++++++++++--
2 files changed, 29 insertions(+), 2 deletions(-)
diff --git a/elbepack/cdroms.py b/elbepack/cdroms.py
index d2c1b2b0..d9e67195 100644
--- a/elbepack/cdroms.py
+++ b/elbepack/cdroms.py
@@ -12,6 +12,8 @@ import logging
from shutil import copyfile
from apt.package import FetchError
+
+from elbepack.archivedir import archive_tmpfile
from elbepack.rpcaptcache import get_rpcaptcache
from elbepack.repomanager import CdromSrcRepo
from elbepack.repomanager import CdromBinRepo
@@ -91,6 +93,22 @@ def mk_source_cdrom(rfs, arch, codename, init_codename, target,
if xml is not None:
options = get_iso_options(xml)
+
+ for arch_vol in xml.node('src-cdrom').all('archive'):
+ volume_attr = arch_vol.et.get('volume')
+
+ if volume_attr == 'all':
+ volume_list = repo.volume_indexes
+ else:
+ volume_list = [int(v) for v in volume_attr.split(",")]
+ for volume_number in volume_list:
+ with archive_tmpfile(arch_vol.text(".")) as fp:
+ if volume_number in repo.volume_indexes:
+ do('tar xvfj "%s" -h -C "%s"' % (fp.name,
+ repo.get_volume_fs(volume_number).path))
+ else:
+ logging.warning("The src-cdrom archive's volume value "
+ "is not contained in the actual volumes")
else:
options = ""
diff --git a/elbepack/repomanager.py b/elbepack/repomanager.py
index f8ec8a23..d99b5083 100644
--- a/elbepack/repomanager.py
+++ b/elbepack/repomanager.py
@@ -98,7 +98,13 @@ class RepoBase(object):
def get_volume_fs(self, volume):
if self.maxsize:
- volname = os.path.join(self.vol_path, "vol%02d" % volume)
+ if volume >= 0:
+ volume_no = volume
+ else:
+ # negative numbers represent the volumes counted from last
+ # (-1: last, -2: second last, ...)
+ volume_no = self.volume_count + 1 + volume
+ volname = os.path.join(self.vol_path, "vol%02d" % volume_no)
return Filesystem(volname)
return Filesystem(self.vol_path)
@@ -289,7 +295,7 @@ class RepoBase(object):
(options, fname, new_path))
files.append(fname)
else:
- for i in range(self.volume_count + 1):
+ for i in self.volume_indexes:
volfs = self.get_volume_fs(i)
newname = fname + ("%02d" % i)
do("genisoimage %s -o %s -J -joliet-long -R %s" %
@@ -298,6 +304,9 @@ class RepoBase(object):
return files
+ @property
+ def volume_indexes(self):
+ return range(self.volume_count + 1)
class UpdateRepo(RepoBase):
def __init__(self, xml, path):
--
2.20.1
More information about the elbe-devel
mailing list