Skip to content

support merged /usr systems

Caleb Connolly requested to merge calebccff/apk-tools:usrmerge into master

Alpine does not currently follow the /usr merge filesystem layout, however it is possible to create a merged /usr Alpine system by adjusting apk to correctly rewrite symlinks and avoid installing symlinks where the link source and target end up in the same path on a /usr merged system.

Implement special handling when unpacking packages to skip these now redundant symlinks, and adjust others to point to the correct paths.

This patch has been tested with a full-fat GNOME installation: image

I'm targeting the 2.14-stable branch as there doesn't appear to be any kind of timeline on Alpine adopting apk3, and this is a change we are in the process of rolling out in postmarketOS. The additional logic is only used if the rootfs that apk is operating on has /bin as a symlink. For existing Alpine users this should have zero impact.

APK 3 rewrite

I reworked this based on @fabled 's feedback, my initial approach was definitely a non-starter. This has also been updated to target apk3. I have also backported to 2.14-stable as the approach taken here makes that trivial.

I'm not super confident that this catches every edge case, in pmOS we'll switch over our systemd branch to use the 2.14 backport of this patch for further testing. The biggest assumption made here is that there are no cases where a user might expect e.g. /bin/bap and /usr/bin/bap to both exist and have different behaviour, since obviously with the /usr merge that usecase is not supported. I haven't checked but I believe with this approach apk should correctly detect and report the file conflict.

apk info and apk audit presumably work better now, but admittedly I haven't verified this extensively.

With this iteration, it is now possible to set up a /usr merge rootfs by manually creating the symlinks and then using this version of apk to initialize the rootfs.

Context

postmarketOS is adopting the /usr merge layout for a few reasons, systemd being a major factor, but we do believe this is an overall improvement to pmOS and a change that would benefit Alpine too. We have investigated updating the FHS to document this layout (which has been common practise in most major distros for the last decade) however it seems that there is very little interest in this, and it doesn't feel like a useful time investment compared to just implementing it.

See this page for arguments in favour of the /usr merge layout.

Edited by Caleb Connolly

Merge request reports

Loading