• project-folder: my-robotnix-work/lineage-prop-file-permission-denied

  • the m command (AOSP) runs soong eventually

    • in the out/soong.log you see args passed to m
    • eg: m hiiiiiiiiiiiiiii produced project-dir/hi-soong-log
  • the build command wants to write to out/target/product/FP4/test_harness_ramdisk/adb_debug.prop with a shell redirection

    • this file is read only
    • i know excatly why it is like that: robotnix mounts the source from the nix-store, where it is read only … and from there on it gets copied with cp and the readonly permission stays…
    • so when developing don’t even assume, that your source files are writeable…
  • test_harness_ramdisk copies it from the debug-ramdisk

    • out/target/product/FP4/debug_ramdisk/adb_debug.prop
    • the cmd of this build step:
    /bin/bash -c "rm -f out/target/product/FP4/debug_ramdisk/adb_debug.prop && cp -f -d out/soong/.intermediates/system/core/rootdir/adb_debug.prop/android_debug_ramdisk_arm64_armv8-a_cortex-a76/adb_debug.prop out/target/product/FP4/debug_ramdisk/adb_debug.prop"
    
    • so here it is copied from: out/soong/.intermediates/system/core/rootdir/adb_debug.prop/android_debug_ramdisk_arm64_armv8-a_cortex-a76/adb_debug.prop
  • all other relevant build commands

[5619/159734] /bin/bash -c "

(rm -f out/target/product/FP4/obj/ETC/adb_debug.prop_intermediates/adb_debug.prop ) && 
(cp \"out/soong/.intermediates/system/core/rootdir/adb_debug.prop/android_debug_ramdisk_arm64_armv8-a_cortex-a76/adb_debug.prop\" \"out/target/product/FP4/obj/ETC/adb_debug.prop_intermediates/adb_debug.prop\" )
(chmod u+w \ "out/target/product/FP4/obj/ETC/adb_debug.prop_intermediates/adb_debug.prop\" )"
  • well there is a chmod u+w here, so out/target/product/FP4/obj/ETC/adb_debug.prop_intermediates/adb_debug.prop is writeable
5582/159734] rm -f out/soong/.intermediates/system/core/rootdir/adb_debug.prop/android_debug_ramdisk_arm64_armv8-a_cortex-a76/adb_debug.prop && 
cp -d  system/core/rootdir/adb_debug.prop out/soong/.intermediates/system/core/rootdir/adb_debug.prop/android_debug_ramdisk_arm64_armv8-a_cortex-a76/adb_debug.prop

other info

robotnix-sysimg> PLATFORM_VERSION_CODENAME=REL
robotnix-sysimg> PLATFORM_VERSION=13
robotnix-sysimg> LINEAGE_VERSION=20.0-20240501-EXPERIMENTAL-FP4
robotnix-sysimg> TARGET_PRODUCT=lineage_FP4
robotnix-sysimg> TARGET_BUILD_VARIANT=userdebug
robotnix-sysimg> TARGET_BUILD_TYPE=release
robotnix-sysimg> TARGET_ARCH=arm64
robotnix-sysimg> TARGET_ARCH_VARIANT=armv8-a
robotnix-sysimg> TARGET_CPU_VARIANT=cortex-a76
robotnix-sysimg> TARGET_2ND_ARCH=arm
robotnix-sysimg> TARGET_2ND_ARCH_VARIANT=armv8-a
robotnix-sysimg> TARGET_2ND_CPU_VARIANT=cortex-a76
robotnix-sysimg> HOST_ARCH=x86_64
robotnix-sysimg> HOST_2ND_ARCH=x86
robotnix-sysimg> HOST_OS=linux
robotnix-sysimg> HOST_OS_EXTRA=Linux-6.5.11-7-pve-x86_64
robotnix-sysimg> HOST_CROSS_OS=windows
robotnix-sysimg> HOST_CROSS_ARCH=x86
robotnix-sysimg> HOST_CROSS_2ND_ARCH=x86_64
robotnix-sysimg> HOST_BUILD_TYPE=release
robotnix-sysimg> BUILD_ID=TQ3A.230901.001
robotnix-sysimg> OUT_DIR=out
robotnix-sysimg> PRODUCT_SOONG_NAMESPACES=vendor/fairphone/FP4 device/fairphone/FP4 vendor/qcom/opensource/usb/e
tc hardware/qcom-caf/sm8250 vendor/qcom/opensource/commonsys/display vendor/qcom/opensource/commonsys-intf/displ
ay vendor/qcom/opensource/display vendor/qcom/opensource/data-ipa-cfg-mgr-legacy-um vendor/qcom/opensource/datas
ervices

this problem goes to a seccond era…

  • my fixing commit
  • so i fixed the problem, by patching the source and with the following patch … but when i then tried building it on another device the same permission error came up again…
  • after some testing, i figured out, that the patch file can change permissions, but after applying it nix removes write permissions from every file before writing finishing building a nix path…
  • next solution was to add a peace to the unpack-script with a config option extraUnpackScript: link
    • but this brought up the following:
nixos❯ one-phone-build ❯❯❯ ./debugEnterEnv
ln: failed to create symbolic link 'build/core/core': Read-only file system
ln: failed to create symbolic link 'build/target/target': Read-only file system
ln: failed to create symbolic link 'build/tools/tools': Read-only file system
chmod: changing permissions of 'system/core/rootdir/adb_debug.prop': Read-only file system
nixos❯ one-phone-build ❯❯❯
  • which makes sense, because it’s bind mounted from the /nix/store…
  • so then how could it have worked on my first building system???
    • well turnes out touch /nix/store/test also works … the nix store is just all writeable…
  • so the only real way to fix this, is to do it in the android src, where it is copied…

so fixing it in the android src

debuging is soo cool…

stack trace after break genrule.generatorFactory

0  0x00000000009cfd6f in android/soong/genrule.generatorFactory
   at ./build/soong/genrule/genrule.go:645
1  0x00000000009d21a5 in android/soong/genrule.NewGenRule
   at ./build/soong/genrule/genrule.go:825
2  0x00000000009d2a05 in android/soong/genrule.GenRuleFactory
   at ./build/soong/genrule/genrule.go:829
3  0x000000000089ebe2 in android/soong/android.ModuleFactoryAdaptor.func1
   at ./build/soong/android/register.go:113
4  0x00000000005c1d6b in github.com/google/blueprint.newModule
   at ./build/blueprint/context.go:1479
5  0x00000000005c2086 in github.com/google/blueprint.processModuleDef
   at ./build/blueprint/context.go:1508
6  0x00000000005b96eb in github.com/google/blueprint.(*Context).ParseFileList.func1
   at ./build/blueprint/context.go:830
7  0x00000000005bb7e8 in github.com/google/blueprint.(*Context).WalkBlueprintsFiles.func1.1
   at ./build/blueprint/context.go:967
8  0x0000000000466f61 in runtime.goexit
   at prebuilts/go/linux-x86/src/runtime/asm_amd64.s:1571

the build rule in the 11G out/soong/build.ninja file

# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# Module:  adb_debug.prop
# Variant: android_debug_ramdisk_arm64_armv8-a_cortex-a53
# Type:    prebuilt_root
# Factory: android/soong/android.ModuleFactoryAdaptor.func1
# Defined: system/core/rootdir/Android.bp:51:1

m.adb_debug.prop_android_debug_ramdisk_arm64_armv8-a_cortex-a53.moduleDesc = //system/core/rootdir:adb_debug.prop
m.adb_debug.prop_android_debug_ramdisk_arm64_armv8-a_cortex-a53.moduleDescSuffix =

build $
        out/soong/.intermediates/system/core/rootdir/adb_debug.prop/android_debug_ramdisk_arm64_armv8-a_cortex-a53/adb_debug.prop: g.android.Cp system/core/rootdir/adb_debug.prop

build $
        out/soong/.intermediates/system/core/rootdir/adb_debug.prop/android_debug_ramdisk_arm64_armv8-a_cortex-a53/meta_lic: g.android.licenseMetadataRule | ${g.android.licenseMetadataCmd}
    description = ${m.adb_debug.prop_android_debug_ramdisk_arm64_armv8-a_cortex-a53.moduleDesc}license metadata${m.adb_debug.prop_android_debug_ramdisk_arm64_armv8-a_cortex-a53.moduleDescSuffix}
    args = -mt prebuilt_root -r system/core/rootdir -mc UNKNOWN -p "Android" -k SPDX-license-identifier-Apache-2.0 -c notice -n 'build/soong/licenses/LICENSE:Android'    -t out/soong/.intermediates/system/core/rootdir/adb_debug.prop/android_debug_ramdisk_arm64_armv8-a_cortex-a53/adb_debug.prop -i out/target/product/starlte/debug_ramdisk/adb_debug.prop

stack trace of break at android/soong/etc.PrebuiltRootFactory()

0  0x00000000009b8ec9 in android/soong/etc.PrebuiltRootFactory
   at ./build/soong/etc/prebuilt_etc.go:453
1  0x000000000089ebe2 in android/soong/android.ModuleFactoryAdaptor.func1
   at ./build/soong/android/register.go:113
2  0x00000000005c1d6b in github.com/google/blueprint.newModule
   at ./build/blueprint/context.go:1479
3  0x00000000005c2086 in github.com/google/blueprint.processModuleDef
   at ./build/blueprint/context.go:1508
4  0x00000000005b96eb in github.com/google/blueprint.(*Context).ParseFileList.func1
   at ./build/blueprint/context.go:830
5  0x00000000005bb7e8 in github.com/google/blueprint.(*Context).WalkBlueprintsFiles.func1.1
   at ./build/blueprint/context.go:967
6  0x0000000000466f61 in runtime.goexit
   at prebuilts/go/linux-x86/src/runtime/asm_amd64.s:1571

found the location

diff --git a/android/defs.go b/android/defs.go
index 362b382..3aff0e0 100644
--- a/android/defs.go
+++ b/android/defs.go
@@ -52,7 +52,7 @@ var (
        // A copy rule.
        Cp = pctx.AndroidStaticRule("Cp",
                blueprint.RuleParams{
-                       Command:     "rm -f $out && cp $cpPreserveSymlinks $cpFlags $in $out$extraCmds",
+                       Command:     "rm -f $out && cp $cpPreserveSymlinks $cpFlags $in $out$extraCmds && chmod u+w $out",
                        Description: "cp $out",
                },
                "cpFlags", "extraCmds")