aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndrea Righi <andrea.righi@canonical.com>2019-09-17 09:38:11 +0200
committerAndrea Righi <andrea.righi@canonical.com>2019-09-17 09:38:11 +0200
commitc0c49adf5827a9c667ecd3695eccc48bda706b85 (patch)
treed442176392631a7e5eeb38d14adc184a9f713b1a
parent7b3c0da92d85e9af1e96e83d7fd77a84c27c7d71 (diff)
downloadvirtme-c0c49adf5827a9c667ecd3695eccc48bda706b85.tar.gz
refresh kernel modules directory when modules.order is updated
Make sure to refresh the kernel modules' directory when modules.order changes. Signed-off-by: Andrea Righi <andrea.righi@canonical.com>
-rw-r--r--virtme/commands/run.py7
1 files changed, 6 insertions, 1 deletions
diff --git a/virtme/commands/run.py b/virtme/commands/run.py
index 05fee7a..d45e9ac 100644
--- a/virtme/commands/run.py
+++ b/virtme/commands/run.py
@@ -118,6 +118,9 @@ def arg_fail(message):
_ARGPARSER.print_usage()
sys.exit(1)
+def is_file_more_recent(a, b):
+ return os.stat(a).st_mtime > os.stat(b).st_mtime
+
def find_kernel_and_mods(arch, args):
use_root_mods = False
@@ -135,11 +138,13 @@ def find_kernel_and_mods(arch, args):
kimg = os.path.join(args.kdir, arch.kimg_path())
virtme_mods = os.path.join(args.kdir, '.virtme_mods')
mod_file = os.path.join(args.kdir, 'modules.order')
+ virtme_mod_file = os.path.join(virtme_mods, 'lib/modules/0.0.0/modules.dep')
try:
if not os.path.exists(mod_file):
raise Exception('%s not found' % mod_file)
# Initialize virtme modules directory
- if not os.path.exists(virtme_mods):
+ if not os.path.exists(virtme_mods) or \
+ is_file_more_recent(mod_file, virtme_mod_file):
os.system('virtme-prep-kdir-mods')
if not os.path.exists(virtme_mods):
raise Exception('%s not found' % virtme_mods)