mirror of the now-defunct rocklinux.org
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

309 lines
11 KiB

  1. # --- ROCK-COPYRIGHT-NOTE-BEGIN ---
  2. #
  3. # This copyright note is auto-generated by ./scripts/Create-CopyPatch.
  4. # Please add additional copyright information _after_ the line containing
  5. # the ROCK-COPYRIGHT-NOTE-END tag. Otherwise it might get removed by
  6. # the ./scripts/Create-CopyPatch script. Do not edit this copyright text!
  7. #
  8. # ROCK Linux: rock-src/package/base/gzip/rsyncable.patch
  9. # ROCK Linux is Copyright (C) 1998 - 2004 Clifford Wolf
  10. #
  11. # This patch file is dual-licensed. It is available under the license the
  12. # patched project is licensed under, as long as it is an OpenSource license
  13. # as defined at http://www.opensource.org/ (e.g. BSD, X11) or under the terms
  14. # of the GNU General Public License as published by the Free Software
  15. # Foundation; either version 2 of the License, or (at your option) any later
  16. # version.
  17. #
  18. # --- ROCK-COPYRIGHT-NOTE-END ---
  19. < http://rsync.samba.org/ftp/unpacked/rsync/patches/gzip-rsyncable.diff >
  20. From: Rusty Russell <rusty@rustcorp.com.au>
  21. [NOTE: this patch is for _gzip_! --Wayne]
  22. It's pending for actual gzip inclusion! The maintainer was dug up and
  23. everything: it'll even be on by default.
  24. But here's the old patch,
  25. Rusty.
  26. --
  27. Anyone who quotes me in their sig is an idiot. -- Rusty Russell.
  28. --- gzip-1.2.4.orig/deflate.c Fri Aug 13 22:35:31 1993
  29. +++ gzip-1.2.4-rsync/deflate.c Sat Dec 30 15:33:25 2000
  30. @@ -121,6 +121,14 @@
  31. #endif
  32. /* Matches of length 3 are discarded if their distance exceeds TOO_FAR */
  33. +#ifndef RSYNC_WIN
  34. +# define RSYNC_WIN 4096
  35. +#endif
  36. +/* Size of rsync window, must be < MAX_DIST */
  37. +
  38. +#define RSYNC_SUM_MATCH(sum) ((sum) % RSYNC_WIN == 0)
  39. +/* Whether window sum matches magic value */
  40. +
  41. /* ===========================================================================
  42. * Local data used by the "longest match" routines.
  43. */
  44. @@ -202,6 +210,8 @@
  45. unsigned near good_match;
  46. /* Use a faster search when the previous match is longer than this */
  47. +local ulg rsync_sum; /* rolling sum of rsync window */
  48. +local ulg rsync_chunk_end; /* next rsync sequence point */
  49. /* Values for max_lazy_match, good_match and max_chain_length, depending on
  50. * the desired pack level (0..9). The values given below have been tuned to
  51. @@ -300,6 +310,10 @@
  52. #endif
  53. /* prev will be initialized on the fly */
  54. + /* rsync params */
  55. + rsync_chunk_end = 0xFFFFFFFFUL;
  56. + rsync_sum = 0;
  57. +
  58. /* Set the default configuration parameters:
  59. */
  60. max_lazy_match = configuration_table[pack_level].max_lazy;
  61. @@ -536,6 +550,8 @@
  62. memcpy((char*)window, (char*)window+WSIZE, (unsigned)WSIZE);
  63. match_start -= WSIZE;
  64. strstart -= WSIZE; /* we now have strstart >= MAX_DIST: */
  65. + if (rsync_chunk_end != 0xFFFFFFFFUL)
  66. + rsync_chunk_end -= WSIZE;
  67. block_start -= (long) WSIZE;
  68. @@ -563,13 +579,46 @@
  69. }
  70. }
  71. +local void rsync_roll(start, num)
  72. + unsigned start;
  73. + unsigned num;
  74. +{
  75. + unsigned i;
  76. +
  77. + if (start < RSYNC_WIN) {
  78. + /* before window fills. */
  79. + for (i = start; i < RSYNC_WIN; i++) {
  80. + if (i == start + num) return;
  81. + rsync_sum += (ulg)window[i];
  82. + }
  83. + num -= (RSYNC_WIN - start);
  84. + start = RSYNC_WIN;
  85. + }
  86. +
  87. + /* buffer after window full */
  88. + for (i = start; i < start+num; i++) {
  89. + /* New character in */
  90. + rsync_sum += (ulg)window[i];
  91. + /* Old character out */
  92. + rsync_sum -= (ulg)window[i - RSYNC_WIN];
  93. + if (rsync_chunk_end == 0xFFFFFFFFUL && RSYNC_SUM_MATCH(rsync_sum))
  94. + rsync_chunk_end = i;
  95. + }
  96. +}
  97. +
  98. +/* ===========================================================================
  99. + * Set rsync_chunk_end if window sum matches magic value.
  100. + */
  101. +#define RSYNC_ROLL(s, n) \
  102. + do { if (rsync) rsync_roll((s), (n)); } while(0)
  103. +
  104. /* ===========================================================================
  105. * Flush the current block, with given end-of-file flag.
  106. * IN assertion: strstart is set to the end of the current match.
  107. */
  108. #define FLUSH_BLOCK(eof) \
  109. flush_block(block_start >= 0L ? (char*)&window[(unsigned)block_start] : \
  110. - (char*)NULL, (long)strstart - block_start, (eof))
  111. + (char*)NULL, (long)strstart - block_start, flush-1, (eof))
  112. /* ===========================================================================
  113. * Processes a new input file and return its compressed length. This
  114. @@ -580,7 +629,7 @@
  115. local ulg deflate_fast()
  116. {
  117. IPos hash_head; /* head of the hash chain */
  118. - int flush; /* set if current block must be flushed */
  119. + int flush; /* set if current block must be flushed, 2=>and padded */
  120. unsigned match_length = 0; /* length of best match */
  121. prev_length = MIN_MATCH-1;
  122. @@ -609,6 +658,7 @@
  123. lookahead -= match_length;
  124. + RSYNC_ROLL(strstart, match_length);
  125. /* Insert new strings in the hash table only if the match length
  126. * is not too large. This saves time but degrades compression.
  127. */
  128. @@ -637,9 +687,14 @@
  129. /* No match, output a literal byte */
  130. Tracevv((stderr,"%c",window[strstart]));
  131. flush = ct_tally (0, window[strstart]);
  132. + RSYNC_ROLL(strstart, 1);
  133. lookahead--;
  134. strstart++;
  135. }
  136. + if (rsync && strstart > rsync_chunk_end) {
  137. + rsync_chunk_end = 0xFFFFFFFFUL;
  138. + flush = 2;
  139. + }
  140. if (flush) FLUSH_BLOCK(0), block_start = strstart;
  141. /* Make sure that we always have enough lookahead, except
  142. @@ -715,6 +770,7 @@
  143. */
  144. lookahead -= prev_length-1;
  145. prev_length -= 2;
  146. + RSYNC_ROLL(strstart, prev_length+1);
  147. do {
  148. strstart++;
  149. INSERT_STRING(strstart, hash_head);
  150. @@ -727,24 +783,39 @@
  151. match_available = 0;
  152. match_length = MIN_MATCH-1;
  153. strstart++;
  154. - if (flush) FLUSH_BLOCK(0), block_start = strstart;
  155. + if (rsync && strstart > rsync_chunk_end) {
  156. + rsync_chunk_end = 0xFFFFFFFFUL;
  157. + flush = 2;
  158. + }
  159. + if (flush) FLUSH_BLOCK(0), block_start = strstart;
  160. } else if (match_available) {
  161. /* If there was no match at the previous position, output a
  162. * single literal. If there was a match but the current match
  163. * is longer, truncate the previous match to a single literal.
  164. */
  165. Tracevv((stderr,"%c",window[strstart-1]));
  166. - if (ct_tally (0, window[strstart-1])) {
  167. - FLUSH_BLOCK(0), block_start = strstart;
  168. - }
  169. + flush = ct_tally (0, window[strstart-1]);
  170. + if (rsync && strstart > rsync_chunk_end) {
  171. + rsync_chunk_end = 0xFFFFFFFFUL;
  172. + flush = 2;
  173. + }
  174. + if (flush) FLUSH_BLOCK(0), block_start = strstart;
  175. + RSYNC_ROLL(strstart, 1);
  176. strstart++;
  177. lookahead--;
  178. } else {
  179. /* There is no previous match to compare with, wait for
  180. * the next step to decide.
  181. */
  182. + if (rsync && strstart > rsync_chunk_end) {
  183. + /* Reset huffman tree */
  184. + rsync_chunk_end = 0xFFFFFFFFUL;
  185. + flush = 2;
  186. + FLUSH_BLOCK(0), block_start = strstart;
  187. + }
  188. match_available = 1;
  189. + RSYNC_ROLL(strstart, 1);
  190. strstart++;
  191. lookahead--;
  192. }
  193. --- gzip-1.2.4.orig/gzip.c Thu Aug 19 23:39:43 1993
  194. +++ gzip-1.2.4-rsync/gzip.c Fri Dec 29 21:20:54 2000
  195. @@ -239,6 +239,7 @@
  196. unsigned insize; /* valid bytes in inbuf */
  197. unsigned inptr; /* index of next byte to be processed in inbuf */
  198. unsigned outcnt; /* bytes in output buffer */
  199. +int rsync = 0; /* make ryncable chunks */
  200. struct option longopts[] =
  201. {
  202. @@ -268,6 +269,7 @@
  203. {"best", 0, 0, '9'}, /* compress better */
  204. {"lzw", 0, 0, 'Z'}, /* make output compatible with old compress */
  205. {"bits", 1, 0, 'b'}, /* max number of bits per code (implies -Z) */
  206. + {"rsyncable", 0, 0, 'R'}, /* make rsync-friendly archive */
  207. { 0, 0, 0, 0 }
  208. };
  209. @@ -357,6 +359,7 @@
  210. " -Z --lzw produce output compatible with old compress",
  211. " -b --bits maxbits max number of bits per code (implies -Z)",
  212. #endif
  213. + " --rsyncable Make rsync-friendly archive",
  214. " file... files to (de)compress. If none given, use standard input.",
  215. 0};
  216. char **p = help_msg;
  217. @@ -516,6 +519,9 @@
  218. #else
  219. recursive = 1; break;
  220. #endif
  221. + case 'R':
  222. + rsync = 1; break;
  223. +
  224. case 'S':
  225. #ifdef NO_MULTIPLE_DOTS
  226. if (*optarg == '.') optarg++;
  227. --- gzip-1.2.4.orig/gzip.h Fri Aug 13 22:35:33 1993
  228. +++ gzip-1.2.4-rsync/gzip.h Sat Dec 30 15:26:56 2000
  229. @@ -131,6 +131,7 @@
  230. extern unsigned insize; /* valid bytes in inbuf */
  231. extern unsigned inptr; /* index of next byte to be processed in inbuf */
  232. extern unsigned outcnt; /* bytes in output buffer */
  233. +extern int rsync; /* deflate into rsyncable chunks */
  234. extern long bytes_in; /* number of input bytes */
  235. extern long bytes_out; /* number of output bytes */
  236. @@ -282,7 +283,7 @@
  237. /* in trees.c */
  238. void ct_init OF((ush *attr, int *method));
  239. int ct_tally OF((int dist, int lc));
  240. -ulg flush_block OF((char *buf, ulg stored_len, int eof));
  241. +ulg flush_block OF((char *buf, ulg stored_len, int pad, int eof));
  242. /* in bits.c */
  243. void bi_init OF((file_t zipfile));
  244. --- gzip-1.2.4.orig/gzip.texi Thu Aug 19 06:42:50 1993
  245. +++ gzip-1.2.4-rsync/gzip.texi Fri Dec 29 21:20:54 2000
  246. @@ -316,6 +316,14 @@
  247. into the directory and compress all the files it finds there (or
  248. decompress them in the case of @code{gunzip}).
  249. +@item --rsyncable
  250. +While compressing, synchronize the output occasionally based on the
  251. +input. This reduces compression by about 1 percent most cases, but
  252. +means that the @code{rsync} program can take advantage of similarities
  253. +in the uncompressed input when syncronizing two files compressed with
  254. +this flag. @code{gunzip} cannot tell the difference between a
  255. +compressed file created with this option, and one created without it.
  256. +
  257. @item --suffix @var{suf}
  258. @itemx -S @var{suf}
  259. Use suffix @samp{@var{suf}} instead of @samp{.gz}. Any suffix can be
  260. --- gzip-1.2.4.orig/trees.c Wed Aug 18 03:36:32 1993
  261. +++ gzip-1.2.4-rsync/trees.c Sat Dec 30 15:37:00 2000
  262. @@ -850,9 +850,10 @@
  263. * trees or store, and output the encoded block to the zip file. This function
  264. * returns the total compressed length for the file so far.
  265. */
  266. -ulg flush_block(buf, stored_len, eof)
  267. +ulg flush_block(buf, stored_len, pad, eof)
  268. char *buf; /* input block, or NULL if too old */
  269. ulg stored_len; /* length of input block */
  270. + int pad; /* pad output to byte boundary */
  271. int eof; /* true if this is the last block for a file */
  272. {
  273. ulg opt_lenb, static_lenb; /* opt_len and static_len in bytes */
  274. @@ -944,6 +967,10 @@
  275. Assert (input_len == isize, "bad input size");
  276. bi_windup();
  277. compressed_len += 7; /* align on byte boundary */
  278. + } else if (pad && (compressed_len % 8) != 0) {
  279. + send_bits((STORED_BLOCK<<1)+eof, 3); /* send block type */
  280. + compressed_len = (compressed_len + 3 + 7) & ~7L;
  281. + copy_block(buf, 0, 1); /* with header */
  282. }
  283. Tracev((stderr,"\ncomprlen %lu(%lu) ", compressed_len>>3,
  284. compressed_len-7*eof));