summaryrefslogtreecommitdiffstats
path: root/src/lib/Bcfg2/Server/Plugins/Packages/Pac.py
diff options
context:
space:
mode:
authorAlexander Sulfrian <asulfrian@zedat.fu-berlin.de>2022-01-16 07:43:05 +0100
committerAlexander Sulfrian <asulfrian@zedat.fu-berlin.de>2022-01-17 16:41:32 +0100
commit000a832751563cfe571363a27e293fd3d9db31a4 (patch)
tree5d96fdc02640d4a7120ad3a83b9965c7e0282113 /src/lib/Bcfg2/Server/Plugins/Packages/Pac.py
parent8605cd3d0cb4d549cb8b43de945d447f6d82892a (diff)
downloadbcfg2-000a832751563cfe571363a27e293fd3d9db31a4.tar.gz
bcfg2-000a832751563cfe571363a27e293fd3d9db31a4.tar.bz2
bcfg2-000a832751563cfe571363a27e293fd3d9db31a4.zip
Packages: Support different compression methods
The new Reader classes implement different compression methods for the files parsed by the Packages backends. Each source can specify a default compression format. The user can configure a compression format per Source and the filename and extension for the metadata files are generated automatically.
Diffstat (limited to 'src/lib/Bcfg2/Server/Plugins/Packages/Pac.py')
-rw-r--r--src/lib/Bcfg2/Server/Plugins/Packages/Pac.py12
1 files changed, 9 insertions, 3 deletions
diff --git a/src/lib/Bcfg2/Server/Plugins/Packages/Pac.py b/src/lib/Bcfg2/Server/Plugins/Packages/Pac.py
index 6fc084cc4..e3432c934 100644
--- a/src/lib/Bcfg2/Server/Plugins/Packages/Pac.py
+++ b/src/lib/Bcfg2/Server/Plugins/Packages/Pac.py
@@ -87,6 +87,9 @@ class PacSource(Source):
#: PacSource sets the ``type`` on Package entries to "pacman"
ptype = 'pacman'
+ #: The database of pacman repositories is compressed with "gzip"
+ default_compression = 'gzip'
+
def __init__(self, basepath, xsource):
self.pacgroups = {}
@@ -113,9 +116,10 @@ class PacSource(Source):
if not self.rawurl:
rv = []
for part in self.components:
+ filename = self.build_filename("%s.db.tar" % part)
for arch in self.arches:
- rv.append("%s%s/os/%s/%s.db.tar.gz" %
- (self.url, part, arch, part))
+ rv.append("%s%s/os/%s/%s" %
+ (self.url, part, arch, filename))
return rv
else:
raise Exception("PacSource : RAWUrl not supported (yet)")
@@ -140,7 +144,8 @@ class PacSource(Source):
bprov[barch] = {}
try:
self.debug_log("Packages: try to read %s" % fname)
- tar = tarfile.open(fname, "r")
+ reader = self.open_file(fname)
+ tar = tarfile.open(fileobj=reader)
except (IOError, tarfile.TarError):
self.logger.error("Packages: Failed to read file %s" % fname)
raise
@@ -185,6 +190,7 @@ class PacSource(Source):
self.pacgroups[group].append(pkgname)
tar.close()
+ reader.close()
self.process_files(bdeps, bprov, brecs)
read_files.__doc__ = Source.read_files.__doc__