Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I have a number of CentOS instances, some of which have been used by developers and have 3rd party repos (sometimes their own) enabled. However from an administrative point of view it is handy to be able to force through an update in a script without messing with the local yum.conf, or parsing the output or yum.repos.d to see which is the offending broken repo.

It looks like the developers had an eye for thisn with this option;

-t, --tolerant

but clearly this was more of a challenge than they had anticipated because in man page;

              This option currently does nothing.

Obviously when I am doing this manually, I can work-around the repos with;

yum --disablerepo=broken-repo  deplist mypackage

and to make a scripted update more robust, I can use (which at least definitely installs distro updates)

yum -y --disablerepo=* --enablerepo=updates update

but this doesn't catch the case where there is EPEL, or rpmforge, or rbel, or some package distributor which I would have to parse the yum.repos.d file first for.

share|improve this question
    
I've corrected a script in my answer - I forgot xargs. –  Tometzky Feb 9 '12 at 11:15

1 Answer 1

up vote 2 down vote accepted

This script can help somewhat:

LC_ALL=C yum repolist 2>/dev/null \
| awk '/^repo id/ {A=1; next} /^[a-zA-Z0-9_-]+ / {if(A) print $1}' \
| xargs -i yum -y --disablerepo=* --enablerepo={} update
# Some packages may need packages from other repository
yum -y update

It works by getting a list of repositories with yum repolist, selecting repository names from output using awk and then trying to update all of them one at the time.

It is not 100% reliable, as it depends on unchanging yum output format. Also if update needs to install another package from different repository and there is a broken repository then it will fail anyway — but I suppose it is not so common.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.