]>
git.ipfire.org Git - pakfire.git/blob - pakfire/distro.py
7 from errors
import ConfigError
9 class Distribution(object):
10 def __init__(self
, pakfire
):
11 self
.pakfire
= pakfire
14 "arch" : self
.host_arch
,
21 if not self
.pakfire
.config
._distro
:
22 raise ConfigError
, "No distribution data was provided in the configuration"
24 # Import settings from Config()
25 self
._data
.update(self
.pakfire
.config
._distro
)
31 logging
.debug("Distribution configuration:")
33 attrs
= ("name", "version", "release", "sname", "dist", "vendor", "machine",)
36 logging
.debug(" %s : %s" % (attr
, getattr(self
, attr
)))
40 return self
._data
.get("name")
44 return self
._data
.get("version")
48 m
= re
.match(r
"^([0-9]+)\..*", self
.version
)
54 return self
.name
.strip().lower()
58 return self
._data
.get("slogan")
62 return self
._data
.get("vendor")
65 return self
._data
.get("arch")
67 def set_arch(self
, arch
):
68 # XXX check if we are allowed to set this arch
69 self
._data
.set("arch", arch
)
71 arch
= property(get_arch
, set_arch
)
75 return self
.sname
[:2] + self
.release
79 return "%s-%s-linux-gnu" % (self
.arch
, self
.vendor
)
84 Return the architecture of the host we are running on.
89 def supported_arches(self
):
91 "i686" : [ "i686", "x86_64", ],
92 "i586" : [ "i586", "i686", "x86_64", ],
93 "i486" : [ "i486", "i586", "i686", "x86_64", ],
96 for host
, can_be_built
in host_arches
.items():
97 if self
.host_arch
in can_be_built
:
100 def host_supports_arch(self
, arch
):
102 Check if this host can build for the target architecture "arch".
104 return arch
in self
.supported_arches
109 An attribute that adds some environment variables to the
113 "DISTRO_NAME" : self
.name
,
114 "DISTRO_SNAME" : self
.sname
,
115 "DISTRO_VERSION" : self
.version
,
116 "DISTRO_RELEASE" : self
.release
,
117 "DISTRO_DISTTAG" : self
.dist
,
118 "DISTRO_ARCH" : self
.arch
,
119 "DISTRO_MACHINE" : self
.machine
,
120 "DISTRO_VENDOR" : self
.vendor
,
129 for k
, v
in self
.environ
.items():