Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Script build/build.bash improvements #27

Open
sobolev-es opened this issue Feb 3, 2025 · 0 comments
Open

Script build/build.bash improvements #27

sobolev-es opened this issue Feb 3, 2025 · 0 comments
Labels
bug Something isn't working

Comments

@sobolev-es
Copy link

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.

@shawniverson shawniverson added the bug Something isn't working label Feb 15, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants