szaszm commented on code in PR #1624:
URL: https://github.com/apache/nifi-minifi-cpp/pull/1624#discussion_r1285527169


##########
linux.sh:
##########
@@ -19,3 +19,30 @@ verify_gcc_enable(){
   #feature="$1"
   [ "$COMPILER_MAJOR" -ge 11 ] && echo true || echo false
 }
+
+install_cmake_from_binary() {
+  CMAKE_VERSION="3.24.4"
+  CMAKE_URL="https://cmake.org/files/v3.24/cmake-3.24.4-linux-x86_64.tar.gz";
+  
EXPECTED_SHA256="cac77d28fb8668c179ac02c283b058aeb846fe2133a57d40b503711281ed9f19"
+
+  TMP_DIR=$(mktemp -d)
+
+  install_pkgs wget
+  wget -P "$TMP_DIR" "$CMAKE_URL"
+
+  ACTUAL_SHA256=$(sha256sum 
"$TMP_DIR/cmake-$CMAKE_VERSION-linux-x86_64.tar.gz" | awk '{print $1}')

Review Comment:
   A small detail, but `cut` is much simler than `awk`, so it may be better to 
default to that.
   ```suggestion
     ACTUAL_SHA256=$(sha256sum 
"$TMP_DIR/cmake-$CMAKE_VERSION-linux-x86_64.tar.gz" | cut -d " " -f 2)
   ```



##########
linux.sh:
##########
@@ -19,3 +19,30 @@ verify_gcc_enable(){
   #feature="$1"
   [ "$COMPILER_MAJOR" -ge 11 ] && echo true || echo false
 }
+
+install_cmake_from_binary() {
+  CMAKE_VERSION="3.24.4"
+  CMAKE_URL="https://cmake.org/files/v3.24/cmake-3.24.4-linux-x86_64.tar.gz";
+  
EXPECTED_SHA256="cac77d28fb8668c179ac02c283b058aeb846fe2133a57d40b503711281ed9f19"
+
+  TMP_DIR=$(mktemp -d)
+
+  install_pkgs wget
+  wget -P "$TMP_DIR" "$CMAKE_URL"
+
+  ACTUAL_SHA256=$(sha256sum 
"$TMP_DIR/cmake-$CMAKE_VERSION-linux-x86_64.tar.gz" | awk '{print $1}')
+
+  if [ "$ACTUAL_SHA256" != "$EXPECTED_SHA256" ]; then
+    echo "ERROR: SHA-256 verification failed. Aborting."
+    rm -r "$TMP_DIR"
+    exit 1
+  fi
+
+  tar -C "$TMP_DIR" -zxvf "$TMP_DIR/cmake-$CMAKE_VERSION-linux-x86_64.tar.gz"
+  sudo mv "$TMP_DIR/cmake-$CMAKE_VERSION-linux-x86_64" 
/opt/cmake-$CMAKE_VERSION
+
+  sudo ln -s "/opt/cmake-$CMAKE_VERSION/bin/cmake" /usr/local/bin/cmake

Review Comment:
   We should print the details of this installation procedure, so the user at 
least knows what we're doing to their system. The best would be a message and a 
`set -x` before these commands, so they know what they're giving sudo password 
for. I'd also remove the verbose flag from tar, to avoid spamming the console, 
and keep the important parts visible.
   ```suggestion
     echo "Installing CMake $CMAKE_VERSION to /opt/cmake-$CMAKE_VERSION..."
     set -x
     tar -C "$TMP_DIR" -zxf "$TMP_DIR/cmake-$CMAKE_VERSION-linux-x86_64.tar.gz"
     sudo mv "$TMP_DIR/cmake-$CMAKE_VERSION-linux-x86_64" 
/opt/cmake-$CMAKE_VERSION
   
     sudo ln -s "/opt/cmake-$CMAKE_VERSION/bin/cmake" /usr/local/bin/cmake
     set +x
   ```



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to