From 50a517b957177a2ed114d902c4a47110571133be Mon Sep 17 00:00:00 2001 From: Dave Abrahams Date: Sun, 19 Feb 2012 11:45:22 -1000 Subject: [PATCH] Add support.uname to be used in lieu of arch._uname 0compile is written to assume zeroinstall.injector.arch._uname has four elements, but on Windows, it doesn't. support.uname, however, always has four elements. Ultimately, this should probably be handled in zeroinstall.injector.arch, e.g. by using platform.uname. Without modifying the zeroinstall source, though, this is a good workaround. Add support.uname to be used in lieu of arch._uname --- autocompile.py | 6 +++--- build.py | 3 +-- support.py | 11 +++++++++-- 3 files changed, 13 insertions(+), 7 deletions(-) diff --git a/autocompile.py b/autocompile.py index e6cff0f..c183c28 100644 --- a/autocompile.py +++ b/autocompile.py @@ -10,7 +10,7 @@ from zeroinstall.injector import arch, handler, policy, model, iface_cache, sele from zeroinstall.zerostore import manifest, NotStored from zeroinstall.support import tasks, basedir, ro_rmtree -from support import BuildEnv +from support import BuildEnv, uname # This is a bit hacky... # @@ -19,7 +19,7 @@ from support import BuildEnv # binaries either. This means that we always prefer an existing binary of the # desired version to compiling a new one, but we'll compile a new version from source # rather than use an older binary. -arch.machine_groups['newbuild'] = arch.machine_groups.get(arch._uname[-1], 0) +arch.machine_groups['newbuild'] = arch.machine_groups.get(uname[-1], 0) arch.machine_ranks['newbuild'] = max(arch.machine_ranks.values()) + 1 host_arch = '*-newbuild' @@ -125,7 +125,7 @@ class AutoCompiler: tasks.check(download_missing) version = s.selections[policy.root].version - local_feed = os.path.join(local_feed_dir, '%s-%s-%s.xml' % (buildenv.iface_name, version, arch._uname[-1])) + local_feed = os.path.join(local_feed_dir, '%s-%s-%s.xml' % (buildenv.iface_name, version, uname[-1])) if os.path.exists(local_feed): if not valid_autocompile_feed(local_feed): os.unlink(local_feed) diff --git a/build.py b/build.py index 5248237..5279a8f 100644 --- a/build.py +++ b/build.py @@ -12,7 +12,7 @@ from zeroinstall import SafeException from zeroinstall.injector import model, namespaces, run from zeroinstall.injector.iface_cache import iface_cache -from support import BuildEnv, ensure_dir, XMLNS_0COMPILE, is_package_impl, parse_bool, depth +from support import BuildEnv, ensure_dir, XMLNS_0COMPILE, is_package_impl, parse_bool, depth, uname from support import spawn_and_check, find_in_path, ENV_FILE, lookup, spawn_maybe_sandboxed, Prefixes # If we have to modify any pkg-config files, we put the new versions in $TMPDIR/PKG_CONFIG_OVERRIDES @@ -183,7 +183,6 @@ def do_build_internal(options, args): info.setAttributeNS(None, 'time', time.strftime('%Y-%m-%d %H:%M').strip()) info.setAttributeNS(None, 'host', socket.getfqdn()) info.setAttributeNS(None, 'user', getpass.getuser()) - uname = os.uname() info.setAttributeNS(None, 'arch', '%s-%s' % (uname[0], uname[4])) stream = file(build_env_xml, 'w') buildenv_doc.writexml(stream, addindent=" ", newl="\n") diff --git a/support.py b/support.py index cde5da2..dd60396 100644 --- a/support.py +++ b/support.py @@ -7,7 +7,7 @@ from os.path import join from logging import info import ConfigParser -from zeroinstall.injector import model, selections, qdom +from zeroinstall.injector import model, selections, qdom, arch from zeroinstall.injector.arch import canonicalize_os, canonicalize_machine from zeroinstall.injector.iface_cache import iface_cache @@ -16,6 +16,14 @@ from zeroinstall.zerostore import Store, NotStored def _(x): return x + +# This is An os.uname() substitute that uses as much of ZI's +# arch._uname as is available and yet has all four elements one +# normally expects from os.uname() on Posix (on Windows, arch._uname +# has only two elements). +import platform +uname = arch._uname + platform.uname()[len(arch._uname):] + ENV_FILE = '0compile.properties' XMLNS_0COMPILE = 'http://zero-install.sourceforge.net/2006/namespaces/0compile' @@ -147,7 +155,6 @@ def exec_maybe_sandboxed(readable, writable, tmpdir, prog, args): os.execl(_pola_run, _pola_run, *pola_args) def get_arch_name(): - uname = os.uname() target_os = canonicalize_os(uname[0]) target_machine = canonicalize_machine(uname[4]) if target_os == 'Darwin' and target_machine == 'i386': -- 2.11.4.GIT