config: set USERLAND if unset
authorZac Medico <zmedico@gentoo.org>
Mon, 12 Sep 2011 01:38:06 +0000 (18:38 -0700)
committerZac Medico <zmedico@gentoo.org>
Mon, 12 Sep 2011 01:38:06 +0000 (18:38 -0700)
pym/portage/package/ebuild/config.py

index 8cca0ef25db0f8c22c5ce9689991229c5525fd66..bf888948184df7bff4d61d1eed81d71b6b10ccca 100644 (file)
@@ -8,6 +8,7 @@ __all__ = [
 import copy
 from itertools import chain
 import logging
+import platform
 import re
 import sys
 import warnings
@@ -687,6 +688,18 @@ class config(object):
                                self["CBUILD"] = self["CHOST"]
                                self.backup_changes("CBUILD")
 
+                       if "USERLAND" not in self:
+                               # Set default USERLAND so that our test cases can assume that
+                               # it's always set. This allows isolated-functions.sh to avoid
+                               # calling uname -s when sourced.
+                               system = platform.system()
+                               if system is not None and \
+                                       (system.endswith("BSD") or system == "DragonFly"):
+                                       self["USERLAND"] = "BSD"
+                               else:
+                                       self["USERLAND"] = "GNU"
+                               self.backup_changes("USERLAND")
+
                        self["PORTAGE_BIN_PATH"] = PORTAGE_BIN_PATH
                        self.backup_changes("PORTAGE_BIN_PATH")
                        self["PORTAGE_PYM_PATH"] = PORTAGE_PYM_PATH