[opensuse] Script to move old versions of rpms from local repository
Listmates, Over the life of 11.0 I had been using the --keep-packages option for all updates so that I would have a local repository for the kids machines, etc. to prevent having to download files more than once. It has worked great. But over the course of time I have accumulated up to 10 or so older versions of all packages (17G worth). There were 10,617 files total so I wasn't going to do it by hand. I needed a way to parse through the local repository and move all older versions to a 'duplicates' folder so they could be removed. Thankfully the rpm naming convention is fairly consistent that allowed this to be done relatively painlessly. Anyway, I wrote a small script to do this and to provide a short log of what was done. So just in case anyone else has a directory full of multiple versions of rpms and would like to separate them without having to reinvent the wheel, I've attached the script. The script relies on FILE DATE to determine the most recent version rather than a parse and sort of the version numbers, so if you moved all your rpms to a directory such that they all have the same date, this won't work. My local repository is laid out as follows: 01:26 ecstasy:/home/rpms/openSUSE_11.0> ls -1 delta i386 i586 i686 noarch repodata src x86_64 You simply run the script passing the directory containing the rpms and it will create a directory/duplicates directory and move the older versions to the new directory leaving the most recent versions in place. In other words: 01:26 ecstasy:/home/rpms/openSUSE_11.0> ../data/fduprpm x86_64/ will move all old version in the x86_64/ directory to "x86_64/duplicates". Just run it once for each directory containing rpms. The log simply tell what was moved and what stayed: <snip> Keeping: x86_64/ufraw-0.15-10.13.x86_64.rpm x86_64/ufraw-0.15-10.11.x86_64.rpm --> x86_64/duplicates x86_64/ufraw-0.15-10.9.x86_64.rpm --> x86_64/duplicates x86_64/ufraw-0.15-10.8.x86_64.rpm --> x86_64/duplicates x86_64/ufraw-0.15-10.7.x86_64.rpm --> x86_64/duplicates x86_64/ufraw-0.15-10.3.x86_64.rpm --> x86_64/duplicates x86_64/ufraw-0.15-10.1.x86_64.rpm --> x86_64/duplicates Keeping: x86_64/unrar-3.70.8-32.1.x86_64.rpm Keeping: x86_64/unsermake-0.4_20070504-136.1.x86_64.rpm <snip> Make use of it if you can, if not, just delete. -- David C. Rankin, J.D.,P.E. Rankin Law Firm, PLLC 510 Ochiltree Street Nacogdoches, Texas 75961 Telephone: (936) 715-9333 Facsimile: (936) 715-9339 www.rankinlawfirm.com
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 On Saturday, 2009-08-08 at 01:37 -0500, David C. Rankin wrote:
Listmates,
Over the life of 11.0 I had been using the --keep-packages option for all updates so that I would have a local repository for the kids machines, etc. to prevent having to download files more than once. It has worked great. But over the course of time I have accumulated up to 10 or so older versions of all packages (17G worth). There were 10,617 files total so I wasn't going to do it by hand. I needed a way to parse through the local repository and move all older versions to a 'duplicates' folder so they could be removed. Thankfully the rpm naming convention is fairly consistent that allowed this to be done relatively painlessly.
That's very interesting :-) Thanks!
Anyway, I wrote a small script to do this and to provide a short log of what was done. So just in case anyone else has a directory full of multiple versions of rpms and would like to separate them without having to reinvent the wheel, I've attached the script. The script relies on FILE DATE to determine the most recent version rather than a parse and sort of the version numbers, so if you moved all your rpms to a directory such that they all have the same date, this won't work.
Ah... well, perhaps somebody else can chirp in and add that logic to your script ;-) - -- Cheers, Carlos E. R. -----BEGIN PGP SIGNATURE----- Version: GnuPG v2.0.9 (GNU/Linux) iEYEARECAAYFAkp9OVMACgkQtTMYHG2NR9V7VgCggaTLlohLESLmE8xvDiq2WTru wIgAoIqKHdMimQY/FKXi97syW+JEfM/y =xhR0 -----END PGP SIGNATURE----- -- To unsubscribe, e-mail: opensuse+unsubscribe@opensuse.org For additional commands, e-mail: opensuse+help@opensuse.org
participants (2)
-
Carlos E. R.
-
David C. Rankin