7

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

1
6

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

6
  • what happens with files that are changed after install, for example config files that are delivered on install? do they get overwritten?
    – b0x0rz
    Oct 3 '12 at 12:27
  • 3
    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
    – Mike
    Oct 3 '12 at 14:37
  • 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 ;)
    – b0x0rz
    Oct 5 '12 at 18:31
  • 1
    revsion is the same as release its the number after the - so it would be package-version-release.arch.rpm
    – Mike
    Oct 5 '12 at 20:58
  • 1
    yes it is since it's not an install
    – Mike
    Oct 15 '12 at 13:35
4

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.

3
  • This is the right answer. Mar 11 '15 at 2:21
  • 1
    part 1, step 3 should be 'sudo createrepo --update .', not 'suod' Jul 24 '17 at 19:18
  • 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. Jul 26 '20 at 13:55
3

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

6
  • what happens with files that are changed after install, for example config files that are delivered on install? do they get overwritten?
    – b0x0rz
    Oct 3 '12 at 12:27
  • 1
    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. Oct 3 '12 at 12:39
  • 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...
    – b0x0rz
    Oct 3 '12 at 12:52
  • Any update on this? Oct 4 '12 at 19:22
  • 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
    Oct 5 '12 at 18:29

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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