Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 29 Apr 2016 04:55:00 +0000 (UTC)
From:      Kurt Jaeger <pi@FreeBSD.org>
To:        ports-committers@freebsd.org, svn-ports-all@freebsd.org, svn-ports-head@freebsd.org
Subject:   svn commit: r414255 - in head/misc/bdelta: . files
Message-ID:  <201604290455.u3T4t0uW025157@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: pi
Date: Fri Apr 29 04:55:00 2016
New Revision: 414255
URL: https://svnweb.freebsd.org/changeset/ports/414255

Log:
  misc/bdelta: 0.1.0 -> 0.3.1 with patches
  
  - changed to github
  - many changes since first release
  - added FEFE patch, see https://ptrace.fefe.de/bdelta.diff
  - added LICENSE
  
  PR:		209063
  Approved by:	novel (maintainer)

Added:
  head/misc/bdelta/files/
  head/misc/bdelta/files/patch-bdelta.cpp   (contents, props changed)
  head/misc/bdelta/files/patch-bpatch.cpp   (contents, props changed)
  head/misc/bdelta/files/patch-file.h   (contents, props changed)
  head/misc/bdelta/files/patch-libbdelta.cpp   (contents, props changed)
Modified:
  head/misc/bdelta/Makefile
  head/misc/bdelta/distinfo

Modified: head/misc/bdelta/Makefile
==============================================================================
--- head/misc/bdelta/Makefile	Fri Apr 29 04:22:42 2016	(r414254)
+++ head/misc/bdelta/Makefile	Fri Apr 29 04:55:00 2016	(r414255)
@@ -2,15 +2,22 @@
 # $FreeBSD$
 
 PORTNAME=	bdelta
-PORTVERSION=	0.1.0
+PORTVERSION=	0.3.1
+DISTVERSIONPREFIX=v
 CATEGORIES=	misc devel
-MASTER_SITES=	SF/deltup/${PORTNAME}/${PORTVERSION}
 
 MAINTAINER=	novel@FreeBSD.org
 COMMENT=	Advanced delta creator, patcher, and library
 
+LICENSE=	MPL
+
+WRKSRC=		${WRKDIR}/BDelta-${PORTVERSION}/src
+
 USES=		gmake
 USE_LDCONFIG=	yes
+USE_GITHUB=	yes
+GH_ACCOUNT=	jjwhitney
+GH_PROJECT=	BDelta
 
 PLIST_FILES=	bin/bdelta bin/bpatch lib/libbdelta.so
 

Modified: head/misc/bdelta/distinfo
==============================================================================
--- head/misc/bdelta/distinfo	Fri Apr 29 04:22:42 2016	(r414254)
+++ head/misc/bdelta/distinfo	Fri Apr 29 04:55:00 2016	(r414255)
@@ -1,2 +1,2 @@
-SHA256 (bdelta-0.1.0.tar.gz) = 7222011d8e3d2955f1ed094a0cc3edde6c681dd82bad5edb829ed68df32cd78d
-SIZE (bdelta-0.1.0.tar.gz) = 7418
+SHA256 (jjwhitney-BDelta-v0.3.1_GH0.tar.gz) = 0ae5d6ede96d60efca2d142db7ed59af48d3044de5d329cfeaa48727171cd1bc
+SIZE (jjwhitney-BDelta-v0.3.1_GH0.tar.gz) = 14464

Added: head/misc/bdelta/files/patch-bdelta.cpp
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ head/misc/bdelta/files/patch-bdelta.cpp	Fri Apr 29 04:55:00 2016	(r414255)
@@ -0,0 +1,59 @@
+--- bdelta.cpp.orig	2013-01-30 20:16:01 UTC
++++ bdelta.cpp
+@@ -10,6 +10,8 @@
+ #include "file.h"
+ #include "compatibility.h"
+ 
++#define FEFE
++
+ const void *f_read(void *f, void *buf, unsigned place, unsigned num) {
+ 	fseek((FILE *)f, place, SEEK_SET);
+ 	fread_fixed((FILE *)f, buf, num);
+@@ -103,9 +105,15 @@ int main(int argc, char **argv) {
+ 
+ 		nummatches = bdelta_numMatches(b);
+ 
++#ifdef FEFE
++		long long * copyloc1 = new long long[nummatches + 1];
++		long long * copyloc2 = new long long[nummatches + 1];
++		unsigned *  copynum = new unsigned[nummatches + 1];
++#else
+ 		unsigned * copyloc1 = new unsigned[nummatches + 1];
+ 		unsigned * copyloc2 = new unsigned[nummatches + 1];
+ 		unsigned *  copynum = new unsigned[nummatches + 1];
++#endif
+ 
+ 		FILE *fout = fopen(argv[3], "wb");
+ 		if (!fout) {
+@@ -115,7 +123,7 @@ int main(int argc, char **argv) {
+ 
+ 		const char *magic = "BDT";
+ 		fwrite_fixed(fout, magic, 3);
+-		unsigned short version = 1;
++		unsigned short version = 2;
+ 		write_word(fout, version);
+ 		unsigned char intsize = 4;
+ 		fwrite_fixed(fout, &intsize, 1);
+@@ -129,12 +137,22 @@ int main(int argc, char **argv) {
+ 			unsigned p1, p2, num;
+ 			bdelta_getMatch(b, i, &p1, &p2, &num);
+ 			// printf("%*x, %*x, %*x, %*x\n", 10, p1, 10, p2, 10, num, 10, p2-lastp2);
++#ifdef FEFE
++			copyloc1[i] = (long long)p1 - lastp1;
++			copyloc2[i] = (long long)p2 - lastp2;
++			copynum[i] = num;
++			write_varint(fout, copyloc1[i]);
++			write_varint(fout, copyloc2[i]);
++			write_varint(fout, copynum[i]);
++//			printf("%u/%u: (%ld -> %u,%ld -> %u,%u)\n",i,nummatches,copyloc1[i],p1,copyloc2[i],p2,copynum[i]);
++#else
+ 			copyloc1[i] = p1 - lastp1;
+ 			write_dword(fout, copyloc1[i]);
+ 			copyloc2[i] = p2 - lastp2;
+ 			write_dword(fout, copyloc2[i]);
+ 			copynum[i] = num;
+ 			write_dword(fout, copynum[i]);
++#endif
+ 			lastp1 = p1 + num;
+ 			lastp2 = p2 + num;
+ 		}

Added: head/misc/bdelta/files/patch-bpatch.cpp
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ head/misc/bdelta/files/patch-bpatch.cpp	Fri Apr 29 04:55:00 2016	(r414255)
@@ -0,0 +1,87 @@
+--- bpatch.cpp.orig	2013-01-30 20:16:01 UTC
++++ bpatch.cpp
+@@ -7,6 +7,8 @@
+ #include "file.h"
+ #include "compatibility.h"
+ 
++#define FEFE
++
+ bool copy_bytes_to_file(FILE *infile, FILE *outfile, unsigned numleft) {
+ 	size_t numread;
+ 	do {
+@@ -42,10 +44,17 @@ int main(int argc, char **argv) {
+ 			return 1;
+ 		}
+ 		unsigned short version = read_word(patchfile);
++#ifdef FEFE
++		if (version != 1 && version != 2) {
++			printf("unsupported patch version\n");
++			return 1;
++		}
++#else
+ 		if (version != 1) {
+ 			printf("unsupported patch version\n");
+ 			return 1;
+ 		}
++#endif
+ 		char intsize;
+ 		fread_fixed(patchfile, &intsize, 1);
+ 		if (intsize != 4) {
+@@ -57,14 +66,32 @@ int main(int argc, char **argv) {
+ 
+ 		unsigned nummatches = read_dword(patchfile);
+ 
++#ifdef FEFE
++		long long * copyloc1 = new long long[nummatches + 1];
++		long long * copyloc2 = new long long[nummatches + 1];
++		unsigned *  copynum = new unsigned[nummatches + 1];
++#else
+ 		unsigned * copyloc1 = new unsigned[nummatches + 1];
+ 		unsigned * copyloc2 = new unsigned[nummatches + 1];
+ 		unsigned *  copynum = new unsigned[nummatches + 1];
++#endif
+ 
+ 		for (unsigned i = 0; i < nummatches; ++i) {
++#ifdef FEFE
++		  if (version==2) {
++			copyloc1[i] = read_varint(patchfile);
++			copyloc2[i] = read_varint(patchfile);
++			copynum[i] = read_varint(patchfile);
++		  } else {
+ 			copyloc1[i] = read_dword(patchfile);
+ 			copyloc2[i] = read_dword(patchfile);
+ 			copynum[i] = read_dword(patchfile);
++		  }
++#else
++			copyloc1[i] = read_dword(patchfile);
++			copyloc2[i] = read_dword(patchfile);
++			copynum[i] = read_dword(patchfile);
++#endif
+ 			size2 -= copyloc2[i] + copynum[i];
+ 		}
+ 		if (size2) {
+@@ -77,16 +104,22 @@ int main(int argc, char **argv) {
+ 		FILE *outfile = fopen(argv[2], "wb");
+ 
+ 		for (unsigned i = 0; i < nummatches; ++i) {
++//			printf("%u/%u: copy %u bytes from patch file ofs %ld (dest ofs %u)\n",i,nummatches,copyloc2[i],ftell(patchfile),ftell(outfile));
+ 			if (!copy_bytes_to_file(patchfile, outfile, copyloc2[i])) {
+ 				printf("Error.  patchfile is truncated\n");
+ 				return -1;
+ 			}
+ 
+-			int copyloc = copyloc1[i];
++			long long copyloc = copyloc1[i];
+ 			fseek(ref, copyloc, SEEK_CUR);
+ 
++			long curofs=ftell(ref);
++
++#ifdef FEFE
++//			printf("%u/%u: (%d -> %u,%d -> %u,%u)\n",i,nummatches-1,copyloc,ftell(ref),copyloc2[i],ftell(outfile),copynum[i]);
++#endif
+ 			if (!copy_bytes_to_file(ref, outfile, copynum[i])) {
+-				printf("Error while copying from reference file\n");
++				printf("Error while copying from reference file (ofs %ld, %u bytes)\n", curofs, copynum[i]);
+ 				return -1;
+ 			}
+ 		}

Added: head/misc/bdelta/files/patch-file.h
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ head/misc/bdelta/files/patch-file.h	Fri Apr 29 04:55:00 2016	(r414255)
@@ -0,0 +1,87 @@
+--- file.h.orig	2013-01-30 20:16:01 UTC
++++ file.h
+@@ -3,6 +3,7 @@
+  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+ 
+ #include <stdio.h>
++#include <cstdlib>
+ 
+ #define MAX_IO_BLOCK_SIZE (1024 * 1024)
+ 
+@@ -58,6 +59,44 @@ unsigned read_dword(FILE *f) {
+ 	return (read_word(f) << 16) + low;
+ }
+ 
++static size_t scan_varint(const char* in,size_t len, unsigned long long* n) {
++  size_t i;
++  unsigned long long l;
++  if (len==0) return 0;
++  for (l=0, i=0; i<len; ++i) {
++    l+=(unsigned long long)(in[i]&0x7f) << (i*7);
++    if (!(in[i]&0x80)) {
++      *n=l;
++      return i+1;
++    }
++  }
++  return 0;
++}
++
++size_t scan_pb_type0_sint(const char* in,size_t len,signed long long* l) {
++  unsigned long long m;
++  size_t n=scan_varint(in,len,&m);
++  if (!n) return 0;
++  *l=(-(m&1)) ^ (m>>1);
++  return n;
++}
++
++long long read_varint(FILE* f) {
++  char buf[20];
++  size_t i;
++  long long l;
++  for (i=0; i<sizeof(buf); ++i) {
++    fread_fixed(f,buf+i,1);
++    if (!(buf[i]&0x80)) {
++      if (scan_pb_type0_sint(buf,i+1,&l)!=i+1) break;
++      return l;
++    }
++  }
++  static char read_error_message[128];
++  strcpy(read_error_message, "parse error: read_varint() failed");
++  throw read_error_message;
++}
++
+ void write_word(FILE *f, unsigned number) {
+ 	unsigned char b = number & 255,
+ 	              b2 = number >> 8;
+@@ -70,6 +109,31 @@ void write_dword(FILE *f, unsigned numbe
+ 	write_word(f, number >> 16);
+ }
+ 
++
++/* write int in least amount of bytes, return number of bytes */
++/* as used in varints from Google protocol buffers */
++static size_t fmt_varint(char* dest,unsigned long long l) {
++  /* high bit says if more bytes are coming, lower 7 bits are payload; little endian */
++  size_t i;
++  for (i=0; l; ++i, l>>=7) {
++    if (dest) dest[i]=(l&0x7f) | ((!!(l&~0x7f))<<7);
++  }
++  if (!i) {	/* l was 0 */
++    if (dest) dest[0]=0;
++    ++i;
++  }
++  return i;
++}
++
++static size_t fmt_pb_type0_sint(char* dest,signed long long l) {
++  return fmt_varint(dest,(l << 1) ^ (l >> (sizeof(l)*8-1)));
++}
++
++void write_varint(FILE* f, long long number) {
++  char tmp[20];
++  fwrite_fixed(f,tmp,fmt_pb_type0_sint(tmp,number));
++}
++
+ bool fileExists(char *fname) {
+ 	FILE *f = fopen(fname, "rb");
+ 	bool exists = (f != NULL);

Added: head/misc/bdelta/files/patch-libbdelta.cpp
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ head/misc/bdelta/files/patch-libbdelta.cpp	Fri Apr 29 04:55:00 2016	(r414255)
@@ -0,0 +1,20 @@
+--- libbdelta.cpp.orig	2016-04-26 04:19:52 UTC
++++ libbdelta.cpp
+@@ -118,7 +118,7 @@ unsigned match_backward(BDelta_Instance 
+ template <class T>
+ inline T prior(T i) {return --i;}
+ template <class T>
+-inline T next(T i) {return ++i;}
++inline T bnext(T i) {return ++i;}
+ 
+ 
+ struct UnusedRange {
+@@ -421,7 +421,7 @@ void bdelta_pass(BDelta_Instance *b, uns
+ 			UnusedRange u1 = unused[i], u2 = unused2[i];
+ 			if (u1.num >= blocksize && u2.num >= blocksize)
+ 				if (! maxHoleSize || (u1.num <= maxHoleSize && u2.num <= maxHoleSize))
+-					if (! (flags & BDELTA_SIDES_ORDERED) || (next(u1.ml) == u1.mr && next(u2.ml) == u2.mr))
++					if (! (flags & BDELTA_SIDES_ORDERED) || (bnext(u1.ml) == u1.mr && bnext(u2.ml) == u2.mr))
+ 						bdelta_pass_2(b, blocksize, minMatchSize, &u1, 1, &u2, 1);
+ 		}
+ 	}



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201604290455.u3T4t0uW025157>