]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
build: Remove old ceph-libboost* packages in install-deps 52559/head
authorAdam Emerson <aemerson@redhat.com>
Wed, 19 Jul 2023 21:12:08 +0000 (17:12 -0400)
committerAdam Emerson <aemerson@redhat.com>
Mon, 31 Jul 2023 15:17:43 +0000 (11:17 -0400)
Here, we extract `clean_boost_on_ubuntu()` and call it before other
installs on Debian distributions so that if we install a system boost,
a potentially newer `ceph-libboost` won't get in the way.

As the sources.list.d being removed in the original cleanup code isn't
the one we're currently installing in the install code, add a removal
for the currently used source, then do apt-update so packages from the
removed source are no longer included as available.

Two subsidiary dev packages from conflicting boost libraries can be
installed, but it leaves apt in an inconsistent state. To clean this
up, add `--fix-missing` to the removal line and call
`clean_boost_on_ubuntu()` before other uses of apt.

Fixes: https://tracker.ceph.com/issues/62097
Signed-off-by: Adam Emerson <aemerson@redhat.com>
install-deps.sh

index 611aaeccf24e73ba4ce2e5788ec1ead6c00f6a2d..50a62682765c1cdaeb9ac81e32c1ff70c05fcca5 100755 (executable)
@@ -146,19 +146,51 @@ function install_pkg_on_ubuntu {
     fi
 }
 
+boost_ver=1.82
+
+function clean_boost_on_ubuntu {
+    ci_debug "Running clean_boost_on_ubuntu() in install-deps.sh"
+    # Find currently installed version. If there are multiple
+    # versions, they end up newline separated
+    local installed_ver=$(apt -qq list --installed ceph-libboost*-dev 2>/dev/null |
+                              cut -d' ' -f2 |
+                              cut -d'.' -f1,2 |
+                             sort -u)
+    # If installed_ver contains whitespace, we can't really count on it,
+    # but otherwise, bail out if the version installed is the version
+    # we want.
+    if test -n "$installed_ver" &&
+           echo -n "$installed_ver" | tr '[:space:]' ' ' | grep -v -q ' '; then
+       if echo "$installed_ver" | grep -q "^$boost_ver"; then
+           return
+        fi
+    fi
+
+    # Historical packages
+    $SUDO rm -f /etc/apt/sources.list.d/ceph-libboost*.list
+    # Currently used
+    $SUDO rm -f /etc/apt/sources.list.d/libboost.list
+    # Refresh package list so things aren't in the available list.
+    $SUDO env DEBIAN_FRONTEND=noninteractive apt-get update -y || true
+    # Remove all ceph-libboost packages. We have an early return if
+    # the desired version is already (and the only) version installed,
+    # so no need to spare it.
+    if test -n "$installed_ver"; then
+       $SUDO env DEBIAN_FRONTEND=noninteractive apt-get -y --fix-missing remove "ceph-libboost*"
+    fi
+}
+
 function install_boost_on_ubuntu {
     ci_debug "Running install_boost_on_ubuntu() in install-deps.sh"
-    local ver=1.82
+    # Once we get to this point, clean_boost_on_ubuntu() should ensure
+    # that there is no more than one installed version.
     local installed_ver=$(apt -qq list --installed ceph-libboost*-dev 2>/dev/null |
                               grep -e 'libboost[0-9].[0-9]\+-dev' |
                               cut -d' ' -f2 |
                               cut -d'.' -f1,2)
     if test -n "$installed_ver"; then
-        if echo "$installed_ver" | grep -q "^$ver"; then
+        if echo "$installed_ver" | grep -q "^$boost_ver"; then
             return
-        else
-            $SUDO env DEBIAN_FRONTEND=noninteractive apt-get -y remove "ceph-libboost.*${installed_ver}.*"
-            $SUDO rm -f /etc/apt/sources.list.d/ceph-libboost${installed_ver}.list
         fi
     fi
     local codename=$1
@@ -169,22 +201,22 @@ function install_boost_on_ubuntu {
         $sha1 \
         $codename \
         check \
-        ceph-libboost-atomic$ver-dev \
-        ceph-libboost-chrono$ver-dev \
-        ceph-libboost-container$ver-dev \
-        ceph-libboost-context$ver-dev \
-        ceph-libboost-coroutine$ver-dev \
-        ceph-libboost-date-time$ver-dev \
-        ceph-libboost-filesystem$ver-dev \
-        ceph-libboost-iostreams$ver-dev \
-        ceph-libboost-program-options$ver-dev \
-        ceph-libboost-python$ver-dev \
-        ceph-libboost-random$ver-dev \
-        ceph-libboost-regex$ver-dev \
-        ceph-libboost-system$ver-dev \
-        ceph-libboost-test$ver-dev \
-        ceph-libboost-thread$ver-dev \
-        ceph-libboost-timer$ver-dev
+        ceph-libboost-atomic${boost_ver}-dev \
+        ceph-libboost-chrono${boost_ver}-dev \
+        ceph-libboost-container${boost_ver}-dev \
+        ceph-libboost-context${boost_ver}-dev \
+        ceph-libboost-coroutine${boost_ver}-dev \
+        ceph-libboost-date-time${boost_ver}-dev \
+        ceph-libboost-filesystem${boost_ver}-dev \
+        ceph-libboost-iostreams${boost_ver}-dev \
+        ceph-libboost-program-options${boost_ver}-dev \
+        ceph-libboost-python${boost_ver}-dev \
+        ceph-libboost-random${boost_ver}-dev \
+        ceph-libboost-regex${boost_ver}-dev \
+        ceph-libboost-system${boost_ver}-dev \
+        ceph-libboost-test${boost_ver}-dev \
+        ceph-libboost-thread${boost_ver}-dev \
+        ceph-libboost-timer${boost_ver}-dev
 }
 
 function install_libzbd_on_ubuntu {
@@ -396,6 +428,9 @@ else
     case "$ID" in
     debian|ubuntu|devuan|elementary|softiron)
         echo "Using apt-get to install dependencies"
+       # Put this before any other invocation of apt so it can clean
+       # up in a broken case.
+        clean_boost_on_ubuntu
         if [ "$INSTALL_EXTRA_PACKAGES" ]; then
             if ! $SUDO apt-get install -y $INSTALL_EXTRA_PACKAGES ; then
                 # try again. ported over from run-make.sh (orignally e278295)