summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDenis 'GNUtoo' Carikli <GNUtoo@cyberdimension.org>2021-10-01 04:23:35 +0200
committerDenis 'GNUtoo' Carikli <GNUtoo@cyberdimension.org>2021-10-01 04:46:57 +0200
commitff77871f904f0811dde200529879dc9d23351fa9 (patch)
tree8dc2697128584ea69d6641be996f215ec1da143c
parent2b119c758b0366ec69d8597080736d06b7fea162 (diff)
downloadvendor_replicant-scripts-ff77871f904f0811dde200529879dc9d23351fa9.tar.gz
vendor_replicant-scripts-ff77871f904f0811dde200529879dc9d23351fa9.tar.bz2
vendor_replicant-scripts-ff77871f904f0811dde200529879dc9d23351fa9.zip
add_adb_root: switch from FSO's unbootimg to abootimg
While abootimg git[1] has no new commits since 2021, FSO's unbootimg is not maintained at all as work on the Freesmartphone.org has stopped. As abootimg is used by diffoscope and it is pakcaged by Debian and Guix, so it's probably better to use to abootimg since more people will more likely already have it in the distribution they use and since it's a dependency of diffoscope we are more likely tools with the same command line interface in the future than the interface of FSO's unbootimg. I added a package for abootimg 6.0 in Parabola and Aur in order to make it easier for Parabola users to transition from fso-unbootimg to abootimg. [1]https://github.com/ggrandou/abootimg Signed-off-by: Denis 'GNUtoo' Carikli <GNUtoo@cyberdimension.org>
-rwxr-xr-ximages/add_adb_root/add_adb_root.py34
1 files changed, 19 insertions, 15 deletions
diff --git a/images/add_adb_root/add_adb_root.py b/images/add_adb_root/add_adb_root.py
index c47a90b..b13d69f 100755
--- a/images/add_adb_root/add_adb_root.py
+++ b/images/add_adb_root/add_adb_root.py
@@ -48,24 +48,21 @@ def automatically_identify_file(path):
# TODO: is it really relevant?
file_infos['target'] = None
- output = str(sh.unbootimg("-i", path)).split(os.linesep)
+ output = str(sh.abootimg("-i", path)).split(os.linesep)
for line in output:
- if line.startswith('kernel load addr:'):
+ if line.startswith(' kernel:'):
for word in line.split(" "):
if word.startswith("0x"):
kernel_load_addr = int(word, 16)
# TODO: Add support for 64bit targets
file_infos['base_address'] = kernel_load_addr & 0xffff0000
- if line.startswith('cmdline:'):
- for word in line.split(" "):
- if word.startswith("`"):
- file_infos['cmdline'] = \
- word.replace("`", "").replace("'", "")
+ if line.startswith('* cmdline = '):
+ file_infos['cmdline'] = line[len('* cmdline = '):]
- if line.startswith('id:'):
- file_infos['id'] = re.sub("^id: *", "", line)
+ if line.startswith('* id ='):
+ file_infos['id'] = line[len('* id ='):].replace(" 0x", "")
return file_infos
@@ -83,9 +80,18 @@ def identify_file(path):
def identify_image_type(path):
try:
- output = sh.unbootimg("-i", path)
+ output = sh.abootimg("-i", path)
except Exception as e:
- if e.stderr == b'error: supplied file is not an Android boot image\n':
+
+ no_android_magic_value = False
+ not_a_valid_android_boot_image = False
+ for line in e.stderr.decode().split(os.linesep):
+ if re.search(': no Android Magic Value$', line):
+ no_android_magic_value = True
+ if re.search(': not a valid Android Boot Image.$', line):
+ not_a_valid_android_boot_image = True
+
+ if no_android_magic_value and not_a_valid_android_boot_image:
return ImageType.zImage
else:
return ImageType.unknown
@@ -214,15 +220,13 @@ def add_adb_to_bootimage(input_file, output_file):
kernel = tmpdir + os.sep + "kernel.img"
ramdisk = tmpdir + os.sep + "ramdisk.cpio"
compressed_ramdisk = ramdisk + ".gz"
+ config = tmpdir + os.sep + "bootimg.cfg"
# TODO: autodetect cmdline and base_address
base_address = file_infos['base_address']
cmdline = file_infos['cmdline']
- # TODO: check output
- output = sh.unbootimg("--kernel", kernel,
- "--ramdisk", compressed_ramdisk,
- "-i", input_file)
+ sh.abootimg("-x", input_file, config, kernel, compressed_ramdisk)
sh.gunzip(compressed_ramdisk)