From 08b60b1721f0e7c0d287980f35872edcc9d2c95c Mon Sep 17 00:00:00 2001 From: Paul Sherwood Date: Sun, 28 Feb 2016 18:40:33 +0000 Subject: Remove migrations - this content is now in baserock/spec.git Change-Id: Icf333b87e3ae5d6e9984d6e534d8b8c0ae15c7a4 --- migrations/001-empty-build-depends.py | 82 ----------------------------------- 1 file changed, 82 deletions(-) delete mode 100755 migrations/001-empty-build-depends.py (limited to 'migrations/001-empty-build-depends.py') diff --git a/migrations/001-empty-build-depends.py b/migrations/001-empty-build-depends.py deleted file mode 100755 index 5d4296d6..00000000 --- a/migrations/001-empty-build-depends.py +++ /dev/null @@ -1,82 +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 . - - -'''Migration to Baserock Definitions format version 1. - -In version 1, the 'build-depends' parameter was made optional. It was -previously mandatory to specify 'build-depends' for a chunk, even if it was an -empty list. - -''' - - -import sys -import warnings - -import migrations - - -TO_VERSION = 1 - - -def check_empty_build_depends(contents, filename): - assert contents['kind'] == 'stratum' - - valid = True - for chunk_ref in contents.get('chunks', []): - if 'build-depends' not in chunk_ref: - chunk_ref_name = chunk_ref.get('name', chunk_ref.get('morph')) - warnings.warn( - "%s:%s has no build-depends field, which " - "is invalid in definitions version 0." % - (contents['name'], chunk_ref_name)) - valid = False - - return valid - - -def remove_empty_build_depends(contents, filename): - assert contents['kind'] == 'stratum' - - changed = False - for chunk_ref in contents.get('chunks', []): - if 'build-depends' in chunk_ref: - if len(chunk_ref['build-depends']) == 0: - del chunk_ref['build-depends'] - changed = True - - return changed - - -try: - if migrations.check_definitions_version(TO_VERSION - 1): - success = migrations.process_definitions( - path='.', kinds=['stratum'], - validate_cb=check_empty_build_depends, - modify_cb=remove_empty_build_depends) - if success: - migrations.set_definitions_version(TO_VERSION) - sys.stdout.write("Migration completed successfully.\n") - sys.exit(0) - else: - sys.stderr.write("Migration failed due to warnings.\n") - sys.exit(1) - 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) -- cgit v1.2.1