Search code examples
android-x86

"depmod" is not allowed to be used


I am trying to build android-x86 https://www.android-x86.org/source.html Branch q-x86 Using ubuntu 20. I followed the instructions and installed all the dependencies mentioned at the page. But I am facing the following error. I don`t know how to deal with it. Google search did not help me at all.

DEPMOD  4.19.175-android-x86-gad005d7cff5c
"depmod" is not allowed to be used. See https://android.googlesource.com/platform/build/+/master/Changes.md#PATH_Tools for more information.
make[1]: *** [/home/nadir/androidx86/kernel/Makefile:1404: _modinst_post] Error 1
make[1]: Leaving directory '/home/nadir/androidx86/out/target/product/x86/obj/kernel'
make: *** [Makefile:146: sub-make] Error 2
make: Leaving directory '/home/nadir/androidx86/kernel'
FAILED: [W][2021-05-16T08:15:17-0400][535663] void cmdline::logParams(nsjconf_t *)():250 Process will be UID/EUID=0 in the global user namespace, and will have user root-level access to files
[W][2021-05-16T08:15:17-0400][535663] void cmdline::logParams(nsjconf_t *)():260 Process will be GID/EGID=0 in the global user namespace, and will have group root-level access to files
08:41:17 ninja failed with: exit status 1

How to deal with this because the URL mentioned in the error does not help in this case. On that page there is not even a single time depmode or anything related to it mentioned.


Solution

  • I figured out what was happening after I had the same issue. As I can see the answer can technically be found in the link the error gives you, but the error and fix don’t make a whole lot of correlation. I attempted to fix this problem by giving my non-root user permission to execute depmod with sudo without a password. After some trial and error I discovered the lines that called depmod were on lines 20 and 48 of the kernel/scripts/depmod.sh, I amended the two lines by adding sudo in the front and restarted my build. However, I got a different error, “sudo is not allowed to be used”. This really got my thinking.

    So I checked that link they gave for the AOSP source code. In the “PATH Tools” section it states:

    The build has started restricting the external host tools usable inside the build. …

    This led me to two ways of working out the issue. First one which is likely the easiest is to add TEMPORARY_DISABLE_PATH_RESTRICTIONS=true after your command to build the kernel. As you may guess this would disable the restriction that is disallowing the depmod command. The alternative option is to open the file build/soong/ui/build/paths/config.go and add the line "depmod": Allowed, like so:

    “date”:     Allowed,
    “dd”:       Allowed,
    “depmod”:   Allowed,
    “diff”:     Allowed,
    “egrep”:    Allowed,
    

    Both methods allowed me to build the kernel as expected. However, it is only a workaround for something that I can’t identify as a Ubuntu issue or an oversight by the Android x86 developers. Likely a patch would need to be proposed, but since I don’t know more than about the Android kernel ecosystem, I’m unable to know if just adding the command to the allowed configuration will fix it.