ADeadTrousers / android_vendor_magisk

AOSP Integration for Magisk
Apache License 2.0
12 stars 1 forks source link

Build error #1

Open mattfbacon opened 4 months ago

mattfbacon commented 4 months ago

I get this error from running m:

[  1% 228/13867 2m57s remaining] Install: out/target/product/barbet/system/addon.d/99-magisk.sh
FAILED: out/target/product/barbet/system/addon.d/99-magisk.sh
/bin/bash -c "(rm -f out/target/product/barbet/system/addon.d/99-magisk.sh ) && (cp out/target/product/barbet/obj/ETC/99-magisk_intermediates/99-magisk.sh out/target/product/barbet/system/addon.d/99-magisk.sh ) && (rm -f vendor/magisk/addon.d.sh && unzip -p vendor/magisk/Magisk-v26.4.apk assets/boot_patch.sh > out/target/product/barbet/obj/ETC/99-magisk_intermediates/boot_patch.sh; unzip -p vendor/magisk/Magisk-v26.4.apk assets/util_functions.sh > out/target/product/barbet/obj/ETC/99-magisk_intermediates/util_functions.sh && unzip -p vendor/magisk/Magisk-v26.4.apk assets/stub.apk > out/target/product/barbet/obj/ETC/99-magisk_intermediates/stub.apk && unzip -p vendor/magisk/Magisk-v26.4.apk lib/x86_64/libmagiskboot.so > out/target/product/barbet/obj/ETC/99-magisk_intermediates/magiskboot && unzip -p vendor/magisk/Magisk-v26.4.apk lib/arm64-v8a/libmagiskinit.so > out/target/product/barbet/obj/ETC/99-magisk_intermediates/magiskinit && unzip -p vendor/magisk/Magisk-v26.4.apk lib/arm64-v8a/libmagisk64.so > out/target/product/barbet/obj/ETC/99-magisk_intermediates/magisk64 && unzip -p vendor/magisk/Magisk-v26.4.apk lib/armeabi-v7a/libmagisk32.so > out/target/product/barbet/obj/ETC/99-magisk_intermediates/magisk32 && sed -i '1d' out/target/product/barbet/obj/ETC/99-magisk_intermediates/boot_patch.sh && chmod 755 out/target/product/barbet/obj/ETC/99-magisk_intermediates/boot_patch.sh && export OUTFD=\"1\" && out/target/product/barbet/obj/ETC/99-magisk_intermediates/boot_patch.sh ../../../boot.img &&  /boot out/target/product/barbet/obj/ETC/99-magisk_intermediates/new-boot.img build/make/target/product/security/verity.pk8 build/make/target/product/security/verity.x509.pem out/target/product/barbet/obj/ETC/99-magisk_intermediates/new-boot.img && out/host/linux-x86/bin/avbtool add_hash_footer --image out/target/product/barbet/obj/ETC/99-magisk_intermediates/new-boot.img --partition_size 0x06000000 --partition_name boot --prop com.android.build.boot.os_version:14 && mv -f out/target/product/barbet/obj/ETC/99-magisk_intermediates/new-boot.img out/target/product/barbet/boot.img )"
./util_functions.sh: line 53: dos2unix: command not found
./util_functions.sh: line 60: getprop: command not found
./util_functions.sh: line 53: dos2unix: command not found
./util_functions.sh: line 60: getprop: command not found
ui_print - Unpacking boot image
ui_print
Parsing boot image: [../../../boot.img]
HEADER_VER      [3]
KERNEL_SZ       [11729497]
RAMDISK_SZ      [2302022]
OS_VERSION      [14.0.0]
OS_PATCH_LEVEL  [2024-04]
PAGESIZE        [4096]
CMDLINE         []
KERNEL_FMT      [lz4]
RAMDISK_FMT     [lz4_legacy]
unexpected ASN.1 DER tag: expected SEQUENCE, got APPLICATION [1] (primitive)
VBMETA
ui_print - Checking ramdisk status
ui_print
Loading cpio: [ramdisk.cpio]
ui_print - Stock boot image detected
ui_print
ui_print - Patching ramdisk
ui_print
Loading cpio: [ramdisk.cpio]
Add file [init] (100750)
Create directory [overlay.d] (0750)
Create directory [overlay.d/sbin] (0750)
Add file [overlay.d/sbin/magisk32.xz] (100644)
Add file [overlay.d/sbin/magisk64.xz] (100644)
Add file [overlay.d/sbin/stub.xz] (100644)
Patch with flag KEEPVERITY=[false] KEEPFORCEENCRYPT=[false]
Loading cpio: [ramdisk.cpio.orig]
Backup [init] -> [.backup/init]
Record new entry: [overlay.d] -> [.backup/.rmlist]
Record new entry: [overlay.d/sbin] -> [.backup/.rmlist]
Record new entry: [overlay.d/sbin/magisk32.xz] -> [.backup/.rmlist]
Record new entry: [overlay.d/sbin/magisk64.xz] -> [.backup/.rmlist]
Record new entry: [overlay.d/sbin/stub.xz] -> [.backup/.rmlist]
Create directory [.backup] (0000)
Add file [.backup/.magisk] (100000)
Dumping cpio: [ramdisk.cpio]
ui_print - Repacking boot image
ui_print
Parsing boot image: [../../../boot.img]
HEADER_VER      [3]
KERNEL_SZ       [11729497]
RAMDISK_SZ      [2302022]
OS_VERSION      [14.0.0]
OS_PATCH_LEVEL  [2024-04]
PAGESIZE        [4096]
CMDLINE         []
KERNEL_FMT      [lz4]
RAMDISK_FMT     [lz4_legacy]
unexpected ASN.1 DER tag: expected SEQUENCE, got APPLICATION [1] (primitive)
VBMETA
Repack to boot image: [new-boot.img]
HEADER_VER      [3]
KERNEL_SZ       [11729497]
RAMDISK_SZ      [2907109]
OS_VERSION      [14.0.0]
OS_PATCH_LEVEL  [2024-04]
PAGESIZE        [4096]
CMDLINE         []
/bin/bash: line 1: /boot: Is a directory

This causes the build to fail. Any ideas what the issue is?

ADeadTrousers commented 4 months ago

Hi. As I mentioned in the README under known issues this whole repo is not working as I initially intended: It needs to have a "boot.img" present in the "out" directory. So I usually run my build twice. First with magisk disabled (in device.mk) and then with it enabled. That should fix the build error. I forgot to mention this in the README. Sorry for that. Regardless of that in the end you still need to replace the "boot.img" in the resulting zip file with the one from the "out" directory.

This whole ordeal is due to two problems I encountered: 1) I cannot time the build process "after" the building of "boot.img" (or make it dependent of it) 2) I cannot change the contents of the packaging step to use the "boot.img" directly from the "out" directory as it uses the one from the "intermediate" directory.

If you or someone else happens to know a way to work around these problems I'd be happy if you could share it with me.

wkr ADT

EDIT: Nope. It's not this problem. See my next post.

ADeadTrousers commented 4 months ago

Wait a minute...

OS_VERSION [14.0.0]

I don't think magisk is ready for A14 yet.

EDIT: Or maybe I need to update to 27.0 (although nothing about A14 is mentioned in the changelogs) I'll not be able to to that for now but you can try to set the variable MAGISK_VERSION to 27.0 in your BoardConfig.mk and place the official 27.0.apk inside the vendor/magisk folder. Hopefully the internal layout didn't change too much between 26.4 and 27.0.

mattfbacon commented 4 months ago

Same error with 27.0.

mattfbacon commented 4 months ago

I was able to trace the output up to line 250 of boot_patch.sh where it invokes ./magiskboot, then to https://github.com/topjohnwu/Magisk/blob/33b7b8b297291b26e3b4928355bd17b458361d25/native/src/boot/bootimg.cpp#L887. At this point I don't know why it prints /bin/bash: line 1: /boot: Is a directory since I don't see any invocation of bash and I also don't see any place where this function tries to use "/boot" which is passed in the name parameter as a filesystem path.

ADeadTrousers commented 4 months ago

Try to trace it with https://github.com/topjohnwu/Magisk/blob/2c6adbc69ba0e5dce09cd13c6d9aca5de30efe76/native/src/boot/bootimg.cpp (It's the tag used for 27.0)

Anyway, are you able to install magisk the "usual" way (install apk, modify boot.img within magisk manager, flash boot.img)?

mattfbacon commented 4 months ago

(It's the tag used for 27.0)

Dang it, you're right, I always do that.

Are you able to install magisk the usual way

Well the magisk app part works fine with no errors but installing the patched image puts my phone into a boot loop. I might be using the wrong boot.img though.

mattfbacon commented 4 months ago

OK, my understanding is that /boot is only used as the name of the signed image. So I really don't understand why it is getting an error from being interpreted as a filesystem path, when it should never have been used as a path to begin with.