1
0
Fork 0
mirror of git://git.code.sf.net/p/cdesktopenv/code synced 2025-03-09 15:50:02 +00:00

src/cmd/INIT: allow compiling on system with noexec /tmp

Some systems disallow executing files in /tmp and there is nothing
regular users can do about it. The build would fail with a
misleading error message about cc being a cross-compiler.

This commit makes the build system consistently use $TMPDIR with
/tmp as a fallback if that variable is not defined. This allows the
user to use another temporary directory with execute permission.

The error message in bin/package is also extended to signal the
possibility of a noexec temp dir.
This commit is contained in:
Martijn Dekker 2020-08-03 23:52:41 +00:00
parent aa4669ad17
commit 07b240d4f9
6 changed files with 40 additions and 28 deletions

View file

@ -59,6 +59,9 @@ esac
LC_ALL=C
export LC_ALL
TMPDIR=${TMPDIR:-/tmp}
export TMPDIR
src="cmd contrib etc lib"
use="/usr/common /exp /usr/local /usr/add-on /usr/addon /usr/tools /usr /opt"
usr="/home"
@ -1783,7 +1786,7 @@ hostinfo() # attribute ...
esac
case $cpu in
0|1) cpu=`(
cd ${TMPDIR:-/tmp}
cd "$TMPDIR"
tmp=hi$$
trap 'rm -f $tmp.*' 0 1 2
cat > $tmp.c <<!
@ -1821,7 +1824,7 @@ int main()
done
case $rating in
[0123456789]*) ;;
*) cd ${TMPDIR:-/tmp}
*) cd "$TMPDIR"
tmp=hi$$
trap 'rm -f $tmp.*' 0 1 2
cat > $tmp.c <<!
@ -2437,7 +2440,7 @@ int main()
esac
;;
*) pwd=`pwd`
cd ${TMPDIR:-/tmp}
cd "$TMPDIR"
tmp=hi$$
trap 'rm -f $tmp.*' 0 1 2
cat > $tmp.a.c <<!
@ -2495,7 +2498,7 @@ int b() { return 0; }
'') case `file /bin/sh 2>/dev/null` in
*universal*64* | *64-bit* | *x86[_-]64*)
pwd=`pwd`
cd ${TMPDIR:-/tmp}
cd "$TMPDIR"
tmp=hi$$
trap 'rm -f $tmp.*' 0 1 2
cat > $tmp.a.c <<!
@ -2848,7 +2851,7 @@ cat $INITROOT/$i.sh
# check if $CC (full path $cc) is a cross compiler
(
cd /tmp || exit 3
cd "$TMPDIR" || exit 3
cp $INITROOT/hello.c pkg$$.c || exit 3
$cc -o pkg$$.exe pkg$$.c > pkg$$.e 2>&1 || {
if $cc -Dnew=old -o pkg$$.exe pkg$$.c > /dev/null 2>&1
@ -3050,6 +3053,8 @@ cat $INITROOT/$i.sh
$EXECTYPE)
echo "$command: $CC: seems to be a cross-compiler" >&2
echo "$command: set HOSTTYPE to something other than the native $EXECTYPE" >&2
echo "$command: If not, your $TMPDIR directory may be mounted without execute permission." >&2
echo "$command: Try exporting TMPDIR as a directory where you can execute binary files." >&2
exit 1
;;
esac
@ -3214,10 +3219,10 @@ cygwin.*)
lose=ntsec
;;
*ntsec*);;
*) exe=/tmp/pkg$$.exe
rm -f $exe
: > $exe
if test -x $exe
*) exe=$TMPDIR/pkg$$.exe
rm -f "$exe"
: > "$exe"
if test -x "$exe"
then lose=ntsec
fi
;;