Your message dated Fri, 25 Dec 2015 19:59:01 -0800
with message-id <[email protected]>
and subject line pysam builds successfully on mipsel - is BD-uninstallable on 
mips
has caused the Debian Bug report #753490,
regarding python-pysam FTBFS on mips/mipsel
to be marked as done.

This means that you claim that the problem has been dealt with.
If this is not the case it is now your responsibility to reopen the
Bug report if necessary, and/or fix the problem forthwith.

(NB: If you are a system administrator and have no idea what this
message is talking about, this may indicate a serious mail system
misconfiguration somewhere. Please contact [email protected]
immediately.)


-- 
753490: http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=753490
Debian Bug Tracking System
Contact [email protected] with problems
--- Begin Message ---
Package: python-pysam
Version: 0.7.7-1
Tags: sid patch
Severity: important
Justification: FTBFS
User: [email protected]
Usertags: mips-patch
Control: block -1 by 753485

While trying to build python-pysam on mips/mipsel, build fails on testing.

Build log for 'python-pysam' on mips:
https://buildd.debian.org/status/fetch.php?pkg=python-pysam&arch=mips&ver=0.7.7-1&stamp=1397894446
Build log for 'python-pysam' on mipsel:
https://buildd.debian.org/status/fetch.php?pkg=python-pysam&arch=mipsel&ver=0.7.7-1&stamp=1397887877

The cause of test failures are issues in both 'samtools' and 'python-pysam' 
packages.

For python-pysam to work samtools has to be fixed first since output of
samtools executable from samtools package is used as a reference
during tests in python-pysam (its output is compared with output from
pysam python module).

python-pysam has unaligned memory access and system endianness related issues 
as well.
I have attached patches that fix this.

With samtools fixed (with solution proposed at
https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=753485), and attached patches
are applied to python-pysam, I have successfully built python-pysam on
mips and mipsel.

Could you consider including these patches?

Best regards,
Aleksandar Zlicic
Index: python-pysam-0.7.7/samtools/bam_import.c.pysam.c
===================================================================
--- python-pysam-0.7.7.orig/samtools/bam_import.c.pysam.c
+++ python-pysam-0.7.7/samtools/bam_import.c.pysam.c
@@ -367,6 +367,9 @@ int sam_read1(tamFile fp, bam_header_t *
 	if (dret != '\n' && dret != '\r') { // aux
 		while (ks_getuntil(ks, KS_SEP_TAB, str, &dret) >= 0) {
 			uint8_t *s, type, key[2];
+			uint8_t tmpData[8];
+			int j;
+
 			z += str->l + 1;
 			if (str->l < 6 || str->s[2] != ':' || str->s[4] != ':')
 				parse_error(fp->n_lines, "missing colon in auxiliary data");
@@ -412,15 +415,35 @@ int sam_read1(tamFile fp, bam_header_t *
 					}
 				}
 			} else if (type == 'f') {
+#ifdef ALLOW_UAC
 				s = alloc_data(b, doff + 5) + doff;
 				*s++ = 'f';
 				*(float*)s = (float)atof(str->s + 5);
 				s += 4; doff += 5;
+#else
+				float *ptmpData = (float*)&tmpData;
+				s = alloc_data(b, doff + 5) + doff;
+				*s++ = 'f';
+				for(j=0;j<4;j++) tmpData[j]=s[j];
+				*ptmpData = (float)atof(str->s + 5);
+				for(j=0;j<4;j++) s[j] = tmpData[j];
+				s += 4; doff += 5;
+				#endif
 			} else if (type == 'd') {
+#ifdef ALLOW_UAC
 				s = alloc_data(b, doff + 9) + doff;
 				*s++ = 'd';
 				*(float*)s = (float)atof(str->s + 9);
 				s += 8; doff += 9;
+#else
+				float *ptmpData = (float*)&tmpData;
+				s = alloc_data(b, doff + 9) + doff;
+				*s++ = 'd';
+				for(j=0;j<8;j++) tmpData[j]=s[j];
+				*ptmpData = (float)atof(str->s + 9);
+				for(j=0;j<8;j++) s[j] = tmpData[j];
+				s += 8; doff += 9;
+#endif
 			} else if (type == 'Z' || type == 'H') {
 				int size = 1 + (str->l - 5) + 1;
 				if (type == 'H') { // check whether the hex string is valid
Index: python-pysam-0.7.7/samtools/bam.h
===================================================================
--- python-pysam-0.7.7.orig/samtools/bam.h
+++ python-pysam-0.7.7/samtools/bam.h
@@ -70,6 +70,12 @@ typedef gzFile bamFile;
 /* no bam_write/bam_tell/bam_seek() here */
 #endif
 
+#if defined(__i386__) || defined(__i386) || defined(__amd64__) || defined(__amd64) || defined(__x86_64__) || defined(__x86_64) || defined(__i686__) || defined(__i686)
+#  define ALLOW_UAC
+#else
+#  undef ALLOW_UAC
+#endif
+
 /*! @typedef
   @abstract Structure for the alignment header.
   @field n_targets   number of reference sequences
Index: python-pysam-0.7.7/samtools/bam_aux.c.pysam.c
===================================================================
--- python-pysam-0.7.7.orig/samtools/bam_aux.c.pysam.c
+++ python-pysam-0.7.7/samtools/bam_aux.c.pysam.c
@@ -180,7 +180,18 @@ float bam_aux2f(const uint8_t *s)
 	int type;
 	type = *s++;
 	if (s == 0) return 0.0;
+#ifdef ALLOW_UAC
 	if (type == 'f') return *(float*)s;
+#else
+	if (type == 'f')
+	{
+	        uint8_t tmpData[4];
+	        int j;
+		float *ptmpData = (float*)&tmpData;
+		for(j=0;j<4;j++) tmpData[j]=s[j];
+		return *ptmpData;
+	}
+#endif
 	else return 0.0;
 }
 
@@ -189,7 +200,19 @@ double bam_aux2d(const uint8_t *s)
 	int type;
 	type = *s++;
 	if (s == 0) return 0.0;
+#ifdef ALLOW_UAC
 	if (type == 'd') return *(double*)s;
+#else
+	if (type == 'd')
+	{
+		uint8_t tmpData[8];
+		int j;
+		double *ptmpData = (double*)&tmpData;
+		for(j=0;j<8;j++) tmpData[j]=s[j];
+		return *ptmpData;
+
+	}
+#endif
 	else return 0.0;
 }

Index: python-pysam-0.7.7/pysam/csamtools.pyx
===================================================================
--- python-pysam-0.7.7.orig/pysam/csamtools.pyx
+++ python-pysam-0.7.7/pysam/csamtools.pyx
@@ -2763,7 +2763,7 @@ cdef class AlignedRead:
 
             src = self._delegate
 
-            fmts, args = ["<"], []
+            fmts, args = ["="], []
             
             if tags != None:
 
Index: python-pysam-0.7.7/samtools/bam.c.pysam.c
===================================================================
--- python-pysam-0.7.7.orig/samtools/bam.c.pysam.c
+++ python-pysam-0.7.7/samtools/bam.c.pysam.c
@@ -159,7 +159,7 @@ int bam_header_write(bamFile fp, const b
 	return 0;
 }
 
-static void swap_endian_data(const bam1_core_t *c, int data_len, uint8_t *data)
+static void swap_endian_data(const bam1_core_t *c, int data_len, uint8_t *data, int is_host)
 {
 	uint8_t *s;
 	uint32_t i, *cigar = (uint32_t*)(data + c->l_qname);
@@ -176,17 +176,19 @@ static void swap_endian_data(const bam1_
 		else if (type == 'Z' || type == 'H') { while (*s) ++s; ++s; }
 		else if (type == 'B') {
 			int32_t n, Bsize = bam_aux_type2size(*s);
+			if(!is_host) bam_swap_endian_4p(s+1);
 			memcpy(&n, s + 1, 4);
 			if (1 == Bsize) {
 			} else if (2 == Bsize) {
-				for (i = 0; i < n; i += 2)
+				for (i = 0; i < n*Bsize; i += 2)
 					bam_swap_endian_2p(s + 5 + i);
 			} else if (4 == Bsize) {
-				for (i = 0; i < n; i += 4)
+				for (i = 0; i < n*Bsize; i += 4)
 					bam_swap_endian_4p(s + 5 + i);
 			}
-			bam_swap_endian_4p(s+1); 
-		}
+			if(is_host) bam_swap_endian_4p(s+1);
+			s += n * Bsize + 4;
+ 		}
 	}
 }
 
@@ -219,7 +221,7 @@ int bam_read1(bamFile fp, bam1_t *b)
 	}
 	if (bam_read(fp, b->data, b->data_len) != b->data_len) return -4;
 	b->l_aux = b->data_len - c->n_cigar * 4 - c->l_qname - c->l_qseq - (c->l_qseq+1)/2;
-	if (bam_is_be) swap_endian_data(c, b->data_len, b->data);
+	if (bam_is_be) swap_endian_data(c, b->data_len, b->data, 0);
 	if (bam_no_B) bam_remove_B(b);
 	return 4 + block_len;
 }
@@ -242,11 +244,11 @@ inline int bam_write1_core(bamFile fp, c
 		for (i = 0; i < 8; ++i) bam_swap_endian_4p(x + i);
 		y = block_len;
 		bam_write(fp, bam_swap_endian_4p(&y), 4);
-		swap_endian_data(c, data_len, data);
+		swap_endian_data(c, data_len, data, 1);
 	} else bam_write(fp, &block_len, 4);
 	bam_write(fp, x, BAM_CORE_SIZE);
 	bam_write(fp, data, data_len);
-	if (bam_is_be) swap_endian_data(c, data_len, data);
+	if (bam_is_be) swap_endian_data(c, data_len, data, 0);
 	return 4 + block_len;
 }
 

--- End Message ---
--- Begin Message ---
Version: 0.8.4+ds-1

I'm closing this bug for the same reason as #753485. pysam builds on
mipsel without issue and has not had a chance to build on mips because
of a missing build-dependency.

I did not pay attention to when the build became successful on mipsel,
so I am labeling this as fixed in the current version of the package.

-- 
Afif Elghraoui | عفيف الغراوي
http://afif.ghraoui.name

--- End Message ---

Reply via email to