[arch-general] Script for finding and "moving" older duplicate packages from /var/cache/pacman/pkg

David C. Rankin drankinatty at suddenlinkmail.com
Tue Aug 25 04:51:45 UTC 2009


Listmates,

	I like to keep the current set of updated packages in /var/cache/pacman/pkg but not have all of the older duplicates in there as well. However, I don't want to delete the old packages either, in case I need to downgrade a package. I simply want to move the older packages to a backup location on a different partition so I'm not filling up / with several extra gigabytes of older packages. To do this I adapted a script that I used to clean duplicates from my local rpm repository and changed the script to deal with package-name-v.e.r-arch.pkg.tar.gz instead of rpm-name-v.e.r-s.u.b-arch.rpm. (Thankfully arch just uses the pkg directory instead of a nested spiderweb under /var/cache/zypp/packages/.....)

	The script for finding and moving older duplicate packages is named fduppkg and is fairly self-explanitory. Running without arguments gives the options:

23:33 supersff:~/scripts/file> fduppkg

        Usage:  <search dir> [ -d -l logfile -s -v ]

        Searches <search dir> for duplicate pkgs and moves duplicate files to [dup_dir]
        or <search dir>/duplicates by default.

  -d | --dupdir    Used to specify directory to hold duplicate rpms
  -l | --logfile   Specify the log file name (default ./duplicates.log)
  -s | --silent    Don't output anything to stdout, just log results
  -v | --verbose   Output information showing which files are kept and not moved

	You should note that the actual check for older/newer uses the file modification date to make the decision rather than parsing the version number digit-by-digit. So if you have done something nutty like moving all the packages out of /var/cache and then copying them back so all the file modification times are the same, this script won't work. (I could see it happening) If you have a need for something like this, you can grab the script at:

http://www.3111skyline.com/download/Archlinux/scripts/fduppkg

	Since the script if fairly generic for packages, if you have a number of directories you want to operate on, you can just call the script from another script that sets the command line inputs. Example:

http://www.3111skyline.com/download/Archlinux/scripts/fdup-archpkg

	I generally just create a link to the script in /usr/local/bin so it is in the search path. Also, if you just want to tear it apart for the bash scripting learning, I have commented it so it is somewhat readable. Enjoy.

	


-- 
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


More information about the arch-general mailing list