aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlice Ferrazzi <alicef@gentoo.org>2017-07-11 20:58:17 +0900
committerAlice Ferrazzi <alicef@gentoo.org>2017-07-11 20:58:17 +0900
commita5d0026bc509a45fdc212fd68dfbcdf43f0f2d3c (patch)
treed09dfb083907372a9b2fd7a5c13766aff5d73ccf
parentGit clone is execute only if can be executed without stopping the server. (diff)
downloadelivepatch-a5d0026bc509a45fdc212fd68dfbcdf43f0f2d3c.tar.gz
elivepatch-a5d0026bc509a45fdc212fd68dfbcdf43f0f2d3c.tar.bz2
elivepatch-a5d0026bc509a45fdc212fd68dfbcdf43f0f2d3c.zip
set kernel directory under /tmp/elivepatch- + uuid + /usr/src/linux
-rw-r--r--elivepatch_server/resources/dispatcher.py12
-rw-r--r--elivepatch_server/resources/livepatch.py20
2 files changed, 16 insertions, 16 deletions
diff --git a/elivepatch_server/resources/dispatcher.py b/elivepatch_server/resources/dispatcher.py
index 80fe469..c9478ed 100644
--- a/elivepatch_server/resources/dispatcher.py
+++ b/elivepatch_server/resources/dispatcher.py
@@ -29,15 +29,13 @@ packs = {
}
-def set_kernel_dir(kernel_ID):
+def set_kernel_dir(uuid, kernel_ID):
kernel_absolute_path = 'linux-' + str(kernel_ID) + '-gentoo'
- kernel_path = os.path.join('/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()
kernel_dir = lpatch.get_kernel_dir()
-set_kernel_dir(kernel_dir)
-
class BuildLivePatch(Resource):
@@ -66,7 +64,7 @@ class BuildLivePatch(Resource):
else:
print('UserID: ' + str(args['UserID']))
if args['KernelVersion']:
- set_kernel_dir(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()
@@ -77,8 +75,8 @@ class BuildLivePatch(Resource):
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(kernel_dir)
- lpatch.build_livepatch(kernel_dir, kernel_vmlinux)
+ lpatch.build_kernel(args['UserID'])
+ lpatch.build_livepatch(args['UserID'], kernel_vmlinux)
pack = {
'id': packs['id'] + 1,
'KernelVersion': args['KernelVersion'],
diff --git a/elivepatch_server/resources/livepatch.py b/elivepatch_server/resources/livepatch.py
index 32fb2b5..7be51a9 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, kernel_source, vmlinux):
+ def build_livepatch(self, uuid_dir, vmlinux):
"""
Function for building the livepatch
@@ -79,6 +79,7 @@ class PaTch(object):
:param vmlinux: path to the vmlinux file
:return: void
"""
+ kernel_source = '/tmp/elivepatch-' + uuid_dir + '/usr/src/linux/'
debug=True
bashCommand = ['sudo','kpatch-build']
bashCommand.extend(['-s',kernel_source])
@@ -101,14 +102,15 @@ class PaTch(object):
command(['git','clone','https://github.com/aliceinwire/gentoo-sources_overlay.git'])
except:
print('Gentoo-sources overlay already present.')
- command(['sudo','ROOT=/tmp/' + uuid_dir,'ebuild','gentoo-sources_overlay/sys-kernel/gentoo-sources/gentoo-sources-' + kernel_version + '.ebuild', 'merge'])
-
-
- def build_kernel(self, kernel_source_dir):
- command(['sudo','make','oldconfig'], kernel_source_dir)
- command(['sudo','make'], kernel_source_dir)
- command(['sudo','make', 'modules'], kernel_source_dir)
- command(['sudo','make', 'modules_install'], kernel_source_dir)
+ command(['sudo','ROOT=/tmp/elivepatch-' + uuid_dir,'ebuild','gentoo-sources_overlay/sys-kernel/gentoo-sources/gentoo-sources-' + kernel_version + '.ebuild', 'clean'])
+ command(['sudo','ROOT=/tmp/elivepatch-' + uuid_dir,'ebuild','gentoo-sources_overlay/sys-kernel/gentoo-sources/gentoo-sources-' + kernel_version + '.ebuild', 'merge'])
+
+ def build_kernel(self, uuid_dir):
+ kernel_source_dir = '/tmp/elivepatch-' + uuid_dir + '/usr/src/linux/'
+ command(['sudo','make','oldconfig'], kernel_source_dir)
+ command(['sudo','make'], kernel_source_dir)
+ command(['sudo','make', 'modules'], kernel_source_dir)
+ command(['sudo','make', 'modules_install'], kernel_source_dir)
def command(bashCommand, kernel_source_dir=None):