yum - check if package already installed

Clash Royale CLAN TAG#URR8PPP
up vote
5
down vote
favorite
When I run yum install <X> where <X> has already been installed, yum exits with a return status of 1 and prints "Error: Nothing to do".
Aside from checking for this string in the output (which seems like a very shaky thing to base my script on), is there some way I can test whether the package already exists? Clearly, yum knows whether or not it already exists, since it's throwing that error, but how can I access that knowledge?
To add to this, some of the packages are downloaded by way of URLs, not package names, so checking yum list installed doesn't work.
software-installation yum
add a comment |Â
up vote
5
down vote
favorite
When I run yum install <X> where <X> has already been installed, yum exits with a return status of 1 and prints "Error: Nothing to do".
Aside from checking for this string in the output (which seems like a very shaky thing to base my script on), is there some way I can test whether the package already exists? Clearly, yum knows whether or not it already exists, since it's throwing that error, but how can I access that knowledge?
To add to this, some of the packages are downloaded by way of URLs, not package names, so checking yum list installed doesn't work.
software-installation yum
1
yumknows by querying the rpm database. for example
â Bratchley
Mar 25 '15 at 18:09
@Bratchley Is there a way to get that name from a package url?
â AmadeusDrZaius
Mar 25 '15 at 18:13
You should be able to giverpma full URL to the RPM you're interested in. Example which will give you the package name. One note would be that it useswgetinternally but seems to silently suppress errors.
â Bratchley
Mar 25 '15 at 18:17
@taliezin that's roughly equivalent torpm -qa packageNameexcept it's printed in a way that makes it look likeyumoutput.
â Bratchley
Mar 25 '15 at 18:18
@Bratchley, sorry i saw the link later, but I deleted it.
â taliezin
Mar 25 '15 at 18:25
add a comment |Â
up vote
5
down vote
favorite
up vote
5
down vote
favorite
When I run yum install <X> where <X> has already been installed, yum exits with a return status of 1 and prints "Error: Nothing to do".
Aside from checking for this string in the output (which seems like a very shaky thing to base my script on), is there some way I can test whether the package already exists? Clearly, yum knows whether or not it already exists, since it's throwing that error, but how can I access that knowledge?
To add to this, some of the packages are downloaded by way of URLs, not package names, so checking yum list installed doesn't work.
software-installation yum
When I run yum install <X> where <X> has already been installed, yum exits with a return status of 1 and prints "Error: Nothing to do".
Aside from checking for this string in the output (which seems like a very shaky thing to base my script on), is there some way I can test whether the package already exists? Clearly, yum knows whether or not it already exists, since it's throwing that error, but how can I access that knowledge?
To add to this, some of the packages are downloaded by way of URLs, not package names, so checking yum list installed doesn't work.
software-installation yum
asked Mar 25 '15 at 18:06
AmadeusDrZaius
6921816
6921816
1
yumknows by querying the rpm database. for example
â Bratchley
Mar 25 '15 at 18:09
@Bratchley Is there a way to get that name from a package url?
â AmadeusDrZaius
Mar 25 '15 at 18:13
You should be able to giverpma full URL to the RPM you're interested in. Example which will give you the package name. One note would be that it useswgetinternally but seems to silently suppress errors.
â Bratchley
Mar 25 '15 at 18:17
@taliezin that's roughly equivalent torpm -qa packageNameexcept it's printed in a way that makes it look likeyumoutput.
â Bratchley
Mar 25 '15 at 18:18
@Bratchley, sorry i saw the link later, but I deleted it.
â taliezin
Mar 25 '15 at 18:25
add a comment |Â
1
yumknows by querying the rpm database. for example
â Bratchley
Mar 25 '15 at 18:09
@Bratchley Is there a way to get that name from a package url?
â AmadeusDrZaius
Mar 25 '15 at 18:13
You should be able to giverpma full URL to the RPM you're interested in. Example which will give you the package name. One note would be that it useswgetinternally but seems to silently suppress errors.
â Bratchley
Mar 25 '15 at 18:17
@taliezin that's roughly equivalent torpm -qa packageNameexcept it's printed in a way that makes it look likeyumoutput.
â Bratchley
Mar 25 '15 at 18:18
@Bratchley, sorry i saw the link later, but I deleted it.
â taliezin
Mar 25 '15 at 18:25
1
1
yum knows by querying the rpm database. for exampleâ Bratchley
Mar 25 '15 at 18:09
yum knows by querying the rpm database. for exampleâ Bratchley
Mar 25 '15 at 18:09
@Bratchley Is there a way to get that name from a package url?
â AmadeusDrZaius
Mar 25 '15 at 18:13
@Bratchley Is there a way to get that name from a package url?
â AmadeusDrZaius
Mar 25 '15 at 18:13
You should be able to give
rpm a full URL to the RPM you're interested in. Example which will give you the package name. One note would be that it uses wget internally but seems to silently suppress errors.â Bratchley
Mar 25 '15 at 18:17
You should be able to give
rpm a full URL to the RPM you're interested in. Example which will give you the package name. One note would be that it uses wget internally but seems to silently suppress errors.â Bratchley
Mar 25 '15 at 18:17
@taliezin that's roughly equivalent to
rpm -qa packageName except it's printed in a way that makes it look like yum output.â Bratchley
Mar 25 '15 at 18:18
@taliezin that's roughly equivalent to
rpm -qa packageName except it's printed in a way that makes it look like yum output.â Bratchley
Mar 25 '15 at 18:18
@Bratchley, sorry i saw the link later, but I deleted it.
â taliezin
Mar 25 '15 at 18:25
@Bratchley, sorry i saw the link later, but I deleted it.
â taliezin
Mar 25 '15 at 18:25
add a comment |Â
2 Answers
2
active
oldest
votes
up vote
5
down vote
accepted
In your script use rpm -q packagename:
if rpm -q vim-enhanced
then
...
else
...
fi
Thanks, this worked well. I had to manually fiddle with the package name for packages which were obtained through urls, but other than that, it went smoothly.
â AmadeusDrZaius
Mar 26 '15 at 0:38
1
I'm happy it worked. Sometimes package names can be tricky. I wish package names were slightly more normalized...
â JJoao
Mar 26 '15 at 6:32
add a comment |Â
up vote
3
down vote
You can try:
#yum list installed | grep tmux
tmux.x86_64 1.9a-5.fc21 @updates
or:
#yum list installed tmux
Loaded plugins: langpacks
Installed Packages
tmux.x86_64 1.9a-5.fc21 @updates
Without grep you get some extra lines, but both outputs can be piped through some text editor according to your needs.
add a comment |Â
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
5
down vote
accepted
In your script use rpm -q packagename:
if rpm -q vim-enhanced
then
...
else
...
fi
Thanks, this worked well. I had to manually fiddle with the package name for packages which were obtained through urls, but other than that, it went smoothly.
â AmadeusDrZaius
Mar 26 '15 at 0:38
1
I'm happy it worked. Sometimes package names can be tricky. I wish package names were slightly more normalized...
â JJoao
Mar 26 '15 at 6:32
add a comment |Â
up vote
5
down vote
accepted
In your script use rpm -q packagename:
if rpm -q vim-enhanced
then
...
else
...
fi
Thanks, this worked well. I had to manually fiddle with the package name for packages which were obtained through urls, but other than that, it went smoothly.
â AmadeusDrZaius
Mar 26 '15 at 0:38
1
I'm happy it worked. Sometimes package names can be tricky. I wish package names were slightly more normalized...
â JJoao
Mar 26 '15 at 6:32
add a comment |Â
up vote
5
down vote
accepted
up vote
5
down vote
accepted
In your script use rpm -q packagename:
if rpm -q vim-enhanced
then
...
else
...
fi
In your script use rpm -q packagename:
if rpm -q vim-enhanced
then
...
else
...
fi
answered Mar 25 '15 at 23:36
JJoao
6,7111826
6,7111826
Thanks, this worked well. I had to manually fiddle with the package name for packages which were obtained through urls, but other than that, it went smoothly.
â AmadeusDrZaius
Mar 26 '15 at 0:38
1
I'm happy it worked. Sometimes package names can be tricky. I wish package names were slightly more normalized...
â JJoao
Mar 26 '15 at 6:32
add a comment |Â
Thanks, this worked well. I had to manually fiddle with the package name for packages which were obtained through urls, but other than that, it went smoothly.
â AmadeusDrZaius
Mar 26 '15 at 0:38
1
I'm happy it worked. Sometimes package names can be tricky. I wish package names were slightly more normalized...
â JJoao
Mar 26 '15 at 6:32
Thanks, this worked well. I had to manually fiddle with the package name for packages which were obtained through urls, but other than that, it went smoothly.
â AmadeusDrZaius
Mar 26 '15 at 0:38
Thanks, this worked well. I had to manually fiddle with the package name for packages which were obtained through urls, but other than that, it went smoothly.
â AmadeusDrZaius
Mar 26 '15 at 0:38
1
1
I'm happy it worked. Sometimes package names can be tricky. I wish package names were slightly more normalized...
â JJoao
Mar 26 '15 at 6:32
I'm happy it worked. Sometimes package names can be tricky. I wish package names were slightly more normalized...
â JJoao
Mar 26 '15 at 6:32
add a comment |Â
up vote
3
down vote
You can try:
#yum list installed | grep tmux
tmux.x86_64 1.9a-5.fc21 @updates
or:
#yum list installed tmux
Loaded plugins: langpacks
Installed Packages
tmux.x86_64 1.9a-5.fc21 @updates
Without grep you get some extra lines, but both outputs can be piped through some text editor according to your needs.
add a comment |Â
up vote
3
down vote
You can try:
#yum list installed | grep tmux
tmux.x86_64 1.9a-5.fc21 @updates
or:
#yum list installed tmux
Loaded plugins: langpacks
Installed Packages
tmux.x86_64 1.9a-5.fc21 @updates
Without grep you get some extra lines, but both outputs can be piped through some text editor according to your needs.
add a comment |Â
up vote
3
down vote
up vote
3
down vote
You can try:
#yum list installed | grep tmux
tmux.x86_64 1.9a-5.fc21 @updates
or:
#yum list installed tmux
Loaded plugins: langpacks
Installed Packages
tmux.x86_64 1.9a-5.fc21 @updates
Without grep you get some extra lines, but both outputs can be piped through some text editor according to your needs.
You can try:
#yum list installed | grep tmux
tmux.x86_64 1.9a-5.fc21 @updates
or:
#yum list installed tmux
Loaded plugins: langpacks
Installed Packages
tmux.x86_64 1.9a-5.fc21 @updates
Without grep you get some extra lines, but both outputs can be piped through some text editor according to your needs.
answered Mar 25 '15 at 18:24
petry
6631411
6631411
add a comment |Â
add a comment |Â
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f192473%2fyum-check-if-package-already-installed%23new-answer', 'question_page');
);
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
1
yumknows by querying the rpm database. for exampleâ Bratchley
Mar 25 '15 at 18:09
@Bratchley Is there a way to get that name from a package url?
â AmadeusDrZaius
Mar 25 '15 at 18:13
You should be able to give
rpma full URL to the RPM you're interested in. Example which will give you the package name. One note would be that it useswgetinternally but seems to silently suppress errors.â Bratchley
Mar 25 '15 at 18:17
@taliezin that's roughly equivalent to
rpm -qa packageNameexcept it's printed in a way that makes it look likeyumoutput.â Bratchley
Mar 25 '15 at 18:18
@Bratchley, sorry i saw the link later, but I deleted it.
â taliezin
Mar 25 '15 at 18:25