aboutsummaryrefslogtreecommitdiffstats
path: root/qemu-headless/extract-kernel.py
blob: 71dde88887a8820520d0ad916daab3904961ee0e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
#!/usr/bin/python3


import os
import shutil
import subprocess
import sys

def get_vmlinuz_path():
    return os.path.join('mnt', os.readlink('mnt/vmlinuz').lstrip('/'))

def get_initrd_path():
    return os.path.join('mnt', os.readlink('mnt/initrd.img').lstrip('/'))

if not os.path.exists('mnt'):
    os.mkdir('mnt')

subprocess.run([
    'guestmount',
    '-a', 'unstable-armhf.qcow2',
    '-m', '/dev/sda1',
    '--ro',
    'mnt'])
print(get_vmlinuz_path())
print(get_initrd_path())

shutil.copyfile(get_vmlinuz_path(), 'vmlinuz', follow_symlinks=True)
shutil.copyfile(get_initrd_path(), 'initrd.img', follow_symlinks=True)

subprocess.run(['fusermount', '-u', 'mnt'])