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

Better EPEL repository detection on RHEL and CentOS #717

Merged
merged 2 commits into from
Dec 22, 2015
Merged

Better EPEL repository detection on RHEL and CentOS #717

merged 2 commits into from
Dec 22, 2015

Conversation

vutny
Copy link
Contributor

@vutny vutny commented Dec 21, 2015

Hi,

I had a problem with bootstrapping some CentOS machines were was pre-configured YUM repository which name contains "epel" substring, but that's not main Fedora's EPEL.

In such case script failed with very uninformative error:

         *  INFO: Running install_centos_stable_deps()
        Loaded plugins: fastestmirror


        Error getting repository data for epel, repository not found
         * ERROR: Failed to run install_centos_stable_deps()!!!

Providing more specific regex for grep fixes it.

P.S. I know this is kind of edge case, but somebody may fall into it as well.

@jfindlay
Copy link
Contributor

@vutny, thanks for the pull request. When I do yum repolist I get !epel/x86_64 Extra Packages for Enterprise Linux 7 - x86_64 8,918, which doesn't look like it will be matched by your modified regex.

centos-7-main ~ master # yum repolist | grep -i '^epel/'
centos-7-main ~ master # yum repolist | grep -i 'epel/'
!epel/x86_64          Extra Packages for Enterprise Linux 7 - x86_64      8,918
centos-7-main ~ master #

* use global variable
* handle output from YUM command with repo expiry mark
* suppress grep output instead of redirection
@vutny
Copy link
Contributor Author

vutny commented Dec 22, 2015

Yeah, I got it also. (!) Exclamation mark from yum repolist command output means that repository metadata was expired.
By the way, this is the only one place in the script where hard-coded epel string is used. Everywhere else we have something similar to this command:

yum -y install ${package} --enablerepo=${_EPEL_REPO}

And this caused the error message for me before:

Error getting repository data for epel, repository not found

if the repo with exact name from $_EPEL_REPO variable was not configured. Another case, I've noticed that repo name would be epel-testing when I choose testing installation type on bootstrap.
All those cases are covered now.

The final improvement in my last commit is suppression of grep output with 'quiet' option instead of /dev/null redirection. It just looks more clear.

Thanks.

@jfindlay
Copy link
Contributor

This is excellent, thanks, @vutny!

jfindlay added a commit that referenced this pull request Dec 22, 2015
Better EPEL repository detection on RHEL and CentOS
@jfindlay jfindlay merged commit 71b0b85 into saltstack:develop Dec 22, 2015
@vutny vutny deleted the fix-epel-repo-detection branch December 23, 2015 07:49
@sp1r
Copy link

sp1r commented Sep 23, 2016

Hello,

There is an issue with current grep pattern. Exclamation mark is optional in yum repolist output, and string without it does not match.

# yum repolist | grep '^[!]epel/'
# yum repolist  
...  
epel/7Server/x86_64                                         Extra Packages for RHEL Linux 7Server - x86_64                                     10,580
...

@vutny
Copy link
Contributor Author

vutny commented Sep 23, 2016

Ooops! Indeed, this should be

yum repolist | grep -q '^!\?'"${_EPEL_REPO}/"

Have I really wrote that? 😄
@sp1r Feel free to submit a PR to fix it!

@sp1r
Copy link

sp1r commented Sep 23, 2016

@vutny Thank you. I will be glad to join the contributors ;)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants