robotnix icon indicating copy to clipboard operation
robotnix copied to clipboard

Fix building LineageOS

Open CyberShadow opened this issue 11 months ago • 13 comments

I'm not sure how correct these are, but they do allow building a LineageOS image with signing.

I have not tried flashing it, though. :)

CyberShadow avatar Mar 10 '24 08:03 CyberShadow

If it builds, it should be fine. Thanks a bunch!

I do want it tested but I won't have time to do so until next week.

Atemu avatar Mar 10 '24 09:03 Atemu

I'm not entirely sure, but something about exit codes have changed with this PR (I think). When I ran this PR, and I ran out of memory, the first part of the build would fail, but it would still report it as successful.

I might have to recheck it :)

eyJhb avatar Mar 27 '24 09:03 eyJhb

Building with this PR if I run out of memory I get the following

[ 98% 394/398] test android/soong/rust
[ 99% 395/398] test android/soong/sdk
[ 99% 396/398] test android/soong/java
[ 99% 397/398] test android/soong/apex
[100% 398/398] analyzing Android.bp files and generating ninja file at out/soong/build.ninja
FAILED: out/soong/build.ninja
cd "$(dirname "out/host/linux-x86/bin/soong_build")" && BUILDER="$PWD/$(basename "out/host/linux-x86/bin/soong_build")" && cd / && env -i  "$BUILDER"     --top "$TOP"     --soong_out "out/soong"     --out "out"     -o out/soong/build.ninja --globListDir build --globFile out/soong/globs-build.ninja -t -l out/.module_paths/Android.bp.list --available_env out/soong/soong.environment.available --used_env out/soong/soong.environment.used.build Android.bp
ninja: build stopped: subcommand failed.
08:55:02 soong bootstrap failed with: exit status 1
buildPhase completed in 1 minutes 33 seconds
installing
cat: ANDROID_PRODUCT_OUT: No such file or directory
cp: cannot stat '/otatools.zip': No such file or directory
cp: cannot stat '/obj/PACKAGING/target_files_intermediates/lineage_FP4-target_files-2023100409.zip': No such file or directory
building '/nix/store/dn610hqcgmmcqlrjw3iry3jpyxff1zd8-ota-tools.drv'...
unpacking sources
unpacking source archive /nix/store/43zqjlpf2r4s4v5l6awpgzs36889lvnb-robotnix-lineage_FP4-2023100409/otatools.zip
unzip:  cannot find or open /nix/store/43zqjlpf2r4s4v5l6awpgzs36889lvnb-robotnix-lineage_FP4-2023100409/otatools.zip, /nix/store/43zqjlpf2r4s4v5l6awpgzs36889lvnb-robotnix-lineage_FP4-2023100409/otatools.zip.zip or /nix/store/43zqjlpf2r4s4v5l6awpgzs36889lvnb-robotnix-lineage_FP4-2023100409/otatools.zip.ZIP.
do not know how to unpack source archive /nix/store/43zqjlpf2r4s4v5l6awpgzs36889lvnb-robotnix-lineage_FP4-2023100409/otatools.zip
error: builder for '/nix/store/dn610hqcgmmcqlrjw3iry3jpyxff1zd8-ota-tools.drv' failed with exit code 1;
       last 4 log lines:
       > unpacking sources
       > unpacking source archive /nix/store/43zqjlpf2r4s4v5l6awpgzs36889lvnb-robotnix-lineage_FP4-2023100409/otatools.zip
       > unzip:  cannot find or open /nix/store/43zqjlpf2r4s4v5l6awpgzs36889lvnb-robotnix-lineage_FP4-2023100409/otatools.zip, /nix/store/43zqjlpf2r4s4v5l6awpgzs36889lvnb-robotnix-lineage_FP4-2023100409/otatools.zip.zip or /nix/store/43zqjlpf2r4s4v5l6awpgzs36889lvnb-robotnix-lineage_FP4-2023100409/otatools.zip.ZIP.
       > do not know how to unpack source archive /nix/store/43zqjlpf2r4s4v5l6awpgzs36889lvnb-robotnix-lineage_FP4-2023100409/otatools.zip
       For full logs, run 'nix log /nix/store/dn610hqcgmmcqlrjw3iry3jpyxff1zd8-ota-tools.drv'.
error: 1 dependencies of derivation '/nix/store/1gf5g7lv5dixa45yisf41rnjl25j1fpy-FP4-img-2023100409.zip.drv' failed to build

So it seems to think that /nix/store/43zqjlpf2r4s4v5l6awpgzs36889lvnb-robotnix-lineage_FP4-2023100409 was built, but it actually failed. All builds afterwards have this error

eyjhb@chronos /t/robotnix (lineageos-fixes) [1]> nix-build --arg configuration ./example.nix -A img
warning: Git tree '/tmp/robotnix' is dirty

these 2 derivations will be built:
  /nix/store/dn610hqcgmmcqlrjw3iry3jpyxff1zd8-ota-tools.drv
  /nix/store/1gf5g7lv5dixa45yisf41rnjl25j1fpy-FP4-img-2023100409.zip.drv
building '/nix/store/dn610hqcgmmcqlrjw3iry3jpyxff1zd8-ota-tools.drv'...
unpacking sources
unpacking source archive /nix/store/43zqjlpf2r4s4v5l6awpgzs36889lvnb-robotnix-lineage_FP4-2023100409/otatools.zip
unzip:  cannot find or open /nix/store/43zqjlpf2r4s4v5l6awpgzs36889lvnb-robotnix-lineage_FP4-2023100409/otatools.zip, /nix/store/43zqjlpf2r4s4v5l6awpgzs36889lvnb-robotnix-lineage_FP4-2023100409/otatools.zip.zip or /nix/store/43zqjlpf2r4s4v5l6awpgzs36889lvnb-robotnix-lineage_FP4-2023100409/otatools.zip.ZIP.
do not know how to unpack source archive /nix/store/43zqjlpf2r4s4v5l6awpgzs36889lvnb-robotnix-lineage_FP4-2023100409/otatools.zip
error: builder for '/nix/store/dn610hqcgmmcqlrjw3iry3jpyxff1zd8-ota-tools.drv' failed with exit code 1;
       last 4 log lines:
       > unpacking sources
       > unpacking source archive /nix/store/43zqjlpf2r4s4v5l6awpgzs36889lvnb-robotnix-lineage_FP4-2023100409/otatools.zip
       > unzip:  cannot find or open /nix/store/43zqjlpf2r4s4v5l6awpgzs36889lvnb-robotnix-lineage_FP4-2023100409/otatools.zip, /nix/store/43zqjlpf2r4s4v5l6awpgzs36889lvnb-robotnix-lineage_FP4-2023100409/otatools.zip.zip or /nix/store/43zqjlpf2r4s4v5l6awpgzs36889lvnb-robotnix-lineage_FP4-2023100409/otatools.zip.ZIP.
       > do not know how to unpack source archive /nix/store/43zqjlpf2r4s4v5l6awpgzs36889lvnb-robotnix-lineage_FP4-2023100409/otatools.zip
       For full logs, run 'nix log /nix/store/dn610hqcgmmcqlrjw3iry3jpyxff1zd8-ota-tools.drv'.
error: 1 dependencies of derivation '/nix/store/1gf5g7lv5dixa45yisf41rnjl25j1fpy-FP4-img-2023100409.zip.drv' failed to build

This doesn't happen on master. Might be because of the bump of nixpkgs. Is that required for the build to succeed on your end, or could it be a separate PR instead?

eyJhb avatar Mar 29 '24 09:03 eyJhb

Might be because of the bump of nixpkgs.

I suspect that to be the case too. Considering that nixpkgs scripts are executed without errexit or any other bash strict mode flags, I am not at all surprised about such bugs.

Is that required for the build to succeed on your end, or could it be a separate PR instead?

Yeah, we need to pull in https://github.com/NixOS/nixpkgs/commit/2dcae7d82f5ef0b373413d2fbfc1001141561c74 specifically, in order to fix #224.

Maybe we could try bumping it further and hope that the bug goes away (having been fixed further down the line), or add an explicit success check to that derivation...

Edit: I think this should fix it on our side: https://github.com/nix-community/robotnix/pull/230

CyberShadow avatar Mar 29 '24 09:03 CyberShadow

@CyberShadow could you rebase?

Atemu avatar May 16 '24 18:05 Atemu

I tried but it doesn't build any more :(

CyberShadow avatar May 16 '24 18:05 CyberShadow

Currently stuck on this chromium build failure:

[74409/95482] STAMP clang_x86_v8_arm/obj/v8/v8_headers.stamp
[74410/95482] STAMP clang_x86_v8_arm/obj/v8/cppgc_base.stamp
[74411/95482] STAMP clang_x86_v8_arm/obj/v8/v8_shared_internal_headers.stamp
[74412/95482] STAMP clang_x86_v8_arm/obj/v8/src/inspector/inspector_test_headers.stamp
[74413/95482] STAMP clang_x86_v8_arm/obj/v8/v8_flags.stamp
[74414/95482] CXX clang_x86_v8_arm/obj/v8/torque_base/instance-type-generator.o
[74415/95482] LINK clang_x86_v8_arm/bytecode_builtins_list_generator
FAILED: clang_x86_v8_arm/bytecode_builtins_list_generator 
python3 "../../build/toolchain/gcc_link_wrapper.py" --output="clang_x86_v8_arm/bytecode_builtins_list_generator" -- ../../third_party/llvm-build/Release+Asserts/bin/clang++ -pie -fuse-ld=lld -Wl,--fatal-warnings -Wl,--build-id=sha1 -fPIC -Wl,-z,noexecstack -Wl,-z,relro -Wl,-z,now -Wl,--icf=all -Wl,--color-diagnostics -m32 -no-canonical-prefixes -rdynamic -nostdlib++ -Wl,-z,defs -Wl,--as-needed -pie -Wl,--disable-new-dtags -Wl,-O2 -Wl,--gc-sections -o "clang_x86_v8_arm/bytecode_builtins_list_generator" -Wl,--start-group @"clang_x86_v8_arm/bytecode_builtins_list_generator.rsp"  -Wl,--end-group  -ldl -lpthread -lrt
ld.lld: error: cannot open crtbeginS.o: No such file or directory
ld.lld: error: unable to find library -lgcc
ld.lld: error: unable to find library -lgcc
ld.lld: error: cannot open crtendS.o: No such file or directory
clang++: error: linker command failed with exit code 1 (use -v to see invocation)
[74416/95482] LINK clang_x86_v8_arm/gen-regexp-special-case
FAILED: clang_x86_v8_arm/gen-regexp-special-case 
python3 "../../build/toolchain/gcc_link_wrapper.py" --output="clang_x86_v8_arm/gen-regexp-special-case" -- ../../third_party/llvm-build/Release+Asserts/bin/clang++ -pie -fuse-ld=lld -Wl,--fatal-warnings -Wl,--build-id=sha1 -fPIC -Wl,-z,noexecstack -Wl,-z,relro -Wl,-z,now -Wl,--icf=all -Wl,--color-diagnostics -m32 -no-canonical-prefixes -rdynamic -nostdlib++ -Wl,-z,defs -Wl,--as-needed -pie -Wl,--disable-new-dtags -Wl,-O2 -Wl,--gc-sections -o "clang_x86_v8_arm/gen-regexp-special-case" -Wl,--start-group @"clang_x86_v8_arm/gen-regexp-special-case.rsp"  -Wl,--end-group  -ldl -lpthread -lrt
ld.lld: error: cannot open crtbeginS.o: No such file or directory
ld.lld: error: unable to find library -lgcc
ld.lld: error: unable to find library -lgcc
ld.lld: error: cannot open crtendS.o: No such file or directory
clang++: error: linker command failed with exit code 1 (use -v to see invocation)
[74417/95482] CXX clang_x86_v8_arm/obj/v8/torque_base/declaration-visitor.o
[74418/95482] CXX clang_x86_v8_arm/obj/v8/torque_base/instructions.o
[74419/95482] CXX clang_x86_v8_arm/obj/v8/torque_base/torque-compiler.o
[74420/95482] CXX clang_x86_v8_arm/obj/v8/torque/torque.o
[74421/95482] CXX clang_x86_v8_arm/obj/v8/torque_base/declarations.o
[74422/95482] CXX clang_x86_v8_arm/obj/v8/torque_base/csa-generator.o
[74423/95482] CXX clang_x86_v8_arm/obj/v8/torque_base/type-visitor.o
[74424/95482] CXX clang_x86_v8_arm/obj/v8/torque_base/types.o
[74425/95482] CXX clang_x64_v8_arm64/obj/v8/torque_base/torque-parser.o
[74426/95482] CXX clang_x64_v8_arm64/obj/v8/torque_base/implementation-visitor.o
[74427/95482] CXX clang_x86_v8_arm/obj/v8/torque_base/torque-parser.o
[74428/95482] CXX clang_x86_v8_arm/obj/v8/torque_base/implementation-visitor.o
ninja: build stopped: subcommand failed.
error: builder for '/nix/store/dwslj0dsw07vs1hl9jndansj6cwmgw0q-chromium-100.0.4896.127.drv' failed with exit code 1;
       last 25 log lines:
       > ld.lld: error: unable to find library -lgcc
       > ld.lld: error: unable to find library -lgcc
       > ld.lld: error: cannot open crtendS.o: No such file or directory
       > clang++: error: linker command failed with exit code 1 (use -v to see invocation)
       > [74416/95482] LINK clang_x86_v8_arm/gen-regexp-special-case
       > FAILED: clang_x86_v8_arm/gen-regexp-special-case
       > python3 "../../build/toolchain/gcc_link_wrapper.py" --output="clang_x86_v8_arm/gen-regexp-special-case" -- ../../third_party/llvm-build/Release+Asserts/bin/clang++ -pie -fuse-ld=lld -Wl,--fatal-warnings -Wl,--build-id=sha1 -fPIC -Wl,-z,noexecstack -Wl,-z,relro -Wl,-z,now -Wl,--icf=all -Wl,--color-diagnostics -m32 -no-canonical-prefixes -rdynamic -nostdlib++ -Wl,-z,defs -Wl,--as-needed -pie -Wl,--disable-new-dtags -Wl,-O2 -Wl,--gc-sections -o "clang_x86_v8_arm/gen-regexp-special-case" -Wl,--start-group @"clang_x86_v8_arm/gen-regexp-special-case.rsp"  -Wl,--end-group  -ldl -lpthread -lrt
       > ld.lld: error: cannot open crtbeginS.o: No such file or directory
       > ld.lld: error: unable to find library -lgcc
       > ld.lld: error: unable to find library -lgcc
       > ld.lld: error: cannot open crtendS.o: No such file or directory
       > clang++: error: linker command failed with exit code 1 (use -v to see invocation)
       > [74417/95482] CXX clang_x86_v8_arm/obj/v8/torque_base/declaration-visitor.o
       > [74418/95482] CXX clang_x86_v8_arm/obj/v8/torque_base/instructions.o
       > [74419/95482] CXX clang_x86_v8_arm/obj/v8/torque_base/torque-compiler.o
       > [74420/95482] CXX clang_x86_v8_arm/obj/v8/torque/torque.o
       > [74421/95482] CXX clang_x86_v8_arm/obj/v8/torque_base/declarations.o
       > [74422/95482] CXX clang_x86_v8_arm/obj/v8/torque_base/csa-generator.o
       > [74423/95482] CXX clang_x86_v8_arm/obj/v8/torque_base/type-visitor.o
       > [74424/95482] CXX clang_x86_v8_arm/obj/v8/torque_base/types.o
       > [74425/95482] CXX clang_x64_v8_arm64/obj/v8/torque_base/torque-parser.o
       > [74426/95482] CXX clang_x64_v8_arm64/obj/v8/torque_base/implementation-visitor.o
       > [74427/95482] CXX clang_x86_v8_arm/obj/v8/torque_base/torque-parser.o
       > [74428/95482] CXX clang_x86_v8_arm/obj/v8/torque_base/implementation-visitor.o
       > ninja: build stopped: subcommand failed.
       For full logs, run 'nix-store -l /nix/store/dwslj0dsw07vs1hl9jndansj6cwmgw0q-chromium-100.0.4896.127.drv'.
error: 1 dependencies of derivation '/nix/store/0c1jlfpgp6la4g1yh5azvj6ycqi2m9ba-aab-universal.apk.drv' failed to build
error: 1 dependencies of derivation '/nix/store/n4zh4yka62h76kw776cm2df03lq4g0gx-chromium-webview-trichrome-patched.apk.drv' failed to build
error: 1 dependencies of derivation '/nix/store/0k7qk5m47x6l4ril9plpc41ckfq48ixc-prebuilt_chromiumTrichromeLibrary.drv' failed to build
error: 1 dependencies of derivation '/nix/store/wzicrjbg4hiklsmg5wklqjqfakjk1k0c-unpack.sh.drv' failed to build
error: 1 dependencies of derivation '/nix/store/i22f04d1dgyfrd34ban9n496i85px3n4-robotnix-lineage_instantnoodlep-2023100409.drv' failed to build
error: 1 dependencies of derivation '/nix/store/h9nd48h4cv84hsg9xxac8946c1hxgv2d-release.sh.drv' failed to build
./build.sh  5.47s user 4.79s system 0% cpu 52:11.17 total

CyberShadow avatar May 17 '24 18:05 CyberShadow

You can safely ignore Chromium, nobody is maintaining it atm and it's broken at runtime anyways. Just disable webview for now.

Atemu avatar May 18 '24 09:05 Atemu

How does that work? Aren't webviews required for many parts of the OS?

CyberShadow avatar May 18 '24 09:05 CyberShadow

Also, it used to build with the older nixpkgs.

CyberShadow avatar May 18 '24 09:05 CyberShadow

How does that work? Aren't webviews required for many parts of the OS?

The OS itself not so much but other apps do require them. You have to install a webview after the fact or use a prebuilt. I had a WIP branch laying around that properly deprecates the from-source Chromiums but didn't have time to finish it at the time. It's not very high on my priority list to do so atm either though.

Until someone takes a closer look at from-source Chromium and brings it up to date, it's effectively deprecated and I don't care about breaking it.

Atemu avatar May 18 '24 09:05 Atemu

OK, I got it to build with:

  apps.chromium.enable = false;
  webview.prebuilt.enable = false;
  webview.chromium.availableByDefault = false;
  webview.chromium.enable = false;
  webview.chromium.isFallback = false;

Still no idea if it actually works.

CyberShadow avatar May 18 '24 13:05 CyberShadow

Oops, it actually failed:

Building .img file
2024-05-18 12:35:02 - common.py - WARNING : Failed to read SYSTEM/etc/build.prop
2024-05-18 12:35:02 - common.py - WARNING : Failed to read VENDOR/etc/build.prop
2024-05-18 12:35:02 - common.py - WARNING : Failed to read VENDOR_DLKM/etc/build.prop
2024-05-18 12:35:02 - common.py - WARNING : Failed to read VENDOR_DLKM/build.prop
2024-05-18 12:35:02 - common.py - WARNING : Failed to read build.prop for partition vendor_dlkm
2024-05-18 12:35:02 - common.py - WARNING : Failed to read ODM_DLKM/etc/build.prop
2024-05-18 12:35:02 - common.py - WARNING : Failed to read ODM_DLKM/build.prop
2024-05-18 12:35:02 - common.py - WARNING : Failed to read build.prop for partition odm_dlkm
2024-05-18 12:35:02 - common.py - WARNING : Failed to read SYSTEM_DLKM/etc/build.prop
2024-05-18 12:35:02 - common.py - WARNING : Failed to read SYSTEM_DLKM/build.prop
2024-05-18 12:35:02 - common.py - WARNING : Failed to read build.prop for partition system_dlkm
2024-05-18 12:35:03 - common.py - WARNING : Failed to read IMAGES/init_boot.img
Building factory image
ln: cannot create symbolic link from 'instantnoodlep-signed_target_files-2023100409.zip' to 'instantnoodlep-target_files-2023100409.zip': File exists
ln: cannot create symbolic link from 'instantnoodlep-img-2023100409.zip' to 'instantnoodlep-img-2023100409.zip': File exists
Archive:  instantnoodlep-target_files-2023100409.zip
caution: filename not matched:  RADIO/bootloader.img
cp: bad 'tmp/RADIO/bootloader.img': No such file or directory
  adding: instantnoodlep-2023100409/ (stored 0%)
  adding: instantnoodlep-2023100409/image-instantnoodlep-2023100409.zip (stored 0%)
  adding: instantnoodlep-2023100409/flash-all.sh (deflated 39%)
  adding: instantnoodlep-2023100409/flash-all.bat (deflated 38%)
  adding: instantnoodlep-2023100409/flash-base.sh (deflated 39%)
mv: 'instantnoodlep-factory-2023100409.zip' not directory

CyberShadow avatar May 18 '24 14:05 CyberShadow