[HOWTO] ✏ Compiling Fairphone Open OS / Rooting

Well, it will call just any mk file it can find. Did you clean the build completely and re-ran the environment.sh script (or what it’s called) after applying the changes?

The more clean way to do it would be to clone the repository where you want to do the changes, do the changes, commit and then replace this repository by your local copy in the manifest and re-run repo sync. But I guess for what you are trying the dirty way should be sufficient.

I’ve just noticed that there’s a couple of su-related open code reviews on Gerrit with topic:appops_su.
May be useful.

2 Likes

Wow, I didn’t know they had a public gerrit instance! Maybe it’s worth just cherry-picking all the commits related to supersu? They are supposed to include it in the build process if I read the commit log properly.

Aaaww… this is beautiful :grin:

I don’t have access to Gerrit, but this one here looks interesting.

The su source that gets build is located here:

/system/extras/su

I would just rename it and copy “your” su later.

system/extras/su/Android.mk (change to):
LOCAL_MODULE:= su-old

Not sure if it will work/compile, just a quick hack to make “make” happy.

Too bad there are no changelogs posted for changes in Gerrit here. I have no clue what people are working on there.

This is the full changelog, isn’t it? Normally you can see all open merge requests here:

http://code.fairphone.com/gerrit/#/q/status:open

The ones that were merged into the source should appear under “closed”, but apparently there are none (yet). Personally, I also don’t like the idea of keeping things more or less closed (although you can dig through the git commit history of course if you want to).

But yes, we need a public issue tracker as already has been discussed here:

I guess it’s the right way to do it professionally (review, commit). But there is no howto for the “normal” people on how to pull what kind of changes (even if still under review). Some hints how do use it with repo can be found here.

1 Like

Well if somebody (@xaxa a maybe?) would be so kind to cherry-pick this stuff and do a userdebug build and check if root is working we could include cherry-picking these commits in the build instructions as long as they remain unmerged.

Believe me I will do, and I will put effort into a crystal-clear how-to… just give me some time to make it work and build it.

3 Likes

Ok, I’ve built the source with patches 5…11.

With seSuperuser/Superuser in a local repo manifest, I get the following error:

package/apps/Superuser/Superuser/jni/su/su.c:562: error: undefined reference to 'hacks_update_context'
package/apps/Superuser/Superuser/jni/su/su.c:478: error: undefined reference to 'bind_remove'
package/apps/Superuser/Superuser/jni/su/su.c:486: error: undefined reference to 'bind_ls'
package/apps/Superuser/Superuser/jni/su/su.c:490: error: undefined reference to 'bind_uniq_dst'
package/apps/Superuser/Superuser/jni/su/su.c:509: error: undefined reference to 'init_remove'
package/apps/Superuser/Superuser/jni/su/su.c:517: error: undefined reference to 'init_ls'
package/apps/Superuser/Superuser/jni/su/su.c:520: error: undefined reference to 'init_uniq'
package/apps/Superuser/Superuser/jni/su/su.c:870: error: undefined reference to 'hacks_init'
package/apps/Superuser/Superuser/jni/su/daemon.c:545: error: undefined reference to 'bind_foreach'
package/apps/Superuser/Superuser/jni/su/daemon.c:566: error: undefined reference to 'init_foreach'
collect2: error: ld returned 1 exit status
make: *** [out/target/product/FP2/obj/EXECUTABLES/su_intermediates/LINKED/su] Error 1

When I use CyanogenMod/Superuser instead, the build succeeds, but I find no su binary build anywhere.

After applying this hack, I got it to build. (Really weird error where build doesn’t pick up all source files.) It doesn’t install su to the correct location and correct permissions, though.

edit it turns out seSuperuser hasn’t been updated for building in-tree. Use my fork if you want it to compile. I can’t get the daemon to run on startup, though. Not even after adding import /init.superuser.rc after the other imports in system/core/rootdir/init.rc.

edit after adding some SELinux stuff (part of fork) the daemon starts, I just get Permission denied now.
Also, you can use this manifest now (for as long as the fork is needed).

edit after installing com.koushikdutta.superuser running su on the shell works!

After successful compiling the Image in a Docker Container. Where can i find them? :anguished:

1 Like

@jom in out/target/product/FP2. I use this, from the source root, to flash:

 sudo ANDROID_PRODUCT_OUT=`pwd`/out/target/product/FP2 `which fastboot` flashall

Note that you probably can’t (easily) flash from the Docker container.

You are right. One would have to configure the container to have access to USB. It’s probably possible, I don’t know how.

But you can easily install fastboot on your host operating system (it is available for Linux, Windows, etc) and flash from there. Incidentally that’s what I did half an hour ago.

1 Like

In case anyone else had the same problem, what I did to fix it was open the id_rsa.pub file and copy it from my text editor instead of pasting the results of “cat id_rsa.pub”.

But at the same time I also poked around my account on the website and added a user name, that might have been what actually fixed it.

It seems it’s starting to work! These are the steps I took.

After repo sync, fetch the superuser-related patches from Fairphone’s Gerrit and add Superuser:

# Apply pending Superuser patches
repo download fp2-dev/device/qcom/sepolicy 5
repo download fp2-dev/device/fairphone_devices/sepolicy 6
repo download fp2-dev/device/fairphone_devices/fairphone 7
repo download fp2-dev/platform/frameworks/base 8
repo download fp2-dev/platform/packages/apps/Settings 9
repo download fp2-dev/platform/system/core 10
repo download fp2-dev/platform/system/extras 11

# Add local manifest for Superuser's su
mkdir -p .repo/local_manifests
wget -O .repo/local_manifests/superuser.xml https://raw.githubusercontent.com/wvengen/Superuser/feature/try-fix-aosp-build/local_manifest.xml
repo sync -c package/apps/Superuser package/apps/Widgets

Then edit system/core/rootdir/init.rc and add after the existing imports:

import /init.superuser.rc

edit: editing init.rc may not be necessary, patch 7 seems to add it already.
Then continue to build and upload.
When you have installed Superuser with package name com.koushikdutta.superuser, it may just work.

I’m curious to hear if this works for anyone else.

2 Likes

I’m glad to hear it works for you. I got familiar with this missing import aswell :relieved: Saying I see you are making the same steps I have done right one week before :slightly_smiling:
Since it is not easy to understand short-held compiling questions, I wasn’t sure about your knowledge-level. My build is running right now, and if it works, I’ll have a one-build solution with TWRP and Superuser-embedded all-at-once. We’ll see…

@xaxa great, let’s see!

This does not yet include the Superuser app. It would be useful to have it installed in the system image, and it would be good for security (or any app using the same id could obtain root when it’s not installed).
It seems that currently only su in the shell works, not from apps :frowning: I guess it’s a permissions/user/selinux problem (selinux line + Permission denied for opening local socket).

Does anyone here (running their own version of android) experience the random reboots everybody is discussing here:

2 Likes

When I try to compile, I get the following error:

[code]out/host/linux-x86/bin/checkpolicy: loading policy configuration from out/target/product/generic/obj/ETC/sepolicy_intermediates/policy.conf
external/sepolicy/radio.te:33:ERROR ‘unknown type persist_file’ at token ‘;’ on line 3850:
allow radio persist_file:dir search;

checkpolicy: error(s) encountered while parsing configuration
external/sepolicy/Android.mk:121: recipe for target ‘out/target/product/generic/obj/ETC/sepolicy_intermediates/sepolicy’ failed
make: *** [out/target/product/generic/obj/ETC/sepolicy_intermediates/sepolicy] Error [/code]

When I then do cd external/sepolicy/; git checkout cae72b60bc2e4f5509c08232f211044af7eb375d and try to compile again

clang: error: linker command failed with exit code 1 (use -v to see invocation)
build/core/host_shared_library_internal.mk:44: recipe for target 'out/host/linux-x86/obj32/lib/libnativehelper.so' failed
make: *** [out/host/linux-x86/obj32/lib/libnativehelper.so] Error 1

My build (host) system is Arch Linux.