[findimagedupes] 07/08: Use quilt patches
Andreas Tille
tille at debian.org
Sat Jul 12 22:54:12 UTC 2014
This is an automated email from the git hooks/post-receive script.
tille pushed a commit to branch master
in repository findimagedupes.
commit 08f56043f77e3c05be9b9c7532deaf7217bf29cc
Author: Andreas Tille <tille at debian.org>
Date: Sun Jul 13 00:44:07 2014 +0200
Use quilt patches
---
debian/changelog | 2 +-
debian/patches/Makefile.PL.patch | 10 ++
debian/patches/debian_patches.patch | 251 ++++++++++++++++++++++++++++++++++++
debian/patches/series | 2 +
4 files changed, 264 insertions(+), 1 deletion(-)
diff --git a/debian/changelog b/debian/changelog
index 1892cfe..b5b28c6 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -1,6 +1,6 @@
findimagedupes (2.18-5) UNRELEASED; urgency=medium
- * debian/sources/format: 3.0 (quilt)
+ * debian/sources/format: 3.0 (quilt), consequently use patches
* debhelper 9
* cme fix dpkg-control
* Explicitly (build-) depend on libinline-c-perl (thanks for the patch
diff --git a/debian/patches/Makefile.PL.patch b/debian/patches/Makefile.PL.patch
new file mode 100644
index 0000000..9421a0e
--- /dev/null
+++ b/debian/patches/Makefile.PL.patch
@@ -0,0 +1,10 @@
+--- /dev/null
++++ b/Makefile.PL
+@@ -0,0 +1,7 @@
++use Inline::MakeMaker;
++WriteInlineMakefile(
++ 'NAME' => 'findimagedupes::C',
++ 'VERSION_FROM' => 'C.pm',
++ 'EXE_FILES' => [ 'findimagedupes' ],
++);
++
diff --git a/debian/patches/debian_patches.patch b/debian/patches/debian_patches.patch
new file mode 100644
index 0000000..ddf5294
--- /dev/null
+++ b/debian/patches/debian_patches.patch
@@ -0,0 +1,251 @@
+--- /dev/null
++++ b/C.pm
+@@ -0,0 +1,117 @@
++package findimagedupes::C;
++
++use Inline
++ C => 'DATA',
++ NAME => 'findimagedupes::C',
++ VERSION => '0.01',
++;
++
++our $VERSION = '0.01';
++1;
++
++__DATA__
++
++__C__
++
++/* efficient bit-comparison */
++
++#include <stdint.h>
++#include <string.h>
++
++#define LOOKUP_SIZE 65536
++#define FP_CHUNKS 16
++
++typedef uint16_t FP[FP_CHUNKS];
++
++unsigned int simplecountbits (unsigned int i) {
++ unsigned int val = i, res = 0;
++
++ while (val) {
++ res += (val&1);
++ val >>= 1;
++ }
++ return(res);
++}
++
++void diffbits (SV* oldfiles, SV* newfiles, unsigned int threshold, unsigned limit) {
++ FP *the_data, *a, *b;
++ unsigned int lookup[LOOKUP_SIZE];
++ unsigned int i, j, k, m, bits, old, new;
++ HV *oldhash;
++ HE *oldhash_entry;
++ HV *newhash;
++ HE *newhash_entry;
++ unsigned int numkeys = 0;
++ SV *sv_val;
++ Inline_Stack_Vars;
++
++ if ((threshold<0) || (threshold>256)) {
++ croak("ridiculous threshold specified");
++ }
++
++ /* pack fingerprints into C array */
++ /* partly lifted from Inline::C-Cookbook */
++
++ if (! SvROK(newfiles)) {
++ croak("newfiles is not a reference");
++ }
++ newhash = (HV *)SvRV(newfiles);
++ new = hv_iterinit(newhash);
++
++ if (! SvROK(oldfiles)) {
++ croak("oldfiles is not a reference");
++ }
++ oldhash = (HV *)SvRV(oldfiles);
++ old = hv_iterinit(oldhash);
++
++ numkeys = new+old;
++ if (numkeys<2) {
++ /* minor optimization: return without doing anything */
++ /* malloc(0) could be bad... */
++ Inline_Stack_Void;
++ }
++ the_data = (FP *)malloc(numkeys*sizeof(FP));
++ if (!the_data) {
++ croak("malloc failed");
++ }
++
++ for (i = 0; i<new; i++) {
++ newhash_entry = hv_iternext(newhash);
++ sv_val = hv_iterval(newhash, newhash_entry);
++ memcpy(the_data+i, SvPV(sv_val, PL_na), sizeof(FP));
++ }
++ for (i = new; i<numkeys; i++) {
++ oldhash_entry = hv_iternext(oldhash);
++ sv_val = hv_iterval(oldhash, oldhash_entry);
++ memcpy(the_data+i, SvPV(sv_val, PL_na), sizeof(FP));
++ }
++
++ /* initialise lookup table */
++ /* XXX: fast enough? could optimise more or compile-in a static table */
++ for (i=0; i<LOOKUP_SIZE; i++) {
++ lookup[i] = simplecountbits(i);
++ }
++
++ /* look for matches */
++ Inline_Stack_Reset;
++ for (a=the_data, i=0, m=(limit>0 ? new : numkeys-1); i<m; a++, i++) {
++ for (b=a+1, j=i+1; j<numkeys; b++, j++) {
++ for (bits=0, k=0; k<FP_CHUNKS; k++) {
++ bits += lookup[(*a)[k]^(*b)[k]];
++ if (bits > threshold) goto abortmatch;
++ }
++ /* if (bits <= threshold) */ {
++ Inline_Stack_Push(sv_2mortal(newSViv(i)));
++ Inline_Stack_Push(sv_2mortal(newSViv(j)));
++ Inline_Stack_Push(sv_2mortal(newSViv(bits)));
++ }
++abortmatch:;
++ }
++ }
++ Inline_Stack_Done;
++
++ /* clean up */
++ free(the_data);
++}
++
++
+--- a/findimagedupes
++++ b/findimagedupes
+@@ -34,10 +34,8 @@ use Graphics::Magick;
+ use MIME::Base64;
+ use Pod::Usage;
+
+-use Inline
+- C => 'DATA',
+- NAME => 'findimagedupes',
+- DIRECTORY => '/usr/local/lib/findimagedupes';
++use lib "/usr/lib/findimagedupes/lib";
++use findimagedupes::C;
+
+ # ----------------------------------------------------------------------
+ #
+@@ -511,7 +509,7 @@ sub fingerprint {
+ }
+
+ sub finddupes {
+- my @matches = diffbits(\%fpcache, \%filelist, $threshold, $add);
++ my @matches = findimagedupes::C::diffbits(\%fpcache, \%filelist, $threshold, $add);
+
+ my (%set, %ptr, %val);
+
+@@ -990,106 +988,4 @@ algorithm.
+
+ =cut
+
+-__C__
+-
+-/* efficient bit-comparison */
+-
+-#include <stdint.h>
+-#include <string.h>
+-
+-#define LOOKUP_SIZE 65536
+-#define FP_CHUNKS 16
+-
+-typedef uint16_t FP[FP_CHUNKS];
+-
+-unsigned int simplecountbits (unsigned int i) {
+- unsigned int val = i, res = 0;
+-
+- while (val) {
+- res += (val&1);
+- val >>= 1;
+- }
+- return(res);
+-}
+-
+-void diffbits (SV* oldfiles, SV* newfiles, unsigned int threshold, unsigned limit) {
+- FP *the_data, *a, *b;
+- unsigned int lookup[LOOKUP_SIZE];
+- unsigned int i, j, k, m, bits, old, new;
+- HV *oldhash;
+- HE *oldhash_entry;
+- HV *newhash;
+- HE *newhash_entry;
+- unsigned int numkeys = 0;
+- SV *sv_val;
+- Inline_Stack_Vars;
+-
+- if ((threshold<0) || (threshold>256)) {
+- croak("ridiculous threshold specified");
+- }
+-
+- /* pack fingerprints into C array */
+- /* partly lifted from Inline::C-Cookbook */
+-
+- if (! SvROK(newfiles)) {
+- croak("newfiles is not a reference");
+- }
+- newhash = (HV *)SvRV(newfiles);
+- new = hv_iterinit(newhash);
+-
+- if (! SvROK(oldfiles)) {
+- croak("oldfiles is not a reference");
+- }
+- oldhash = (HV *)SvRV(oldfiles);
+- old = hv_iterinit(oldhash);
+-
+- numkeys = new+old;
+- if (numkeys<2) {
+- /* minor optimization: return without doing anything */
+- /* malloc(0) could be bad... */
+- Inline_Stack_Void;
+- }
+- the_data = (FP *)malloc(numkeys*sizeof(FP));
+- if (!the_data) {
+- croak("malloc failed");
+- }
+-
+- for (i = 0; i<new; i++) {
+- newhash_entry = hv_iternext(newhash);
+- sv_val = hv_iterval(newhash, newhash_entry);
+- memcpy(the_data+i, SvPV(sv_val, PL_na), sizeof(FP));
+- }
+- for (i = new; i<numkeys; i++) {
+- oldhash_entry = hv_iternext(oldhash);
+- sv_val = hv_iterval(oldhash, oldhash_entry);
+- memcpy(the_data+i, SvPV(sv_val, PL_na), sizeof(FP));
+- }
+-
+- /* initialise lookup table */
+- /* XXX: fast enough? could optimise more or compile-in a static table */
+- for (i=0; i<LOOKUP_SIZE; i++) {
+- lookup[i] = simplecountbits(i);
+- }
+-
+- /* look for matches */
+- Inline_Stack_Reset;
+- for (a=the_data, i=0, m=(limit>0 ? new : numkeys-1); i<m; a++, i++) {
+- for (b=a+1, j=i+1; j<numkeys; b++, j++) {
+- for (bits=0, k=0; k<FP_CHUNKS; k++) {
+- bits += lookup[(*a)[k]^(*b)[k]];
+- if (bits > threshold) goto abortmatch;
+- }
+- /* if (bits <= threshold) */ {
+- Inline_Stack_Push(sv_2mortal(newSViv(i)));
+- Inline_Stack_Push(sv_2mortal(newSViv(j)));
+- Inline_Stack_Push(sv_2mortal(newSViv(bits)));
+- }
+-abortmatch:;
+- }
+- }
+- Inline_Stack_Done;
+-
+- /* clean up */
+- free(the_data);
+-}
+
diff --git a/debian/patches/series b/debian/patches/series
new file mode 100644
index 0000000..59917ef
--- /dev/null
+++ b/debian/patches/series
@@ -0,0 +1,2 @@
+Makefile.PL.patch
+debian_patches.patch
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/debian-science/packages/findimagedupes.git
More information about the debian-science-commits
mailing list