[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

Re: How to install a bunch of RPMS if some are already installed?

Jag <agrajag@dragaera.net> writes:

> On Thu, 2002-07-25 at 12:52, Alan Hagge wrote:
>> Hi all,
>> Hopefully this is easy and I've just overlooked something, but I've
>> checked man pages, mailing lists, FAQs, etc. to no avail.  Here's what I
>> want to do:
>> I have a directory with a collection of RPMS in it.  I need to install
>> ALL of these RPMS on my machine.  The caveat is that SOME are already
>> installed.  So the behavior I'm looking for is:
>> - If a package isn't installed, install it.
>> - If a package is installed, but is older, upgrade it.
>> - If a package is installed and the same version as the one in the
>> directory, do nothing.
>> What rpm command can give this behavior?  rpm -i or -U will complain
>> that some packages are already installed and refuse to install the
>> others.  rpm -F won't install/upgrade anything that's not already
>> installed.  And I can't find an option to tell -i or -U to continue even
>> if some packages are already installed.
>> Any hints, suggestions, workarounds, etc. GREATLY appreciated.
> This is what librpm, rpm-python, and rpm-perl are for :)

Probably a simple for loop would sort them out for you.  Then you
could remove those that are dubs (or find other problems, but still
get installable ones installed)

I haven't done this but I think the rpm --test command may be your
friend here.  I only tried agains a very small sample.

Probably work without the --test too, but testing  would be a little safer.
  ## cd to the scene of the crime
  cd $RPM_DIR

  for ii in `ls *rpm`  ## get a working list of all the rpms in there
    ## test and record (including stderr)  each file
    rpm -Uvh --test $ii > test_results 2>&1
    ## if test shows exit status of 0 then run the install command.
    if [ "$? = 0 ]; then
       ## record installationn 
       rpm -Uvh $ii 2>&1|tee -a installed_results 

That should leave you with the installable ones installed,
uninstallable ones will be recorded in test_results
In case there were other reasons besides being installed already.

Install output will be recorded in installed_results but also piped
to screen so you see what is happening.

[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index] []