[med-svn] [Git][med-team/sumalibs][master] 17 commits: Using CMake instead of upstream's Makefile

Pierre Gruet gitlab at salsa.debian.org
Tue Apr 14 16:43:45 BST 2020



Pierre Gruet pushed to branch master at Debian Med / sumalibs


Commits:
4156e521 by Pierre Gruet at 2020-04-13T10:21:32+02:00
Using CMake instead of upstream's Makefile

This is to allow building a shared and a static library easily.

- - - - -
f7bfe474 by Pierre Gruet at 2020-04-13T10:22:56+02:00
Updating debian/rules to fit CMake.

Overriding dh_auto_configure to transmit arguments to CMake
Stopping overriding dh_auto_install
Putting VERSION and SOVERSION in debian/rules

- - - - -
940e8288 by Pierre Gruet at 2020-04-13T10:26:12+02:00
Creating a shared lib and a development package

Modifying debian/control to split the package into:
* libsuma1, which provides the shared lib;
* libsuma-dev, which provides the static lib and include files.

- - - - -
242357ed by Pierre Gruet at 2020-04-13T10:28:56+02:00
Adding debian/*.install files for the two binary packages

- - - - -
2ca78ef5 by Pierre Gruet at 2020-04-13T10:30:03+02:00
Adding symbols file for the shared lib

- - - - -
4352f0a7 by Pierre Gruet at 2020-04-13T10:31:35+02:00
Updating debian/copyright

- - - - -
83f9e108 by Pierre Gruet at 2020-04-13T10:34:53+02:00
Adding a patch to read ACGT-only sequences

Patch formerly used in the sumaclust package.

- - - - -
bf90a3b1 by Pierre Gruet at 2020-04-13T10:57:39+02:00
Removing upstream's Makefile in using_cmake.patch

- - - - -
6174a208 by Pierre Gruet at 2020-04-13T13:27:21+02:00
Overriding dh_clean to remove CMake output

- - - - -
b51bac16 by Pierre Gruet at 2020-04-13T15:05:09+02:00
New upstream version 1.0.36
- - - - -
8c0e2ed5 by Pierre Gruet at 2020-04-13T15:05:10+02:00
Update upstream source from tag 'upstream/1.0.36'

Update to upstream version '1.0.36'
with Debian dir abd464a6c350129433cd0294fa6850515386c654
- - - - -
9960f0b8 by Pierre Gruet at 2020-04-13T15:06:55+02:00
Deleting patch to read sequences, taken into account by upstream

- - - - -
89185eac by Pierre Gruet at 2020-04-13T18:40:16+02:00
Hardening

- - - - -
01f7b446 by Pierre Gruet at 2020-04-14T13:35:46+02:00
Providing autopkgtest for building against the libs

- - - - -
f44d7985 by Pierre Gruet at 2020-04-14T15:34:16+02:00
Providing autopkgtests as examples for the -dev package

- - - - -
30d91520 by Pierre Gruet at 2020-04-14T15:35:34+02:00
Correcting debian/tests/run-unit-test

- - - - -
1933b1fa by Pierre Gruet at 2020-04-14T15:46:48+02:00
Updating changelog

- - - - -


16 changed files:

- + debian/README.test
- debian/changelog
- debian/control
- debian/copyright
- + debian/libsuma-dev.examples
- + debian/libsuma-dev.install
- + debian/libsuma1.install
- + debian/libsuma1.symbols
- − debian/patches/fix_makefile.patch
- debian/patches/series
- + debian/patches/using_cmake.patch
- debian/rules
- + debian/tests/buildAndSimpleRun
- + debian/tests/control
- + debian/tests/run-unit-test
- libfasta/sequence.c


Changes:

=====================================
debian/README.test
=====================================
@@ -0,0 +1,8 @@
+Notes on how this package can be tested.
+────────────────────────────────────────
+
+This package can be tested by running the provided test:
+
+    sh run-unit-test
+
+in order to confirm its integrity.


=====================================
debian/changelog
=====================================
@@ -1,3 +1,18 @@
+sumalibs (1.0.36-1) UNRELEASED; urgency=medium
+
+  * New upstream version 1.0.36
+  * Using CMake instead of upstream's Makefile
+  * Updating debian/rules to fit CMake.
+  * Creating a shared lib and a development package
+  * Adding debian/*.install files for the two binary packages
+  * Adding symbols file for the shared lib
+  * Overriding dh_clean to remove CMake output
+  * Hardening compilation
+  * Providing autopkgtest for building against the libs
+  * Providing autopkgtest as an example for the -dev package
+
+ -- Pierre Gruet <pgtdebian at free.fr>  Tue, 14 Apr 2020 13:37:10 +0200
+
 sumalibs (1.0.35-1) unstable; urgency=medium
 
   * New upstream version


=====================================
debian/control
=====================================
@@ -2,19 +2,34 @@ Source: sumalibs
 Section: science
 Priority: optional
 Maintainer: Debian Med Packaging Team <debian-med-packaging at lists.alioth.debian.org>
-Uploaders: Andreas Tille <tille at debian.org>
-Build-Depends: debhelper-compat (= 12)
+Uploaders: Andreas Tille <tille at debian.org>,
+           Pierre Gruet <pgtdebian at free.fr>
+Build-Depends: debhelper-compat (= 12),
+               cmake
 Standards-Version: 4.5.0
 Vcs-Browser: https://salsa.debian.org/med-team/sumalibs
 Vcs-Git: https://salsa.debian.org/med-team/sumalibs.git
 Homepage: https://git.metabarcoding.org/obitools/sumalibs
 Rules-Requires-Root: no
 
+Package: libsuma1
+Architecture: any
+Section: libs
+Depends: ${shlibs:Depends}, ${misc:Depends}
+Description: shared library for sumatra and sumaclust
+ Sumatra is a tool for fast and exact comparison and clustering of sequences
+ and sumaclust can be used for fast and exact clustering of genomic sequences.
+ Both tools are using this common library.
+ .
+ This package provides the shared library.
+
 Package: libsuma-dev
 Architecture: any
 Section: libdevel
-Depends: ${shlibs:Depends}, ${misc:Depends}
-Description: libraries for sumatra and sumaclust
+Depends: libsuma1 (= ${binary:Version}), ${shlibs:Depends}, ${misc:Depends}
+Description: headers and static library for sumatra and sumaclust
  Sumatra is a tool for fast and exact comparison and clustering of sequences
  and sumaclust can be used for fast and exact clustering of genomic sequences.
  Both tools are using this common library.
+ .
+ This package provides the static library and header files.


=====================================
debian/copyright
=====================================
@@ -10,6 +10,7 @@ License: CeCILL-2
 
 Files: debian/*
 Copyright: 2019-2020 Andreas Tille <tille at debian.org>
+                2020 Pierre Gruet <pgtdebian at free.fr>
 License: CeCILL-2
 
 License: CeCILL-2


=====================================
debian/libsuma-dev.examples
=====================================
@@ -0,0 +1,3 @@
+debian/README.test
+debian/tests/run-unit-test
+debian/tests/buildAndSimpleRun


=====================================
debian/libsuma-dev.install
=====================================
@@ -0,0 +1,3 @@
+usr/include
+usr/lib/*/*.so
+usr/lib/*/*.a


=====================================
debian/libsuma1.install
=====================================
@@ -0,0 +1 @@
+usr/lib/*/*.so.*


=====================================
debian/libsuma1.symbols
=====================================
@@ -0,0 +1,109 @@
+libsuma.so.1 libsuma1 #MINVER#
+* Build-Depends-Package: libsuma-dev
+ addCounts at Base 1.0.35
+ alignForSumathings at Base 1.0.35
+ buildTable at Base 1.0.35
+ calculateLCSmin at Base 1.0.35
+ calculateMaxAndMinLen at Base 1.0.35
+ calculateMaxAndMinLenDB at Base 1.0.35
+ calculateSSEBandLength at Base 1.0.35
+ calculateSizeToAllocate at Base 1.0.35
+ changeValue at Base 1.0.35
+ char_header_add_field at Base 1.0.35
+ check_and_realloc_field at Base 1.0.35
+ check_and_realloc_mem_in_header_table at Base 1.0.35
+ check_mem_field at Base 1.0.35
+ cleanDB at Base 1.0.35
+ compareTable at Base 1.0.35
+ end_header_table at Base 1.0.35
+ errorAbort at Base 1.0.35
+ exitIfEmptyFile at Base 1.0.35
+ fastaSeqPtr_header_add_field at Base 1.0.35
+ file_nextChar at Base 1.0.35
+ file_nextLine at Base 1.0.35
+ file_open at Base 1.0.35
+ file_openrw at Base 1.0.35
+ filters at Base 1.0.35
+ filtersSumatra at Base 1.0.35
+ free_header_table at Base 1.0.35
+ generic_sse_banded_lcs_align at Base 1.0.35
+ getA16Address at Base 1.0.35
+ getItemFromHeader at Base 1.0.35
+ hashDB at Base 1.0.35
+ header_parser at Base 1.0.35
+ header_parser_main at Base 1.0.35
+ header_yy_create_buffer at Base 1.0.35
+ header_yy_delete_buffer at Base 1.0.35
+ header_yy_flex_debug at Base 1.0.35
+ header_yy_flush_buffer at Base 1.0.35
+ header_yy_scan_buffer at Base 1.0.35
+ header_yy_scan_bytes at Base 1.0.35
+ header_yy_scan_string at Base 1.0.35
+ header_yy_switch_to_buffer at Base 1.0.35
+ header_yyalloc at Base 1.0.35
+ header_yyfree at Base 1.0.35
+ header_yyget_debug at Base 1.0.35
+ header_yyget_in at Base 1.0.35
+ header_yyget_leng at Base 1.0.35
+ header_yyget_lineno at Base 1.0.35
+ header_yyget_out at Base 1.0.35
+ header_yyget_text at Base 1.0.35
+ header_yyin at Base 1.0.35
+ header_yyleng at Base 1.0.35
+ header_yylex_destroy at Base 1.0.35
+ header_yylineno at Base 1.0.35
+ header_yyout at Base 1.0.35
+ header_yypop_buffer_state at Base 1.0.35
+ header_yypush_buffer_state at Base 1.0.35
+ header_yyrealloc at Base 1.0.35
+ header_yyrestart at Base 1.0.35
+ header_yyset_debug at Base 1.0.35
+ header_yyset_in at Base 1.0.35
+ header_yyset_lineno at Base 1.0.35
+ header_yyset_out at Base 1.0.35
+ header_yytext at Base 1.0.35
+ header_yywrap at Base 1.0.35
+ iniSeq at Base 1.0.35
+ initializeAddressWithGaps at Base 1.0.35
+ int2bin at Base 1.0.35
+ isPossible at Base 1.0.35
+ isPossibleSumathings at Base 1.0.35
+ malloc_field at Base 1.0.35
+ prepareTablesForSumathings at Base 1.0.35
+ printHeaderAndSeqFromFastaSeqPtr at Base 1.0.35
+ printOnlyHeaderFromFastaSeqPtr at Base 1.0.35
+ printOnlyHeaderFromTable at Base 1.0.35
+ printOnlySeqFromChar at Base 1.0.35
+ printOnlySeqFromFastaSeqPtr at Base 1.0.35
+ putSeqInSeq at Base 1.0.35
+ reallocA16Address at Base 1.0.35
+ realloc_field at Base 1.0.35
+ reverseSortSeqsWithCounts at Base 1.0.35
+ seq_fillDigitSeq at Base 1.0.35
+ seq_fillHeader at Base 1.0.35
+ seq_fillSeq at Base 1.0.35
+ seq_fillSeqOnlyATGC at Base 1.0.35
+ seq_findSeqByAccId at Base 1.0.35
+ seq_getNext at Base 1.0.35
+ seq_printSeqs at Base 1.0.35
+ seq_readAllSeq2 at Base 1.0.35
+ seq_readNextFromFilebyLine at Base 1.0.35
+ sortSeqsWithCounts at Base 1.0.35
+ sse_banded_align_just_lcs at Base 1.0.35
+ sse_banded_align_lcs_and_ali_len at Base 1.0.35
+ sse_banded_lcs_align at Base 1.0.35
+ store_in_field at Base 1.0.35
+ store_in_header_table at Base 1.0.35
+ str_chopAtDelim at Base 1.0.35
+ str_isSpace at Base 1.0.35
+ str_removeSpaces at Base 1.0.35
+ str_sepNameValue at Base 1.0.35
+ str_strrstr at Base 1.0.35
+ table_header_add_field at Base 1.0.35
+ threshold4 at Base 1.0.35
+ thresholdLCS4 at Base 1.0.35
+ uniqSeqsVector at Base 1.0.35
+ util_findInArr at Base 1.0.35
+ util_free at Base 1.0.35
+ util_malloc at Base 1.0.35
+ util_realloc at Base 1.0.35


=====================================
debian/patches/fix_makefile.patch deleted
=====================================
@@ -1,12 +0,0 @@
-Author: Andreas Tille <tille at debian.org>
-Last-Update: Tue, 09 Jul 2019 15:59:36 +0200
-Description: Do not force PREFIX to /usr/local
-
---- a/Makefile
-+++ b/Makefile
-@@ -1,4 +1,4 @@
--PREFIX=/usr/local
-+PREFIX=/usr
- 
- SOURCES = libfasta/fasta_header_parser.c \
- 		  libfasta/fasta_seq_writer.c \


=====================================
debian/patches/series
=====================================
@@ -1 +1 @@
-fix_makefile.patch
+using_cmake.patch


=====================================
debian/patches/using_cmake.patch
=====================================
@@ -0,0 +1,131 @@
+Description: Using CMake instead of original Makefile
+ Upstream provides a Makefile. In order to build both a shared and a static 
+ library, we use a construction with CMake.
+Author: Pierre Gruet <pgtdebian at free.fr>
+Last-Update: 2020-04-13
+
+--- /dev/null
++++ b/CMakeLists.txt
+@@ -0,0 +1,63 @@
++cmake_minimum_required(VERSION 3.16)
++project(sumalibs)
++
++set(CMAKE_INSTALL_PREFIX "/usr")
++
++include_directories(include)
++
++file(GLOB_RECURSE
++        lib_files
++        libfasta/*.c
++        libfile/fileHandling.c
++        liblcs/sse_banded_LCS_alignment.c
++        liblcs/upperband.c
++        libutils/*.c
++)
++
++add_library(suma
++        SHARED
++        ${lib_files}
++)
++
++target_include_directories(suma PUBLIC
++        libfasta/
++        libfile/
++        liblcs/
++        libutils/
++        libsse/
++)
++
++set_target_properties(suma PROPERTIES
++        VERSION ${VERSION}
++        SOVERSION ${SOVERSION}
++)
++
++add_library(sumaa
++        STATIC
++        ${lib_files}
++)
++
++target_include_directories(sumaa PUBLIC
++        libfasta/
++        libfile/
++        liblcs/
++        libutils/
++        libsse/
++)
++
++set_target_properties(sumaa PROPERTIES
++        OUTPUT_NAME suma
++)
++
++set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -O3 -w -g")
++
++install(TARGETS suma DESTINATION "lib/${CMAKE_LIBRARY_ARCHITECTURE}")
++install(TARGETS sumaa DESTINATION "lib/${CMAKE_LIBRARY_ARCHITECTURE}")
++install(DIRECTORY
++        libfasta
++        libfile
++        liblcs
++        libutils
++        libsse
++        DESTINATION include
++        FILES_MATCHING PATTERN "*.h")
+--- a/Makefile
++++ /dev/null
+@@ -1,56 +0,0 @@
+-PREFIX=/usr/local
+-
+-SOURCES = libfasta/fasta_header_parser.c \
+-		  libfasta/fasta_seq_writer.c \
+-		  libfasta/fasta_header_handler.c \
+-		  libfasta/header_mem_handler.c \
+-          libfasta/sequence.c \
+-          libfile/fileHandling.c \
+-          liblcs/sse_banded_LCS_alignment.c \
+-		  liblcs/upperband.c \
+-		  libutils/utilities.c \
+-          libutils/debug.c  
+-                   
+-SRCS=$(SOURCES)
+-         
+-OBJECTS= $(patsubst %.c,%.o,$(SOURCES))
+-
+-LIBFILE = libsuma.a
+-
+-RANLIB = ranlib
+-
+-CC=gcc
+-
+-LDFLAGS=
+-
+-CFLAGS = -O3 -w
+-
+-default: all
+-
+-all: $(LIBFILE)
+-
+-%.o: %.c
+-	$(CC) $(CFLAGS) -c -o $@ $< $(LIB)
+-
+-libfasta/fasta_header_parser.c: libfasta/fasta_header_parser.l
+-	flex -Pheader_yy -t $< > $@
+-
+-libfasta/dic_parser.c: libfasta/dic_parser.l
+-	lex -Phashtable_yy -t $< > $@
+-
+-clean:
+-	rm -rf $(OBJECTS) $(LIBFILE)
+-
+-$(LIBFILE): $(OBJECTS)
+-	ar -cr $@ $?
+-	$(RANLIB) $@
+-
+-install: all
+-	install -d $(DESTDIR)$(PREFIX)/lib/
+-	install -m 644 $(LIBFILE) $(DESTDIR)$(PREFIX)/lib/
+-	install -d $(DESTDIR)$(PREFIX)/include/
+-	for lib in libfasta liblcs libsse libutils libfile ; do \
+-		install -d $(DESTDIR)$(PREFIX)/include/$$lib ; \
+-		cp $$lib/*.h $(DESTDIR)$(PREFIX)/include/$$lib ; \
+-	done
+-


=====================================
debian/rules
=====================================
@@ -5,10 +5,31 @@ export LC_ALL=C.UTF-8
 
 include /usr/share/dpkg/default.mk
 
+export DEB_BUILD_MAINT_OPTIONS=hardening=+all
+DPKG_EXPORT_BUILDFLAGS = 1
+include /usr/share/dpkg/buildflags.mk
+CFLAGS+=$(CPPFLAGS)
+CXXFLAGS+=$(CPPFLAGS)
+
+#Set VERSION and SOVERSION
+VERSION=1.0
+SOVERSION=1
+
 %:
 	dh $@
 
-override_dh_install:
-	dh_install
-	mkdir debian/libsuma-dev/usr/lib/$(DEB_HOST_MULTIARCH)
-	mv debian/libsuma-dev/usr/lib/*.a debian/libsuma-dev/usr/lib/$(DEB_HOST_MULTIARCH)
+override_dh_auto_configure:
+	dh_auto_configure -- \
+		-DCMAKE_LIBRARY_ARCHITECTURE="$(DEB_HOST_MULTIARCH)" \
+		-DVERSION="$(VERSION)" \
+		-DSOVERSION="$(SOVERSION)"
+
+override_dh_clean:
+	dh_clean
+	-rm -rf $(CURDIR)/debian/tmp
+	-rm -rf $(CURDIR)/debian/libsuma1
+	-rm -rf $(CURDIR)/debian/libsuma-dev
+	-rm -rf $(CURDIR)/debian/*debhelper*
+	-rm $(CURDIR)/debian/*.substvars
+	-rm $(CURDIR)/debian/files
+	-rm -rf $(CURDIR)/obj-$(DEB_HOST_MULTIARCH)


=====================================
debian/tests/buildAndSimpleRun
=====================================
@@ -0,0 +1,48 @@
+#!/bin/sh
+# autopkgtest check: build and run a program against sumalibs. We check that 
+# it builds and that it behaves well on a very simple reading exercise.
+# (C) 2020 Pierre Gruet.
+# Author: Pierre Gruet <pgtdebian at free.fr>
+
+set -e
+
+WORKDIR=$(mktemp -d)
+trap "rm -rf $WORKDIR" 0 INT QUIT ABRT PIPE TERM
+cd $WORKDIR
+
+cat <<EOF > test.fasta
+>SEQ1
+ACGATCGCACGCATCGTCAG
+>SEQ2
+ACGTAGCTAGCA
+EOF
+
+cat <<EOF > main.c
+#include <stdio.h>
+#include <libfasta/sequence.h>
+
+int main()
+{
+        fastaSeqCount n;
+        n=seq_readAllSeq2("test.fasta", 1, 1);
+        printf("%d sequences are read\n", n.count);
+        
+        return 0;
+}
+EOF
+
+gcc -c -o main.o main.c
+gcc -o testPrg main.o -lsuma
+
+echo "Build done"
+
+if [ -x testPrg ]; then
+  ./testPrg |
+  sed -n 's/.sequences.*//p' |
+  grep "2"
+  
+  if [ $? -ne 0 ]; then
+    exit 1
+  fi
+fi
+


=====================================
debian/tests/control
=====================================
@@ -0,0 +1,2 @@
+Tests: buildAndSimpleRun
+Depends: @, build-essential


=====================================
debian/tests/run-unit-test
=====================================
@@ -0,0 +1,25 @@
+#!/bin/bash
+set -e
+
+pkg=libsuma-dev
+
+export LC_ALL=C.UTF-8
+if [ "${AUTOPKGTEST_TMP}" = "" ] ; then
+  AUTOPKGTEST_TMP=$(mktemp -d /tmp/${pkg}-test.XXXXXX)
+  # Double quote below to expand the temporary directory variable now versus
+  # later is on purpose.
+  # shellcheck disable=SC2064
+  trap "rm -rf ${AUTOPKGTEST_TMP}" 0 INT QUIT ABRT PIPE TERM
+fi
+
+cp -a /usr/share/doc/${pkg}/examples/* "${AUTOPKGTEST_TMP}"
+
+cd "${AUTOPKGTEST_TMP}"
+
+sh buildAndSimpleRun
+if [ $? -eq 0 ]; then
+  echo "Test buildAndSimpleRun PASSED"
+else
+  echo "Test buildAndSimpleRun FAILED"
+fi
+


=====================================
libfasta/sequence.c
=====================================
@@ -162,19 +162,24 @@ void seq_fillSeqOnlyATGC(char *seq, fastaSeqPtr seqElem, int seqLen)
 {
 	char* seqTemp;
 	char c;
-	int32_t index = 0, seqIndex = 0, len = strlen(seq);
+	int32_t index = 1, seqIndex = 0, len = strlen(seq);
 	char* seqAlphabets = "acgtACGT";
 	int notAllATGC = 0;
+	int goOnParsing = 1;
 
 	seqTemp = (char*) util_malloc(seqLen*sizeof(char), __FILE__, __LINE__);
 
-	while (index < len)
+	while (goOnParsing)
 	{
 		c = seq[index++];
 		if (strchr(seqAlphabets, c) != NULL)
 			seqTemp[seqIndex++] = tolower(c);
+		else if (seq[index+1]=='\0')
+			goOnParsing = 0; // end of the sequence has been reached.
 		else if (c != '\n')
 			notAllATGC = 1;
+		if (index == len)
+			goOnParsing = 0;
 	}
 
 	if (notAllATGC)



View it on GitLab: https://salsa.debian.org/med-team/sumalibs/-/compare/ea09ec9fd34e7a8a5debcdc146a57fad822647ca...1933b1faf6ce40fd4dea3f5bdd3b06a57569504d

-- 
View it on GitLab: https://salsa.debian.org/med-team/sumalibs/-/compare/ea09ec9fd34e7a8a5debcdc146a57fad822647ca...1933b1faf6ce40fd4dea3f5bdd3b06a57569504d
You're receiving this email because of your account on salsa.debian.org.


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://alioth-lists.debian.net/pipermail/debian-med-commit/attachments/20200414/36aa54ca/attachment-0001.html>


More information about the debian-med-commit mailing list