source: ProjectBuilder/projects/buffer/pbconf/1.19/buffer/pbpatch/01-debian-patches.all@ 501

Last change on this file since 501 was 501, checked in by Bruno Cornec, 16 years ago
  • pb now uses upcoming 0.9.3 format for its build files
  • buffer now builds (RPM only ATM) using the new 0.9.3 format + a local patch
File size: 15.7 KB
Line 
1--- buffer-1.19.orig/buffer.man
2+++ buffer-1.19/buffer.man
3@@ -37,7 +37,8 @@
4 Use the given file as the output file. The default is stdout.
5 .TP
6 .B \-S size
7-After every chunk this size has been writen print out how much been writen so far.
8+After every chunk of this size has been written, print out how much has
9+been written so far. Also prints the total througput.
10 By default this is not set.
11 .TP
12 .B \-s size
13@@ -71,9 +72,9 @@
14 throughput on some drives.)
15 .TP
16 .B \-B
17-Force each block writen to be padded out to the blocksize. This is needed by some tape
18+Force each block written to be padded out to the blocksize. This is needed by some tape
19 and cartridge drives. Defaults to unpadded. This only affects the
20-last block writen.
21+last block written.
22 .TP
23 .B \-t
24 On exiting print to stderr a brief message showing the total number of
25@@ -82,7 +83,7 @@
26 .B \-Z
27 If reading/writing directly to a character device (like a tape drive)
28 then after each gigabyte perform an lseek to the start of the file.
29-Use this flag with extreme care. If can only be used on devices where
30+Use this flag with extreme care. It can only be used on devices where
31 an lseek does not rewind the tape but does reset the kernels position
32 flags. It is used to allow more than 2 gigabytes to be written.
33 .PP
34--- buffer-1.19.orig/buffer.c
35+++ buffer-1.19/buffer.c
36@@ -78,7 +78,7 @@
37 * Christoph Wicki <wicki@iis.ethz.ch>
38 *
39 * Revision 1.7 1992/07/23 20:42:03 lmjm
40- * Added 't' option to print total writen at end.
41+ * Added 't' option to print total written at end.
42 *
43 * Revision 1.6 1992/04/07 19:57:30 lmjm
44 * Added Kevins -B and -p options.
45@@ -93,7 +93,7 @@
46 * Make sofar printing size an option.
47 *
48 * Revision 1.3 90/05/15 23:27:46 lmjm
49- * Added -S option (show how much has been writen).
50+ * Added -S option (show how much has been written).
51 * Added -m option to specify how much shared memory to grab.
52 * Now tries to fill this with blocks.
53 * reader waits for writer to terminate and then frees the shared mem and sems.
54@@ -109,6 +109,9 @@
55 * Initial revision
56 *
57 */
58+#include <stdlib.h>
59+#include <string.h>
60+#include <limits.h>
61 #include <unistd.h>
62 #include <stdio.h>
63 #include <signal.h>
64@@ -120,15 +123,16 @@
65 #include <sys/shm.h>
66 #include <sys/sem.h>
67 #include <sys/wait.h>
68+#include <sys/time.h>
69 #include "sem.h"
70
71 #ifndef lint
72 static char *rcsid = "$Header: /a/swan/home/swan/staff/csg/lmjm/src/buffer/RCS/buffer.c,v 1.19 1995/08/24 17:46:28 lmjm Exp lmjm $";
73 #endif
74
75-#ifndef __alpha
76+#ifndef __linux__
77 extern char *shmat();
78-#endif /* __alpha */
79+#endif /* __linux__ */
80
81 /* General macros */
82 #define TRUE 1
83@@ -136,6 +140,14 @@
84 #define K *1024
85 #define M *1024*1024
86
87+#if defined __GNUC__ || __STDC_VERSION__ >= 199901L
88+#define NUM_K_TYPE unsigned long long
89+#define NUM_K_FMT "llu"
90+#else
91+#define NUM_K_TYPE unsigned long
92+#define NUM_K_FMT "lu"
93+#endif
94+
95 /* Some forward declarations */
96 void byee();
97 void start_reader_and_writer();
98@@ -159,7 +171,7 @@
99 void pr_out();
100 void end_writer();
101
102-/* When showing print a note every this many bytes writen */
103+/* When showing print a note every this many bytes written */
104 int showevery = 0;
105 #define PRINT_EVERY 10 K
106
107@@ -250,7 +262,9 @@
108
109 char print_total = 0;
110 /* Number of K output */
111-unsigned long outk = 0;
112+NUM_K_TYPE outk = 0;
113+
114+struct timeval starttime;
115
116 int
117 main( argc, argv )
118@@ -262,6 +276,8 @@
119 set_handlers();
120
121 buffer_allocate();
122+
123+ gettimeofday(&starttime, NULL);
124
125 start_reader_and_writer();
126
127@@ -287,7 +303,7 @@
128
129 while( (c = getopt( argc, argv, "BS:Zdm:s:b:p:u:ti:o:z:" )) != -1 ){
130 switch( c ){
131- case 't': /* Print to stderr the total no of bytes writen */
132+ case 't': /* Print to stderr the total no of bytes written */
133 print_total++;
134 break;
135 case 'u': /* pause after write for given microseconds */
136@@ -384,8 +400,8 @@
137 fprintf( stderr, "Usage: %s [-B] [-t] [-S size] [-m memsize] [-b blocks] [-p percent] [-s blocksize] [-u pause] [-i infile] [-o outfile] [-z size]\n",
138 progname );
139 fprintf( stderr, "-B = blocked device - pad out last block\n" );
140- fprintf( stderr, "-t = show total amount writen at end\n" );
141- fprintf( stderr, "-S size = show amount writen every size bytes\n" );
142+ fprintf( stderr, "-t = show total amount written at end\n" );
143+ fprintf( stderr, "-S size = show amount written every size bytes\n" );
144 fprintf( stderr, "-m size = size of shared mem chunk to grab\n" );
145 fprintf( stderr, "-b num = number of blocks in queue\n" );
146 fprintf( stderr, "-p percent = don't start writing until percent blocks filled\n" );
147@@ -397,6 +413,11 @@
148 byee( -1 );
149 }
150 }
151+
152+ if (argc > optind) {
153+ fprintf( stderr, "too many arguments\n" );
154+ byee( -1 );
155+ }
156
157 if (zflag) showevery = blocksize;
158
159@@ -507,9 +528,9 @@
160 get_buffer();
161
162 if( debug )
163- fprintf( stderr, "%s pbuffer is 0x%08x, buffer_size is %d [%d x %d]\n",
164+ fprintf( stderr, "%s pbuffer is 0x%08lx, buffer_size is %d [%d x %d]\n",
165 proc_string,
166- (char *)pbuffer, buffer_size, blocks, blocksize );
167+ (unsigned long)pbuffer, buffer_size, blocks, blocksize );
168
169 #ifdef SYS5
170 memset( (char *)pbuffer, '\0', buffer_size );
171@@ -528,7 +549,17 @@
172 pbuffer->blocks_free_lock = 1;
173 /* start this off so lock() can be called on it for each block
174 * till all the blocks are used up */
175+ /* Initializing the semaphore to "blocks - 1" causes a hang when using option
176+ * "-p 100" because it always keeps one block free, so we'll never reach 100% fill
177+ * level. However, there doesn't seem to be a good reason to keep one block free,
178+ * so we initialize the semaphore to "blocks" instead.
179+ * <mbuck@debian.org> 2004-01-11
180+ */
181+#if 0
182 sem_set( pbuffer->semid, pbuffer->blocks_free_lock, blocks - 1 );
183+#else
184+ sem_set( pbuffer->semid, pbuffer->blocks_free_lock, blocks );
185+#endif
186
187 /* Detattach the shared memory so the fork doesnt do anything odd */
188 shmdt( (char *)pbuffer );
189@@ -648,7 +679,7 @@
190 int
191 fill_block()
192 {
193- int bytes;
194+ int bytes = 0;
195 char *start;
196 int toread;
197 static char eof_reached = 0;
198@@ -707,7 +738,7 @@
199 {
200 int filled = 0;
201 int maxfilled = (blocks * percent) / 100;
202- int first_block;
203+ int first_block = 0;
204
205 if( debug )
206 fprintf( stderr, "\tW: Entering writer\n blocks = %d\n maxfilled = %d\n",
207@@ -742,7 +773,7 @@
208 }
209
210 if( print_total ){
211- fprintf( stderr, "Kilobytes Out %lu\n", outk );
212+ fprintf( stderr, "Kilobytes Out %" NUM_K_FMT "\n", outk );
213 }
214
215 if( debug )
216@@ -783,14 +814,14 @@
217 void
218 write_block_to_stdout()
219 {
220- static unsigned long out = 0;
221+ unsigned long out = 0;
222 static unsigned long last_gb = 0;
223- static unsigned long next_k = 0;
224+ static NUM_K_TYPE next_k = 0;
225 int written;
226
227 if( next_k == 0 && showevery ){
228 if( debug > 3 )
229- fprintf( stderr, "W: next_k = %lu showevery = %d\n", next_k, showevery );
230+ fprintf( stderr, "W: next_k = %" NUM_K_FMT " showevery = %d\n", next_k, showevery );
231 showevery = showevery / 1024;
232 next_k = showevery;
233 }
234@@ -798,7 +829,7 @@
235 if( (written = write( fdout, curr_block->data, curr_block->bytes )) != curr_block->bytes ){
236 report_proc();
237 perror( "write of data failed" );
238- fprintf( stderr, "bytes to write=%d, bytes written=%d, total written %10luK\n", curr_block->bytes, written, outk );
239+ fprintf( stderr, "bytes to write=%d, bytes written=%d, total written %10" NUM_K_FMT "K\n", curr_block->bytes, written, outk );
240 byee( -1 );
241 }
242
243@@ -825,7 +856,7 @@
244 }
245 if( showevery ){
246 if( debug > 3 )
247- fprintf( stderr, "W: outk = %lu, next_k = %lu\n",
248+ fprintf( stderr, "W: outk = %" NUM_K_FMT ", next_k = %" NUM_K_FMT "\n",
249 outk, next_k );
250 if( outk >= next_k ){
251 pr_out();
252@@ -914,13 +945,12 @@
253 do_size( arg )
254 char *arg;
255 {
256- char format[ 20 ];
257- int ret;
258+ int ret = 0;
259
260- *format = '\0';
261- sscanf( arg, "%d%s", &ret, format );
262+ char unit = '\0';
263+ sscanf( arg, "%d%c", &ret, &unit );
264
265- switch( *format ){
266+ switch( unit ){
267 case 'm':
268 case 'M':
269 ret = ret K K;
270@@ -941,7 +971,36 @@
271 void
272 pr_out()
273 {
274- fprintf( stderr, " %10luK\r", outk );
275+ struct timeval now;
276+ unsigned long ms_delta, k_per_s;
277+
278+ gettimeofday(&now, NULL);
279+ ms_delta = (now.tv_sec - starttime.tv_sec) * 1000
280+ + (now.tv_usec - starttime.tv_usec) / 1000;
281+ if (ms_delta) {
282+ /* Use increased accuracy for small amounts of data,
283+ * decreased accuracy for *huge* throughputs > 4.1GB/s
284+ * to avoid division by 0. This will overflow if your
285+ * machine's throughput exceeds 4TB/s - you deserve to
286+ * loose if you're still using 32 bit longs on such a
287+ * beast ;-)
288+ * <mbuck@debian.org>
289+ */
290+ if (outk < ULONG_MAX / 1000) {
291+ k_per_s = (outk * 1000) / ms_delta;
292+ } else if (ms_delta >= 1000) {
293+ k_per_s = outk / (ms_delta / 1000);
294+ } else {
295+ k_per_s = (outk / ms_delta) * 1000;
296+ }
297+ fprintf( stderr, " %10" NUM_K_FMT "K, %10luK/s\r", outk, k_per_s );
298+ } else {
299+ if (outk) {
300+ fprintf( stderr, " %10" NUM_K_FMT "K, ?K/s\r", outk );
301+ } else {
302+ fprintf( stderr, " 0K, 0K/s\r");
303+ }
304+ }
305 }
306
307 #ifdef SYS5
308--- buffer-1.19.orig/sem.c
309+++ buffer-1.19/sem.c
310@@ -27,6 +27,7 @@
311 * semaphores */
312
313 #include <stdio.h>
314+#include <unistd.h>
315 #include <sys/types.h>
316 #include <sys/stat.h>
317 #include <sys/ipc.h>
318@@ -34,6 +35,20 @@
319 #include <errno.h>
320 #include "sem.h"
321
322+/* If we've got a version of glibc that doesn't define union semun, we do
323+ * it ourseleves like in semctl(2). Otherwise, fall back to the original
324+ * buffer behaviour of defining it (differetly!) only on some systems.
325+ *
326+ * mbuck@debian.org, 1999/08/29
327+ */
328+#if defined(__GNU_LIBRARY__) && defined(_SEM_SEMUN_UNDEFINED)
329+union semun {
330+ int val; /* value for SETVAL */
331+ struct semid_ds *buf; /* buffer for IPC_STAT & IPC_SET */
332+ unsigned short int *array; /* array for GETALL & SETALL */
333+ struct seminfo *__buf; /* buffer for IPC_INFO */
334+};
335+#else
336 #if defined(SYS5) || defined(ultrix) || defined(_AIX)
337 union semun {
338 int val;
339@@ -41,6 +56,7 @@
340 ushort *array;
341 };
342 #endif
343+#endif
344
345 /* IMPORTS */
346
347@@ -95,7 +111,7 @@
348 return sem;
349 }
350
351-static
352+static void
353 do_sem( sem_id, pbuf, err )
354 int sem_id;
355 struct sembuf *pbuf;
356@@ -149,10 +165,13 @@
357 remove_sems( sem_id )
358 int sem_id;
359 {
360+ union semun arg;
361+
362 if( sem_id == -1 )
363 return;
364
365- if( semctl( sem_id, 0, IPC_RMID, NULL ) == -1 ){
366+ arg.val = 0;
367+ if( semctl( sem_id, 0, IPC_RMID, arg ) == -1 ){
368 report_proc();
369 perror( "internal error, failed to remove semaphore" );
370 }
371--- buffer-1.19.orig/debian/changelog
372+++ buffer-1.19/debian/changelog
373@@ -0,0 +1,98 @@
374+buffer (1.19-7) unstable; urgency=low
375+
376+ * Really changed priority this time. Sigh.
377+
378+ -- Martin Buck <mbuck@debian.org> Sat, 1 Jan 2005 23:46:26 +0100
379+
380+buffer (1.19-6) unstable; urgency=low
381+
382+ * Changed priority to optional. Closes: #283803
383+
384+ -- Martin Buck <mbuck@debian.org> Thu, 30 Dec 2004 15:04:31 +0100
385+
386+buffer (1.19-5) unstable; urgency=low
387+
388+ * Disabled obsolete declaration of shmat(). Closes: #260395
389+
390+ -- Martin Buck <mbuck@debian.org> Tue, 27 Jul 2004 23:50:50 +0200
391+
392+buffer (1.19-4) unstable; urgency=low
393+
394+ * Fixed hang when using option "-p 100". Closes: #224984
395+
396+ -- Martin Buck <mbuck@debian.org> Sun, 11 Jan 2004 23:20:39 +0100
397+
398+buffer (1.19-3) unstable; urgency=low
399+
400+ * Added largefile support. Closes: #156847
401+ * Made sure -S/-z works properly with files > 4 TB.
402+ * Upgraded to Standards-Version 3.5.8
403+
404+ -- Martin Buck <mbuck@debian.org> Fri, 31 Jan 2003 23:55:43 +0100
405+
406+buffer (1.19-2) unstable; urgency=low
407+
408+ * Fixed buffer overrun in option parsing.
409+ Fixed (rather theoretical) potential division by zero in
410+ throughput calculation.
411+ Closes: #123543
412+
413+ -- Martin Buck <mbuck@debian.org> Tue, 11 Dec 2001 23:34:46 +0100
414+
415+buffer (1.19-1) unstable; urgency=low
416+
417+ * New upstream version. Closes: #91961
418+ * Added a few spelling fixes from FreeBSD version 1.17.1
419+ * Added (slightly modified version of) patch from Marc Schaefer that prints
420+ the throughput with option -S
421+ * Fixed a few gcc warnings
422+
423+ -- Martin Buck <mbuck@debian.org> Thu, 5 Apr 2001 22:10:07 +0200
424+
425+buffer (1.17-6) unstable; urgency=low
426+
427+ * Added Build-Depends. Closes: #70332
428+
429+ -- Martin Buck <mbuck@debian.org> Mon, 5 Mar 2001 22:19:09 +0100
430+
431+buffer (1.17-5) unstable; urgency=low
432+
433+ * Cleaned up debian/rules
434+ * Upgraded to Debian policy 3.0.1.1
435+
436+ -- Martin Buck <mbuck@debian.org> Mon, 13 Sep 1999 23:19:57 +0200
437+
438+buffer (1.17-4) unstable; urgency=low
439+
440+ * buffer now complains if non-option arguments are found
441+ * Document changes from original version in copyright-file
442+ * Checked conformance with Debian policy 2.5.0
443+
444+ -- Martin Buck <mbuck@debian.org> Sun, 29 Aug 1999 00:57:03 +0200
445+
446+buffer (1.17-3) unstable; urgency=low
447+
448+ * NMU; added missing SEM_SEMUN_UNDEFINED
449+ * closes: #31931
450+ * fixes: #31920
451+
452+ -- Hartmut Koptein <koptein@debian.org> Fri, 9 Jul 1999 10:04:49 +0200
453+
454+buffer (1.17-2) unstable; urgency=low
455+
456+ * Applied patch from Paul Slootman (closes: Bug#26098):
457+ - egcs complains about NULL where union expected. Now it builds on Alpha.
458+ - typos in manpage fixed.
459+ * Switched from debstd to debhelper
460+
461+ -- Martin Buck <mbuck@debian.org> Wed, 9 Sep 1998 22:35:29 +0200
462+
463+buffer (1.17-1) unstable; urgency=low
464+
465+ * Initial Release.
466+
467+ -- Martin Buck <mbuck@debian.org> Wed, 27 Aug 1997 01:11:29 +0200
468+
469+Local variables:
470+mode: debian-changelog
471+End:
472--- buffer-1.19.orig/debian/control
473+++ buffer-1.19/debian/control
474@@ -0,0 +1,19 @@
475+Source: buffer
476+Section: utils
477+Priority: optional
478+Maintainer: Martin Buck <mbuck@debian.org>
479+Standards-Version: 3.5.8
480+Build-Depends: debhelper (>= 4)
481+
482+Package: buffer
483+Architecture: any
484+Depends: ${shlibs:Depends}
485+Description: Buffering/reblocking program for tape backups, printing, etc.
486+ Buffer implements double buffering and can be used to keep backup tapes
487+ streaming or printers printing. It can also be used to convert a data
488+ stream to a given output blocksize.
489+ .
490+ Buffer uses shared memory to convert a variable input data rate to a
491+ constant output data rate. It is typically used in a pipe between a backup
492+ program and the tape device, but there are also other applications like
493+ buffering printer data in lpd's input filter.
494--- buffer-1.19.orig/debian/rules
495+++ buffer-1.19/debian/rules
496@@ -0,0 +1,64 @@
497+#!/usr/bin/make -f
498+
499+export DH_COMPAT = 4
500+
501+CFLAGS = -g -Wall -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE
502+
503+ifneq (,$(findstring noopt,$(DEB_BUILD_OPTIONS)))
504+ CFLAGS += -O0
505+else
506+ CFLAGS += -O2
507+endif
508+
509+
510+build: build-stamp
511+build-stamp:
512+ dh_testdir
513+
514+ make CFLAGS="$(CFLAGS)"
515+
516+ touch build-stamp
517+
518+clean:
519+ dh_testdir
520+ dh_testroot
521+ -rm -f build-stamp install-stamp
522+ -make clean
523+ dh_clean
524+
525+install: install-stamp
526+install-stamp: build-stamp
527+ dh_testdir
528+ dh_testroot
529+ dh_clean -k
530+ dh_installdirs usr/bin usr/share/man/man1
531+ make install INSTBIN=debian/buffer/usr/bin INSTMAN=debian/buffer/usr/share/man/man1 S=1
532+ touch install-stamp
533+
534+binary-indep: build install
535+
536+binary-arch: build install
537+ dh_testdir
538+ dh_testroot
539+ dh_installdocs README
540+# dh_installexamples
541+# dh_installmenu
542+# dh_installemacsen
543+# dh_installinit
544+# dh_installcron
545+# dh_installman
546+# dh_undocumented
547+ dh_installchangelogs
548+ dh_strip
549+ dh_compress
550+ dh_fixperms
551+# dh_suidregister
552+ dh_installdeb
553+ dh_shlibdeps
554+ dh_gencontrol
555+# dh_makeshlibs
556+ dh_md5sums
557+ dh_builddeb
558+
559+binary: binary-indep binary-arch
560+.PHONY: build clean binary-indep binary-arch binary install
561--- buffer-1.19.orig/debian/copyright
562+++ buffer-1.19/debian/copyright
563@@ -0,0 +1,11 @@
564+This package was debianized by Martin Buck mbuck@debian.org on
565+Wed, 27 Aug 1997 01:11:29 +0200.
566+
567+It was downloaded from
568+http://sunsite.org.uk/public/public/packages/buffer/
569+
570+Copyright:
571+GPL (see /usr/share/common-licenses/GPL)
572+In addtion under NO circumstances can I (Lee McLoughlin), or Imperial
573+College, be held liable for any event caused by the running or storing of
574+this program or its documentation.
Note: See TracBrowser for help on using the repository browser.