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:
parent
aa4669ad17
commit
07b240d4f9
6 changed files with 40 additions and 28 deletions
|
@ -21,7 +21,9 @@
|
|||
|
||||
command=filter
|
||||
|
||||
tmp=/tmp/$command$$
|
||||
TMPDIR=${TMPDIR:-/tmp}
|
||||
export TMPDIR
|
||||
tmp=$TMPDIR/$command$$
|
||||
suf=
|
||||
|
||||
case `(getopts '[-][123:xyz]' opt --xyz; echo 0$opt) 2>/dev/null` in
|
||||
|
|
|
@ -1518,7 +1518,7 @@ require(char* lib, int dontcare)
|
|||
else if (dontcare)
|
||||
{
|
||||
append(tmp, "set -\n");
|
||||
append(tmp, "cd /tmp\n");
|
||||
append(tmp, "cd \"${TMPDIR:-/tmp}\"\n");
|
||||
append(tmp, "echo 'int main(){return 0;}' > x.${!-$$}.c\n");
|
||||
append(tmp, "${CC} ${CCFLAGS} -o x.${!-$$}.x x.${!-$$}.c ");
|
||||
append(tmp, r);
|
||||
|
|
|
@ -197,7 +197,7 @@ esac
|
|||
|
||||
case $info in
|
||||
-) ;;
|
||||
*) tmp=/tmp/mam$$
|
||||
*) tmp=${TMPDIR:-/tmp}/mam$$
|
||||
trap "exec >/dev/null; rm -f $tmp" 0 1 2 3 15
|
||||
exec > $tmp
|
||||
echo "probing C language processor $cc for mam information" >&2
|
||||
|
@ -268,8 +268,8 @@ done
|
|||
case $info in
|
||||
-) ;;
|
||||
*) exec >/dev/null
|
||||
test -f $info && rm -f $info
|
||||
cp $tmp $info
|
||||
chmod -w $info
|
||||
test -f "$info" && rm -f "$info"
|
||||
cp "$tmp" "$info"
|
||||
chmod -w "$info"
|
||||
;;
|
||||
esac
|
||||
|
|
|
@ -58,6 +58,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"
|
||||
|
@ -1782,7 +1785,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 <<!
|
||||
|
@ -1820,7 +1823,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 <<!
|
||||
|
@ -2436,7 +2439,7 @@ int main()
|
|||
esac
|
||||
;;
|
||||
*) pwd=`pwd`
|
||||
cd ${TMPDIR:-/tmp}
|
||||
cd "$TMPDIR"
|
||||
tmp=hi$$
|
||||
trap 'rm -f $tmp.*' 0 1 2
|
||||
cat > $tmp.a.c <<!
|
||||
|
@ -2494,7 +2497,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 <<!
|
||||
|
@ -2847,7 +2850,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
|
||||
|
@ -3049,6 +3052,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
|
||||
|
@ -3213,10 +3218,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
|
||||
;;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue