diff options
25 files changed, 64 insertions, 173 deletions
diff --git a/morphlib/morph2.py b/morphlib/morph2.py index 73d55d1d..4fdf7ba4 100644 --- a/morphlib/morph2.py +++ b/morphlib/morph2.py @@ -1,4 +1,4 @@ -# Copyright (C) 2012 Codethink Limited +# Copyright (C) 2012-2013 Codethink Limited # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -14,16 +14,19 @@ # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. -import sys -have_python27 = sys.version_info >= (2,7) - -import collections -if not hasattr(collections, 'OrderedDict'): # pragma: no cover - collections.OrderedDict = dict import copy -import json import re +# It is intentional that if collections does not have OrderedDict that +# simplejson is also used in preference to json, as OrderedDict became +# a member of collections in the same release json got its object_pairs_hook +try: # pragma: no cover + from collections import OrderedDict + import json +except ImportError: # pragma: no cover + from ordereddict import OrderedDict + import simplejson as json + class Morphology(object): @@ -58,19 +61,8 @@ class Morphology(object): ] } - if have_python27: # pragma: no cover - @staticmethod - def _order_keys(pairs): - result = collections.OrderedDict() - for k,v in pairs: - result[k] = v - return result - def __init__(self, text): - if have_python27: # pragma: no cover - self._dict = json.loads(text, object_pairs_hook=self._order_keys) - else: # pragma: no cover - self._dict = json.loads(text) + self._dict = json.loads(text, object_pairs_hook=OrderedDict) self._set_defaults() self._validate_children() @@ -158,7 +150,7 @@ class Morphology(object): # Recreate dict without the empty default values, with a few kind # specific hacks to try and edit standard morphologies as # non-destructively as possible - as_dict = collections.OrderedDict() + as_dict = OrderedDict() for key in self.keys(): if self['kind'] == 'stratum' and key == 'chunks': value = copy.copy(self[key]) diff --git a/morphlib/morph2_tests.py b/morphlib/morph2_tests.py index baa6f724..756873a0 100644 --- a/morphlib/morph2_tests.py +++ b/morphlib/morph2_tests.py @@ -1,4 +1,4 @@ -# Copyright (C) 2012 Codethink Limited +# Copyright (C) 2012-2013 Codethink Limited # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -14,9 +14,6 @@ # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. -import sys -have_python27 = sys.version_info >= (2,7) - import StringIO import unittest @@ -202,9 +199,8 @@ class MorphologyTests(unittest.TestCase): Morphology, text) - if have_python27: - def test_writing_preserves_field_order(self): - text = '''{ + def test_writing_preserves_field_order(self): + text = '''{ "kind": "system", "disk-size": 1073741824, "description": "Some text", @@ -223,19 +219,18 @@ class MorphologyTests(unittest.TestCase): } ] }''' - morphology = Morphology(text) - output = StringIO.StringIO() - morphology.write_to_file(output) + morphology = Morphology(text) + output = StringIO.StringIO() + morphology.write_to_file(output) - text_lines = text.splitlines() - output_lines = output.getvalue().splitlines() + text_lines = text.splitlines() + output_lines = output.getvalue().splitlines() - # Verify that input and output are equal. - self.assertEqual(text_lines, output_lines) + # Verify that input and output are equal. + self.assertEqual(text_lines, output_lines) - if have_python27: - def test_writing_stratum_morphology_preserves_chunk_order(self): - text = '''{ + def test_writing_stratum_morphology_preserves_chunk_order(self): + text = '''{ "kind": "stratum", "chunks": [ { @@ -252,30 +247,29 @@ class MorphologyTests(unittest.TestCase): } ] }''' - morphology = Morphology(text) - output = StringIO.StringIO() - morphology.write_to_file(output) + morphology = Morphology(text) + output = StringIO.StringIO() + morphology.write_to_file(output) - text_lines = text.splitlines() - output_lines = output.getvalue().splitlines() + text_lines = text.splitlines() + output_lines = output.getvalue().splitlines() - # Verify that input and output are equal. - self.assertEqual(text_lines, output_lines) + # Verify that input and output are equal. + self.assertEqual(text_lines, output_lines) - if have_python27: - def test_writing_preserves_disk_size(self): - text = '''{ + def test_writing_preserves_disk_size(self): + text = '''{ "kind": "system", "disk-size": "1g", "arch": "x86_64", "system-kind": "syslinux-disk" }''' - morphology = Morphology(text) - output = StringIO.StringIO() - morphology.write_to_file(output) + morphology = Morphology(text) + output = StringIO.StringIO() + morphology.write_to_file(output) - text_lines = text.splitlines() - output_lines = output.getvalue().splitlines() + text_lines = text.splitlines() + output_lines = output.getvalue().splitlines() - # Verify that in- and output are the same. - self.assertEqual(text_lines, output_lines) + # Verify that in- and output are the same. + self.assertEqual(text_lines, output_lines) diff --git a/run-bootstrap-in-chroot b/run-bootstrap-in-chroot index 406eb0b7..20a67c5a 100755 --- a/run-bootstrap-in-chroot +++ b/run-bootstrap-in-chroot @@ -128,6 +128,7 @@ if ! "$snapshot" || ! has_pass pass1a; then EXTRAPACKAGES="build-essential,gawk,bison,flex,python,autoconf" EXTRAPACKAGES="$EXTRAPACKAGES,autopoint,automake,gettext,libtool" EXTRAPACKAGES="$EXTRAPACKAGES,help2man,texinfo,sudo,ccache,gperf" + EXTRAPACKAGES="$EXTRAPACKAGES,python-pip,python-simplejson" EXTRAARGS= if [ -n $ARCH]; then @@ -156,6 +157,7 @@ EOF "./do-squeeze-chroot" \ sh -c 'cd /src/cliapp && "$@"' -- python setup.py install + "./do-squeeze-chroot" pip install ordereddict if "$snapshot" then diff --git a/scripts/python-check b/scripts/python-check deleted file mode 100644 index 6b79897f..00000000 --- a/scripts/python-check +++ /dev/null @@ -1,36 +0,0 @@ -#!/bin/sh -# Copyright (C) 2012 Codethink Limited -# -# This program is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; version 2 of the License. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License along -# with this program; if not, write to the Free Software Foundation, Inc., -# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - -# When sourced by scripts, if the python version is too old -# fake the output and exit. - -if ! python --version 2>&1 | grep '^Python 2\.[78]' > /dev/null -then - outpath="$(dirname "$0")/$(basename "$0" .script).stdout" - errpath="$(dirname "$0")/$(basename "$0" .script).stderr" - exitpath="$(dirname "$0")/$(basename "$0" .script).exit" - if [ -r "$outpath" ]; then - cat "$outpath" - fi - if [ -r "$errpath" ]; then - cat "$errpath" >&2 - fi - if [ -r "$exitpath" ]; then - exit "$(cat "$exitpath")" - else - exit 0 - fi -fi diff --git a/tests.as-root/build-handles-stratum-build-depends.script b/tests.as-root/build-handles-stratum-build-depends.script index 5df90bfc..1d1aa4ee 100755 --- a/tests.as-root/build-handles-stratum-build-depends.script +++ b/tests.as-root/build-handles-stratum-build-depends.script @@ -1,5 +1,5 @@ #!/bin/bash -# Copyright (C) 2012 Codethink Limited +# Copyright (C) 2012-2013 Codethink Limited # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -18,9 +18,6 @@ set -eu -# Disable test on versions of Python before 2.7. -. "$SRCDIR/scripts/python-check" - . "$SRCDIR/tests.as-root/setup-build" cd "$DATADIR/workspace" diff --git a/tests.as-root/build-with-external-strata.script b/tests.as-root/build-with-external-strata.script index c3d84ec6..2d5d0fed 100755 --- a/tests.as-root/build-with-external-strata.script +++ b/tests.as-root/build-with-external-strata.script @@ -1,5 +1,5 @@ #!/bin/bash -# Copyright (C) 2012 Codethink Limited +# Copyright (C) 2012-2013 Codethink Limited # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -19,9 +19,6 @@ set -eu -# Disable test on versions of Python before 2.7. -. "$SRCDIR/scripts/python-check" - . "$SRCDIR/scripts/setup-3rd-party-strata" cd "$DATADIR/workspace" diff --git a/tests.as-root/build-with-push.script b/tests.as-root/build-with-push.script index 554edaaa..55ef54bb 100755 --- a/tests.as-root/build-with-push.script +++ b/tests.as-root/build-with-push.script @@ -1,5 +1,5 @@ #!/bin/bash -# Copyright (C) 2012 Codethink Limited +# Copyright (C) 2012-2013 Codethink Limited # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -19,9 +19,6 @@ set -eu -# Disable test on versions of Python before 2.7. -source "$SRCDIR/scripts/python-check" - source "$SRCDIR/tests.as-root/setup-build" cd "$DATADIR/workspace/branch1" diff --git a/tests.as-root/building-a-system-branch-multiple-times-doesnt-generate-new-artifacts.script b/tests.as-root/building-a-system-branch-multiple-times-doesnt-generate-new-artifacts.script index 7b26e84e..829c3f96 100755 --- a/tests.as-root/building-a-system-branch-multiple-times-doesnt-generate-new-artifacts.script +++ b/tests.as-root/building-a-system-branch-multiple-times-doesnt-generate-new-artifacts.script @@ -1,6 +1,6 @@ #!/bin/bash # -# Copyright (C) 2012 Codethink Limited +# Copyright (C) 2012-2013 Codethink Limited # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -20,9 +20,6 @@ set -eu -# Disable test on versions of Python before 2.7. -source "$SRCDIR/scripts/python-check" - source "$SRCDIR/tests.as-root/setup-build" # Build once. diff --git a/tests.as-root/building-a-system-branch-picks-up-uncommitted-changes.script b/tests.as-root/building-a-system-branch-picks-up-uncommitted-changes.script index 73682736..fa8159cc 100755 --- a/tests.as-root/building-a-system-branch-picks-up-uncommitted-changes.script +++ b/tests.as-root/building-a-system-branch-picks-up-uncommitted-changes.script @@ -1,5 +1,5 @@ #!/bin/bash -# Copyright (C) 2012 Codethink Limited +# Copyright (C) 2012-2013 Codethink Limited # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -20,9 +20,6 @@ set -eu -# Disable test on versions of Python before 2.7. -source "$SRCDIR/scripts/python-check" - source "$SRCDIR/tests.as-root/setup-build" # Build the linux system from the system branch. diff --git a/tests.as-root/building-a-system-branch-works-anywhere.script b/tests.as-root/building-a-system-branch-works-anywhere.script index 3f96e00e..87b49199 100755 --- a/tests.as-root/building-a-system-branch-works-anywhere.script +++ b/tests.as-root/building-a-system-branch-works-anywhere.script @@ -1,6 +1,6 @@ #!/bin/bash # -# Copyright (C) 2012 Codethink Limited +# Copyright (C) 2012-2013 Codethink Limited # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -21,9 +21,6 @@ set -eu -# Disable test on versions of Python before 2.7. -source "$SRCDIR/scripts/python-check" - source "$SRCDIR/tests.as-root/setup-build" # Build from the workspace root. diff --git a/tests.as-root/rootfs-tarball-builds-rootfs-and-kernel.script b/tests.as-root/rootfs-tarball-builds-rootfs-and-kernel.script index 8bf25dee..088e6925 100755 --- a/tests.as-root/rootfs-tarball-builds-rootfs-and-kernel.script +++ b/tests.as-root/rootfs-tarball-builds-rootfs-and-kernel.script @@ -1,6 +1,6 @@ #!/bin/sh # -# Copyright (C) 2011, 2012 Codethink Limited +# Copyright (C) 2011, 2012, 2013 Codethink Limited # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -21,8 +21,6 @@ set -eu -. "$SRCDIR/scripts/python-check" - cache="$DATADIR/cache/artifacts" arch=$(uname -m) diff --git a/tests.as-root/tarball-image-is-sensible.script b/tests.as-root/tarball-image-is-sensible.script index 46510252..2a9044b7 100755 --- a/tests.as-root/tarball-image-is-sensible.script +++ b/tests.as-root/tarball-image-is-sensible.script @@ -1,6 +1,6 @@ #!/bin/sh # -# Copyright (C) 2012 Codethink Limited +# Copyright (C) 2012-2013 Codethink Limited # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -21,8 +21,6 @@ set -eu -. "$SRCDIR/scripts/python-check" - . "$SRCDIR/scripts/fix-committer-info" tar=$("$SRCDIR/scripts/test-morph" --find-system-artifact \ diff --git a/tests.as-root/unimportant-morphology-contents-do-not-change-cache-keys.script b/tests.as-root/unimportant-morphology-contents-do-not-change-cache-keys.script index 27adf8c6..44b261d2 100755 --- a/tests.as-root/unimportant-morphology-contents-do-not-change-cache-keys.script +++ b/tests.as-root/unimportant-morphology-contents-do-not-change-cache-keys.script @@ -1,6 +1,6 @@ #!/bin/bash # -# Copyright (C) 2012 Codethink Limited +# Copyright (C) 2012-2013 Codethink Limited # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -23,9 +23,6 @@ set -eu -# Disable test on versions of Python before 2.7. -source "$SRCDIR/scripts/python-check" - source "$SRCDIR/tests.as-root/setup-build" # Build once. diff --git a/tests.branching/ambiguous-refs.script b/tests.branching/ambiguous-refs.script index 0ea8a55f..cce7b52e 100755 --- a/tests.branching/ambiguous-refs.script +++ b/tests.branching/ambiguous-refs.script @@ -1,6 +1,6 @@ #!/bin/sh # -# Copyright (C) 2012 Codethink Limited +# Copyright (C) 2012-2013 Codethink Limited # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -23,9 +23,6 @@ set -eu -# Disable test on versions of Python before 2.7. -. "$SRCDIR/scripts/python-check" - . "$SRCDIR/scripts/fix-committer-info" cd "$DATADIR/morphs" diff --git a/tests.branching/edit-updates-stratum-build-depends.script b/tests.branching/edit-updates-stratum-build-depends.script index 525822c9..83d5e2a4 100755 --- a/tests.branching/edit-updates-stratum-build-depends.script +++ b/tests.branching/edit-updates-stratum-build-depends.script @@ -1,6 +1,6 @@ #!/bin/sh # -# Copyright (C) 2012 Codethink Limited +# Copyright (C) 2012-2013 Codethink Limited # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -20,9 +20,6 @@ set -eu -# Disable test on versions of Python before 2.7. -. "$SRCDIR/scripts/python-check" - # Add a second stratum that build-depends on the first. We can ignore the fact # that both strata contain the same chunk for this test. cd "$DATADIR/morphs" diff --git a/tests.branching/edit-updates-stratum.script b/tests.branching/edit-updates-stratum.script index c2716cab..bfe16c8b 100755 --- a/tests.branching/edit-updates-stratum.script +++ b/tests.branching/edit-updates-stratum.script @@ -1,6 +1,6 @@ #!/bin/sh # -# Copyright (C) 2012 Codethink Limited +# Copyright (C) 2012-2013 Codethink Limited # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -20,9 +20,6 @@ set -eu -# Disable test on versions of Python before 2.7. -. "$SRCDIR/scripts/python-check" - # Create system branch. cd "$DATADIR/workspace" "$SRCDIR/scripts/test-morph" init diff --git a/tests.branching/petrify-no-double-petrify.script b/tests.branching/petrify-no-double-petrify.script index 25c977b6..c263e590 100755 --- a/tests.branching/petrify-no-double-petrify.script +++ b/tests.branching/petrify-no-double-petrify.script @@ -1,6 +1,6 @@ #!/bin/sh # -# Copyright (C) 2012 Codethink Limited +# Copyright (C) 2012-2013 Codethink Limited # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -21,9 +21,6 @@ set -eu -# Disable test on versions of Python before 2.7. -. "$SRCDIR/scripts/python-check" - cd "$DATADIR/workspace" "$SRCDIR/scripts/test-morph" init "$SRCDIR/scripts/test-morph" branch test:morphs test/petrify diff --git a/tests.branching/petrify.script b/tests.branching/petrify.script index 6b6581d3..76c906c3 100755 --- a/tests.branching/petrify.script +++ b/tests.branching/petrify.script @@ -1,6 +1,6 @@ #!/bin/sh # -# Copyright (C) 2012 Codethink Limited +# Copyright (C) 2012-2013 Codethink Limited # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -21,9 +21,6 @@ set -eu -# Disable test on versions of Python before 2.7. -. "$SRCDIR/scripts/python-check" - . "$SRCDIR/tests.branching/setup-second-chunk" cd "$DATADIR/workspace" diff --git a/tests.branching/workflow-petrify.script b/tests.branching/workflow-petrify.script index b84dd977..79279340 100755 --- a/tests.branching/workflow-petrify.script +++ b/tests.branching/workflow-petrify.script @@ -1,6 +1,6 @@ #!/bin/sh # -# Copyright (C) 2012 Codethink Limited +# Copyright (C) 2012-2013 Codethink Limited # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -21,9 +21,6 @@ set -eu -# Disable test on versions of Python before 2.7. -. "$SRCDIR/scripts/python-check" - . "$SRCDIR/scripts/setup-3rd-party-strata" cd "$DATADIR/workspace" diff --git a/tests.merging/basic.script b/tests.merging/basic.script index 0dbc2367..6d01ba16 100755 --- a/tests.merging/basic.script +++ b/tests.merging/basic.script @@ -1,6 +1,6 @@ #!/bin/sh # -# Copyright (C) 2012 Codethink Limited +# Copyright (C) 2012-2013 Codethink Limited # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -21,9 +21,6 @@ set -eu -# Disable test on versions of Python before 2.7. -. "$SRCDIR/scripts/python-check" - cd "$DATADIR/workspace" "$SRCDIR/scripts/test-morph" init diff --git a/tests.merging/conflict-chunks.script b/tests.merging/conflict-chunks.script index e5f6618d..5a0c5f52 100755 --- a/tests.merging/conflict-chunks.script +++ b/tests.merging/conflict-chunks.script @@ -1,6 +1,6 @@ #!/bin/sh # -# Copyright (C) 2012 Codethink Limited +# Copyright (C) 2012-2013 Codethink Limited # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -21,9 +21,6 @@ set -eu -# Disable test on versions of Python before 2.7. -. "$SRCDIR/scripts/python-check" - . "$SRCDIR/scripts/setup-3rd-party-strata" # Create stable branch to merge TO diff --git a/tests.merging/conflict-stratum-field-ordering.script b/tests.merging/conflict-stratum-field-ordering.script index f5bfb4b8..c96c59ab 100755 --- a/tests.merging/conflict-stratum-field-ordering.script +++ b/tests.merging/conflict-stratum-field-ordering.script @@ -1,6 +1,6 @@ #!/bin/sh # -# Copyright (C) 2012 Codethink Limited +# Copyright (C) 2012-2013 Codethink Limited # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -26,9 +26,6 @@ set -eu -# Disable test on versions of Python before 2.7. -. "$SRCDIR/scripts/python-check" - cd "$DATADIR/workspace" "$SRCDIR/scripts/test-morph" init diff --git a/tests.merging/move-chunk-repo.script b/tests.merging/move-chunk-repo.script index 7b96bc81..3a00015b 100755 --- a/tests.merging/move-chunk-repo.script +++ b/tests.merging/move-chunk-repo.script @@ -1,6 +1,6 @@ #!/bin/sh # -# Copyright (C) 2012 Codethink Limited +# Copyright (C) 2012-2013 Codethink Limited # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -21,9 +21,6 @@ set -eu -# Disable test on versions of Python before 2.7. -. "$SRCDIR/scripts/python-check" - # Create system branch. cd "$DATADIR/workspace" "$SRCDIR/scripts/test-morph" init diff --git a/tests.merging/rename-chunk.script b/tests.merging/rename-chunk.script index ef4c96a2..8c323798 100755 --- a/tests.merging/rename-chunk.script +++ b/tests.merging/rename-chunk.script @@ -1,6 +1,6 @@ #!/bin/sh # -# Copyright (C) 2012 Codethink Limited +# Copyright (C) 2012-2013 Codethink Limited # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -21,9 +21,6 @@ set -eu -# Disable test on versions of Python before 2.7. -. "$SRCDIR/scripts/python-check" - # Create system branch. cd "$DATADIR/workspace" "$SRCDIR/scripts/test-morph" init diff --git a/tests.merging/rename-stratum.script b/tests.merging/rename-stratum.script index c5c92823..ba759fa3 100755 --- a/tests.merging/rename-stratum.script +++ b/tests.merging/rename-stratum.script @@ -1,6 +1,6 @@ #!/bin/sh # -# Copyright (C) 2012 Codethink Limited +# Copyright (C) 2012-2013 Codethink Limited # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -21,9 +21,6 @@ set -eu -# Disable test on versions of Python before 2.7. -. "$SRCDIR/scripts/python-check" - # Create system branch. cd "$DATADIR/workspace" "$SRCDIR/scripts/test-morph" init |