fdupes is a utility to find duplicate files in a directory hierarchy.
submitted by Antti Harri "sounds like you should import it" pvalchev@
This commit is contained in:
parent
3d4e2b4594
commit
cd39f46e3e
28
sysutils/fdupes/Makefile
Normal file
28
sysutils/fdupes/Makefile
Normal file
@ -0,0 +1,28 @@
|
||||
# $OpenBSD: Makefile,v 1.1.1.1 2008/06/20 06:03:43 ckuethe Exp $
|
||||
|
||||
COMMENT= identify or delete duplicates
|
||||
|
||||
DISTNAME= fdupes-1.40
|
||||
CATEGORIES= sysutils
|
||||
|
||||
MAINTAINER= Antti Harri <iku@openbsd.fi>
|
||||
|
||||
HOMEPAGE= http://netdial.caribe.net/~adrian2/fdupes.html
|
||||
MASTER_SITES= ${HOMEPAGE:fdupes.html=programs/}
|
||||
|
||||
PERMIT_PACKAGE_CDROM= Yes
|
||||
PERMIT_PACKAGE_FTP= Yes
|
||||
PERMIT_DISTFILES_CDROM= Yes
|
||||
PERMIT_DISTFILES_FTP= Yes
|
||||
|
||||
WANTLIB= c
|
||||
|
||||
ALL_TARGET=
|
||||
|
||||
do-install:
|
||||
${INSTALL_PROGRAM} ${WRKSRC}/fdupes ${PREFIX}/bin/
|
||||
${INSTALL_MAN} ${WRKSRC}/fdupes.1 ${PREFIX}/man/man1/
|
||||
${INSTALL_DATA_DIR} ${PREFIX}/share/doc/fdupes
|
||||
${INSTALL_DATA} ${WRKSRC}/README ${PREFIX}/share/doc/fdupes/
|
||||
|
||||
.include <bsd.port.mk>
|
5
sysutils/fdupes/distinfo
Normal file
5
sysutils/fdupes/distinfo
Normal file
@ -0,0 +1,5 @@
|
||||
MD5 (fdupes-1.40.tar.gz) = Ed6atEZgibasu2KBazCxiQ==
|
||||
RMD160 (fdupes-1.40.tar.gz) = Cr0vDf7jjLMzwQaTY6ZfirN+GN0=
|
||||
SHA1 (fdupes-1.40.tar.gz) = 4bzpvfUNe/cA3aPrij0hixgbOTE=
|
||||
SHA256 (fdupes-1.40.tar.gz) = 4e2RxEv0oI3pqSywGcIEIIdP3u1JpW6PJwrX/Ca73ec=
|
||||
SIZE (fdupes-1.40.tar.gz) = 16026
|
53
sysutils/fdupes/patches/patch-Makefile
Normal file
53
sysutils/fdupes/patches/patch-Makefile
Normal file
@ -0,0 +1,53 @@
|
||||
$OpenBSD: patch-Makefile,v 1.1.1.1 2008/06/20 06:03:43 ckuethe Exp $
|
||||
--- Makefile.orig Thu Mar 15 04:49:11 2001
|
||||
+++ Makefile Fri May 30 13:50:55 2008
|
||||
@@ -20,22 +20,45 @@ VERSION = "1.40"
|
||||
# built in MD5 message digest routines) uncomment the following
|
||||
# line (try this if you're having trouble with built in code).
|
||||
#
|
||||
-#EXTERNAL_MD5 = -DEXTERNAL_MD5=\"md5sum\"
|
||||
+#EXTERNAL_MD5 = 1
|
||||
|
||||
#
|
||||
+# Uncomment to enable system built-in MD5 functions
|
||||
+SYSTEM_MD5 = 1
|
||||
+
|
||||
+#
|
||||
# This version of fdupes can use a red-black tree structure to
|
||||
# store file information. This is disabled by default, as it
|
||||
# hasn't been optimized or verified correct. If you wish to
|
||||
# enable this untested option, uncomment the following line.
|
||||
#
|
||||
-#EXPERIMENTAL_RBTREE = -DEXPERIMENTAL_RBTREE
|
||||
+#EXPERIMENTAL_RBTREE = 1
|
||||
|
||||
#####################################################################
|
||||
# no need to modify anything beyond this point #
|
||||
#####################################################################
|
||||
|
||||
-fdupes: fdupes.c md5/md5.c
|
||||
- gcc fdupes.c md5/md5.c -Wall -o fdupes -DVERSION=\"$(VERSION)\" $(EXTERNAL_MD5) $(EXPERIMENTAL_RBTREE)
|
||||
+CFLAGS = -Wall -DVERSION=\"$(VERSION)\"
|
||||
+LDFLAGS =
|
||||
+SRC_FILES = fdupes.c
|
||||
+
|
||||
+.ifdef SYSTEM_MD5
|
||||
+CFLAGS += -DHAVE_MD5
|
||||
+#LDFLAGS += -lssl -lcrypto
|
||||
+.else
|
||||
+SRC_FILES += md5/md5.c
|
||||
+.endif
|
||||
+
|
||||
+.ifdef EXTERNAL_MD5
|
||||
+CFLAGS += -DEXTERNAL_MD5=\"md5sum\"
|
||||
+.endif
|
||||
+
|
||||
+.ifdef EXPERIMENTAL_RBTREE
|
||||
+CFLAGS += -DEXPERIMENTAL_RBTREE
|
||||
+.endif
|
||||
+
|
||||
+fdupes: $(SRC_FILES)
|
||||
+ gcc $(CFLAGS) $(SRC_FILES) $(LDFLAGS) -o fdupes
|
||||
|
||||
install: fdupes
|
||||
cp fdupes $(INSTALLDIR)
|
178
sysutils/fdupes/patches/patch-fdupes_c
Normal file
178
sysutils/fdupes/patches/patch-fdupes_c
Normal file
@ -0,0 +1,178 @@
|
||||
$OpenBSD: patch-fdupes_c,v 1.1.1.1 2008/06/20 06:03:43 ckuethe Exp $
|
||||
--- fdupes.c.orig Thu Mar 15 04:16:09 2001
|
||||
+++ fdupes.c Fri May 30 13:49:42 2008
|
||||
@@ -34,6 +34,11 @@
|
||||
#include "md5/md5.h"
|
||||
#endif
|
||||
|
||||
+#ifdef HAVE_MD5
|
||||
+#include <sys/types.h>
|
||||
+#include <md5.h>
|
||||
+#endif
|
||||
+
|
||||
#define ISFLAG(a,b) ((a & b) == b)
|
||||
#define SETFLAG(a,b) (a |= b)
|
||||
|
||||
@@ -94,11 +99,13 @@ void escapefilename(char *escape_list, char **filename
|
||||
{
|
||||
int x;
|
||||
int tx;
|
||||
+ size_t l;
|
||||
char *tmp;
|
||||
char *filename;
|
||||
|
||||
filename = *filename_ptr;
|
||||
|
||||
+ l = strlen(filename) * 2 + 1;
|
||||
tmp = (char*) malloc(strlen(filename) * 2 + 1);
|
||||
if (tmp == NULL) {
|
||||
errormsg("out of memory!\n");
|
||||
@@ -118,7 +125,7 @@ void escapefilename(char *escape_list, char **filename
|
||||
errormsg("out of memory!\n");
|
||||
exit(1);
|
||||
}
|
||||
- strcpy(*filename_ptr, tmp);
|
||||
+ strlcpy(*filename_ptr, tmp, l);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -145,6 +152,7 @@ int grokdir(char *dir, file_t **filelistp)
|
||||
struct dirent *dirinfo;
|
||||
int lastchar;
|
||||
int filecount = 0;
|
||||
+ size_t l;
|
||||
struct stat info;
|
||||
struct stat linfo;
|
||||
static int progress = 0;
|
||||
@@ -177,7 +185,8 @@ int grokdir(char *dir, file_t **filelistp)
|
||||
newfile->duplicates = NULL;
|
||||
newfile->hasdupes = 0;
|
||||
|
||||
- newfile->d_name = (char*)malloc(strlen(dir)+strlen(dirinfo->d_name)+2);
|
||||
+ l = strlen(dir)+strlen(dirinfo->d_name)+2;
|
||||
+ newfile->d_name = (char*)malloc(l);
|
||||
|
||||
if (!newfile->d_name) {
|
||||
errormsg("out of memory!\n");
|
||||
@@ -186,11 +195,11 @@ int grokdir(char *dir, file_t **filelistp)
|
||||
exit(1);
|
||||
}
|
||||
|
||||
- strcpy(newfile->d_name, dir);
|
||||
+ strlcpy(newfile->d_name, dir, l);
|
||||
lastchar = strlen(dir) - 1;
|
||||
if (lastchar >= 0 && dir[lastchar] != '/')
|
||||
- strcat(newfile->d_name, "/");
|
||||
- strcat(newfile->d_name, dirinfo->d_name);
|
||||
+ strlcat(newfile->d_name, "/", l);
|
||||
+ strlcat(newfile->d_name, dirinfo->d_name, l);
|
||||
|
||||
if (filesize(newfile->d_name) == 0 && ISFLAG(flags, F_EXCLUDEEMPTY)) {
|
||||
free(newfile->d_name);
|
||||
@@ -241,14 +250,22 @@ char *getcrcsignature(char *filename)
|
||||
int x;
|
||||
off_t fsize;
|
||||
off_t toread;
|
||||
+#ifdef HAVE_MD5
|
||||
+ MD5_CTX state;
|
||||
+#else
|
||||
md5_state_t state;
|
||||
+#endif
|
||||
md5_byte_t digest[16];
|
||||
static md5_byte_t chunk[CHUNK_SIZE];
|
||||
static char signature[16*2 + 1];
|
||||
char *sigp;
|
||||
FILE *file;
|
||||
-
|
||||
+
|
||||
+#ifdef HAVE_MD5
|
||||
+ MD5Init(&state);
|
||||
+#else
|
||||
md5_init(&state);
|
||||
+#endif
|
||||
|
||||
fsize = filesize(filename);
|
||||
|
||||
@@ -264,16 +281,24 @@ char *getcrcsignature(char *filename)
|
||||
errormsg("error reading from file %s\n", filename);
|
||||
return NULL;
|
||||
}
|
||||
+#ifdef HAVE_MD5
|
||||
+ MD5Update(&state, chunk, toread);
|
||||
+#else
|
||||
md5_append(&state, chunk, toread);
|
||||
+#endif
|
||||
fsize -= toread;
|
||||
}
|
||||
|
||||
+#ifdef HAVE_MD5
|
||||
+ MD5Final(digest, &state);
|
||||
+#else
|
||||
md5_finish(&state, digest);
|
||||
+#endif
|
||||
|
||||
sigp = signature;
|
||||
|
||||
for (x = 0; x < 16; x++) {
|
||||
- sprintf(sigp, "%02x", digest[x]);
|
||||
+ snprintf(sigp, 2, "%02x", digest[x]);
|
||||
sigp = strchr(sigp, '\0');
|
||||
}
|
||||
|
||||
@@ -488,6 +513,7 @@ file_t *checkmatch(filetree_t **root, filetree_t *chec
|
||||
{
|
||||
int cmpresult;
|
||||
char *crcsignature;
|
||||
+ size_t l;
|
||||
off_t fsize;
|
||||
|
||||
/* If inodes are equal one of the files is a hard link, which
|
||||
@@ -508,24 +534,26 @@ file_t *checkmatch(filetree_t **root, filetree_t *chec
|
||||
crcsignature = getcrcsignature(checktree->file->d_name);
|
||||
if (crcsignature == NULL) return NULL;
|
||||
|
||||
- checktree->file->crcsignature = (char*) malloc(strlen(crcsignature)+1);
|
||||
+ l = strlen(crcsignature)+1;
|
||||
+ checktree->file->crcsignature = (char*) malloc(l);
|
||||
if (checktree->file->crcsignature == NULL) {
|
||||
errormsg("out of memory\n");
|
||||
exit(1);
|
||||
}
|
||||
- strcpy(checktree->file->crcsignature, crcsignature);
|
||||
+ strlcpy(checktree->file->crcsignature, crcsignature, l);
|
||||
}
|
||||
|
||||
if (file->crcsignature == NULL) {
|
||||
crcsignature = getcrcsignature(file->d_name);
|
||||
if (crcsignature == NULL) return NULL;
|
||||
|
||||
- file->crcsignature = (char*) malloc(strlen(crcsignature)+1);
|
||||
+ l = strlen(crcsignature)+1;
|
||||
+ file->crcsignature = (char*) malloc(l);
|
||||
if (file->crcsignature == NULL) {
|
||||
errormsg("out of memory\n");
|
||||
exit(1);
|
||||
}
|
||||
- strcpy(file->crcsignature, crcsignature);
|
||||
+ strlcpy(file->crcsignature, crcsignature, l);
|
||||
}
|
||||
|
||||
cmpresult = strcmp(file->crcsignature, checktree->file->crcsignature);
|
||||
@@ -588,7 +616,7 @@ void printmatches(file_t *files)
|
||||
while (files != NULL) {
|
||||
if (files->hasdupes) {
|
||||
if (!ISFLAG(flags, F_OMITFIRST)) {
|
||||
- if (ISFLAG(flags, F_SHOWSIZE)) printf("%ld byte%seach:\n", files->size,
|
||||
+ if (ISFLAG(flags, F_SHOWSIZE)) printf("%lld byte%seach:\n", files->size,
|
||||
(files->size != 1) ? "s " : " ");
|
||||
if (ISFLAG(flags, F_DSAMELINE)) escapefilename("\\ ", &files->d_name);
|
||||
printf("%s%c", files->d_name, ISFLAG(flags, F_DSAMELINE)?' ':'\n');
|
||||
@@ -676,7 +704,7 @@ void autodelete(file_t *files)
|
||||
do {
|
||||
printf("Set %d of %d, preserve files [1 - %d, all]",
|
||||
curgroup, groups, counter);
|
||||
- if (ISFLAG(flags, F_SHOWSIZE)) printf(" (%ld byte%seach)", files->size,
|
||||
+ if (ISFLAG(flags, F_SHOWSIZE)) printf(" (%lld byte%seach)", files->size,
|
||||
(files->size != 1) ? "s " : " ");
|
||||
printf(": ");
|
||||
fflush(stdout);
|
19
sysutils/fdupes/patches/patch-md5_md5_c
Normal file
19
sysutils/fdupes/patches/patch-md5_md5_c
Normal file
@ -0,0 +1,19 @@
|
||||
$OpenBSD: patch-md5_md5_c,v 1.1.1.1 2008/06/20 06:03:43 ckuethe Exp $
|
||||
--- md5/md5.c.orig Thu May 29 22:20:16 2008
|
||||
+++ md5/md5.c Thu May 29 22:20:27 2008
|
||||
@@ -38,6 +38,7 @@
|
||||
1999-05-03 lpd Original version.
|
||||
*/
|
||||
|
||||
+#include <string.h>
|
||||
#include "md5.h"
|
||||
|
||||
#ifdef TEST
|
||||
@@ -46,7 +47,6 @@
|
||||
* The test program should print out the same values as given in section
|
||||
* A.5 of RFC 1321, reproduced below.
|
||||
*/
|
||||
-#include <string.h>
|
||||
main()
|
||||
{
|
||||
static const char *const test[7] = {
|
2
sysutils/fdupes/pkg/DESCR
Normal file
2
sysutils/fdupes/pkg/DESCR
Normal file
@ -0,0 +1,2 @@
|
||||
Fdupes is a program for identifying or deleting duplicate
|
||||
files residing within specified directories.
|
5
sysutils/fdupes/pkg/PLIST
Normal file
5
sysutils/fdupes/pkg/PLIST
Normal file
@ -0,0 +1,5 @@
|
||||
@comment $OpenBSD: PLIST,v 1.1.1.1 2008/06/20 06:03:43 ckuethe Exp $
|
||||
bin/fdupes
|
||||
@man man/man1/fdupes.1
|
||||
share/doc/fdupes/
|
||||
share/doc/fdupes/README
|
Loading…
Reference in New Issue
Block a user