This is an automated email from the ASF dual-hosted git repository.

joemcdonnell pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/impala.git

commit 9c6df6a69142801467c82fa8e0d972b366766f99
Author: Joe McDonnell <[email protected]>
AuthorDate: Tue Jun 13 19:12:20 2023 -0700

    IMPALA-12179 (part 1): Remove dependency on lsb_release for docker CMake
    
    Newer operating systems like Redhat 9 do not supply
    lsb_release as an official package. The /etc/os-release
    file provides the same information in a more convenient
    form. CMake 3.22 added support for reading those
    /etc/os-release values directly via cmake_host_system_information().
    
    This changes docker/CMakeLists.txt to use the new CMake
    cmake_host_system_information() APIs to get values from
    /etc/os-release. This removes the lsb_release code.
    
    Testing:
     - Ran a docker build locally and verified it detected
       the distribution / version correctly
    
    Change-Id: I04afd2b1c923f1331f7234d53a105a17956e3e18
    Reviewed-on: http://gerrit.cloudera.org:8080/20069
    Reviewed-by: Michael Smith <[email protected]>
    Tested-by: Joe McDonnell <[email protected]>
---
 CMakeLists.txt        |  2 +-
 docker/CMakeLists.txt | 47 ++++++++++++++++++++++-------------------------
 2 files changed, 23 insertions(+), 26 deletions(-)

diff --git a/CMakeLists.txt b/CMakeLists.txt
index 7b86e421d..8f91ae26a 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -15,7 +15,7 @@
 # specific language governing permissions and limitations
 # under the License.
 
-cmake_minimum_required(VERSION 3.14)
+cmake_minimum_required(VERSION 3.22)
 
 # This is a Kudu-specific flag that disables Kudu targets that are test-only.
 set(NO_TESTS 1)
diff --git a/docker/CMakeLists.txt b/docker/CMakeLists.txt
index 7f0455760..b4aebf352 100644
--- a/docker/CMakeLists.txt
+++ b/docker/CMakeLists.txt
@@ -25,42 +25,39 @@ set(IMPALA_UTILITY_BUILD_CONTEXT_DIR
 
 set(DOCKER_BUILD ${CMAKE_SOURCE_DIR}/docker/docker-build.sh)
 
-find_program(LSB_RELEASE_EXEC lsb_release)
-execute_process(COMMAND ${LSB_RELEASE_EXEC} -is
-  OUTPUT_VARIABLE LSB_RELEASE_ID
-  OUTPUT_STRIP_TRAILING_WHITESPACE
-)
-execute_process(COMMAND ${LSB_RELEASE_EXEC} -rs
-  OUTPUT_VARIABLE LSB_RELEASE_VERSION
-  OUTPUT_STRIP_TRAILING_WHITESPACE
-)
+# These CMake commands are using information from /etc/os-release
+cmake_host_system_information(RESULT OS_DISTRIB_ID QUERY DISTRIB_ID)
+cmake_host_system_information(RESULT OS_DISTRIB_VERSION_ID QUERY 
DISTRIB_VERSION_ID)
 
 set(QUICKSTART_BASE_IMAGE "UNSUPPORTED")
 set(DISTRO_BASE_IMAGE "UNSUPPORTED")
 
-if(${LSB_RELEASE_ID} STREQUAL "Ubuntu")
-  if(${LSB_RELEASE_VERSION} STREQUAL "16.04" OR
-     ${LSB_RELEASE_VERSION} STREQUAL "18.04" OR
-     ${LSB_RELEASE_VERSION} STREQUAL "20.04")
-    set(DISTRO_BASE_IMAGE "ubuntu:${LSB_RELEASE_VERSION}")
-    set(QUICKSTART_BASE_IMAGE "ubuntu:${LSB_RELEASE_VERSION}")
+# The CMake variables are using information from /etc/os-release.
+# A database of /etc/os-release files is available at
+# https://github.com/chef/os_release
+# These comparisons are based on those values.
+if(${OS_DISTRIB_ID} STREQUAL "ubuntu")
+  if(${OS_DISTRIB_VERSION_ID} STREQUAL "16.04" OR
+     ${OS_DISTRIB_VERSION_ID} STREQUAL "18.04" OR
+     ${OS_DISTRIB_VERSION_ID} STREQUAL "20.04")
+    set(DISTRO_BASE_IMAGE "ubuntu:${OS_DISTRIB_VERSION_ID}")
+    set(QUICKSTART_BASE_IMAGE "ubuntu:${OS_DISTRIB_VERSION_ID}")
   endif()
-  if (${LSB_RELEASE_VERSION} STREQUAL "16.04" OR
-      ${LSB_RELEASE_VERSION} STREQUAL "18.04")
+  if (${OS_DISTRIB_VERSION_ID} STREQUAL "16.04" OR
+      ${OS_DISTRIB_VERSION_ID} STREQUAL "18.04")
     set(PIP "python-pip")
-  elseif (${LSB_RELEASE_VERSION} STREQUAL "20.04")
+  elseif (${OS_DISTRIB_VERSION_ID} STREQUAL "20.04")
     set(PIP "python3-pip")
   endif()
-elseif(${LSB_RELEASE_ID} STREQUAL "RedHatEnterpriseServer" OR
-       ${LSB_RELEASE_ID} STREQUAL "RedHatEnterprise" OR
-       ${LSB_RELEASE_ID} STREQUAL "Rocky" OR
-       ${LSB_RELEASE_ID} STREQUAL "AlmaLinux" OR
-       ${LSB_RELEASE_ID} STREQUAL "CentOS")
+elseif(${OS_DISTRIB_ID} STREQUAL "rhel" OR
+       ${OS_DISTRIB_ID} STREQUAL "rocky" OR
+       ${OS_DISTRIB_ID} STREQUAL "almalinux" OR
+       ${OS_DISTRIB_ID} STREQUAL "centos")
   # The Quickstart images currently don't support using a Redhat
   # base image, so this doesn't set QUICKSTART_BASE_IMAGE.
-  if(${LSB_RELEASE_VERSION} MATCHES "7.*")
+  if(${OS_DISTRIB_VERSION_ID} MATCHES "7.*")
     set(DISTRO_BASE_IMAGE "$ENV{IMPALA_REDHAT7_DOCKER_BASE}")
-  elseif(${LSB_RELEASE_VERSION} MATCHES "8.*")
+  elseif(${OS_DISTRIB_VERSION_ID} MATCHES "8.*")
     set(DISTRO_BASE_IMAGE "$ENV{IMPALA_REDHAT8_DOCKER_BASE}")
   endif()
 endif()

Reply via email to