]>
git.ipfire.org Git - people/ms/pakfire.git/blob - pakfire/distro.py
7 from errors
import ConfigError
8 from repository
import Repositories
10 class Distribution(object):
11 def __init__(self
, pakfire
, distro_config
=None):
12 self
.pakfire
= pakfire
15 "arch" : self
.host_arch
,
22 # Inherit configuration from Pakfire configuration.
23 self
.update(self
.pakfire
.config
._distro
)
25 # Update my configuration from the constructor.
26 self
.update(distro_config
)
32 logging
.debug("Distribution configuration:")
34 attrs
= ("name", "version", "release", "sname", "dist", "vendor",
38 logging
.debug(" %s : %s" % (attr
, getattr(self
, attr
)))
40 def update(self
, config
):
44 # Exceptional handling for arch.
45 if config
.has_key("arch"):
46 self
.arch
= config
["arch"]
49 self
._data
.update(config
)
53 return self
._data
.get("name")
57 return self
._data
.get("version")
61 m
= re
.match(r
"^([0-9]+)\..*", self
.version
)
67 return self
.name
.strip().lower()
71 return self
._data
.get("slogan")
75 return self
._data
.get("vendor")
78 return self
._data
.get("arch") or self
.host_arch
80 def set_arch(self
, arch
):
81 # XXX check if we are allowed to set this arch
85 self
._data
["arch"] = arch
87 arch
= property(get_arch
, set_arch
)
91 return self
.sname
[:2] + self
.release
95 vendor
= self
.vendor
.split()[0]
97 return "%s-%s-linux-gnu" % (self
.arch
, vendor
.lower())
102 Return the architecture of the host we are running on.
107 def supported_arches(self
):
109 "i686" : [ "i686", "x86_64", ],
110 "i586" : [ "i586", "i686", "x86_64", ],
111 "i486" : [ "i486", "i586", "i686", "x86_64", ],
114 for host
, can_be_built
in host_arches
.items():
115 if self
.host_arch
in can_be_built
:
118 def host_supports_arch(self
, arch
):
120 Check if this host can build for the target architecture "arch".
122 return arch
in self
.supported_arches
127 An attribute that adds some environment variables to the
131 "DISTRO_NAME" : self
.name
,
132 "DISTRO_SNAME" : self
.sname
,
133 "DISTRO_VERSION" : self
.version
,
134 "DISTRO_RELEASE" : self
.release
,
135 "DISTRO_DISTTAG" : self
.dist
,
136 "DISTRO_ARCH" : self
.arch
,
137 "DISTRO_MACHINE" : self
.machine
,
138 "DISTRO_VENDOR" : self
.vendor
,
139 "DISTRO_SLOGAN" : self
.slogan
,
148 for k
, v
in self
.environ
.items():
154 def personality(self
):
156 Return the personality of the target system.
158 If host and target system are of the same architecture, we return
159 None to skip the setting of the personality in the build chroot.
162 if self
.arch
== self
.host_arch
:
166 "x86_64" : "linux64",
172 return arch2personality
[self
.arch
]