summaryrefslogtreecommitdiff
path: root/migrations/002-missing-chunk-morphs.py
diff options
context:
space:
mode:
authorPaul Sherwood <paul.sherwood@codethink.co.uk>2016-02-28 18:40:33 +0000
committerBaserock Gerrit <gerrit@baserock.org>2016-03-01 10:23:16 +0000
commit08b60b1721f0e7c0d287980f35872edcc9d2c95c (patch)
tree08fe0cc230bef5bbe01f90f242453ab387c2ae95 /migrations/002-missing-chunk-morphs.py
parent9eb70b9f20fe79ff7509993d735b742cf956f5c6 (diff)
downloaddefinitions-08b60b1721f0e7c0d287980f35872edcc9d2c95c.tar.gz
Remove migrations - this content is now in baserock/spec.git
Change-Id: Icf333b87e3ae5d6e9984d6e534d8b8c0ae15c7a4
Diffstat (limited to 'migrations/002-missing-chunk-morphs.py')
-rwxr-xr-xmigrations/002-missing-chunk-morphs.py73
1 files changed, 0 insertions, 73 deletions
diff --git a/migrations/002-missing-chunk-morphs.py b/migrations/002-missing-chunk-morphs.py
deleted file mode 100755
index 2c93804e..00000000
--- a/migrations/002-missing-chunk-morphs.py
+++ /dev/null
@@ -1,73 +0,0 @@
-#!/usr/bin/env python
-# Copyright (C) 2015 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, see <http://www.gnu.org/licenses/>.
-
-
-'''Migration to Baserock Definitions format version 2.
-
-In version 2, the processing of the 'morph:' field within stratum .morph files
-became more strict. This migration checks whether definitions are valid
-according to version 2 of the format.
-
-'''
-
-
-import os
-import sys
-import warnings
-
-import migrations
-
-
-TO_VERSION = 2
-
-
-def check_missing_chunk_morphs(contents, filename):
- assert contents['kind'] == 'stratum'
-
- valid = True
-
- for chunk_ref in contents.get('chunks', []):
- if 'morph' in chunk_ref:
- chunk_path = os.path.join('.', chunk_ref['morph'])
- if not os.path.exists(chunk_path):
- # There's no way we can really fix this, so
- # just warn and say the migration failed.
- warnings.warn(
- "%s points to non-existant file %s" %
- (contents['name'], chunk_ref['morph']))
- valid = False
-
- return valid
-
-
-try:
- if migrations.check_definitions_version(TO_VERSION - 1):
- safe_to_migrate = migrations.process_definitions(
- kinds=['stratum'], validate_cb=check_missing_chunk_morphs)
-
- if not safe_to_migrate:
- sys.stderr.write(
- "Migration failed due to one or more warnings.\n")
- sys.exit(1)
- else:
- migrations.set_definitions_version(TO_VERSION)
- sys.stdout.write("Migration completed successfully.\n")
- sys.exit(0)
- else:
- sys.stdout.write("Nothing to do.\n")
- sys.exit(0)
-except RuntimeError as e:
- sys.stderr.write("Error: %s\n" % e.message)
- sys.exit(1)