canonical / snapcraft-rocks

Sources for Snapcraft as OCI images, maintained by the Starcraft team
GNU General Public License v3.0
4 stars 1 forks source link

fix: make dpkg/apt aware of installed python packages #45

Closed tigarmo closed 3 months ago

tigarmo commented 3 months ago

This fixes an issue where calling "craftctl" in a scriptlet would fail with a ModuleNotFoundError for craft_parts. This happened when the snapcraft project included build-packages that pulled in libpython3.10-minimal.

The reason that this failed is because in Rockcraft the python plugin (used to build the snapcraft part) works by adding a custom "sitecustomize.py" in /usr/lib/python3.10/ to add the part's Python libraries to the Python path. This is fine unless the libpython3.10-minimal package is explicitly installed later on a container created from the rock, because that package has its own sitecustomize.py file which overwrites Rockcraft's.

The solution is to make apt and dpkg aware that all of these Python-related packages are already installed in the rock, by adding the dependency explicitly as an overlay-package. This also has the extra beneficial side-effect of improving installation of build-packages because dpkg/apt are aware of the installed packages and don't have to download and re-install them unnecessarily.

Fixes #33.