From 6c4c284968b0d541ffca465f9116ec842d711f77 Mon Sep 17 00:00:00 2001 From: Sam Thursfield Date: Sat, 20 Feb 2016 11:38:51 +0000 Subject: Creation of Baserock definitions format specification repo This contains: - textual description of the Baserock definitions format, and the list of changes since version 0, taken from: git://baserock.branchable.com/ - migrations and schemas taken from git://git.baserock.org/baserock/baserock/definitions. --- migrations/007-defaults-in-definitions.py | 67 +++++++++++++++++++++++++++++++ 1 file changed, 67 insertions(+) create mode 100755 migrations/007-defaults-in-definitions.py (limited to 'migrations/007-defaults-in-definitions.py') diff --git a/migrations/007-defaults-in-definitions.py b/migrations/007-defaults-in-definitions.py new file mode 100755 index 0000000..489baf9 --- /dev/null +++ b/migrations/007-defaults-in-definitions.py @@ -0,0 +1,67 @@ +#!/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 7. + +Definitions version 7 adds a file named DEFAULTS which sets the default +build commands and default split rules for the set of definitions in that +repo. + +''' + + +import os +import shutil +import sys +import warnings + +import migrations + + +TO_VERSION = 7 + + + +try: + if migrations.check_definitions_version(TO_VERSION - 1): + if os.path.exists('DEFAULTS'): + warnings.warn( + "DEFAULTS file already exists in these definitions.") + valid = False + else: + shutil.copy( + 'migrations/007-initial-defaults', + 'DEFAULTS') + valid = True + + if valid: + migrations.set_definitions_version(TO_VERSION) + sys.stdout.write("Migration completed successfully.\n") + sys.exit(0) + else: + sys.stderr.write( + "Migration failed due to one or more warnings.\n") + sys.exit(1) + else: + if not os.path.exists('DEFAULTS'): + warnings.warn( + "These definitions are marked as version 7 but there is no " + "DEFAULTS file.") + 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