Skip to content

Script build/build.bash improvements #27

Description

@sobolev-es

Hello.

  1. Return code of pipe
yum -y install wget | tee -a $LOGFILE

is the return code of tee, not yum.
Add "set -o pipefail" or use more bash-specific PIPESTATUS

  1. We use oracle linux - code ready builder repo name is ol9_codeready_builder

Patch

--- build.bash.orig     2025-02-03 10:23:22.277692320 +0300
+++ build.bash  2025-02-03 10:47:08.576374670 +0300
@@ -17,6 +17,8 @@
 # You should have received a copy of the GNU General Public License
 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
 #-----------------------------------------------------------------------------#
+set -o pipefail
+
 action=$1
 [[ -z $action ]] && action="production" # default to prod if no arg supplied
 
@@ -214,13 +216,21 @@
     #-----------------------------------------------------------------------------#
     # crb repo
     #-----------------------------------------------------------------------------#
-    rpm -q redhat-release >/dev/null 2>&1
+    which subscription-manager >/dev/null 2>&1
     if [ $? -ne 0 ]; then
-        dnf config-manager --set-enabled crb | tee -a $LOGFILE
+        REPONAME=`dnf repolist --all | awk '/(codeready|crb)/{print $1}'`
+        CRB=${CRB:=$REPONAME}
+        if [ -z "$CRB" ]; then
+            logthis "ERROR: crb repo name not found"
+            logthis "Try: CRB=<codeready repo name> $0"
+            logthis "^^^^^^^^^^ SCRIPT ABORTED ^^^^^^^^^^"
+            exit 1
+        fi
+        dnf config-manager --set-enabled $CRB | tee -a $LOGFILE
         if [ $? -eq 0 ]; then
             logthis "crb repo enabled"
         else
-            logthis "ERROR: crb repo enable failed"
+            logthis "ERROR: crb repo '$CRB' enable failed"
             logthis "^^^^^^^^^^ SCRIPT ABORTED ^^^^^^^^^^"
             exit 1
         fi

If necessary, I can create merge request.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions