From d64eca6379dda83560044b5d949d60b54b908411 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Karel=20Ko=C4=8D=C3=AD?= Date: Wed, 19 Aug 2015 14:58:36 +0200 Subject: Added dirty repository check Test run and initialization now shows warning about dirty repository and loop can't be executed if linux or root repository is dirty. --- scripts/exceptions.py | 6 ++++++ scripts/initialize.py | 4 ++++ scripts/loop.py | 1 + scripts/test.py | 5 +++++ scripts/utils.py | 11 +++++++++++ 5 files changed, 27 insertions(+) diff --git a/scripts/exceptions.py b/scripts/exceptions.py index ac7f093..649c235 100644 --- a/scripts/exceptions.py +++ b/scripts/exceptions.py @@ -42,3 +42,9 @@ class ProcessFailed(Exception): class DatabaseUninitialized(Exception): def __str__(self): return "Database seems to be uninitialized." + +class DirtyRepository(Exception): + def __init__(self, repo): + self.repo = repo + def __str__(self): + return "Detected dirty repository: " + self.repo diff --git a/scripts/initialize.py b/scripts/initialize.py index ff891f8..745f822 100755 --- a/scripts/initialize.py +++ b/scripts/initialize.py @@ -11,6 +11,10 @@ from conf import sf import exceptions def all(): + try: + utils.dirtycheck() + except exceptions.DirtyRepository as e: + print("Warning: " + str(e)) base() parse_kconfig() gen_fixed() diff --git a/scripts/loop.py b/scripts/loop.py index 380f191..0f0aa8c 100755 --- a/scripts/loop.py +++ b/scripts/loop.py @@ -102,6 +102,7 @@ def sigterm_handler(_signo, _stack_frame): __terminate__ = True def loop(): + utils.dirtycheck() initialize.all() global thr thr = mainThread() diff --git a/scripts/test.py b/scripts/test.py index f0eee8e..ce0b698 100755 --- a/scripts/test.py +++ b/scripts/test.py @@ -8,8 +8,13 @@ import initialize import kernel import boot import database +import exceptions def test(): + try: + utils.dirtycheck() + except exceptions.DirtyRepository as e: + print("Warning: " + str(e)) initialize.base() print("-- Make --") conf.kernel_make_output = True diff --git a/scripts/utils.py b/scripts/utils.py index af98fce..4260cc9 100644 --- a/scripts/utils.py +++ b/scripts/utils.py @@ -67,3 +67,14 @@ def get_kernel_env(): env = dict(os.environ) env.update(conf.kernel_env) return env + +def __dirty_repo__(path): + cwd = os.getcwd() + os.chdir(conf.absroot) + out = subprocess.check_output(conf.git_describe_cmd) + if re.search('dirty', out.decode(sys.getdefaultencoding())): + raise exceptions.DirtyRepository(path) + +def dirtycheck(): + __dirty_repo__(conf.absroot) + __dirty_repo__(conf.linux_sources) -- cgit v1.2.3