libdevmapper-dev fails to install as build-package using snapcraft:core20 (Multipass)
Metadata
Current evaluation
No evaluation has been recorded for this issue yet.
Issue body
# Description
When trying to install the package `libdevmapper-dev` as a build-package in a core20 based snap, the package fails due to a discrepancy in the apt sources between updating the multipass build instance and installing the build packages specified in the `snapcraft.yaml` file.
# Snapcraft, Multipass, and Ubuntu versions
$ snapcraft version
snapcraft 7.0.11
$ multipass version
multipass 1.10.1
multipassd 1.10.1
# Stacktrace and what I expect to happen
```
Some packages could not be installed. This may mean that you have
requested an impossible situation or if you are using the unstable
distribution that some required packages have not yet been created
or been moved out of Incoming.
The following information may help to resolve the situation:
The following packages have unmet dependencies:
libdevmapper-dev : Depends: libdevmapper1.02.1 (= 2:1.02.167-1ubuntu1) but 2:1.02.175-2ubuntu4~ubuntu20.04.1 is to be installed
E: Unable to correct problems, you have held broken packages.
```
I expect libdevmapper-dev to install correctly because I already have libdevmapper1.02.1 installed inside the multipass instance.
# Steps to reproduce
Currently, I am trying to build the microstack snap to troubleshoot some confinement issues (not related to this issue). Here are the commands that I am using to try and build the package:
1. sudo snap install multipass --classic
2. sudo snap install snapcraft --classic
3. git clone https://opendev.org/x/microstack.git
4. cd microstack
5. snapcraft
# Preliminary investigation
Browsing two separate environments, I noticed there is a discrepancy between the apt-cache policy for the libdevmapper-dev package between the unmodified snapcraft:core20 image and the failed build instance.
*Policy for base instance*
```
$ apt-cache policy libdevmapper-dev
libdevmapper-dev:
Installed: (none)
Candidate: 2:1.02.167-1ubuntu1
Version table:
2:1.02.175-2ubuntu4~ubuntu20.04.1 100
100 http://archive.ubuntu.com/ubuntu focal-backports/main amd64 Packages
2:1.02.167-1ubuntu1 500
500 http://archive.ubuntu.com/ubuntu focal/main amd64 Packages
```
*Policy for failed build instance*
```
$ apt-cache policy libdevmapper-dev
libdevmapper-dev:
Installed: (none)
Candidate: 2:1.02.167-1ubuntu1
Version table:
2:1.02.167-1ubuntu1 500
500 http://archive.ubuntu.com/ubuntu focal/main amd64 Packages
```
Looking at these policies, it seems that when the build instance is upgrading, before pulling in the build-dependencies, apt is pulling packages from both the main and focal-backports pockets. Once the upgrade finishes, the apt sources update so that apt will only pull from the main pocket. However, since libdevmapper-dev is not compatible with the libdevmapper1.02.1 pulled from focal-backports pocket, libdevmapper-dev fails to install. I found the apt sources being changed when parsing output from journalctl.
# Potential impact and mitigation
Any snap package using core20 as its base that requires `libdevmapper-dev` will fail to build if using multipass as the build provider. This bug might also affect other packages that are tied to a specific version of a package modified when the multipass instance is upgraded.
To get around this issue for now, any package that requires `libdevmapper-dev` as a build dependency should use LXD as the build provider.
1. sudo snap install lxd
2. lxd init --auto
3. snapcraft --use-lxd
You can also add focal-backports as a package repository in the `snapcraft.yaml` file: https://snapcraft.io/docs/package-repositories
# Potential solution
Either enable snapcraft to use the focal-backports pocket in multipass-backed builds, or disable the focal-backports pocket in the snapcraft:core20 multipass image so that apt does not pull from there when upgrading the instance.
# Attachments
* Log file for the snap package build
* journalctl | grep ".sources" output
Evaluation history
No evaluation history available.