[jhbuild/desrt/master: 7/35] sysid: handle condition sets
- From: Ryan Lortie <desrt src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [jhbuild/desrt/master: 7/35] sysid: handle condition sets
- Date: Sun, 4 Jan 2015 04:30:07 +0000 (UTC)
commit 5906afa5715fae38c48254081fcb532ed92d5703
Author: Ryan Lortie <desrt desrt ca>
Date: Fri Jan 2 09:56:54 2015 -0500
sysid: handle condition sets
Move the determination of the default conditions for the system to a
better home in the sysid module. Add conditions for the ID and ID_LIKE
that we find in the os-release file. That means, for example, that an
Ubuntu system will end up with "debian" and "ubuntu" conditions set by
default.
https://bugzilla.gnome.org/show_bug.cgi?id=742267
jhbuild/config.py | 27 ++-------------------------
jhbuild/utils/sysid.py | 34 ++++++++++++++++++++++++++++++++++
2 files changed, 36 insertions(+), 25 deletions(-)
---
diff --git a/jhbuild/config.py b/jhbuild/config.py
index 81c7797..613a9ce 100644
--- a/jhbuild/config.py
+++ b/jhbuild/config.py
@@ -31,6 +31,7 @@ import __builtin__
from jhbuild.environment import setup_env, setup_env_defaults, addpath
from jhbuild.errors import FatalError
+from jhbuild.utils import sysid
if sys.platform.startswith('win'):
# For munging paths for MSYS's benefit
@@ -79,30 +80,6 @@ def parse_relative_time(s):
else:
raise ValueError
-def get_default_conditions():
- # the default conditions set. We determine which set to used based on
- # the first item in the list which is a prefix of 'sys.platform', which
- # is a name like 'linux2', 'darwin', 'freebsd10', etc.
- #
- # if we watch to match (eg 'freebsd10' more closely than other versions
- # of 'freebsd') then we just need to make sure the more-specific one
- # comes first in the list
- conditions_sets = [
- ('linux', ['linux', 'wayland', 'udev', 'x11', 'systemd', 'gnu-elf']),
- ('freebsd', ['freebsd', 'x11', 'bsd', 'gnu-elf']),
- ('darwin', ['darwin', 'macos', 'quartz']),
-
- # this must be left here so that at least one will be found
- ('', ['x11'])
- ]
-
- for prefix, flags in conditions_sets:
- if sys.platform.startswith(prefix):
- return set(flags)
-
- # we will only hit this if someone removed the '' entry above
- raise FatalError('failed to find matching condition set...')
-
def modify_conditions(conditions, conditions_modifiers):
for flag in conditions_modifiers:
for mod in flag.split(','):
@@ -183,7 +160,7 @@ class Config:
# on it to set new autogenargs, for example) but also so that the
# condition flags given on the commandline will ultimately override
# those in jhbuildrc.
- self._config['conditions'] = get_default_conditions()
+ self._config['conditions'] = sysid.get_default_conditions()
modify_conditions(self._config['conditions'], conditions_modifiers)
self.load(filename)
modify_conditions(self.conditions, conditions_modifiers)
diff --git a/jhbuild/utils/sysid.py b/jhbuild/utils/sysid.py
index 2cf784f..04bc224 100644
--- a/jhbuild/utils/sysid.py
+++ b/jhbuild/utils/sysid.py
@@ -23,8 +23,10 @@ import ast
sys_id = None
sys_name = None
+default_conditions = None
def read_os_release():
+ global default_conditions
global sys_name
global sys_id
@@ -69,6 +71,11 @@ def read_os_release():
# fall back
sys_name = fields['ID'] + ' ' + fields['VERSION_ID']
+ default_conditions.add(fields['ID'])
+
+ if 'ID_LIKE' in fields:
+ default_conditions.union(fields['ID_LIKE'].split(' '))
+
return True
def get_macos_info():
@@ -87,12 +94,34 @@ def get_macos_info():
return False
def ensure_loaded():
+ global default_conditions
global sys_name
global sys_id
if sys_id is not None:
return
+ # the default conditions set. We determine which set to used based on
+ # the first item in the list which is a prefix of 'sys.platform', which
+ # is a name like 'linux2', 'darwin', 'freebsd10', etc.
+ #
+ # if we watch to match (eg 'freebsd10' more closely than other versions
+ # of 'freebsd') then we just need to make sure the more-specific one
+ # comes first in the list
+ conditions_sets = [
+ ('linux', ['linux', 'wayland', 'udev', 'x11', 'systemd', 'gnu-elf']),
+ ('freebsd', ['freebsd', 'x11', 'bsd', 'gnu-elf']),
+ ('darwin', ['darwin', 'macos', 'quartz']),
+
+ # this must be left here so that at least one will be found
+ ('', ['x11'])
+ ]
+
+ for prefix, flags in conditions_sets:
+ if sys.platform.startswith(prefix):
+ default_conditions = set(flags)
+ break
+
# our first choice is to use os-release info
if read_os_release():
return
@@ -123,3 +152,8 @@ def get_pretty_name():
ensure_loaded()
return sys_name
+
+def get_default_conditions():
+ ensure_loaded()
+
+ return default_conditions
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]