Bug 154503

Summary: [patch] math/lp_solve: respect TMPDIR
Product: Ports & Packages Reporter: Eygene Ryabinkin <rea>
Component: Individual Port(s)Assignee: Eygene Ryabinkin <rea>
Status: Closed FIXED    
Severity: Affects Only Me    
Priority: Normal    
Version: Latest   
Hardware: Any   
OS: Any   

Description Eygene Ryabinkin freebsd_committer freebsd_triage 2011-02-04 09:00:20 UTC
Currently, the ccc script for lp_solve hardcodes the temporary
directory to /tmp and tries to run some compiled binaries from
there to determine the system and its properties.

This fails on the /tmp that lies on the noexec filesystem and
port installation breaks (build is still fine, at least on amd64).

Fix: The following patch fixes the problem for me:


It also passes Tinderbox testing,
 * http://gpf.codelabs.ru/tb-logs/mine-7/lp_solve-5.5.0.15_1.log
 * http://gpf.codelabs.ru/tb-logs/mine-8/lp_solve-5.5.0.15_1.log
 * http://gpf.codelabs.ru/tb-logs/mine-9/lp_solve-5.5.0.15_1.log
so no users that have no TMPDIR set should be harmed.--Hlo5YajzZARu9Mapjwb81IhP8FZaltGY3BFe5hpfkXk2qsWq
Content-Type: text/plain; name="respect-TMPDIR.diff"
Content-Transfer-Encoding: 7bit
Content-Disposition: attachment; filename="respect-TMPDIR.diff"

From 49a815820c11a3bc39e88ef95025b97c5b5b634c Mon Sep 17 00:00:00 2001
From: Eygene Ryabinkin <rea-fbsd@codelabs.ru>
Date: Fri, 4 Feb 2011 11:22:22 +0300

Some People (TM) are using non-executable /tmp on their machines.
The ccc utility from the port tries to run compiled executables
from /tmp, so this fails and port installation does not work.

It is always good to respect TMPDIR and this patch does just that.

Signed-off-by: Eygene Ryabinkin <rea-fbsd@codelabs.ru>
---
 math/lp_solve/Makefile                   |   10 ++-
 math/lp_solve/files/patch-respect-TMPDIR |   98 ++++++++++++++++++++++++++++++
 2 files changed, 105 insertions(+), 3 deletions(-)
 create mode 100644 math/lp_solve/files/patch-respect-TMPDIR

diff --git a/math/lp_solve/Makefile b/math/lp_solve/Makefile
index 8e7d652..7922fe8 100644
--- a/math/lp_solve/Makefile
+++ b/math/lp_solve/Makefile
@@ -19,6 +19,10 @@ WRKSRC=		${WRKDIR}/${PORTNAME}_${PORTVERSION:R:R}
 
 USE_LDCONFIG=	yes
 
+.if defined(TMPDIR)
+BUILDENV=	${ENV} TMPDIR="${TMPDIR}"
+.endif
+
 .include <bsd.port.pre.mk>
 
 .if ${ARCH} == "i386"
@@ -39,9 +43,9 @@ post-patch:
 		 s|-ldl||g"
 
 do-build:
-	cd ${WRKSRC}/lp_solve  ; ${SH} -x ccc
-	cd ${WRKSRC}/demo      ; ${SH} -x ccc
-	cd ${WRKSRC}/lpsolve55 ; ${SH} -x ccc
+	cd ${WRKSRC}/lp_solve  ; ${BUILDENV} ${SH} -x ccc
+	cd ${WRKSRC}/demo      ; ${BUILDENV} ${SH} -x ccc
+	cd ${WRKSRC}/lpsolve55 ; ${BUILDENV} ${SH} -x ccc
 
 do-install:
 	${INSTALL_PROGRAM} ${WRKSRC}/lp_solve/bin/${LPSOLVE_ARCH}/lp_solve ${PREFIX}/bin
diff --git a/math/lp_solve/files/patch-respect-TMPDIR b/math/lp_solve/files/patch-respect-TMPDIR
new file mode 100644
index 0000000..0b59af5
--- /dev/null
+++ b/math/lp_solve/files/patch-respect-TMPDIR
@@ -0,0 +1,98 @@
+--- lp_solve/ccc.orig	2009-01-25 21:39:03.000000000 +0300
++++ lp_solve/ccc	2011-02-04 10:52:07.000000000 +0300
+@@ -2,31 +2,33 @@
+ src='../lp_MDO.c ../shared/commonlib.c ../colamd/colamd.c ../shared/mmio.c ../shared/myblas.c ../ini.c ../fortify.c ../lp_rlp.c ../lp_crash.c ../bfp/bfp_LUSOL/lp_LUSOL.c ../bfp/bfp_LUSOL/LUSOL/lusol.c ../lp_Hash.c ../lp_lib.c ../lp_wlp.c ../lp_matrix.c ../lp_mipbb.c ../lp_MPS.c ../lp_params.c ../lp_presolve.c ../lp_price.c ../lp_pricePSE.c ../lp_report.c ../lp_scale.c ../lp_simplex.c lp_solve.c ../lp_SOS.c ../lp_utils.c ../yacc_read.c'
+ c=cc
+ 
++tmp="${TMPDIR:-/tmp}"
++
+ #determine platform (32/64 bit)
+->/tmp/platform.c
+-echo '#include <stdlib.h>'>>/tmp/platform.c
+-echo '#include <stdio.h>'>>/tmp/platform.c
+-echo 'main(){printf("ux%d", (int) (sizeof(void *)*8));}'>>/tmp/platform.c
+-$c /tmp/platform.c -o /tmp/platform
+-PLATFORM=`/tmp/platform`
+-rm /tmp/platform /tmp/platform.c >/dev/null 2>&1
++>"${tmp}"/platform.c
++echo '#include <stdlib.h>'>>"${tmp}"/platform.c
++echo '#include <stdio.h>'>>"${tmp}"/platform.c
++echo 'main(){printf("ux%d", (int) (sizeof(void *)*8));}'>>"${tmp}"/platform.c
++$c "${tmp}"/platform.c -o "${tmp}"/platform
++PLATFORM=`"${tmp}"/platform`
++rm "${tmp}"/platform "${tmp}"/platform.c >/dev/null 2>&1
+ 
+ mkdir bin bin/$PLATFORM >/dev/null 2>&1
+ 
+ math=-lm
+ 
+ #check if this system has the isnan function
+->/tmp/isnan.c
+-echo '#include <stdio.h>'>>/tmp/isnan.c
+-echo '#include <stdlib.h>'>>/tmp/isnan.c
+-echo '#include <math.h>'>>/tmp/isnan.c
+-echo 'main(){isnan(0);}'>>/tmp/isnan.c
+-$c /tmp/isnan.c -o /tmp/isnan $math >/dev/null 2>&1
++>"${tmp}"/isnan.c
++echo '#include <stdio.h>'>>"${tmp}"/isnan.c
++echo '#include <stdlib.h>'>>"${tmp}"/isnan.c
++echo '#include <math.h>'>>"${tmp}"/isnan.c
++echo 'main(){isnan(0);}'>>"${tmp}"/isnan.c
++$c "${tmp}"/isnan.c -o "${tmp}"/isnan $math >/dev/null 2>&1
+ if [ $? = 0 ]
+ then NOISNAN=
+ else NOISNAN=-DNOISNAN
+ fi
+-rm /tmp/isnan.c /tmp/isnan >/dev/null 2>&1
++rm "${tmp}"/isnan.c "${tmp}"/isnan >/dev/null 2>&1
+ 
+ opts='-O3'
+ 
+--- lpsolve55/ccc.bak	2009-03-25 03:27:18.000000000 +0300
++++ lpsolve55/ccc	2011-02-04 11:00:40.000000000 +0300
+@@ -2,29 +2,31 @@
+ src='../lp_MDO.c ../shared/commonlib.c ../shared/mmio.c ../shared/myblas.c ../ini.c ../fortify.c ../colamd/colamd.c ../lp_rlp.c ../lp_crash.c ../bfp/bfp_LUSOL/lp_LUSOL.c ../bfp/bfp_LUSOL/LUSOL/lusol.c ../lp_Hash.c ../lp_lib.c ../lp_wlp.c ../lp_matrix.c ../lp_mipbb.c ../lp_MPS.c ../lp_params.c ../lp_presolve.c ../lp_price.c ../lp_pricePSE.c ../lp_report.c ../lp_scale.c ../lp_simplex.c ../lp_SOS.c ../lp_utils.c ../yacc_read.c'
+ c=cc
+ 
++tmp="${TMPDIR:-/tmp}"
++
+ #determine platform (32/64 bit)
+->/tmp/platform.c
+-echo '#include <stdlib.h>'>>/tmp/platform.c
+-echo '#include <stdio.h>'>>/tmp/platform.c
+-echo 'main(){printf("ux%d", (int) (sizeof(void *)*8));}'>>/tmp/platform.c
+-$c /tmp/platform.c -o /tmp/platform
+-PLATFORM=`/tmp/platform`
+-rm /tmp/platform /tmp/platform.c >/dev/null 2>&1
++>"${tmp}"/platform.c
++echo '#include <stdlib.h>'>>"${tmp}"/platform.c
++echo '#include <stdio.h>'>>"${tmp}"/platform.c
++echo 'main(){printf("ux%d", (int) (sizeof(void *)*8));}'>>"${tmp}"/platform.c
++$c "${tmp}"/platform.c -o "${tmp}"/platform
++PLATFORM=`"${tmp}"/platform`
++rm "${tmp}"/platform "${tmp}"/platform.c >/dev/null 2>&1
+ 
+ mkdir bin bin/$PLATFORM >/dev/null 2>&1
+ 
+ #check if this system has the isnan function
+->/tmp/isnan.c
+-echo '#include <stdio.h>'>>/tmp/isnan.c
+-echo '#include <stdlib.h>'>>/tmp/isnan.c
+-echo '#include <math.h>'>>/tmp/isnan.c
+-echo 'main(){isnan(0);}'>>/tmp/isnan.c
+-$c /tmp/isnan.c -o /tmp/isnan $math >/dev/null 2>&1
++>"${tmp}"/isnan.c
++echo '#include <stdio.h>'>>"${tmp}"/isnan.c
++echo '#include <stdlib.h>'>>"${tmp}"/isnan.c
++echo '#include <math.h>'>>"${tmp}"/isnan.c
++echo 'main(){isnan(0);}'>>"${tmp}"/isnan.c
++$c "${tmp}"/isnan.c -o "${tmp}"/isnan $math >/dev/null 2>&1
+ if [ $? = 0 ]
+ then NOISNAN=
+ else NOISNAN=-DNOISNAN
+ fi
+-rm /tmp/isnan.c /tmp/isnan >/dev/null 2>&1
++rm "${tmp}"/isnan.c "${tmp}"/isnan >/dev/null 2>&1
+ 
+ def=
+ so=
-- 
1.7.3.5
How-To-Repeat: 
Make /tmp to be a filesystem with noexec mount flag set.  Try
to build math/lp_solve.
Comment 1 Edwin Groothuis freebsd_committer freebsd_triage 2011-02-04 09:00:30 UTC
Responsible Changed
From-To: freebsd-ports-bugs->rea

Submitter has GNATS access (via the GNATS Auto Assign Tool)
Comment 2 Edwin Groothuis freebsd_committer freebsd_triage 2011-02-04 09:00:34 UTC
Maintainer of math/lp_solve,

Please note that PR ports/154503 has just been submitted.

If it contains a patch for an upgrade, an enhancement or a bug fix
you agree on, reply to this email stating that you approve the patch
and a committer will take care of it.

The full text of the PR can be found at:
    http://www.freebsd.org/cgi/query-pr.cgi?pr=ports/154503

-- 
Edwin Groothuis via the GNATS Auto Assign Tool
edwin@FreeBSD.org
Comment 3 Edwin Groothuis freebsd_committer freebsd_triage 2011-02-04 09:00:37 UTC
State Changed
From-To: open->feedback

Awaiting maintainers feedback (via the GNATS Auto Assign Tool)
Comment 4 mayo 2011-02-13 08:03:59 UTC
Looks good, please commit it.

(Sorry for the delay, the message got stuck on a misconfigured mail server)

Thank you,
Mayo Jordanov 

On 2011-02-04, at 01:00 , Edwin Groothuis wrote:

> Maintainer of math/lp_solve,
> 
> Please note that PR ports/154503 has just been submitted.
> 
> If it contains a patch for an upgrade, an enhancement or a bug fix
> you agree on, reply to this email stating that you approve the patch
> and a committer will take care of it.
> 
> The full text of the PR can be found at:
>   http://www.freebsd.org/cgi/query-pr.cgi?pr=ports/154503
> 
> -- 
> Edwin Groothuis via the GNATS Auto Assign Tool
> edwin@FreeBSD.org
Comment 5 Eygene Ryabinkin freebsd_committer freebsd_triage 2011-02-14 06:01:00 UTC
Sun, Feb 13, 2011 at 08:20:13AM +0000, Mayo Jordanov wrote:
>  Looks good, please commit it.

Thanks!  Will do once my mentors will approve the changes.

>  (Sorry for the delay, the message got stuck on a misconfigured mail
>  server)

No problems, glad it was resolved ;))
-- 
Eygene Ryabinkin                                        ,,,^..^,,,
[ Life's unfair - but root password helps!           | codelabs.ru ]
[ 82FE 06BC D497 C0DE 49EC  4FF0 16AF 9EAE 8152 ECFB | freebsd.org ]
Comment 6 dfilter service freebsd_committer freebsd_triage 2011-03-04 15:13:57 UTC
rea         2011-03-04 15:13:44 UTC

  FreeBSD ports repository

  Modified files:
    math/lp_solve        Makefile 
  Added files:
    math/lp_solve/files  patch-respect-TMPDIR 
  Log:
  math/lp_solve: respect TMPDIR environment variable
  
  Some People (TM) are using non-executable /tmp on their machines.
  The ccc utility from the port tries to run compiled executables
  from /tmp, so this fails and port installation does not work.
  
  It is always good to respect TMPDIR and this patch does just that.
  
  PR: 154503
  Feature safe: yes
  Approved by: garga (mentor)
  
  Revision  Changes    Path
  1.22      +7 -3      ports/math/lp_solve/Makefile
  1.1       +98 -0     ports/math/lp_solve/files/patch-respect-TMPDIR (new)
_______________________________________________
cvs-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/cvs-all
To unsubscribe, send any mail to "cvs-all-unsubscribe@freebsd.org"
Comment 7 Eygene Ryabinkin freebsd_committer freebsd_triage 2011-03-04 15:29:00 UTC
State Changed
From-To: feedback->closed

Change commited, thanks to everyone!