-
Notifications
You must be signed in to change notification settings - Fork 71
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fool build process into thinking sources are mounted with write permissions in order to work around the copy patch #240
Comments
Ok, so I actually ended up playing around with it a bit and it's more complicated than it seems. So the initial solution I mentioned in matrix (to wit, using Your suggestion to I then remembered there's a FUSE-based At this point I decided to do away with
At this point I noticed that I have actually rediscovered something robotnix was already doing between 2019 and 2020: https://github.com/search?q=repo%3Anix-community%2Frobotnix+bind&type=commits. It's unclear from the commit messages why it was removed, but I can assume that it could've been the perf impact. At some later point I remembered hearing about kernel-level idmapping support and decide to see if that could work, but so far no dice. By that I mean that sure, But if it doesn't, then I guess the best we can do is what we currently do — that is, patching with EDIT: idmapped kernel mounts also seem out, as they are checked against |
It's been a long time since I was experimenting with this, but I remember trying to do this with both bindfs and using overlayfs + chmod. In both cases the impact on build performance too much, which is why I ultimately abandoned those approaches. |
A super simple hack around that'd obviate patches could be to just inject a Ideally check whether the src isn't in the output directory to avoid any potential correctness issues but, honestly, I don't see how it could cause any actual issue. |
@alyaeanyx tried adding a wrapper to the FHSEnv yesterday but it didn't work. Likely the AOSP build process provides its own coreutils that we'd need to patch. |
I'm not sure what flavour you're talking about — so it might be different in your case — but at least in the case of GrapheneOS it seems it's exactly the thing I linked above does: # hack to make sure the out directory remains writeable after copying files/directories from /nix/store mounted sources
source.dirs."prebuilts/build-tools".postPatch = mkIf (config.androidVersion >= 13) ''
pushd path/linux-x86
mv cp .cp-wrapped
cp ${pkgs.substituteAll { src = ./fix-perms.sh; inherit (pkgs) bash; }} cp
chmod +x cp
popd
''; with #!@bash@/bin/bash
make_writeable() {
for a in "$@"; do
if [[ "$a" == ${OUT_DIR}* ]] && [[ -e "$(realpath "$a")" ]]; then
chmod u+w -R "$a"
fi
done
}
bash -c "exec -a cp $(dirname ''${BASH_SOURCE[0]})/.cp-wrapped $*" && make_writeable "$@" Not sure if that's the best way to do it, but seemed to work properly last time I touched it. |
Indeed, something like that would work. I had totally missed that. |
We have a patch for many generic copy functions to not copy the permissions as all permissions of the sources are the default nix store permissions. This patch has to be rebased for every major android version though and isn't the best of solutions.
An idea I had on this was to somehow fool the build system into thinking the source dirs have write permissions via some mount magic.
The text was updated successfully, but these errors were encountered: