[arch-general] Manager Duplicates in /var/cache/pacman/pkg

David C. Rankin drankinatty at suddenlinkmail.com
Sat Jul 17 02:55:42 EDT 2010


Guys,

	I've updated my find duplicates script to work with the .xz packages. There are 
actually 2 scripts involved:

'fduparch.sh' is the wrapper script that just sets the directories and options 
for the actual duplicate finding script 'fduppkg'.

	In its current configuration fduparch.sh actually calls fduppkg twice.

PASS 1:

it calls fduppkg to scan /var/cache/pacman/pkg and move any duplicates found to 
'/home/backup/pkg-old'. Packages with the same name are then checked by DATE and 
any older packages are moved /home/backup/pkg-old. This leaves only the current 
packages in /var/cache/pacman/pkg making it much easing to move your install 
from machine-to-machine without copying unneeded duplicates. Second, it frees up 
space on / by moving duplicates to the /home partition.

PASS 2:

it calls fduppkg a second time to scan '/home/backup/pkg-old' and move any 
duplicates found to '/home/backup/pkg-older'.

	That way you have the latest packages in the normal '/var/cache/pacman/pkg' and 
you have a duplicate-free set of the last packages before update in 
'/home/backup/pkg-old'. All older versions are kept in '/home/backup/pkg-older'

	The way I use the scripts is to create softlinks to the scripts in 
/usr/local/bin (making sure /usr/local/bin is in your PATH) as follows:

ln -s /wherever/you/put/fduparch.sh /usr/local/bin/fduparch
ln -s /wherever/you/put/fduppkg /usr/local/bin/fduppkg

then I simply call fduparch after each update to clean the duplicates out of 
/var/cache/pacman/pkg.

running fduppkg without arguments gives the general usage:

01:16 nirvana:/srv/http/dl/Archlinux/scripts> sh fduppkg

	Usage: fduppkg <search dir> [ -d dup_dir -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

However, to change the default duplicate directories, just edit the wrapper 
script 'fduparch' and set the directories you want there. I have used a wrapper 
script to keep fduppkg as flexible as possible so I can simply run it on any 
package directory to find and move duplicates. (the split setup was originally 
developed to handle suse's archane cache directory structure, but it handles 
Arch's simple setup as well)

	Grab the duplicate scripts at:

http://www.3111skyline.com/dl/Archlinux/scripts/fduparch.sh
http://www.3111skyline.com/dl/Archlinux/scripts/fduppkg

	Finally, I have developed a script for determining which packages in 
/var/cache/pacman/pkg are 'Installed' or not. The script is 'chkinstpkgs.sh' and 
is available here:

http://www.3111skyline.com/dl/Archlinux/scripts/chkinstpkgs.sh

Running the script without argument will check the status of all packages in 
/var/cache/pacman/pkg and provide you with a concise list of 
installed/uninstalled packages in the following format:

01:24 alchemy:~/scr/arch> sh chkinstpkgs.sh

   Determining installed/orphaned packages in /var/cache/pacman/pkg...

     Initializing the package-information arrays
     Checking installed packages

     Total Number of Packages : 2713
     Total Number Installed   : 2225
     Total Number Orphaned    : 488

     Updating the installed package array with installed/orphaned info
     ( be patient, time required is: [~30 sec/1000 pkgs] )

ORPHANS (pkg in /var/cache/pacman/pkg but not installed):

  Total packages orphaned:  488

  Package                                                    Arch          Installed
----------------------------------------------------------------------------
  a2ps-4.14-1                                                x86_64        no
  acct-6.5.1-1                                               x86_64        no
  acpi-1.4-2                                                 x86_64        no
<snip>

INSTALLED PACKAGES:

  Total packages installed:  2225

  Package                                                      Arch 
Installed
----------------------------------------------------------------------------
  a52dec-0.7.4-4                                             x86_64        yes
  aalib-1.4rc5-6                                             x86_64        yes
<snip>


	I find all 3 scripts useful in managing my Arch boxes and for moving installs 
to new arch boxes. The chkinstpkgs.sh script is great for checking what I have 
forgotten to install on a new box.

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