Frank Cox
2016-May-18 06:54 UTC
[CentOS] one-shot yum command to match rpms between systems?
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? -- MELVILLE THEATRE ~ Real D 3D Digital Cinema ~ www.melvilletheatre.com
James Hogarth
2016-May-18 08:30 UTC
[CentOS] one-shot yum command to match rpms between systems?
On 18 May 2016 07:55, "Frank Cox" <theatre at melvilletheatre.com> wrote:> > Given a list of rpms on one system (rpm -qa > list.txt), is there aone-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?>If you had an internal repo of these packages you could yum distro-sync ... otherwise there is no one shot command to do this given a list. And of course as will be pointed out by many the only right answer is yum update anyway given cherry picking updates is not supported.
Frank Cox
2016-May-18 16:56 UTC
[CentOS] one-shot yum command to match rpms between systems?
On Wed, 18 May 2016 09:30:54 +0100 James Hogarth wrote:> And of course as will be pointed out by many the only right answer is yum > update anyway given cherry picking updates is not supported.The objective is not to cherry pick updates, but rather to install a second system with packages that match the first system. After fine-tuning the installed packages and stripping out the unnecessary stuff, it would be nice to just say "make that system look like this one" -- rsync for yum if you will. The specific package versions aren't important at that stage since I can run yum update after the initial installation. -- MELVILLE THEATRE ~ Real D 3D Digital Cinema ~ www.melvilletheatre.com
Noam Bernstein
2016-May-18 17:02 UTC
[CentOS] one-shot yum command to match rpms between systems?
> On May 18, 2016, at 2:54 AM, Frank Cox <theatre at melvilletheatre.com> 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?It wouldn?t be a one liner except in the most general sense that you can string multiple bash commands with ?;?, but I?m sure someone can do something clever with uniq(1). Noam
Jonathan Billings
2016-May-18 17:16 UTC
[CentOS] one-shot yum command to match rpms between systems?
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'd probably turn it into a puppet manifest or ansible playbook, and use that to install the packages. I'd not use rpm -qa unadorned, though, but rpm -qa --qf "%{NAME}.%{ARCH}\n". -- Jonathan Billings <billings at negate.org>
Matthew Miller
2016-May-18 17:32 UTC
[CentOS] one-shot yum command to match rpms between systems?
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 at fedoraproject.org> Fedora Project Leader
Александр Кириллов
2016-May-18 17:35 UTC
[CentOS] one-shot yum command to match rpms between systems?
Jonathan Billings ????? 2016-05-18 20:16:> 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'd probably turn it into a puppet manifest or ansible playbook, and > use that to install the packages. I'd not use rpm -qa unadorned, > though, but rpm -qa --qf "%{NAME}.%{ARCH}\n".You can either use the tools suggested or write a simple helper script. Diff sorted list of packages on these two systems (using "%{NAME}.%{ARCH}" format). Add the packages in lines starting with "<", remove the packages in lines starting with ">". Sort of.
Frank Cox
2016-May-18 17:39 UTC
[CentOS] one-shot yum command to match rpms between systems?
On Wed, 18 May 2016 13:32:36 -0400 Matthew Miller wrote:> ( 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 shellThis looks pretty much like what I had in mind. Great! Thanks! -- MELVILLE THEATRE ~ Real D 3D Digital Cinema ~ www.melvilletheatre.com
Noam Bernstein
2016-May-18 18:12 UTC
[CentOS] one-shot yum command to match rpms between systems?
> On May 18, 2016, at 1:02 PM, Noam Bernstein <noam.bernstein at nrl.navy.mil> wrote: > > It wouldn?t be a one liner except in the most general sense that you can string multiple bash commands with ?;?, but I?m sure someone can do something clever with uniq(1).I meant comm(1), by the way, although the other answers in this thread, especially the ?yum shell? based ones, are cleaner. Noam
Johnny Hughes
2016-May-18 18:26 UTC
[CentOS] one-shot yum command to match rpms between systems?
On 05/18/2016 12:32 PM, Matthew Miller wrote:> 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.Right .. if you are not at the same update levels then name.arch is better than full versions.> > 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.-------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 198 bytes Desc: OpenPGP digital signature URL: <http://lists.centos.org/pipermail/centos/attachments/20160518/b62cfdec/attachment-0001.sig>
Maybe Matching Threads
- one-shot yum command to match rpms between systems?
- one-shot yum command to match rpms between systems?
- one-shot yum command to match rpms between systems?
- one-shot yum command to match rpms between systems?
- one-shot yum command to match rpms between systems?