aboutsummaryrefslogtreecommitdiffstats
path: root/util/extract-version-hash-from-factory.bash
diff options
context:
space:
mode:
Diffstat (limited to 'util/extract-version-hash-from-factory.bash')
-rwxr-xr-xutil/extract-version-hash-from-factory.bash15
1 files changed, 12 insertions, 3 deletions
diff --git a/util/extract-version-hash-from-factory.bash b/util/extract-version-hash-from-factory.bash
index a9e0778..8e95a5b 100755
--- a/util/extract-version-hash-from-factory.bash
+++ b/util/extract-version-hash-from-factory.bash
@@ -5,6 +5,7 @@ URL="$1"
# Expecting URL like https://dl.google.com/dl/android/aosp/crosshatch-qp1a.191005.007-factory-2989a08d.zip
[[ -n $URL ]] || { echo "Usage: $0 URL" >&2; exit 1; }
+UTIL="$(dirname "$(readlink -f "$0")")"
D="$(mktemp -d)"
trap 'rm -rf "$D"' INT TERM EXIT
cd "$D"
@@ -12,8 +13,16 @@ cd "$D"
curl -#o out.zip "$URL"
bsdtar --strip-components 1 -xvf out.zip
bsdtar -xvf image-*.zip boot.img
-abootimg -x boot.img
-unlz4 zImage Image
-version="$(strings Image | grep '^Linux version [^%]' | head -n 1)"
+if [[ $URL =~ bramble || $URL =~ redfin ]]; then
+ "$UTIL"/unpack_bootimg.py --boot_img boot.img
+ COMP_IMG=out/kernel
+ DECOMP_IMG=out/kernel-decomp
+else
+ abootimg -x boot.img
+ COMP_IMG=zImage
+ DECOMP_IMG=Image
+fi
+unlz4 "$COMP_IMG" "$DECOMP_IMG"
+version="$(strings "$DECOMP_IMG" | grep '^Linux version [^%]' | head -n 1)"
[[ -n $version ]] || { echo "ERROR: no proper version in image" >&2; exit 1; }
printf '\n==========================================\n\n%s|%s\n' "$(echo "$version" | sha256sum | cut -d ' ' -f 1)" "$version"