]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
build/ops: refrain from installing/using lsb_release in install-deps.sh
authorNathan Cutler <ncutler@suse.com>
Wed, 1 Aug 2018 10:52:45 +0000 (12:52 +0200)
committerNathan Cutler <ncutler@suse.com>
Fri, 4 Oct 2019 15:20:29 +0000 (17:20 +0200)
Unfortunately the mapping between release number and codename (which is only
relevant for Debian and Ubuntu btw) is not available from /etc/os-release.
In that one respect, lsb_release was "better".

However, when I weigh the advantages of obtaining that mapping from an external
tool, with the (substantial) risk that the external dependency might cause
trouble on one or more supported distros (to say nothing of the non- or
semi-/pseudo-supported ones), against the work involved in maintaining a
hard-coded mapping (negligible), the needle on my scale immediately swings
toward eliminating the dependency.

Also, I see this commit as part of the longer-term effort to completely expunge
lsb_release from our codebase. See git log --grep lsb_release.

For another example of an external distro-detection tool (albeit one that was
included in Python 2) gone awry, see http://tracker.ceph.com/issues/18163.

Signed-off-by: Nathan Cutler <ncutler@suse.com>
(cherry picked from commit 38508b41dc7f33a0b35e3633be3da1d2dae844dc)

Conflicts:
install-deps.sh

install-deps.sh

index 30df5efacb012816bec81061bb63234599121c5d..98e8a6c30e074dc12fe13ac08a66391d932c5d8e 100755 (executable)
@@ -164,11 +164,11 @@ else
 
        backports=""
        control="debian/control"
-        case $(lsb_release -sc) in
-            squeeze|wheezy)
+        case "$VERSION" in
+            *squeeze*|*wheezy*)
                control="/tmp/control.$$"
                grep -v babeltrace debian/control > $control
-                backports="-t $(lsb_release -sc)-backports"
+                backports="-t $codename-backports"
                 ;;
         esac
 
@@ -187,30 +187,28 @@ else
             builddepcmd="dnf -y builddep --allowerasing"
         fi
         echo "Using $yumdnf to install dependencies"
-       if [ $(lsb_release -si) = CentOS -a $(uname -m) = aarch64 ]; then
+       if [ "$ID" = "centos" -a $(uname -m) = aarch64 ]; then
            $SUDO yum-config-manager --disable centos-sclo-sclo || true
            $SUDO yum-config-manager --disable centos-sclo-rh || true
            $SUDO yum remove centos-release-scl || true
        fi
 
-        $SUDO $yumdnf install -y redhat-lsb-core
-        case $(lsb_release -si) in
-            Fedora)
+        case $ID in
+            fedora)
                 if test $yumdnf = yum; then
                     $SUDO $yumdnf install -y yum-utils
                 fi
                 ;;
-            CentOS|RedHatEnterpriseServer|VirtuozzoLinux)
+            centos|rhel|ol|virtuozzo)
                 $SUDO yum install -y yum-utils
-                MAJOR_VERSION=$(lsb_release -rs | cut -f1 -d.)
-                if test $(lsb_release -si) = RedHatEnterpriseServer ; then
-                    $SUDO yum-config-manager --enable rhel-$MAJOR_VERSION-server-optional-rpms
+                if test $ID = rhel ; then
+                    $SUDO yum-config-manager --enable rhel-$VERSION_ID-server-optional-rpms
                 fi
-                $SUDO yum-config-manager --add-repo https://dl.fedoraproject.org/pub/epel/$MAJOR_VERSION/x86_64/
+                $SUDO yum-config-manager --add-repo https://dl.fedoraproject.org/pub/epel/$VERSION_ID/x86_64/
                 $SUDO yum install --nogpgcheck -y epel-release
-                $SUDO rpm --import /etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-$MAJOR_VERSION
+                $SUDO rpm --import /etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-$VERSION_ID
                 $SUDO rm -f /etc/yum.repos.d/dl.fedoraproject.org*
-                if test $(lsb_release -si) = CentOS -a $MAJOR_VERSION = 7 ; then
+                if test $ID = centos -a $VERSION_ID = 7 ; then
                     $SUDO yum-config-manager --enable cr
                    case $(uname -m) in
                        x86_64)
@@ -224,10 +222,10 @@ else
                            dts_ver=7
                            ;;
                    esac
-                elif test $(lsb_release -si) = RedHatEnterpriseServer -a $MAJOR_VERSION = 7 ; then
+                elif test $ID = rhel -a $MAJOR_VERSION = 7 ; then
                     $SUDO yum-config-manager --enable rhel-server-rhscl-7-rpms
                     dts_ver=7
-                elif test $(lsb_release -si) = VirtuozzoLinux -a $MAJOR_VERSION = 7 ; then
+                elif test $ID = virtuozzo -a $MAJOR_VERSION = 7 ; then
                     $SUDO yum-config-manager --enable cr
                 fi
                 ;;
@@ -243,7 +241,7 @@ else
     opensuse*|suse|sles)
         echo "Using zypper to install dependencies"
         zypp_install="zypper --gpg-auto-import-keys --non-interactive install --no-recommends"
-        $SUDO $zypp_install lsb-release systemd-rpm-macros
+        $SUDO $zypp_install systemd-rpm-macros
         munge_ceph_spec_in $DIR/ceph.spec
         $SUDO $zypp_install $(rpmspec -q --buildrequires $DIR/ceph.spec) || exit 1
         ;;