update to 1.51 [release 1.51-1mamba;Mon May 13 2013]

This commit is contained in:
Automatic Build System 2024-01-05 22:14:28 +01:00
parent eeab9d76c0
commit 2a4cd36f2f
7 changed files with 262 additions and 0 deletions

View File

@ -1,2 +1,4 @@
# fdupes
FDUPES is a program for identifying or deleting duplicate files residing within specified directories.

20
fdupes-endianness.patch Normal file
View File

@ -0,0 +1,20 @@
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.

64
fdupes-sort-output.diff Normal file
View File

@ -0,0 +1,64 @@
--- 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;
}

44
fdupes-speedup.patch Normal file
View File

@ -0,0 +1,44 @@
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;
}

45
fdupes.diff Normal file
View File

@ -0,0 +1,45 @@
--- 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] = {

65
fdupes.spec Normal file
View File

@ -0,0 +1,65 @@
Name: fdupes
Version: 1.51
Release: 1mamba
Summary: A program for identifying or deleting duplicate files residing within specified directories.identifying or deleting duplicate files
Group: Applications/File
Vendor: openmamba
Distribution: openmamba
Packager: Silvan Calarco <silvan.calarco@mambasoft.it>
URL: https://code.google.com/p/fdupes/
Source0: https://fdupes.googlecode.com/files/fdupes-%{version}.tar.gz
# from opensuse
Source1: macros.fdupes
Patch0: fdupes.diff
Patch1: fdupes-sort-output.diff
Patch2: fdupes-speedup.patch
Patch3: fdupes-endianness.patch
License: MIT
BuildRoot: %{_tmppath}/%{name}-%{version}-root
%description
FDUPES is a program for identifying or deleting duplicate files residing within specified directories.
%prep
%setup -q
#%patch0
#%patch1
#%patch2 -p0 -b .speedup
%patch3 -p1 -b .endianness
%build
%make
%check
./fdupes testdir
./fdupes --omitfirst testdir
./fdupes --recurse testdir
./fdupes --size testdir
%install
[ "%{buildroot}" != / ] && rm -rf "%{buildroot}"
mkdir -p %{buildroot}%{_sysconfdir}/rpm
mkdir -p %{buildroot}%{_bindir}
mkdir -p %{buildroot}%{_mandir}/man1
install -pm 644 %{SOURCE1} %{buildroot}%{_sysconfdir}/rpm/macros.fdupes
install -pm 755 fdupes %{buildroot}%{_bindir}/fdupes
install -pm 644 fdupes.1 %{buildroot}%{_mandir}/man1/
%clean
[ "%{buildroot}" != / ] && rm -rf "%{buildroot}"
%files
%defattr(-,root,root)
%{_sysconfdir}/rpm/macros.fdupes
%{_bindir}/fdupes
%{_mandir}/man1/fdupes.1.gz
%doc CHANGES README TODO
%changelog
* Mon May 13 2013 Automatic Build System <autodist@mambasoft.it> 1.51-1mamba
- update to 1.51
* Wed Jun 02 2010 gil <puntogil@libero.it> 1.40-1mamba
- package created by autospec

22
macros.fdupes Normal file
View File

@ -0,0 +1,22 @@
%fdupes(s) \
_target=""; \
_symlinks=0; \
%{-s:_symlinks=1;} \
fdupes -q -n -r %1 | \
while read _file; do \
if test -z "$_target" ; then \
_target="$_file"; \
else \
if test -z "$_file" ; then \
_target=""; \
continue ; \
fi ; \
if test "$_symlinks" = 1; then \
ln -sf "${_target#%{buildroot}}" "$_file"; \
else \
ln -f "$_target" "$_file"; \
fi ;\
fi ; \
done \
%{nil}