]>
git.ipfire.org Git - pakfire.git/blob - pakfire/distro.py
2 ###############################################################################
4 # Pakfire - The IPFire package management system #
5 # Copyright (C) 2011 Pakfire development team #
7 # This program is free software: you can redistribute it and/or modify #
8 # it under the terms of the GNU General Public License as published by #
9 # the Free Software Foundation, either version 3 of the License, or #
10 # (at your option) any later version. #
12 # This program is distributed in the hope that it will be useful, #
13 # but WITHOUT ANY WARRANTY; without even the implied warranty of #
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the #
15 # GNU General Public License for more details. #
17 # You should have received a copy of the GNU General Public License #
18 # along with this program. If not, see <http://www.gnu.org/licenses/>. #
20 ###############################################################################
26 from errors
import ConfigError
27 from repository
import Repositories
29 class Distribution(object):
30 def __init__(self
, pakfire
, distro_config
=None):
31 self
.pakfire
= pakfire
34 "arch" : self
.config
.host_arch
,
41 # Inherit configuration from Pakfire configuration.
42 self
.update(self
.pakfire
.config
._distro
)
44 # Update my configuration from the constructor.
45 self
.update(distro_config
)
52 return self
.pakfire
.config
55 logging
.debug("Distribution configuration:")
57 attrs
= ("name", "version", "release", "sname", "dist", "vendor",
58 "arch", "machine", "source_dl",)
61 logging
.debug(" %s : %s" % (attr
, getattr(self
, attr
)))
63 def update(self
, config
):
67 # Exceptional handling for arch.
68 if config
.has_key("arch"):
69 self
.arch
= config
["arch"]
72 self
._data
.update(config
)
76 return self
._data
.get("name")
80 return self
._data
.get("version")
84 m
= re
.match(r
"^([0-9]+)\..*", self
.version
)
90 return self
.name
.strip().lower()
94 return self
._data
.get("slogan")
98 return self
._data
.get("vendor")
101 def maintainer(self
):
102 return self
._data
.get("maintainer")
105 return self
._data
.get("arch") or self
.config
.host_arch
107 def set_arch(self
, arch
):
108 # XXX check if we are allowed to set this arch
112 self
._data
["arch"] = arch
114 arch
= property(get_arch
, set_arch
)
118 return self
.sname
[:2] + self
.release
122 vendor
= self
.vendor
.split()[0]
124 return "%s-%s-linux-gnu" % (self
.arch
, vendor
.lower())
127 def buildtarget(self
):
128 return self
.machine
.replace("-gnu", "")
132 return self
._data
.get("source_dl", None)
137 An attribute that adds some environment variables to the
141 "DISTRO_NAME" : self
.name
,
142 "DISTRO_SNAME" : self
.sname
,
143 "DISTRO_VERSION" : self
.version
,
144 "DISTRO_RELEASE" : self
.release
,
145 "DISTRO_DISTTAG" : self
.dist
,
146 "DISTRO_ARCH" : self
.arch
,
147 "DISTRO_MACHINE" : self
.machine
,
148 "DISTRO_BUILDTARGET" : self
.buildtarget
,
149 "DISTRO_MAINTAINER" : self
.maintainer
,
150 "DISTRO_VENDOR" : self
.vendor
,
151 "DISTRO_SLOGAN" : self
.slogan
,
160 for k
, v
in self
.environ
.items():
166 def personality(self
):
168 Return the personality of the target system.
170 If host and target system are of the same architecture, we return
171 None to skip the setting of the personality in the build chroot.
174 if self
.arch
== self
.config
.host_arch
:
178 "x86_64" : "linux64",
184 return arch2personality
[self
.arch
]