yum update, how to make rpm package updateable

9,241

Solution 1

The only thing you need to do to make it work is make sure the version number or release number for the same version in the .spec file is higher then the current version installed. Then when added to your repo and a createrepo is run yum will pick it up and update

Solution 2

The answer is not as simple as sticking an RPM with a newer revision in the repo.

There are things to be done on the server side and on the client side.

Server Side

  1. Copy RPM to repo
  2. cd /path/to/repo (let's assume /var/www/html/repo)
  3. sudo createrepo --update . This will update the repo's database to include the new RPM
  4. sudo chmod -R ugo+rX /var/www/html/repo/ This will make the new RPM visible

Client Side

  1. sudo yum clean all This will get rid off all the cached info related to the repo.
  2. sudo yum info rpmname You should now see that the latest rpm version is available.
  3. sudo yum -y update rpmname You should be updated.

I got very frustrated with all the answers (here, there, and everywhere) that glossed over all of these details. Anyone going through the process of creating a repo with updates is going to test it. The test will go like this:

Server Side, Add new RPM to repository, run createrepo, change permissions Client Side, yum -y install rpmname. User, "Cool it worked. Now let's try doing and update."

Server Side, Add RPM with newer revision, run createrepo, change permissions Client Side, yum -y upgrade rpmname, "No Packages marked for Update" User, "What the #?!@ I just followed all of the instructions I found on the web and this didn't work!"

On the client side, yum will cache information about the repository including the newest available release. The next time the client does an update or info command yum will not go back to the internet and check the repository. Yum will use the cached version of the repo.

Solution 3

If the RPM's version is greater than the installed version it will update.

Share:
9,241

Related videos on Youtube

b0x0rz
Author by

b0x0rz

Updated on September 18, 2022

Comments

  • b0x0rz
    b0x0rz over 1 year

    need a link or tutorial on how to make an rpm package work with yum UPDATE. i have it and already works with yum INSTALL and yum ERASE, but is there somewhere info on how to make rpm package work when using yum UPDATE (what code to add, in what files, etc...)?

    thnx a lot

  • b0x0rz
    b0x0rz over 11 years
    what happens with files that are changed after install, for example config files that are delivered on install? do they get overwritten?
  • Aaron Copley
    Aaron Copley over 11 years
    It depends on how the RPM is written, but well behaving RPMs won't clobber your configuration. The new configuration file is usually written as somefile.conf.rpmnew. If there is a significant update/change that causes the package to overwrite your config, yours will be backed up as somefile.conf.rpmsave.
  • b0x0rz
    b0x0rz over 11 years
    thnx for the info. i can only try it tomorrow though :P will let you know how it goes. thnx a lot. probably i'll have to do something so that the config files remain as-is...
  • Mike
    Mike over 11 years
    depends how the spec file is written if it uses %config(noreplace) to set the config in the rpm it will not be overwritten on an update. The rpm from the update will be given a an extension on the filename. I think it is like file.rpmnew
  • Aaron Copley
    Aaron Copley over 11 years
    Any update on this?
  • b0x0rz
    b0x0rz over 11 years
    sorry was unable to try it, other tasks got precedence, this task got relegated a bit. i have not forgotten. however, we will have the same version usually, but the revision will be different, so that is another variable in the mix ;)
  • b0x0rz
    b0x0rz over 11 years
    i was unable to try it as of yet, other tasks got precedence, this task got relegated a bit. i have not forgotten. however, we will have the same version usually, but the revision will be different, so that is another variable in the mix ;)
  • Mike
    Mike over 11 years
    revsion is the same as release its the number after the - so it would be package-version-release.arch.rpm
  • b0x0rz
    b0x0rz over 11 years
    k that "seems" to work as you said, but during the update it seems that postinstall.in script is not executed. is this normal for an update?
  • b0x0rz
    b0x0rz over 11 years
    k that "seems" to work as you said, but during the update it seems that postinstall.in script is not executed. is this normal for an update?
  • Mike
    Mike over 11 years
    yes it is since it's not an install
  • Steve Goodman
    Steve Goodman almost 7 years
    part 1, step 3 should be 'sudo createrepo --update .', not 'suod'
  • Annihilannic
    Annihilannic almost 4 years
    One more detail that would be good to mention is that the package would update without having to do a yum clean all if you just waited long enough for the cache to expire. By default this is 6 hours, unless it is overriden in your yum.conf. See metadata_expire on the man yum.conf page for details.