blob: 15fb62431da369bd7a998b581db99dda9544cae6 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
|
import tarfile
from Bcfg2.Server.Plugins.Packages.Collection import _Collection
from Bcfg2.Server.Plugins.Packages.Source import Source
class PacCollection(_Collection):
pass
class PacSource(Source):
basegroups = ['arch', 'parabola']
ptype = 'pacman'
@property
def urls(self):
if not self.rawurl:
rv = []
for part in self.components:
for arch in self.arches:
rv.append("%s%s/os/%s/%s.db.tar.gz" %
(self.url, part, arch, part))
return rv
else:
raise Exception("PacSource : RAWUrl not supported (yet)")
def read_files(self):
bdeps = dict()
bprov = dict()
depfnames = ['Depends', 'Pre-Depends']
if self.recommended:
depfnames.append('Recommends')
for fname in self.files:
if not self.rawurl:
barch = [x for x in fname.split('@') if x in self.arches][0]
else:
# RawURL entries assume that they only have one <Arch></Arch>
# element and that it is the architecture of the source.
barch = self.arches[0]
if barch not in bdeps:
bdeps[barch] = dict()
bprov[barch] = dict()
try:
self.debug_log("Packages: try to read %s" % fname)
tar = tarfile.open(fname, "r")
except:
self.logger.error("Packages: Failed to read file %s" % fname)
raise
for tarinfo in tar:
if tarinfo.isdir():
self.pkgnames.add(tarinfo.name.rsplit("-", 2)[0])
self.debug_log("Packages: added %s" %
tarinfo.name.rsplit("-", 2)[0])
tar.close()
self.process_files(bdeps, bprov)
|