chriswoope / resign-android-image

Resign Android OS (esp. GrapheneOS) images with your signing keys and add ADB root and other modifications
MIT License
86 stars 6 forks source link

Problem with with 'extract_boot_image' #6

Open oam2022 opened 2 years ago

oam2022 commented 2 years ago

Hi there, first of all I have to say how amazed I am with this project, it is what I've been looking for ever since there are smartphones :)

So I tried to run the script and it always fails at the same spot, not sure why. It looks line it's trying to move items that are not where they're supposed to be. The directory '/root/build/out_resign/bootimg' is completely empty. I tried the whole day now to get it to work without success and I think it's time to ask the expert here... I also tried to run it with 'raven' instead of 'bonito' as I'm sure it works for your device but the same problem occurs.

It runs on a clean Debian 11 as root. I hope it's something minor that I overlooked, if you could point me in the right direction that would be greatly appreciated! Kind regards from Canada!

Here is the output:

root@androidresign:~/build/resign-android-image-main# ./resign-android-image /root/build /root/build/keys grapheneos bonito 2022051100 --ota --generate-keys --adb-root --allowbackup --adb-backup --hosts-url https://adaway.org/hosts.txt

Already up to date. Already up to date. Already up to date. MAKING /root/build/keys with gen_keys Generating RSA private key, 4096 bit long modulus (2 primes) ......++++ ............................................................................................................................................................++++ e is 65537 (0x010001) Generating RSA private key, 4096 bit long modulus (2 primes) ........................++++ ....................................................................................++++ e is 65537 (0x010001) Generating RSA private key, 4096 bit long modulus (2 primes) ............................++++ ......................................................................................................................................................................................++++ e is 65537 (0x010001) Generating RSA private key, 4096 bit long modulus (2 primes) ...........................................................................................................................................................++++ ..................................++++ e is 65537 (0x010001) Generating RSA private key, 4096 bit long modulus (2 primes) ..............................................................................................................................................................................++++ ...................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................++++ e is 65537 (0x010001) Generating RSA private key, 4096 bit long modulus (2 primes) ....................................................................................................................................................................................++++ .....................................................................................................................................................................................................................++++ e is 65537 (0x010001) MADE /root/build/keys with gen_keys MAKING /root/build/out_resign/target_files.zip with make_target_files_zip MAKING /root/build/out_resign/target_files with make_target_files_base MAKING /root/build/out_resign/target_files_signed with make_target_files_signed MAKING /root/build/out_resign/target_files_intermediates.zip with make_target_files_intermediates_zip MAKING /root/build/out_resign/target_files_intermediates.done with make_target_files_intermediates MAKING /root/build/out_resign/target_files_intermediates with make_target_files_intermediates_base MAKING /root/build/out_resign/target_files_extracted.done with make_target_files_extracted MAKING /root/build/ota_payload with make_extract_ota_payload MAKING /root/build/ota with make_extract_ota MAKING /root/build/ota.zip.ok with download_ota % Total % Received % Xferd Average Speed Time Time Time Current Dload Upload Total Spent Left Speed 100 823M 100 823M 0 0 9544k 0 0:01:28 0:01:28 --:--:-- 9375k Package: /root/build/ota.zip Certificate: /root/build/resign-android-image-main/grapheneos-otacerts/bonito.pem Package length: 863028498 Comment length: 1215 Signed data length: 863027281 Signature start: 863027301 Use SHA-256: True Digest: 6bd3e6cbc42112f8fe1a2fcd3b976a78bfe8e7022579bcd77a017a1797d0d77b

Whole package signature VERIFIED

Verifying A/B OTA payload signatures...

Payload signatures VERIFIED

MADE /root/build/ota.zip.ok with download_ota
MADE /root/build/ota with make_extract_ota
DISCARD: /root/build/ota.zip
MAKING /root/build/ota_meta with do_extract_ota_manifest
MADE /root/build/ota_meta with do_extract_ota_manifest
MAKING /root/build/ota_meta/apex_info.pb with make_hardlink
MADE /root/build/ota_meta/apex_info.pb with make_hardlink

Extracting 'vendor.img' Extracting 'abl.img' Extracting 'aop.img' Extracting 'cmnlib.img' Extracting 'cmnlib64.img' Extracting 'devcfg.img' Extracting 'hyp.img' Extracting 'keymaster.img' Extracting 'modem.img' Extracting 'qupfw.img' Extracting 'tz.img' Extracting 'xbl.img' Extracting 'xbl_config.img' Extracting 'boot.img' Extracting 'system.img' Extracting 'vbmeta.img' Extracting 'dtbo.img' Extracting 'product.img' Extracting 'system_ext.img'

MADE /root/build/ota_payload with make_extract_ota_payload
DISCARD: /root/build/ota/payload.bin
MAKING /root/build/out_resign/target_files_extracted/VENDOR with make_extract_fs
MADE /root/build/out_resign/target_files_extracted/VENDOR with make_extract_fs
MAKING /root/build/out_resign/target_files_extracted/PRODUCT with make_extract_fs
MADE /root/build/out_resign/target_files_extracted/PRODUCT with make_extract_fs
MAKING /root/build/out_resign/target_files_extracted/SYSTEM_EXT with make_extract_fs
MADE /root/build/out_resign/target_files_extracted/SYSTEM_EXT with make_extract_fs
MAKING /root/build/out_resign/target_files_extracted/SYSTEM with extract_system
MADE /root/build/out_resign/target_files_extracted/SYSTEM with extract_system
MAKING /root/build/out_resign/target_files_extracted/ROOT with extract_root
MADE /root/build/out_resign/target_files_extracted/ROOT with extract_root
MAKING /root/build/out_resign/target_files_extracted/BOOT with make_extract_boot
MAKING /root/build/out_resign/bootimg/boot with extract_boot_image

mv: cannot stat '/root/build/out_resign/bootimg/boot.HZ2uiW.tmp/bootimg/cmdline': No such file or directory Error 44 : Unrecognized header : file cannot be decoded cpio: premature end of archive Failed to run: extract_boot_image /root/build/out_resign/bootimg/boot.HZ2uiW.tmp /root/build/out_resign/target_files_extracted/BOOT.Qt4DC4.tmp /root/build/ota_payload/boot.img Failed to run: make_extract_boot /root/build/out_resign/target_files_extracted/BOOT.Qt4DC4.tmp /root/build/out_resign/bootimg/boot /root/build/ota_payload/boot.img Failed to run: make_target_files_extracted /root/build/out_resign/target_files_extracted.done.4jaBxJ.tmp Failed to run: make_target_files_intermediates_base /root/build/out_resign/target_files_intermediates.58Lqfh.tmp Failed to run: make_target_files_intermediates /root/build/out_resign/target_files_intermediates.done.FY6wk4.tmp Failed to run: make_target_files_intermediates_zip /root/build/out_resign/target_files_intermediates.zip.xoN5YH.tmp Failed to run: make_target_files_signed /root/build/out_resign/target_files_signed.VvINzd.tmp Failed to run: make_target_files_base /root/build/out_resign/target_files.T2xsiP.tmp Failed to run: make_target_files_zip /root/build/out_resign/target_files.zip.0WY1q6.tmp root@androidresign:~/build/resign-android-image-main#

chriswoope commented 2 years ago

Looks like the ramdisk for the bonito device is not in lz4 format (probably in gzip format?), and currently the script assumes that because I developed it for the Pixel 6 Pro.

I'll try to fix it once I have some time, patches also welcome.

oam2022 commented 2 years ago

Thanks for your reply! I'll check for that. Just makes me wonder that I got the same issue doing it with 'raven' instead of 'bonito' as well...

chriswoope commented 2 years ago

Are you getting "Error 44 : Unrecognized header : file cannot be decoded" with raven as well?

oam2022 commented 2 years ago

Yes, that's what puzzles me... I'll look into the ramdisk format and maybe try running it for a different device besides 'bonito' and 'raven' and see what happens... I tried running it on a different system too with the same error...

oam2022 commented 2 years ago

So I can confirm that the ramdisk is in lz4 format and I tried running for bonito, raven & redfin without success :(

paranoyed commented 2 years ago

Yes, I have the same Issue on sunfish as well.

                            MAKING ./workspace/out_resign/target_files_extracted/BOOT with make_extract_boot
                                MAKING ./workspace/out_resign/bootimg/boot with extract_boot_image
mv: cannot stat './workspace/out_resign/bootimg/boot.yI9ggk.tmp/bootimg/cmdline': No such file or directory
Error 44 : Unrecognized header : file cannot be decoded 
cpio: premature end of archive
Failed to run: extract_boot_image ./workspace/out_resign/bootimg/boot.yI9ggk.tmp ./workspace/out_resign/target_files_extracted/BOOT.bkEWF7.tmp ./workspace/ota_payload/boot.img
Failed to run: make_extract_boot ./workspace/out_resign/target_files_extracted/BOOT.bkEWF7.tmp ./workspace/out_resign/bootimg/boot ./workspace/ota_payload/boot.img
Failed to run: make_target_files_extracted ./workspace/out_resign/target_files_extracted.done.iAPtLw.tmp 
Failed to run: make_target_files_intermediates_base ./workspace/out_resign/target_files_intermediates.wXPfnL.tmp 
Failed to run: make_target_files_intermediates ./workspace/out_resign/target_files_intermediates.done.ITL7ND.tmp 
Failed to run: make_target_files_intermediates_zip ./workspace/out_resign/target_files_intermediates.zip.zwjeSo.tmp 
Failed to run: make_target_files_signed ./workspace/out_resign/target_files_signed.c1MUhY.tmp 
Failed to run: make_target_files_base ./workspace/out_resign/target_files.ikQoat.tmp 
Failed to run: make_target_files_zip ./workspace/out_resign/target_files.zip.Oz4YKD.tmp 

Started with: ./resign-android-image ./workspace ./keys grapheneos sunfish 2022062200 --ota --factory-image --adb-root --factory-zip --allowbackup --adb-backup --replace-boot

paranoyed commented 2 years ago

I created the missing directory with mkdir workspace/out_resign/target_files_extracted/BOOT But I have no clue if this is the correct way to solve this. Now it fails when signing in later steps.