canonical / snapcraft

Package, distribute, and update any app for Linux and IoT.
https://snapcraft.io
GNU General Public License v3.0
1.18k stars 442 forks source link

Python apt resolves differently with apt from Ubuntu 22.04 #4254

Open sergiusens opened 1 year ago

sergiusens commented 1 year ago

Bug Description

The resolver seems to not see packages it once saw when using Apt and Python Apt from Ubuntu 20.04

To Reproduce

Environment

Spread GHA

snapcraft.yaml

name: catkin-rosrun-wrapper
version: "1.0"
summary: hello world
description: |
  A ROS 1 roscpp-based workspace.

grade: stable
confinement: strict
base: core20

apps:
  catkin-rosrun-wrapper:
    command: rosrun snapcraft_hello snapcraft_hello
    plugs: [network, network-bind]
    extensions: [ros1-noetic]
    environment:
      ROS_HOME: "$SNAP_USER_DATA/ros"

parts:
  hello:
    plugin: catkin-tools
    source: .
    build-packages: [g++, make]
    stage-packages: [rosbash]

Relevant log output

Marking 'rosbash' (and its dependencies) to be fetched
package: <Package: name:'rosbash' architecture='amd64' id:81639>
Failed to fetch stage packages: Error downloading packages for part 'hello': The package 'rosbash' was not found..

Additional context

No response

cmatsuoka commented 1 year ago

Building the focal apt in the core22 snap (using the patch below) restores the original behavior, so differences in the dependency resolution algorithm between the two versions seems to be causing this issue. Maybe this is a consequence of a bugfix, @julian-klode may have more information on what could be happening here.

diff --git a/snap/snapcraft.yaml b/snap/snapcraft.yaml
index c2139c108..4201d9591 100644
--- a/snap/snapcraft.yaml
+++ b/snap/snapcraft.yaml
@@ -29,7 +29,7 @@ build-packages:
   - cargo
   - build-essential
   - intltool
-  - libapt-pkg-dev
+  #- libapt-pkg-dev
   - libffi-dev
   - libssl-dev
   - libsodium-dev
@@ -44,6 +44,31 @@ build-packages:
   - sed

 parts:
+  apt:
+    source: http://archive.ubuntu.com/ubuntu/pool/main/a/apt/apt_2.0.2ubuntu0.2.tar.xz
+    plugin: cmake
+    cmake-parameters:
+      - -DCMAKE_INSTALL_PREFIX=/usr
+    build-attributes:
+      - enable-patchelf
+    build-packages:
+      - triehash
+      - libgnutls28-dev
+      - libbz2-dev
+      - liblz4-dev
+      - docbook-xml
+      - docbook-xsl
+      - doxygen
+      - libgtest-dev
+      - libdb-dev
+      - libgcrypt20-dev
+      - po4a
+      - libzstd-dev
+      - xsltproc
+      - w3m
+    stage-packages:
+      - libxxhash0
+
   bash-completion:
     source: debian
     plugin: dump
     plugin: dump
@@ -77,11 +102,12 @@ parts:
       - bin/patchelf

   snapcraft-libs:
+    after: [apt]
     plugin: nil
     stage-packages:
-        - apt
-        - apt-transport-https
-        - apt-utils
+        #- apt
+        #- apt-transport-https
+        #- apt-utils
         - binutils
         - execstack
         - gpg
cmatsuoka commented 1 year ago

This is the apt commit that causes the rosbash problem:

ae23e53f99ea0b7920744a7303fdee64796b7cce is the first bad commit
commit ae23e53f99ea0b7920744a7303fdee64796b7cce
Author: David Kalnischkies <david@kalnischkies.de>
Date:   Mon Apr 27 13:51:46 2020 +0200

    Protect a package while resolving in MarkInstall

    Strange things happen if while resolving the dependencies of a package
    said dependencies want to remove the package. The allow-scores test e.g.
    removed the preferred alternative in favor of the last one now that they
    were exclusive. In our or-group for Recommends we would "just" not
    statisfy the Recommends and for Depends we engage the ProblemResolver…

 apt-pkg/depcache.cc                                | 35 +++++++++++++++++-----
 apt-pkg/depcache.h                                 |  4 +--
 .../test-allow-scores-for-all-dependency-types     | 34 ++++-----------------
 .../test-explore-or-groups-in-markinstall          | 14 +++++++++
 4 files changed, 48 insertions(+), 39 deletions(-)