Re: one-shot yum command to match rpms between systems?

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



On Wed, May 18, 2016 at 12:54:51AM -0600, Frank Cox wrote:
> Given a list of rpms on one system (rpm -qa > list.txt), is there a
> one-shot command that I can run on another system to remove all of
> the rpms not listed and add any that are on the list and not present
> on the second system?

I think you can pull this off with `yum shell`. First, though, don't do
`rpm -qa` as your list — do `rpm -qa --qf '%{name}.%{arch}\n'|sort` instead.
That way, version numbers won't complicate things.

And then, on the second system (the one you want to change), try this
crazy oneliner:

( rpm -qa --qf '%{name}.%{arch}\n' | sort | diff --old-line-format='install %L' --new-line-format='remove %L' -unchanged-line-format='' list.txt - ; echo run ) | yum shell

It's not really as bad as it looks — the diff formatting is just
verbose. The first command just gets the package list from the current
system; then we sort it, and then get the difference in a formatted as
a list of "install" and "remove" commands. Then add "run" to the end,
and pipe all of that to yum shell.

This is totally untested but I'll give it good odds of working. :)





-- 
Matthew Miller
<mattdm@xxxxxxxxxxxxxxxxx>
Fedora Project Leader
_______________________________________________
CentOS mailing list
CentOS@xxxxxxxxxx
https://lists.centos.org/mailman/listinfo/centos




[Index of Archives]     [CentOS]     [CentOS Announce]     [CentOS Development]     [CentOS ARM Devel]     [CentOS Docs]     [CentOS Virtualization]     [Carrier Grade Linux]     [Linux Media]     [Asterisk]     [DCCP]     [Netdev]     [Xorg]     [Linux USB]
  Powered by Linux