All pastes #496744 Raw Edit

Mine

public text v1 · immutable
·published 2007-05-19 12:56 UTC
rendered paste body
#!/bin/bash

###############################################################################
# Script to find the same file spread accross repositories (in my case mirrors#
# made by running debmirror) and hardlink duplicated files into one location. #
###############################################################################

# Steps need to be:

md5sum files
sha1sum files

create a DB of files, with both hashes in it.
file syntax: filename firstpath md5sum sha1sum
line is repeated for multiple paths (ie line is always repeated)
compare all lines that start with teh same string (ie filename)
if they have the same hashs (both must match) then hard symlink to master

move onto next file

problems:
how to decide which is master?

implimentation:
probably grep through package lists, 
cut+[g,m]awk out the package names and paths into a file,
using cut+vars look at $path/$name and run both hashs
output hashes into the file on the correct line
loop through and check for collisions (unsure how)
symlink as required