]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
build: Remove old ceph-libboost* packages in install-deps 52769/head
authorAdam Emerson <aemerson@redhat.com>
Wed, 19 Jul 2023 21:12:08 +0000 (17:12 -0400)
committerAdam Emerson <aemerson@redhat.com>
Thu, 3 Aug 2023 14:14:35 +0000 (10:14 -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>
(cherry picked from commit 0c3f511e14af639b6509e69b889258b2f718f8fd)

Conflicts:
install-deps.sh
 - Different boost version for Reef than Squid
 - ci_debug does not exist in Reef
 - No INSTALL_EXTRA

Signed-off-by: Adam Emerson <aemerson@redhat.com>
install-deps.sh

index e9dae008e289f04ddd02ec252c352048e001cc18..eb773c3eb40c1dc7a2489225e7ea1d20476beac8 100755 (executable)
@@ -141,19 +141,51 @@ function install_pkg_on_ubuntu {
     fi
 }
 
+boost_ver=1.79
+
+function clean_boost_on_ubuntu {
+    in_jenkins && echo "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 {
     in_jenkins && echo "CI_DEBUG: Running install_boost_on_ubuntu() in install-deps.sh"
-    local ver=1.79
+    # 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
@@ -164,22 +196,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 {
@@ -330,6 +362,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
         $SUDO apt-get install -y devscripts equivs
         $SUDO apt-get install -y dpkg-dev
         ensure_python3_sphinx_on_ubuntu