Note: This bug is displayed in read-only format because the product is no longer active in Red Hat Bugzilla.
RHEL Engineering is moving the tracking of its product development work on RHEL 6 through RHEL 9 to Red Hat Jira (issues.redhat.com). If you're a Red Hat customer, please continue to file support cases via the Red Hat customer portal. If you're not, please head to the "RHEL project" in Red Hat Jira and file new tickets here. Individual Bugzilla bugs in the statuses "NEW", "ASSIGNED", and "POST" are being migrated throughout September 2023. Bugs of Red Hat partners with an assigned Engineering Partner Manager (EPM) are migrated in late September as per pre-agreed dates. Bugs against components "kernel", "kernel-rt", and "kpatch" are only migrated if still in "NEW" or "ASSIGNED". If you cannot log in to RH Jira, please consult article #7032570. That failing, please send an e-mail to the RH Jira admins at rh-issues@redhat.com to troubleshoot your issue as a user management inquiry. The email creates a ServiceNow ticket with Red Hat. Individual Bugzilla bugs that are migrated will be moved to status "CLOSED", resolution "MIGRATED", and set with "MigratedToJIRA" in "Keywords". The link to the successor Jira issue will be found under "Links", have a little "two-footprint" icon next to it, and direct you to the "RHEL project" in Red Hat Jira (issue links are of type "https://issues.redhat.com/browse/RHEL-XXXX", where "X" is a digit). This same link will be available in a blue banner at the top of the page informing you that that bug has been migrated.

Bug 1701314

Summary: sapconf function check_rhn() does not catch major release number from /etc/redhat-release in RHEL 8
Product: Red Hat Enterprise Linux 8 Reporter: Bernd Finger <bfinger>
Component: sapconfAssignee: Than Ngo <than>
Status: CLOSED ERRATA QA Contact: Daniel Yeisley <dyeisley>
Severity: low Docs Contact:
Priority: unspecified    
Version: 8.0CC: djez, dyeisley
Target Milestone: rcKeywords: Rebase
Target Release: 8.0Flags: pm-rhel: mirror+
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: sapconf-0.99-1.el8 Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2019-11-05 20:40:22 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description Bernd Finger 2019-04-18 15:15:27 UTC
Description of problem:
When executing sapconf on RHEL 8, avoiding call to check_rpms() (line 998) to avoid BZ 1670494, the following error message is shown:
grep: Unmatched ( or \(

Version-Release number of selected component (if applicable):
0.98

How reproducible:
see Steps to Reproduce

Steps to Reproduce:
1. Install RHEL 8 Minimal Environment or Server
2. Install the sapconf package (sapconf-0.98-15.el8.noarch.rpm). Dependencies:
   dnf-utils-4.0.2.2-3.el8.noarch
   tuned-profiles-sap-2.10.0-14.el8.noarch
3. Uncomment the call to check_rpms() (line 999) to avoid BZ 1670494 .
4. Execute sapconf

Actual results:
The following lines are shown:
# /usr/bin/sapconf
######    	sapconf-0.98-15  by Red Hat   	######
###### Preparing System for SAP Installation  ######

grep: Unmatched ( or \(
Failed to set locale, defaulting to C
RHEL system not subscribed to RHEL for SAP channel ... WARNING
/etc/sysconfig/network settings ... OK

This error occurs if the number of fields in /etc/redhat-release is different compared to RHEL 7. Example:

# cat /etc/redhat-release
Red Hat Enterprise Linux Server release 7.6 (Maipo)

# cat /etc/redhat-release
Red Hat Enterprise Linux release 8.0 (Ootpa)

So if the release number in /etc/redhat-release is always the second last one, we can avoid this problem by using awk $(NF-1) to select the release number. We also can use awk instead of cut to select the major release number.

Note that as per https://docs.engineering.redhat.com/pages/viewpage.action?spaceKey=RHELPLAN&title=SAP+Offerings , the name of the repo changes in RHEL 8 as well. The new name is now:
rhel-8-for-{x86_64-|ls390x-|ppc64le-}sap-netweaver-{beta-|e4s-|els-}rpms

Expected results:
Same as above but without the line containing the string "Unmatched ( or \("

This error can be avoided while keeping the same functionality as before by changing the first line of function check_rhn():
--->
if yum repolist | egrep -q "rhel-$(uname -m)-server-sap|rhel-sap-for-rhel-$(awk '{print $7}' /etc/redhat-release | cut -c -1)-server(-e4s|-eus)?-rpms"; then
<---
to:
--->
yum repolist | egrep "rhel-$(uname -m)-server-sap|rhel-sap-for-rhel-$(awk '{split($(NF-1), a, "."); print a[1]}' /etc/redhat-release)-server(-e4s|-eus)?-rpms"
<---

This will work on RHEL 7, and the egrep search pattern will be:
rhel-x86_64-server-sap|rhel-sap-for-rhel-7-server(-e4s|-eus)?-rpms

For RHEL 8, if we want to search for the new name rhel-8-for-{x86_64-|ls390x-|ppc64le-}sap-netweaver-{beta-|e4s-|els-}rpms, we would likely have to construct the egrep pattern as follows:

# echo "rhel-$(awk '{split($(NF-1), a, "."); print a[1]}' /etc/redhat-release)-for-$(uname -m)-sap-netweaver(-beta|-e4s|-eus)?-rpms"

Sample output on RHEL 7:
rhel-7-for-x86_64-sap-netweaver(-beta|-e4s|-eus)?-rpms

Sample output on RHEL 8:
rhel-8-for-x86_64-sap-netweaver(-beta|-e4s|-eus)?-rpms

With this, the new line for yum repolist in sapconf would be:
--->
yum repolist | egrep "rhel-$(awk '{split($(NF-1), a, "."); print a[1]}' /etc/redhat-release)-for-$(uname -m)-sap-netweaver(-beta|-e4s|-eus)?-rpms"
<---

Additional info:
To test and verify the solution, you may execute:
# echo "Red Hat Enterprise Linux release 8.0 (Ootpa)" | awk '{split($(NF-1), a, "."); print a[1]}'
8
# echo "Red Hat Enterprise Linux release 10.0 (XXX)" | awk '{split($(NF-1), a, "."); print a[1]}'
10
# echo "Red Hat Enterprise Linux Server release 100.0 (XXX)" | \
awk '{split($(NF-1), a, "."); print a[1]}'
100
# echo "RHEL 9.4 (XXX)" | awk '{split($(NF-1), a, "."); print a[1]}'
9

Comment 2 Bernd Finger 2019-04-18 19:34:52 UTC
Just tested and verified that the awk stuff also works with the 8.0 beta string, which might become relevant with later releases:
# echo "Red Hat Enterprise Linux release 8.0 Beta" | awk '{split($(NF-1), a, "."); print a[1]}'
8
What about 8.0.1?
# echo "Red Hat Enterprise Linux release 8.0.1 Beta" | awk '{split($(NF-1), a, "."); print a[1]}'
8
# echo "Red Hat Enterprise Linux release 8.0.1 (XXX)" | awk '{split($(NF-1), a, "."); print a[1]}'
8

Comment 8 Daniel Yeisley 2019-06-11 17:36:27 UTC
sapconf-0.99-3.el8.noarch looks good.

Comment 10 errata-xmlrpc 2019-11-05 20:40:22 UTC
Since the problem described in this bug report should be
resolved in a recent advisory, it has been closed with a
resolution of ERRATA.

For information on the advisory, and where to find the updated
files, follow the link below.

If the solution does not work for you, open a new bug report.

https://access.redhat.com/errata/RHBA-2019:3313