SHA256
3
0
forked from pool/fdupes

Accepting request 139254 from utilities

- update to 1.5.0-PR2
  * new "--summarize" option
  * new  "--recurse:" selective recursion option
  * new "--noprompt" option for totally automated deletion of
  duplicate files.
  * sorts duplicates (old to new) for consistent order when
  listing or deleteing duplicate files.
  * tests for early matching of files, which should help speed up
  the matching process when large files are involved.
  * warns whenever a file cannot be deleted.
  * bugfixes (proper file closing, zero-length files, ...)
- drop the fdupes-sort-output.diff (upstream uses mtime based)
- rename and rebase fdupes-speedup.patch to 0008-speedup-the-compare.patch
- rename and rebase fdupes-endianness.patch to
  0009-glibc-endianness-check-in-md5.patch
- add -p/--permissions switch so files with different permissions or uid/gid
  are not considered as duplicates (bnc#784670)
  * this mode is a default one for fdupes macro
  0010-add-permissions-mode.patch
- imported several fixes from Debian
  * 0001-restore-pristine-code.patch - some common code fixes, partly obsoletes
    speedup patch
  * manual page fixes
    0002-Added-to-escape-minus-signs-in-manpage-lintian-warni.patch
    0003-Fix-a-typo-in-a-manpage-bts353789.patch
    0005-add-summarize-to-manpage-bts481809.patch
    0006-add-nohidden-support-bts511702.patch
    0007-Disambiguate-the-options-recurse-and-recurse-bts5371.patch
  * 0004-Large-file-support-for-2GB-files-bts447601.patch - large file support

OBS-URL: https://build.opensuse.org/request/show/139254
OBS-URL: https://build.opensuse.org/package/show/openSUSE:Factory/fdupes?expand=0&rev=19
This commit is contained in:
Stephan Kulow 2012-10-27 11:22:47 +00:00 committed by Git OBS Bridge
commit 461a3455ba
20 changed files with 654 additions and 198 deletions

View File

@ -0,0 +1,73 @@
From 1e8e84ee52397881558e083bcae4d243d319e811 Mon Sep 17 00:00:00 2001
From: Sandro Tosi <matrixhasu@gmail.com>
Date: Fri, 12 Oct 2012 14:54:42 +0200
Subject: [PATCH 01/10] restore pristine code
speedup the file compare by reading larger buffers, comparing the
results of fread and so
---
fdupes.c | 25 +++++++++++++++----------
1 file changed, 15 insertions(+), 10 deletions(-)
diff --git a/fdupes.c b/fdupes.c
index 4b870b2..f16e4e0 100644
--- a/fdupes.c
+++ b/fdupes.c
@@ -492,7 +492,10 @@ file_t **checkmatch(filetree_t **root, filetree_t *checktree, file_t *file)
else {
if (checktree->file->crcpartial == NULL) {
crcsignature = getcrcpartialsignature(checktree->file->d_name);
- if (crcsignature == NULL) return NULL;
+ if (crcsignature == NULL) {
+ errormsg ("cannot read file %s\n", checktree->file->d_name);
+ return NULL;
+ }
checktree->file->crcpartial = (char*) malloc(strlen(crcsignature)+1);
if (checktree->file->crcpartial == NULL) {
@@ -504,7 +507,10 @@ file_t **checkmatch(filetree_t **root, filetree_t *checktree, file_t *file)
if (file->crcpartial == NULL) {
crcsignature = getcrcpartialsignature(file->d_name);
- if (crcsignature == NULL) return NULL;
+ if (crcsignature == NULL) {
+ errormsg ("cannot read file %s\n", file->d_name);
+ return NULL;
+ }
file->crcpartial = (char*) malloc(strlen(crcsignature)+1);
if (file->crcpartial == NULL) {
@@ -577,8 +583,8 @@ file_t **checkmatch(filetree_t **root, filetree_t *checktree, file_t *file)
int confirmmatch(FILE *file1, FILE *file2)
{
- unsigned char c1 = 0;
- unsigned char c2 = 0;
+ unsigned char c1[CHUNK_SIZE];
+ unsigned char c2[CHUNK_SIZE];
size_t r1;
size_t r2;
@@ -586,14 +592,13 @@ int confirmmatch(FILE *file1, FILE *file2)
fseek(file2, 0, SEEK_SET);
do {
- r1 = fread(&c1, sizeof(c1), 1, file1);
- r2 = fread(&c2, sizeof(c2), 1, file2);
+ r1 = fread(c1, 1, sizeof(c1), file1);
+ r2 = fread(c2, 1, sizeof(c2), file2);
- if (c1 != c2) return 0; /* file contents are different */
- } while (r1 && r2);
+ if (r1 != r2) return 0; /* file lengths are different */
+ if (memcmp (c1, c2, r1)) return 0; /* file contents are different */
+ } while (r2);
- if (r1 != r2) return 0; /* file lengths are different */
-
return 1;
}
--
1.7.11.5

View File

@ -0,0 +1,26 @@
From 05157cf087829d18092c6906ac9a61b93f390059 Mon Sep 17 00:00:00 2001
From: Sandro Tosi <matrixhasu@gmail.com>
Date: Fri, 12 Oct 2012 14:57:06 +0200
Subject: [PATCH 02/10] Added to escape minus signs in manpage (lintian
warning)
---
fdupes.1 | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/fdupes.1 b/fdupes.1
index 2102344..c0a02f0 100644
--- a/fdupes.1
+++ b/fdupes.1
@@ -53,7 +53,7 @@ prompt user for files to preserve, deleting all others (see
below)
.TP
.B -N --noprompt
-when used together with --delete, preserve the first file in each
+when used together with \-\-delete, preserve the first file in each
set of duplicates and delete the others without prompting the user
.TP
.B -v --version
--
1.7.11.5

View File

@ -0,0 +1,25 @@
From 445205969c23e8c51e19456b3fcd1571b44c6e5c Mon Sep 17 00:00:00 2001
From: A Costa <agcosta@gis.net>
Date: Fri, 12 Oct 2012 14:58:00 +0200
Subject: [PATCH 03/10] Fix a typo in a manpage (bts353789)
---
fdupes.1 | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/fdupes.1 b/fdupes.1
index c0a02f0..71da2c4 100644
--- a/fdupes.1
+++ b/fdupes.1
@@ -84,7 +84,7 @@ If fdupes returns with an error message such as
.B fdupes: error invoking md5sum
it means the program has been compiled to use an external
program to calculate MD5 signatures (otherwise, fdupes uses
-interal routines for this purpose), and an error has occurred
+internal routines for this purpose), and an error has occurred
while attempting to execute it. If this is the case, the
specified program should be properly installed prior
to running fdupes.
--
1.7.11.5

View File

@ -0,0 +1,48 @@
From 9024d0c1bbbb323ae30b3b025705b076094e2c6c Mon Sep 17 00:00:00 2001
From: Andrew Vaughan <ajv-lists@netspace.net.au>
Date: Fri, 12 Oct 2012 15:00:30 +0200
Subject: [PATCH 04/10] Large file support for >2GB files (bts447601)
---
Makefile | 2 +-
fdupes.c | 4 ++--
2 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/Makefile b/Makefile
index 0c968a8..4d50924 100644
--- a/Makefile
+++ b/Makefile
@@ -74,7 +74,7 @@ MKDIR = mkdir -p
CC = gcc
COMPILER_OPTIONS = -Wall -O -g
-CFLAGS= $(COMPILER_OPTIONS) -I. -DVERSION=\"$(VERSION)\" $(EXTERNAL_MD5) $(EXPERIMENTAL_RBTREE) $(OMIT_GETOPT_LONG)
+CFLAGS= $(COMPILER_OPTIONS) -I. -D_FILE_OFFSET_BITS=64 -DVERSION=\"$(VERSION)\" $(EXTERNAL_MD5) $(EXPERIMENTAL_RBTREE) $(OMIT_GETOPT_LONG)
INSTALL_PROGRAM = $(INSTALL) -c -m 0755
INSTALL_DATA = $(INSTALL) -c -m 0644
diff --git a/fdupes.c b/fdupes.c
index f16e4e0..4ecf51b 100644
--- a/fdupes.c
+++ b/fdupes.c
@@ -648,7 +648,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');
@@ -801,7 +801,7 @@ void deletefiles(file_t *files, int prompt)
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);
--
1.7.11.5

View File

@ -0,0 +1,26 @@
From 9b6800eb5bdcea2ceb0a2e44c4ea744c77656213 Mon Sep 17 00:00:00 2001
From: Sandro Tosi <matrixhasu@gmail.com>
Date: Fri, 12 Oct 2012 15:01:35 +0200
Subject: [PATCH 05/10] add --summarize to manpage (bts481809)
---
fdupes.1 | 3 +++
1 file changed, 3 insertions(+)
diff --git a/fdupes.1 b/fdupes.1
index 71da2c4..f12945b 100644
--- a/fdupes.1
+++ b/fdupes.1
@@ -44,6 +44,9 @@ list each set of matches on a single line
.B -S --size
show size of duplicate files
.TP
+.B -m --summarize
+summarize duplicate files information
+.TP
.B -q --quiet
hide progress indicator
.TP
--
1.7.11.5

View File

@ -0,0 +1,108 @@
From 1e15ced9c10a04b6f4ae816ced687fd982760dbc Mon Sep 17 00:00:00 2001
From: maxy <maxy@debian.org>
Date: Fri, 12 Oct 2012 15:02:49 +0200
Subject: [PATCH 06/10] add --nohidden support (bts511702)
---
fdupes.1 | 3 +++
fdupes.c | 21 ++++++++++++++++++++-
2 files changed, 23 insertions(+), 1 deletion(-)
diff --git a/fdupes.1 b/fdupes.1
index f12945b..5f7c526 100644
--- a/fdupes.1
+++ b/fdupes.1
@@ -38,6 +38,9 @@ exclude zero-length files from consideration
.B -f --omitfirst
omit the first file in each set of matches
.TP
+.B -A --nohidden
+exclude hidden files from consideration
+.TP
.B -1 --sameline
list each set of matches on a single line
.TP
diff --git a/fdupes.c b/fdupes.c
index 4ecf51b..fe540e6 100644
--- a/fdupes.c
+++ b/fdupes.c
@@ -31,6 +31,7 @@
#endif
#include <string.h>
#include <errno.h>
+#include <libgen.h>
#ifndef EXTERNAL_MD5
#include "md5/md5.h"
@@ -51,6 +52,7 @@
#define F_RECURSEAFTER 0x0200
#define F_NOPROMPT 0x0400
#define F_SUMMARIZEMATCHES 0x0800
+#define F_EXCLUDEHIDDEN 0x1000
char *program_name;
@@ -240,6 +242,7 @@ int grokdir(char *dir, file_t **filelistp)
struct stat linfo;
static int progress = 0;
static char indicator[] = "-\\|/";
+ char *fullname, *name;
cd = opendir(dir);
@@ -285,6 +288,17 @@ int grokdir(char *dir, file_t **filelistp)
strcat(newfile->d_name, "/");
strcat(newfile->d_name, dirinfo->d_name);
+ if (ISFLAG(flags, F_EXCLUDEHIDDEN)) {
+ fullname = strdup(newfile->d_name);
+ name = basename(fullname);
+ if (name[0] == '.' && strcmp(name, ".") && strcmp(name, "..") ) {
+ free(newfile->d_name);
+ free(newfile);
+ continue;
+ }
+ free(fullname);
+ }
+
if (filesize(newfile->d_name) == 0 && ISFLAG(flags, F_EXCLUDEEMPTY)) {
free(newfile->d_name);
free(newfile);
@@ -945,6 +959,7 @@ void help_text()
printf(" \tdisk area they are treated as non-duplicates; this\n");
printf(" \toption will change this behavior\n");
printf(" -n --noempty \texclude zero-length files from consideration\n");
+ printf(" -A --nohidden \texclude hidden files from consideration\n");
printf(" -f --omitfirst \tomit the first file in each set of matches\n");
printf(" -1 --sameline \tlist each set of matches on a single line\n");
printf(" -S --size \tshow size of duplicate files\n");
@@ -996,6 +1011,7 @@ int main(int argc, char **argv) {
{ "hardlinks", 0, 0, 'H' },
{ "relink", 0, 0, 'l' },
{ "noempty", 0, 0, 'n' },
+ { "nohidden", 0, 0, 'A' },
{ "delete", 0, 0, 'd' },
{ "version", 0, 0, 'v' },
{ "help", 0, 0, 'h' },
@@ -1013,7 +1029,7 @@ int main(int argc, char **argv) {
oldargv = cloneargs(argc, argv);
- while ((opt = GETOPT(argc, argv, "frRq1Ss::HlndvhNm"
+ while ((opt = GETOPT(argc, argv, "frRq1Ss::HlnAdvhNm"
#ifndef OMIT_GETOPT_LONG
, long_options, NULL
#endif
@@ -1046,6 +1062,9 @@ int main(int argc, char **argv) {
case 'n':
SETFLAG(flags, F_EXCLUDEEMPTY);
break;
+ case 'A':
+ SETFLAG(flags, F_EXCLUDEHIDDEN);
+ break;
case 'd':
SETFLAG(flags, F_DELETEFILES);
break;
--
1.7.11.5

View File

@ -0,0 +1,58 @@
From 299e999ba8ac1916797e4956ee774a46ef11851b Mon Sep 17 00:00:00 2001
From: Sandro Tosi <morph@debian.org>
Date: Fri, 12 Oct 2012 15:06:16 +0200
Subject: [PATCH 07/10] Disambiguate the options '--recurse' and '--recurse:'
(bts537138)
---
fdupes.1 | 12 +++++++++++-
fdupes.c | 3 ++-
2 files changed, 13 insertions(+), 2 deletions(-)
diff --git a/fdupes.1 b/fdupes.1
index 5f7c526..9263adc 100644
--- a/fdupes.1
+++ b/fdupes.1
@@ -23,7 +23,8 @@ for every directory given follow subdirectories encountered within
.TP
.B -R --recurse:
for each directory given after this option follow subdirectories
-encountered within
+encountered within (note the ':' at the end of option; see the
+Examples section below for further explanation)
.TP
.B -s --symlinks
follow symlinked directories
@@ -85,6 +86,15 @@ or
.B --sameline
is specified, spaces and backslash characters (\fB\e\fP) appearing
in a filename are preceded by a backslash character.
+
+.SH EXAMPLES
+.TP
+.B fdupes a --recurse: b
+will follow subdirectories under b, but not those under a.
+.TP
+.B fdupes a --recurse b
+will follow subdirectories under both a and b.
+
.SH CAVEATS
If fdupes returns with an error message such as
.B fdupes: error invoking md5sum
diff --git a/fdupes.c b/fdupes.c
index fe540e6..1e9e620 100644
--- a/fdupes.c
+++ b/fdupes.c
@@ -953,7 +953,8 @@ void help_text()
printf(" -r --recurse \tfor every directory given follow subdirectories\n");
printf(" \tencountered within\n");
printf(" -R --recurse: \tfor each directory given after this option follow\n");
- printf(" \tsubdirectories encountered within\n");
+ printf(" \tsubdirectories encountered within (note the ':' at\n");
+ printf(" \tthe end of the option, manpage for more details)\n");
printf(" -s --symlinks \tfollow symlinks\n");
printf(" -H --hardlinks \tnormally, when two or more files point to the same\n");
printf(" \tdisk area they are treated as non-duplicates; this\n");
--
1.7.11.5

View File

@ -0,0 +1,39 @@
From c2bd76bb103b3a5b873bee72fbacce6bbe58bbe2 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Stefan=20Br=C3=BCns?= <stefan.bruens@rwth-aachen.de>
Date: Fri, 12 Oct 2012 15:20:53 +0200
Subject: [PATCH 08/10] speedup the file compare
Use aligned reads for md5 computation, saves another memcpy.
https://bugzilla.novell.com/show_bug.cgi?id=406825
---
fdupes.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/fdupes.c b/fdupes.c
index 1e9e620..678f31f 100644
--- a/fdupes.c
+++ b/fdupes.c
@@ -370,7 +370,7 @@ char *getcrcsignatureuntil(char *filename, off_t max_read)
}
while (fsize > 0) {
- toread = (fsize % CHUNK_SIZE) ? (fsize % CHUNK_SIZE) : CHUNK_SIZE;
+ toread = (fsize >= CHUNK_SIZE) ? CHUNK_SIZE : fsize;
if (fread(chunk, toread, 1, file) != 1) {
errormsg("error reading from file %s\n", filename);
fclose(file); // bugfix
@@ -606,8 +606,8 @@ int confirmmatch(FILE *file1, FILE *file2)
fseek(file2, 0, SEEK_SET);
do {
- r1 = fread(c1, 1, sizeof(c1), file1);
- r2 = fread(c2, 1, sizeof(c2), file2);
+ r1 = fread(c1, sizeof(unsigned char), sizeof(c1), file1);
+ r2 = fread(c2, sizeof(unsigned char), sizeof(c2), file2);
if (r1 != r2) return 0; /* file lengths are different */
if (memcmp (c1, c2, r1)) return 0; /* file contents are different */
--
1.7.11.5

View File

@ -0,0 +1,33 @@
From 6b0f55c489ff78bd29d6d881fddf7abeabbed12f Mon Sep 17 00:00:00 2001
From: Michal Vyskocil <mvyskocil@suse.cz>
Date: Fri, 12 Oct 2012 15:21:49 +0200
Subject: [PATCH 09/10] glibc endianness check in md5
https://bugzilla.novell.com/show_bug.cgi?id=406825
---
md5/md5.c | 9 +++++++++
1 file changed, 9 insertions(+)
diff --git a/md5/md5.c b/md5/md5.c
index 233ee2d..3ad899b 100644
--- a/md5/md5.c
+++ b/md5/md5.c
@@ -45,6 +45,15 @@
#include "md5.h"
#include <string.h>
+/* endianness check using glibc endian.h */
+#include <endian.h>
+
+#if __BYTE_ORDER == __BIG_ENDIAN
+# define ARCH_IS_BIG_ENDIAN 1
+#elif __BYTE_ORDER == __LITTLE_ENDIAN
+# define ARCH_IS_BIG_ENDIAN 0
+#endif
+
#ifdef TEST
/*
* Compile with -DTEST to create a self-contained executable test program.
--
1.7.11.5

View File

@ -0,0 +1,110 @@
From 0cf7f38569e1c0ff65803342f63244f864d87141 Mon Sep 17 00:00:00 2001
From: Michal Vyskocil <mvyskocil@suse.cz>
Date: Fri, 12 Oct 2012 15:24:16 +0200
Subject: [PATCH 10/10] add --permissions mode
With -p/--permissions mode enabled fdupes checks if the
uid/gid/secure-bits are same or not. In later case, files are not
considered as duplicates.
Requested-in: https://bugzilla.novell.com/show_bug.cgi?id=784670
---
fdupes.1 | 3 +++
fdupes.c | 25 ++++++++++++++++++++++++-
2 files changed, 27 insertions(+), 1 deletion(-)
diff --git a/fdupes.1 b/fdupes.1
index 9263adc..e0516f1 100644
--- a/fdupes.1
+++ b/fdupes.1
@@ -63,6 +63,9 @@ below)
when used together with \-\-delete, preserve the first file in each
set of duplicates and delete the others without prompting the user
.TP
+.B -p --permissions
+don't consider files with different owner/group or permission bits as duplicates
+.TP
.B -v --version
display fdupes version
.TP
diff --git a/fdupes.c b/fdupes.c
index 678f31f..b3275a9 100644
--- a/fdupes.c
+++ b/fdupes.c
@@ -53,6 +53,7 @@
#define F_NOPROMPT 0x0400
#define F_SUMMARIZEMATCHES 0x0800
#define F_EXCLUDEHIDDEN 0x1000
+#define F_PERMISSIONS 0x2000
char *program_name;
@@ -481,6 +482,19 @@ int registerfile(filetree_t **branch, file_t *file)
return 1;
}
+int same_permissions(char* name1, char* name2)
+{
+ struct stat s1, s2;
+
+ if (stat(name1, &s1) != 0) return -1;
+ if (stat(name2, &s2) != 0) return -1;
+
+ return (s1.st_mode == s2.st_mode &&
+ s1.st_uid == s2.st_uid &&
+ s1.st_gid == s2.st_gid);
+}
+
+
file_t **checkmatch(filetree_t **root, filetree_t *checktree, file_t *file)
{
int cmpresult;
@@ -503,6 +517,10 @@ file_t **checkmatch(filetree_t **root, filetree_t *checktree, file_t *file)
cmpresult = -1;
else
if (fsize > checktree->file->size) cmpresult = 1;
+ else
+ if (ISFLAG(flags, F_PERMISSIONS) &&
+ !same_permissions(file->d_name, checktree->file->d_name))
+ cmpresult = -1;
else {
if (checktree->file->crcpartial == NULL) {
crcsignature = getcrcpartialsignature(checktree->file->d_name);
@@ -976,6 +994,7 @@ void help_text()
printf(" -N --noprompt \ttogether with --delete, preserve the first file in\n");
printf(" \teach set of duplicates and delete the rest without\n");
printf(" \twithout prompting the user\n");
+ printf(" -p --permissions \tdon't consider files with different owner/group or permission bits as duplicates\n");
printf(" -v --version \tdisplay fdupes version\n");
printf(" -h --help \tdisplay this help message\n\n");
#ifdef OMIT_GETOPT_LONG
@@ -1019,6 +1038,7 @@ int main(int argc, char **argv) {
{ "noprompt", 0, 0, 'N' },
{ "summarize", 0, 0, 'm'},
{ "summary", 0, 0, 'm' },
+ { "permissions", 0, 0, 'p' },
{ 0, 0, 0, 0 }
};
#define GETOPT getopt_long
@@ -1030,7 +1050,7 @@ int main(int argc, char **argv) {
oldargv = cloneargs(argc, argv);
- while ((opt = GETOPT(argc, argv, "frRq1Ss::HlnAdvhNm"
+ while ((opt = GETOPT(argc, argv, "frRq1Ss::HlnAdvhNmp"
#ifndef OMIT_GETOPT_LONG
, long_options, NULL
#endif
@@ -1081,6 +1101,9 @@ int main(int argc, char **argv) {
case 'm':
SETFLAG(flags, F_SUMMARIZEMATCHES);
break;
+ case 'p':
+ SETFLAG(flags, F_PERMISSIONS);
+ break;
default:
fprintf(stderr, "Try `fdupes --help' for more information.\n");
--
1.7.11.5

View File

@ -1,3 +0,0 @@
version https://git-lfs.github.com/spec/v1
oid sha256:f4a5e0ae771bcad37d59bcdcbcfe78d5e7b9f584eff559b38a1e4772acae71ca
size 14974

3
fdupes-1.50-PR2.tar.gz Normal file
View File

@ -0,0 +1,3 @@
version https://git-lfs.github.com/spec/v1
oid sha256:5af2c71206fece42e0f9554427e323bef96653a4dceb5130bc8ac63e2ceb1619
size 19436

View File

@ -1,20 +0,0 @@
Index: fdupes-1.40/md5/md5.c
===================================================================
--- fdupes-1.40.orig/md5/md5.c 2010-02-15 15:36:58.000000000 +0100
+++ fdupes-1.40/md5/md5.c 2010-02-15 16:01:34.350140290 +0100
@@ -41,6 +41,15 @@
#include "md5.h"
#include <string.h>
+/* endianness check using glibc endian.h */
+#include <endian.h>
+
+#if __BYTE_ORDER == __BIG_ENDIAN
+# define ARCH_IS_BIG_ENDIAN 1
+#elif __BYTE_ORDER == __LITTLE_ENDIAN
+# define ARCH_IS_BIG_ENDIAN 0
+#endif
+
#ifdef TEST
/*
* Compile with -DTEST to create a self-contained executable test program.

22
fdupes-makefile.patch Normal file
View File

@ -0,0 +1,22 @@
Index: Makefile
===================================================================
--- Makefile.orig 2002-05-31 09:31:45.000000000 +0200
+++ Makefile 2012-10-12 11:46:35.152408642 +0200
@@ -11,7 +11,7 @@
# determination of the actual installation directories.
# Suggested values are "/usr/local", "/usr", "/pkgs/fdupes-$(VERSION)"
#
-PREFIX = /usr/local
+PREFIX = /usr
#
# Certain platforms do not support long options (command line options).
@@ -50,7 +50,7 @@
# MAN_DIR indicates directory where the fdupes man page is to be
# installed. Suggested value is "$(PREFIX)/man/man1"
#
-MAN_BASE_DIR = $(PREFIX)/man
+MAN_BASE_DIR = $(PREFIX)/share/man
MAN_DIR = $(MAN_BASE_DIR)/man1
MAN_EXT = 1

View File

@ -1,64 +0,0 @@
--- fdupes.c
+++ fdupes.c
@@ -581,24 +581,45 @@
return 1;
}
+/* from qsort man page */
+static int
+cmpstringp(const void *p1, const void *p2)
+{
+ /* The actual arguments to this function are "pointers to
+ pointers to char", but strcmp(3) arguments are "pointers
+ to char", hence the following cast plus dereference */
+
+ return strcmp(* (char * const *) p1, * (char * const *) p2);
+}
+
void printmatches(file_t *files)
{
file_t *tmpfile;
while (files != NULL) {
if (files->hasdupes) {
+ char **names = (char**)malloc(sizeof(char*)*(files->hasdupes+1));
+ int count = 0, index;
+ names[count++] = files->d_name;
+ tmpfile = files->duplicates;
+ while (tmpfile != NULL) {
+ names[count++] = tmpfile->d_name;
+ tmpfile = tmpfile->duplicates;
+ }
+ qsort(names, count, sizeof(char *), cmpstringp);
+
if (!ISFLAG(flags, F_OMITFIRST)) {
if (ISFLAG(flags, F_SHOWSIZE)) printf("%ld 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');
+ if (ISFLAG(flags, F_DSAMELINE)) escapefilename("\\ ", &names[0]);
+ printf("%s%c", names[0], ISFLAG(flags, F_DSAMELINE)?' ':'\n');
}
- tmpfile = files->duplicates;
- while (tmpfile != NULL) {
- if (ISFLAG(flags, F_DSAMELINE)) escapefilename("\\ ", &tmpfile->d_name);
- printf("%s%c", tmpfile->d_name, ISFLAG(flags, F_DSAMELINE)?' ':'\n');
- tmpfile = tmpfile->duplicates;
+ for (index = 1; index < count; index++) {
+ if (ISFLAG(flags, F_DSAMELINE)) escapefilename("\\ ", &names[index]);
+ printf("%s%c", names[index], ISFLAG(flags, F_DSAMELINE)?' ':'\n');
+
}
+ free(names);
printf("\n");
}
@@ -869,7 +890,7 @@
}
if (confirmmatch(file1, file2)) {
- match->hasdupes = 1;
+ match->hasdupes++;
curfile->duplicates = match->duplicates;
match->duplicates = curfile;
}

View File

@ -1,44 +0,0 @@
Index: fdupes.c
===================================================================
--- fdupes.c.orig 2010-02-15 15:36:58.000000000 +0100
+++ fdupes.c 2010-02-15 15:38:11.091108207 +0100
@@ -259,7 +259,7 @@
}
while (fsize > 0) {
- toread = (fsize % CHUNK_SIZE) ? (fsize % CHUNK_SIZE) : CHUNK_SIZE;
+ toread = (fsize >= CHUNK_SIZE) ? CHUNK_SIZE : fsize;
if (fread(chunk, toread, 1, file) != 1) {
errormsg("error reading from file %s\n", filename);
return NULL;
@@ -561,22 +561,23 @@
int confirmmatch(FILE *file1, FILE *file2)
{
- unsigned char c1;
- unsigned char c2;
+ unsigned char c1[8192];
+ unsigned char c2[8192];
size_t r1;
size_t r2;
+ int res;
fseek(file1, 0, SEEK_SET);
fseek(file2, 0, SEEK_SET);
do {
- r1 = fread(&c1, sizeof(c1), 1, file1);
- r2 = fread(&c2, sizeof(c2), 1, file2);
+ r1 = fread(c1, sizeof(unsigned char), sizeof(c1), file1);
+ r2 = fread(c2, sizeof(unsigned char), sizeof(c2), file2);
- if (c1 != c2) return 0; /* file contents are different */
+ if (r1 != r2) return 0; /* file lengths are different */
+ res = memcmp(c1, c2, r1);
+ if ( 0 != res ) return 0; /* file contents are different */
} while (r1 && r2);
-
- if (r1 != r2) return 0; /* file lengths are different */
return 1;
}

View File

@ -1,3 +1,36 @@
-------------------------------------------------------------------
Tue Oct 16 11:44:08 UTC 2012 - mvyskocil@suse.com
- update to 1.5.0-PR2
* new "--summarize" option
* new "--recurse:" selective recursion option
* new "--noprompt" option for totally automated deletion of
duplicate files.
* sorts duplicates (old to new) for consistent order when
listing or deleteing duplicate files.
* tests for early matching of files, which should help speed up
the matching process when large files are involved.
* warns whenever a file cannot be deleted.
* bugfixes (proper file closing, zero-length files, ...)
- drop the fdupes-sort-output.diff (upstream uses mtime based)
- rename and rebase fdupes-speedup.patch to 0008-speedup-the-compare.patch
- rename and rebase fdupes-endianness.patch to
0009-glibc-endianness-check-in-md5.patch
- add -p/--permissions switch so files with different permissions or uid/gid
are not considered as duplicates (bnc#784670)
* this mode is a default one for fdupes macro
0010-add-permissions-mode.patch
- imported several fixes from Debian
* 0001-restore-pristine-code.patch - some common code fixes, partly obsoletes
speedup patch
* manual page fixes
0002-Added-to-escape-minus-signs-in-manpage-lintian-warni.patch
0003-Fix-a-typo-in-a-manpage-bts353789.patch
0005-add-summarize-to-manpage-bts481809.patch
0006-add-nohidden-support-bts511702.patch
0007-Disambiguate-the-options-recurse-and-recurse-bts5371.patch
* 0004-Large-file-support-for-2GB-files-bts447601.patch - large file support
-------------------------------------------------------------------
Sun Mar 25 22:13:12 UTC 2012 - behrisch@users.sf.net

View File

@ -1,45 +0,0 @@
--- Makefile
+++ Makefile
@@ -2,13 +2,13 @@
# INSTALLDIR indicates directory where program is to be installed.
# Suggested values are "/usr/local/bin" or "/usr/bin".
#
-INSTALLDIR = /usr/local/bin
+INSTALLDIR = /usr/bin
#
# MANPAGEDIR indicates directory where the fdupes man page is to be
# installed. Suggested values are "/usr/local/man" or "/usr/man".
#
-MANPAGEDIR = /usr/local/man
+MANPAGEDIR = /usr/share/man
#
# VERSION determines the program's version number.
@@ -35,7 +35,7 @@
#####################################################################
fdupes: fdupes.c md5/md5.c
- gcc fdupes.c md5/md5.c -Wall -o fdupes -DVERSION=\"$(VERSION)\" $(EXTERNAL_MD5) $(EXPERIMENTAL_RBTREE)
+ gcc fdupes.c md5/md5.c $(RPM_OPT_FLAGS) -o fdupes -DVERSION=\"$(VERSION)\" $(EXTERNAL_MD5) $(EXPERIMENTAL_RBTREE)
install: fdupes
cp fdupes $(INSTALLDIR)
--- md5/md5.c
+++ md5/md5.c
@@ -39,6 +39,7 @@
*/
#include "md5.h"
+#include <string.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] = {

View File

@ -16,20 +16,40 @@
#
Name: fdupes
Url: http://premium.caribe.net/~adrian2/fdupes.html
Group: Productivity/Archiving/Compression
Version: 1.50
Release: 0
Summary: Identifying or deleting duplicate files
Version: 1.40
Release: 111
Url: http://code.google.com/p/fdupes/
Group: Productivity/Archiving/Compression
License: MIT
Source0: %name-%{version}.tar.bz2
Source0: http://fdupes.googlecode.com/files/fdupes-1.50-PR2.tar.gz
Source1: macros.fdupes
Patch0: %name.diff
Patch1: fdupes-sort-output.diff
#PATCH-FIX-OPENSUSE - bnc#406825
Patch2: fdupes-speedup.patch
#PATCH-FIX-OPENSUSE - bnc#406825
Patch3: fdupes-endianness.patch
#PATCH-FIX-SUSE: fix patch according distro's needs
Patch0: fdupes-makefile.patch
# I'v imported all patches from Debian (Fedora and Gentoo has the subset only)
# to git and added there as individual patches
# TODO: export the git repo or upstream it
#PATCH-FIX-DEBIAN: obsoletes partly the speedup patch
Patch1: 0001-restore-pristine-code.patch
#PATCH-FIX-DEBIAN: minor typo in man page
Patch2: 0002-Added-to-escape-minus-signs-in-manpage-lintian-warni.patch
#PATCH-FIX-DEBIAN: dtto
Patch3: 0003-Fix-a-typo-in-a-manpage-bts353789.patch
#PATCH-FIX-DEBIAN: support for large files
Patch4: 0004-Large-file-support-for-2GB-files-bts447601.patch
#PATCH-FIX-DEBIAN: manpage fix
Patch5: 0005-add-summarize-to-manpage-bts481809.patch
#PATCH-FIX-DEBIAN: dtto
Patch6: 0006-add-nohidden-support-bts511702.patch
#PATCH-FIX-DEBIAN: manpage fix
Patch7: 0007-Disambiguate-the-options-recurse-and-recurse-bts5371.patch
#PATCH-FIX-OPENSUSE: speedup the compare
Patch8: 0008-speedup-the-file-compare.patch
#PATCH-FIX-OPENSUSE: endianness check in md5.h
Patch9: 0009-glibc-endianness-check-in-md5.patch
#PATCH-FIX-OPENSUSE: -p/--permissions mode
Patch10: 0010-add-permissions-mode.patch
BuildRoot: %{_tmppath}/%{name}-%{version}-build
%if 0%{?centos_version} || 0%{?rhel_version} || 0%{?fedora_version}
BuildRequires: which
@ -40,11 +60,19 @@ FDUPES is a program for identifying or deleting duplicate files
residing within specified directories
%prep
%setup -q
%setup -q -n %name-%{version}-PR2
%patch0
%patch1
%patch2 -p0 -b .speedup
%patch3 -p1 -b .endianness
%patch1 -p1
%patch2 -p1
%patch3 -p1
%patch4 -p1
%patch5 -p1
%patch6 -p1
%patch7 -p1
%patch8 -p1
%patch9 -p1
%patch10 -p1
%build
echo -e "#!/bin/bash\n`which %__cc` \"\$@\"" >gcc
@ -53,15 +81,15 @@ export PATH=`pwd`:$PATH
make %{?_smp_mflags}
%install
install -D -m755 fdupes $RPM_BUILD_ROOT/usr/bin/fdupes
install -D -m644 fdupes.1 $RPM_BUILD_ROOT/usr/share/man/man1/fdupes.1
install -D -m644 %{SOURCE1} $RPM_BUILD_ROOT/etc/rpm/macros.fdupes
install -D -m755 %{name} %{buildroot}%{_bindir}/%{name}
install -D -m644 %{name}.1 %{buildroot}%{_mandir}/man1/%{name}.1
install -D -m644 %{SOURCE1} %{buildroot}%{_sysconfdir}/rpm/macros.%{name}
%files
%defattr(-, root, root)
%doc CHANGES
%{_prefix}/bin/fdupes
%{_mandir}/*/*
/etc/rpm
%{_bindir}/%{name}
%{_mandir}/man1/%{name}.1*
%config %{_sysconfdir}/rpm/macros.%{name}
%changelog

View File

@ -3,7 +3,7 @@
_target=""; \
_symlinks=0; \
%{-s:_symlinks=1;} \
fdupes -q -n -r %1 | \
fdupes -q -p -n -r %1 | \
while read _file; do \
if test -z "$_target" ; then \
_target="$_file"; \