yum install local rpm throws error if up to date
on my system (centos6, centos7) "yum localinstall" will return code 0 even with "Error: Nothing to do" message, while "yum install" returns 1.
sudo yum localinstall packages/* -y --disablerepo=*
Anyway you can also check the message result to ignore this as a "normal error" in your automation scripts, like for example using bash:
sudo yum install packages/* -y --disablerepo=* 2>&1 | tee /tmp/yum.output
grep -q "Error: Nothing to do" /tmp/yum.output
if [ $? -eq 0 ]; then
... code for no error
else
... code for error
fi
Related videos on Youtube
JackLeo
Updated on September 18, 2022Comments
-
JackLeo over 1 year
When installing rpm packages from local file directory it runs fine the first time
sudo yum install packages/* -y --disablerepo=*
When the same thing is run the second time as part of automated scripts, it throws an error (exit code 1)
packages/package.rpm: does not update installed package. Error: Nothing to do
I can run yum update (exit code 0)
sudo yum update packages/* -y --disablerepo=* ... No packages marked for update
The problem with this is that update will skip the packages that are not installed.
I don't want to ignore exit code if there are any real problems here, and just want to do
install-or-update
. Is there arpm -i
equivalent that would achieve that? Please take note that this is done on a group of rpm packages that might at any point include additional ones.I guess one option would be to iterate over them in a shell script and check if they are installed or not, but then again dependency resolution might become rather painful and it does sound like re-inventing a bike.
UPDATE:
rpm --install
will throw exit code depending on the number of failed packages. https://www.redhat.com/archives/rpm-list/2005-July/msg00071.htmlrpm --freshen
will ignore any rpms that are not installed previously while giving no output at all.-
c4f4t0r over 6 yearsyum localinstall for installing local package
-
JackLeo over 6 years@c4f4t0r localinstall is a legacy option. yum install behaves the same given the rpm local file. Same exit code, same error. linux.die.net/man/8/yum
-
Alexander Tolkachev over 6 yearsWhy not to use
rpm -F packages/*
for update? -
JackLeo over 6 years@AlexanderTolkachev same issue as
yum update
. It updates/freshens the packages that are already installed. If the list of packages includes a new one, it will be skipped. -
Alexander Tolkachev over 6 years@JackLeo could you show output for
rpm -F <a new one>.rpm
? -
JackLeo over 6 years@AlexanderTolkachev I could generate it a tad later, yes, I've only checked that with the manual. linux.die.net/man/8/rpm At the moment I am looking into install via
rpm
directly, and that trows more explicit exit codes. In a case of no updates it trows 3. So I am looking into it at the moment. -
JackLeo over 6 years@AlexanderTolkachev added. No output at all. Just ignores the package both if given a list
*.rpm
or explicitly the name of the package.
-
-
tonioc over 6 yearsIndeed, it looks like a bug that should be submitted to redhat...