aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlice Ferrazzi <alicef@gentoo.org>2017-07-11 21:47:02 +0900
committerAlice Ferrazzi <alicef@gentoo.org>2017-07-11 21:47:02 +0900
commit2d57e7fdba810b7c076c1db6f1562e1854a3d1ab (patch)
tree4bd3b3c4ec9918970da65333db09d7caabb4c209
parentadd livepatch in uuid subdirectories for divide builded livepatch (diff)
downloadelivepatch-2d57e7fdba810b7c076c1db6f1562e1854a3d1ab.tar.gz
elivepatch-2d57e7fdba810b7c076c1db6f1562e1854a3d1ab.tar.bz2
elivepatch-2d57e7fdba810b7c076c1db6f1562e1854a3d1ab.zip
small directories fixes
-rw-r--r--elivepatch_server/resources/dispatcher.py19
-rw-r--r--elivepatch_server/resources/livepatch.py10
2 files changed, 13 insertions, 16 deletions
diff --git a/elivepatch_server/resources/dispatcher.py b/elivepatch_server/resources/dispatcher.py
index c9478ed..d16975d 100644
--- a/elivepatch_server/resources/dispatcher.py
+++ b/elivepatch_server/resources/dispatcher.py
@@ -31,7 +31,7 @@ packs = {
def set_kernel_dir(uuid, kernel_ID):
kernel_absolute_path = 'linux-' + str(kernel_ID) + '-gentoo'
- kernel_path = os.path.join('/tmp/', 'elivepatch-' + uuid, '/usr/', 'src', kernel_absolute_path)
+ kernel_path = os.path.join('/tmp/', 'elivepatch-' + uuid, 'usr', 'src', kernel_absolute_path)
lpatch.set_kernel_dir(kernel_path)
lpatch = PaTch()
@@ -65,18 +65,14 @@ class BuildLivePatch(Resource):
print('UserID: ' + str(args['UserID']))
if args['KernelVersion']:
set_kernel_dir(args['UserID'], args['KernelVersion'])
- kernel_dir = lpatch.get_kernel_dir()
kernel_config = lpatch.get_config()
kernel_patch = lpatch.get_patch()
if kernel_config and kernel_patch:
lpatch.set_lp_status('working')
print("build livepatch: " + str(args))
# check vmlinux presence if not rebuild the kernel
- kernel_vmlinux = os.path.join(kernel_dir, 'vmlinux')
lpatch.get_kernel_sources(args['UserID'], args['KernelVersion'])
- if not os.path.isfile(kernel_vmlinux):
- lpatch.build_kernel(args['UserID'])
- lpatch.build_livepatch(args['UserID'], kernel_vmlinux)
+ lpatch.build_livepatch(args['UserID'], 'vmlinux')
pack = {
'id': packs['id'] + 1,
'KernelVersion': args['KernelVersion'],
@@ -108,13 +104,10 @@ class SendLivePatch(Resource):
else:
print('UserID: ' + str(args['UserID']))
# Getting livepatch build status
- status = lpatch.update_lp_status("kpatch-1.ko")
- if status == 'done':
- with open('kpatch-1.ko', 'rb') as fp:
- response = make_response(fp.read())
- response.headers['content-type'] = 'application/octet-stream'
- return response
- return {'packs': [marshal(pack, pack_fields) for pack in packs]}
+ with open('kpatch-1.ko', 'rb') as fp:
+ response = make_response(fp.read())
+ response.headers['content-type'] = 'application/octet-stream'
+ return response
def post(self):
return make_response(jsonify({'message': 'These are not the \
diff --git a/elivepatch_server/resources/livepatch.py b/elivepatch_server/resources/livepatch.py
index 7be51a9..703a807 100644
--- a/elivepatch_server/resources/livepatch.py
+++ b/elivepatch_server/resources/livepatch.py
@@ -71,7 +71,7 @@ class PaTch(object):
# kpatch-build/kpatch-build -s /usr/src/linux-4.9.16-gentoo/
# -v /usr/src/linux-4.9.16-gentoo/vmlinux examples/test.patch
# -c ../elivepatch/elivepatch_server/config --skip-gcc-check
- def build_livepatch(self, uuid_dir, vmlinux):
+ def build_livepatch(self, uuid, vmlinux):
"""
Function for building the livepatch
@@ -79,11 +79,14 @@ class PaTch(object):
:param vmlinux: path to the vmlinux file
:return: void
"""
- kernel_source = '/tmp/elivepatch-' + uuid_dir + '/usr/src/linux/'
+ kernel_source = os.path.join('/tmp/','elivepatch-' + uuid, 'usr/src/linux/')
+ vmlinux_source = os.path.join(kernel_source, vmlinux)
+ if not os.path.isfile(vmlinux_source):
+ self.build_kernel(uuid)
debug=True
bashCommand = ['sudo','kpatch-build']
bashCommand.extend(['-s',kernel_source])
- bashCommand.extend(['-v',vmlinux])
+ bashCommand.extend(['-v',vmlinux_source])
bashCommand.extend(['-c',self.config_file])
bashCommand.extend([self.patch_file])
bashCommand.extend(['--skip-gcc-check'])
@@ -107,6 +110,7 @@ class PaTch(object):
def build_kernel(self, uuid_dir):
kernel_source_dir = '/tmp/elivepatch-' + uuid_dir + '/usr/src/linux/'
+ command(['sudo','cp','/tmp/elivepatch-' + uuid_dir + '/.config',kernel_source_dir + '.config'])
command(['sudo','make','oldconfig'], kernel_source_dir)
command(['sudo','make'], kernel_source_dir)
command(['sudo','make', 'modules'], kernel_source_dir)