forked from AnwariJr/vendor_intel_build
-
Notifications
You must be signed in to change notification settings - Fork 0
/
getdnx
executable file
·34 lines (25 loc) · 988 Bytes
/
getdnx
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
31
32
33
#!/usr/bin/env python
import subprocess
import argparse
import os
parser = argparse.ArgumentParser(description='Get DnX artifacts from a bootloader image. If run with no --extract arguments, pulls loader.efi and fastboot.img to the current working directory')
parser.add_argument('fat_img', metavar="BOOTLOADER", help="Path to bootloader image")
parser.add_argument('-e', '--extract', nargs="+", help="filename or src=dest pair to extract")
args = parser.parse_args()
def get_fat_file(fat_img, in_path, out_path):
subprocess.call(["mcopy", "-i", fat_img, "::" + in_path, out_path])
bpath = args.fat_img
if not args.extract:
e = [("fastboot.img", "fastboot.img"), ("loader.efi", "loader.efi")]
else:
e = []
for i in args.extract:
j = i.split("=")
if len(j) == 1:
e.append((i,i))
else:
e.append((j[0], j[1]))
for src, dest in e:
if os.path.exists(dest):
os.unlink(dest)
get_fat_file(bpath, src, dest)