From: Diane Trout Date: Mon, 24 Oct 2011 21:52:53 +0000 (-0700) Subject: Include Henry's out-of-memory check. X-Git-Url: http://woldlab.caltech.edu/gitweb/?p=samtools.git;a=commitdiff_plain;h=ee9d1abc1046f46d40357e56074d64ad9ef050b7 Include Henry's out-of-memory check. Builld samtools with a shared library --- diff --git a/debian/control b/debian/control index f608086..8b96cd1 100644 --- a/debian/control +++ b/debian/control @@ -25,7 +25,7 @@ Package: libbam-dev Architecture: any Section: libdevel Depends: ${shlibs:Depends}, ${misc:Depends} -Description: manipulates nucleotide sequence alignments in BAM or SAM format +Description: manipulates nucleotide sequence alignments in BAM or SAM format The BAM library provides I/O and various operations on manipulating nucleotide sequence alignments in the BAM (Binary Alignment/Mapping) or SAM (Sequence Alignment/Map) format. It now supports importing from or exporting to SAM, @@ -33,3 +33,14 @@ Description: manipulates nucleotide sequence alignments in BAM or SAM format with a specified region. . This library is part SAMtools. + +Package: libbam1 +Architecture: any +Section: libdevel +Depends: ${shlibs:Depends}, ${misc:Depends} +Description: manipulates nucleotide sequence alignments in BAM or SAM format + The BAM library provides I/O and various operations on manipulating nucleotide + sequence alignments in the BAM (Binary Alignment/Mapping) or SAM (Sequence + Alignment/Map) format. It now supports importing from or exporting to SAM, + sorting, merging, generating pileup, and quickly retrieval of reads overlapped + with a specified region. diff --git a/debian/libbam1.install b/debian/libbam1.install new file mode 100644 index 0000000..5bdd3a0 --- /dev/null +++ b/debian/libbam1.install @@ -0,0 +1 @@ +libbam.so.1 usr/lib diff --git a/debian/libbam1.postinst b/debian/libbam1.postinst new file mode 100644 index 0000000..c120531 --- /dev/null +++ b/debian/libbam1.postinst @@ -0,0 +1,7 @@ +#!/bin/sh +# postinst script for libbam1 +set -e + +if [ "$1" = "configure" ]; then + ldconfig +fi diff --git a/debian/libbam1.postrm b/debian/libbam1.postrm new file mode 100644 index 0000000..345d667 --- /dev/null +++ b/debian/libbam1.postrm @@ -0,0 +1,7 @@ +#!/bin/sh +# postinst script for libbam1 +set -e + +if [ "$1" = "remove" ]; then + ldconfig +fi diff --git a/debian/patches/build-so b/debian/patches/build-so new file mode 100644 index 0000000..ffe66d2 --- /dev/null +++ b/debian/patches/build-so @@ -0,0 +1,38 @@ +diff --git a/Makefile b/Makefile +index db18333..926059b 100644 +--- a/Makefile ++++ b/Makefile +@@ -1,5 +1,5 @@ + CC= gcc +-CFLAGS= -g -Wall -O2 #-m64 #-arch ppc ++CFLAGS= -g -Wall -O2 -fPIC #-m64 #-arch ppc + DFLAGS= -D_FILE_OFFSET_BITS=64 -D_LARGEFILE64_SOURCE -D_USE_KNETFILE -D_CURSES_LIB=1 + KNETFILE_O= knetfile.o + LOBJS= bgzf.o kstring.o bam_aux.o bam.o bam_import.o sam.o bam_index.o \ +@@ -35,13 +35,13 @@ all:$(PROG) + .PHONY:all lib clean cleanlocal + .PHONY:all-recur lib-recur clean-recur cleanlocal-recur install-recur + +-lib:libbam.a ++lib:libbam.so.1 + + libbam.a:$(LOBJS) + $(AR) -csru $@ $(LOBJS) + + samtools:lib-recur $(AOBJS) +- $(CC) $(CFLAGS) -o $@ $(AOBJS) -Lbcftools $(LIBPATH) libbam.a -lbcf $(LIBCURSES) -lm -lz ++ $(CC) $(CFLAGS) -o $@ $(AOBJS) -Lbcftools $(LIBPATH) -L. -lbam -lbcf $(LIBCURSES) -lm -lz + + razip:razip.o razf.o $(KNETFILE_O) + $(CC) $(CFLAGS) -o $@ razf.o razip.o $(KNETFILE_O) -lz +@@ -75,8 +75,9 @@ faidx_main.o:faidx.h razf.h + libbam.1.dylib-local:$(LOBJS) + libtool -dynamic $(LOBJS) -o libbam.1.dylib -lc -lz + +-libbam.so.1-local:$(LOBJS) ++libbam.so.1:$(LOBJS) + $(CC) -shared -Wl,-soname,libbam.so -o libbam.so.1 $(LOBJS) -lc -lz ++ ln -s $@ libbam.so + + dylib: + @$(MAKE) cleanlocal; \ diff --git a/debian/patches/razip-oom-check b/debian/patches/razip-oom-check new file mode 100644 index 0000000..d4cc299 --- /dev/null +++ b/debian/patches/razip-oom-check @@ -0,0 +1,18 @@ +--- a/razip.c 2011-10-20 11:05:21.020305754 -0700 ++++ b/razip.c 2011-10-20 11:48:26.208271871 -0700 +@@ -79,7 +79,13 @@ + if(pstdout){ + f_dst = fileno(stdout); + } else { +- char *name = malloc(sizeof(strlen(argv[optind]) + 5)); ++ char *name = (char *)malloc(sizeof(char) * (strlen(argv[optind]) + 5)); ++ if (name == NULL) ++ { ++ fprintf(stderr, " -- Out of memory --\n"); ++ return 1; ++ } ++ + strcpy(name, argv[optind]); + strcat(name, ".rz"); + f_dst = write_open(name, is_forced); + diff --git a/debian/patches/series b/debian/patches/series index ed908a5..180fd32 100644 --- a/debian/patches/series +++ b/debian/patches/series @@ -1 +1,3 @@ no-pileup-tests.patch +razip-oom-check +build-so \ No newline at end of file diff --git a/debian/patches/use-shlib b/debian/patches/use-shlib new file mode 100644 index 0000000..e747a11 --- /dev/null +++ b/debian/patches/use-shlib @@ -0,0 +1,38 @@ +Index: samtools-0.1.17/Makefile +=================================================================== +--- samtools-0.1.17.orig/Makefile 2011-07-25 21:00:44.145494440 -0700 ++++ samtools-0.1.17/Makefile 2011-07-25 21:09:46.265494761 -0700 +@@ -1,5 +1,5 @@ + CC= gcc +-CFLAGS= -g -Wall -O2 #-m64 #-arch ppc ++CFLAGS= -g -Wall -O2 -fPIC #-m64 #-arch ppc + DFLAGS= -D_FILE_OFFSET_BITS=64 -D_LARGEFILE64_SOURCE -D_USE_KNETFILE -D_CURSES_LIB=1 + KNETFILE_O= knetfile.o + LOBJS= bgzf.o kstring.o bam_aux.o bam.o bam_import.o sam.o bam_index.o \ +@@ -35,13 +35,13 @@ + .PHONY:all lib clean cleanlocal + .PHONY:all-recur lib-recur clean-recur cleanlocal-recur install-recur + +-lib:libbam.a ++lib:libbam.so.1 + + libbam.a:$(LOBJS) + $(AR) -csru $@ $(LOBJS) + + samtools:lib-recur $(AOBJS) +- $(CC) $(CFLAGS) -o $@ $(AOBJS) -Lbcftools $(LIBPATH) libbam.a -lbcf $(LIBCURSES) -lm -lz ++ $(CC) $(CFLAGS) -o $@ $(AOBJS) -Lbcftools $(LIBPATH) -L. -lbam -lbcf $(LIBCURSES) -lm -lz + + razip:razip.o razf.o $(KNETFILE_O) + $(CC) $(CFLAGS) -o $@ razf.o razip.o $(KNETFILE_O) -lz +@@ -75,8 +75,9 @@ + libbam.1.dylib-local:$(LOBJS) + libtool -dynamic $(LOBJS) -o libbam.1.dylib -lc -lz + +-libbam.so.1-local:$(LOBJS) ++libbam.so.1:$(LOBJS) + $(CC) -shared -Wl,-soname,libbam.so -o libbam.so.1 $(LOBJS) -lc -lz ++ ln -s $@ libbam.so + + dylib: + @$(MAKE) cleanlocal; \ diff --git a/debian/rules b/debian/rules index e4a2566..b3cf88d 100755 --- a/debian/rules +++ b/debian/rules @@ -7,7 +7,7 @@ include /usr/share/cdbs/1/rules/patchsys-quilt.mk CFLAGS += -fPIC DEB_MAKE_BUILD_TARGET = all all-recur razip lib -DEB_MAKE_CHECK_TARGET = -C examples all +DEB_MAKE_CHECK_TARGET = LD_LIBRARY_PATH=$(CURDIR) -C examples all DEB_DH_BUILDDEB_ARGS = -- -Z=xz diff --git a/debian/shlibs.libbam1 b/debian/shlibs.libbam1 new file mode 100644 index 0000000..90480ec --- /dev/null +++ b/debian/shlibs.libbam1 @@ -0,0 +1 @@ +libbam 1 samtools (>= 1.1.17)