diff options
-rwxr-xr-x | clubber | 49 |
1 files changed, 39 insertions, 10 deletions
@@ -39,14 +39,6 @@ if (!$ldd) { } # -# Check md5sum is available. -# -chomp(my $md5sum = `which md5sum`); -if (!$md5sum) { - error("Couldn't find md5sum in your \$PATH."); -} - -# # Check options. # my ($chroot, $dry) = ("", 0); @@ -116,13 +108,50 @@ if ($chroot) { # foreach my $library (keys(%$libraries)) { my $directory = dirname($library); + + # + # If the directory doesn't exist, flag it for creation. + # if (!-d "${chroot}${directory}") { $directories->{$directory} = 1; } - if (-f "${chroot}{$library}") { - if (qx/${md5sum} ${library}/ ne qx/${md5sum} ${chroot}${library}/) { + + # + # If the library exists, we need to see if it's the same as our source + # library. + # + if (-f "${chroot}${library}") { + + # + # Get MD5 checksum of source library. + # + open(my $src, "<", $library) + or error("Couldn't read file %s to checksum it.", $library); + binmode($src); + my $src_checksum = Digest::MD5->new->addfile($src)->hexdigest; + close($src); + + # + # Get MD5 checksum of library presently occupying the path to + # which we intend to copy this library. + # + open(my $dst, "<", "${chroot}${library}") + or error("Couldn't read file %s to checksum it.", "${chroot}${library}"); + binmode($dst); + my $dst_checksum = Digest::MD5->new->addfile($dst)->hexdigest; + close($dst); + + # + # Compare checksums; if they're different, we need to copy the + # library in. + # + if ($src_checksum ne $dst_checksum) { $imports->{$library} = 1; } + + # + # The library doesn't exist, so we need to copy it in. + # } else { $imports->{$library} = 1; } |