From b4ad5a64ae2717658a484666b3adc12bb31cf354 Mon Sep 17 00:00:00 2001 From: Alice Ferrazzi Date: Mon, 24 Jul 2017 11:21:14 +0900 Subject: catch gentoo-sources not available error --- elivepatch_server/resources/dispatcher.py | 4 +++- elivepatch_server/resources/livepatch.py | 3 +++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/elivepatch_server/resources/dispatcher.py b/elivepatch_server/resources/dispatcher.py index d470cd7..70a62d7 100644 --- a/elivepatch_server/resources/dispatcher.py +++ b/elivepatch_server/resources/dispatcher.py @@ -72,7 +72,9 @@ class BuildLivePatch(Resource): if args['KernelVersion']: print("build livepatch: " + str(args)) # check vmlinux presence if not rebuild the kernel - lpatch.get_kernel_sources(args['UUID'], args['KernelVersion']) + kernel_sources_status = lpatch.get_kernel_sources(args['UUID'], args['KernelVersion']) + if not kernel_sources_status: + return make_response(jsonify({'message': 'gentoo-sources not available'}), 403) lpatch.build_livepatch(args['UUID'], 'vmlinux') pack = { 'id': packs['id'] + 1, diff --git a/elivepatch_server/resources/livepatch.py b/elivepatch_server/resources/livepatch.py index 46c6fab..bba1491 100644 --- a/elivepatch_server/resources/livepatch.py +++ b/elivepatch_server/resources/livepatch.py @@ -60,8 +60,11 @@ class PaTch(object): print(ebuild_path) if os.path.isfile(ebuild_path): command(['sudo', 'ROOT=/tmp/elivepatch-' + uuid, 'ebuild', ebuild_path, 'clean', 'merge']) + kernel_sources_status = True else: print('ebuild not present') + kernel_sources_status = None + return kernel_sources_status def build_kernel(self, uuid): kernel_source_dir = '/tmp/elivepatch-' + uuid + '/usr/src/linux/' -- cgit v1.2.3-65-gdbad