1
0
Fork 0
mirror of git://git.code.sf.net/p/cdesktopenv/code synced 2025-02-15 04:32:24 +00:00

Fixes to compile on Solaris variants, NetBSD, and NixOS

Solaris, Illumos distributions, and NetBSD need LDFLAGS set to link
explicitly to libm, otherwise, due to as-yet unknown reasons, the
src/lib/libdll/features/dll fails to write a valid header file and
compilation fails due to unknown identifiers such as Dllscan_t.
This commit adds the flag on those systems.

NixOS is a Linux distro that uses very different paths from the
usual Unix conventions (though it's POSIX compliant), and the
regression tests still needed a lot of tweaks to be compatible.

src/cmd/INIT/package.sh, bin/package:
- On SunOS (Solaris and illumos distros) and NetBSD, add '-lm' to
  LDFLAGS before compiling.

src/cmd/INIT/mamprobe.sh, bin/mamprobe,
src/cmd/INIT/execrate.sh, bin/execrate:
- Instead of only in /bin, /usr/bin, /sbin and /usr/sbin, search
  utilities in the path given by the OS 'getconf PATH', and use the
  user's original $PATH as a fallback.

src/cmd/ksh93/tests/*.sh:
- Miscellaneous portability fixes, mainly elimination of unportable
  hardcoded paths to commands.
- basic.sh: Remove test for 'time' keyword millisecond precision.
  It was racy and could fail depending on system and system load.
This commit is contained in:
Martijn Dekker 2020-08-03 08:57:00 +01:00
parent 5a7bd2c196
commit d3cd4cf906
18 changed files with 102 additions and 42 deletions

7
TODO
View file

@ -4,11 +4,16 @@ ______
Fix regression test failures:
- On OpenBSD, there are 15 locale-related test failures in variables.sh.
- There are many regression test failures on NetBSD.
______
Fix build system:
- ksh does not currently build on NetBSD, AIX, Solaris, or QNX.
- ksh does not currently build on AIX or QNX.
- On NetBSD 9.0, the build fails if /bin/sh is used as $SHELL (the default)
as iffe writes line numbers directly into generated header files. The cause
needs to be investigated. It could be a regression in NetBSD 9.0 sh.
Workaround: bin/package make SHELL=/some/other/shell
- Reimport the removed nmake. It is necessary for changes in Makefiles
to take effect. The machine-generated Mamfiles are now used as a fallback,
but they are not meant to be edited by hand.

View file

@ -27,6 +27,14 @@ esac
command=mamprobe
bins=`
(
userPATH=$PATH
PATH=/run/current-system/sw/bin:/usr/xpg7/bin:/usr/xpg6/bin:/usr/xpg4/bin:/bin:/usr/bin:$PATH
getconf PATH 2>/dev/null && echo "$userPATH" || echo /bin:/usr/bin:/sbin:/usr/sbin:"$userPATH"
) | sed 's/:/ /g'
` || exit
# check the options
opt=
@ -236,7 +244,7 @@ do case $# in
0|1) break ;;
esac
p=$2
for d in /bin /usr/bin /usr/sbin
for d in $bins
do if test -x $d/$p
then p=$d/$p
break

View file

@ -5395,6 +5395,19 @@ license)# all work in $PACKAGESRC/LICENSES
;;
make|view)
# Hack to build on some systems that need an explicit link with libm due to a bug in the build system
case `uname` in
NetBSD | SunOS)
case " $LDFLAGS " in
*" -m "*)
;;
*) LDFLAGS="-lm${LDFLAGS:+ $LDFLAGS}"
export LDFLAGS
;;
esac
;;
esac
cd $PACKAGEROOT
case $package in
'') lic="lib/package/*.lic"

View file

@ -21,7 +21,13 @@
command=execrate
bins='/bin /usr/bin /usr/sbin'
bins=`
(
userPATH=$PATH
PATH=/run/current-system/sw/bin:/usr/xpg7/bin:/usr/xpg6/bin:/usr/xpg4/bin:/bin:/usr/bin:$PATH
getconf PATH 2>/dev/null && echo "$userPATH" || echo /bin:/usr/bin:/sbin:/usr/sbin:"$userPATH"
) | sed 's/:/ /g'
` || exit
case `(getopts '[-][123:xyz]' opt --xyz; echo 0$opt) 2>/dev/null` in
0123) ARGV0="-a $command"

View file

@ -27,6 +27,14 @@ esac
command=mamprobe
bins=`
(
userPATH=$PATH
PATH=/run/current-system/sw/bin:/usr/xpg7/bin:/usr/xpg6/bin:/usr/xpg4/bin:/bin:/usr/bin:$PATH
getconf PATH 2>/dev/null && echo "$userPATH" || echo /bin:/usr/bin:/sbin:/usr/sbin:"$userPATH"
) | sed 's/:/ /g'
` || exit
# check the options
opt=
@ -236,7 +244,7 @@ do case $# in
0|1) break ;;
esac
p=$2
for d in /bin /usr/bin /usr/sbin
for d in $bins
do if test -x $d/$p
then p=$d/$p
break

View file

@ -5394,6 +5394,19 @@ license)# all work in $PACKAGESRC/LICENSES
;;
make|view)
# Hack to build on some systems that need an explicit link with libm due to a bug in the build system
case `uname` in
NetBSD | SunOS)
case " $LDFLAGS " in
*" -m "*)
;;
*) LDFLAGS="-lm${LDFLAGS:+ $LDFLAGS}"
export LDFLAGS
;;
esac
;;
esac
cd $PACKAGEROOT
case $package in
'') lic="lib/package/*.lic"

View file

@ -84,7 +84,7 @@ then [[ ! $(alias -t | grep rm= ) ]] && err_exit 'tracked alias not set'
[[ $(alias -t | grep rm= ) ]] && err_exit 'tracked alias not cleared'
fi
if hash -r 2>/dev/null && [[ ! $(hash) ]]
then PATH=$tmp:/bin:/usr/bin
then PATH=$tmp:$PATH
for i in foo -foo --
do print ':' > $tmp/$i
chmod +x $tmp/$i

View file

@ -492,14 +492,13 @@ typeset -A expect=(
[Mtoupper]='typeset -x -r -u foo'
[R]='typeset -x -r -R 0 foo'
# [R17]='typeset -x -r -R 17 foo' # TODO: outputs '-L 0'
[X]='typeset -x -r -X 32 foo'
[X17]='typeset -x -r -X 17 foo'
[S]='typeset -x -r foo'
[T]='typeset -x -r foo'
[Z]='typeset -x -r -Z 0 -R 0 foo'
# [Z13]='typeset -x -r -Z 13 -R 13 foo' # TODO: outputs 'typeset -x -r -Z 0 -R 0 foo'
)
for flag in a b i i37 l n s u A C E E12 F F12 H L Mtolower Mtoupper R X X17 S T Z
for flag in a b i i37 l n s u A C E E12 F F12 H L Mtolower Mtoupper R X17 S T Z
do unset foo
actual=$(
redirect 2>&1

View file

@ -553,21 +553,7 @@ $SHELL 2> /dev/null -c $'for i;\ndo :;done' || err_exit 'for i ; <newline> not v
) || err_exit "crash when sourcing multiple files (exit status $?)"
# ======
# The time keyword should correctly handle millisecond precision, except
# on older systems that do not support getrusage(2) or gettimeofday(2).
result=$(
TIMEFORMAT=$'\%3R'
redirect 2>&1
set +x
time sleep .002
)
case $result in
0.000 | 0.010)
err_exit "warning: 'time' keyword doesn't support millisecond precision"
let "Errors--" ;;
0.002) ;;
*) err_exit "'time' keyword, millisecond precision: expected 0.002, got $result" ;;
esac
# The time keyword
# A single '%' after a format specifier should not be a syntax
# error (it should be treated as a literal '%').

View file

@ -123,7 +123,7 @@ fi
if [[ ! -w /dev/fd/2 ]]
then err_exit "/dev/fd/2 not open for writing"
fi
sleep .01
sleep 1 # there are still file systems with 1-second timestamp granularity...
> $newer_file
if [[ ! $file -ot $newer_file ]]
then err_exit "$file should be older than $newer_file"

View file

@ -307,7 +307,7 @@ x=$(LC_ALL=debug $SHELL -c 'typeset -L10 x="a<2b|>c";print -r -- "${x}"')
if $SHELL -c "export LC_ALL=en_US.UTF-8; c=$'\342\202\254'; [[ \${#c} == 1 ]]" 2>/dev/null
then LC_ALL=en_US.UTF-8
unset i p1 p2 x
for i in 9 b c d 20 1680 2000 2001 2002 2003 2004 2005 2006 2008 2009 200a 2028 2029 3000 # 1803 2007 202f 205f
for i in 9 b c d 20 2000 2001 2002 2003 2004 2005 2006 2008 2009 200a 2028 2029 3000 # 1680 1803 2007 202f 205f
do if ! eval "[[ \$'\\u[$i]' == [[:space:]] ]]"
then x+=,$i
fi

View file

@ -72,7 +72,7 @@ PATH=$p
[[ $($SHELL -c 'print -r -- "$PATH"') == "$PATH" ]] || err_exit 'export PATH lost in subshell'
cat > bug1 <<- EOF
print print ok > $tmp/ok
/bin/chmod 755 $tmp/ok
command -p chmod 755 $tmp/ok
function a
{
typeset -x PATH=$tmp
@ -207,11 +207,11 @@ got=$(whence $PWD/notfound)
[[ $got == $exp ]] || err_exit "whence \$PWD/$cmd failed -- expected '$exp', got '$got'"
PATH=$d:
cp "$rm" kshrm
command -p cp "$rm" kshrm
if [[ $(whence kshrm) != $PWD/kshrm ]]
then err_exit 'trailing : in pathname not working'
fi
cp "$rm" rm
command -p cp "$rm" rm
PATH=:$d
if [[ $(whence rm) != $PWD/rm ]]
then err_exit 'leading : in pathname not working'
@ -220,9 +220,9 @@ PATH=$d: whence rm > /dev/null
if [[ $(whence rm) != $PWD/rm ]]
then err_exit 'pathname not restored after scoping'
fi
mkdir bin
command -p mkdir bin
print 'print ok' > bin/tst
chmod +x bin/tst
command -p chmod +x bin/tst
if [[ $(PATH=$PWD/bin tst 2>/dev/null) != ok ]]
then err_exit '(PATH=$PWD/bin foo) does not find $PWD/bin/foo'
fi
@ -371,10 +371,14 @@ EOF
x=$(FPATH= PATH=$PWD/bin $SHELL -c ': $(whence less);myfun') 2> /dev/null
[[ $x == myfun ]] || err_exit 'function myfun not found'
cp $(whence -p echo) user_to_group_relationship.hdr.query
command -p cat >user_to_group_relationship.hdr.query <<EOF
#!$SHELL
print -r -- "\$@"
EOF
command -p chmod 755 user_to_group_relationship.hdr.query
FPATH=/foobar:
PATH=$FPATH:$PATH:.
[[ $(user_to_group_relationship.hdr.query foobar) == foobar ]] 2> /dev/null || err_exit 'Cannot execute command with . in name when PATH and FPATH end in :.'
[[ $(user_to_group_relationship.hdr.query foobar) == foobar ]] || err_exit 'Cannot execute command with . in name when PATH and FPATH end in :.'
mkdir -p $tmp/new/bin
mkdir $tmp/new/fun
@ -386,12 +390,14 @@ x=$(whence -p echo 2> /dev/null)
[[ $x == "$tmp/new/bin/echo" ]] || err_exit 'nonexistant FPATH directory in .paths file causes path search to fail'
$SHELL 2> /dev/null <<- \EOF || err_exit 'path search problem with non-existent directories in PATH'
PATH=/usr/nogood1/bin:/usr/nogood2/bin:/bin:/usr/bin
builtin getconf
PATH=$(getconf PATH)
PATH=/dev/null/nogood1/bin:/dev/null/nogood2/bin:$PATH
tail /dev/null && tail /dev/null
EOF
( PATH=/bin:usr/bin
cat << END >/dev/null 2>&1
( PATH=/dev/null
command -p cat << END >/dev/null 2>&1
${.sh.version}
END
) || err_exit '${.sh.xxx} variables causes cat not be found'

View file

@ -493,7 +493,7 @@ p :test-1:
w set +o vi +o emacs
p :test-2:
w true /de\tv/nu\tl\tl
r ^:test-2: true /de\tv/nu\tl\tl\r\n$
r ^:test-2: true (/de\tv/nu\tl\tl|/de v/nu l l)\r\n$
p :test-3:
!

View file

@ -256,7 +256,10 @@ case $SHELL in
*/*) SHELL=$d/$SHELL;;
*) SHELL=$(whence $SHELL);;
esac
PATH=/bin:/usr/bin
PATH=$(
PATH=/run/current-system/sw/bin:/usr/xpg7/bin:/usr/xpg6/bin:/usr/xpg4/bin:/bin:/usr/bin:$PATH
getconf PATH 2>/dev/null || { builtin getconf 2>/dev/null && getconf PATH; }
) || PATH=/bin:/usr/bin
if [[ -d /usr/ucb ]]
then PATH=$PATH:/usr/ucb
fi

View file

@ -442,10 +442,10 @@ let "$? == 256+9" && err_exit 'exit with status > 256 makes shell kill itself'
# and that a signal still causes the exit status to be set to a value > 128
cat >"$tmp/sigtest.sh" <<\EOF
echo begin
sh -c 'kill -9 "$$"'
"$1" -c 'kill -9 "$$"'
EOF
expect=$'^begin\n/.*/sigtest.sh: line 2: [1-9][0-9]*: Killed\n[1-9][0-9]{1,2}$'
actual=$("$SHELL" -c 'ksh "$1"; echo "$?"' x "$tmp/sigtest.sh" 2>&1)
actual=$(LANG=C "$SHELL" -c '"$1" "$2" "$1"; echo "$?"' x "$SHELL" "$tmp/sigtest.sh" 2>&1)
if ! [[ $actual =~ $expect ]]
then [[ $actual == *Killed*Killed* ]] && msg='ksh killed itself' || msg='unexpected output'
err_exit "$msg after child process signal (expected match to $(printf %q "$expect"); got $(printf %q "$actual"))"

View file

@ -238,6 +238,7 @@ foo=$($SHELL <<- ++EOF++
[[ $foo == foobar ]] || err_exit 'trap on exit when last commands is subshell is not triggered'
err=$(
ulimit -n 1024
$SHELL 2>&1 <<- \EOF
date=$(whence -p date)
function foo
@ -333,7 +334,8 @@ done
# Ref.: https://github.com/att/ast/issues/478
expect='foo=bar'
actual=$(
foo=$(print `/bin/echo bar`) # should print nothing
bin_echo=${ whence -p echo; } || bin_echo=echo
foo=$(print `"$bin_echo" bar`) # should print nothing
print foo=$foo # should print "foo=bar"
)
[[ $actual == "$expect" ]] \
@ -602,7 +604,7 @@ trap ERR ERR
[[ $(trap -p) == *ERR* ]] || err_exit 'trap -p in subshell does not contain ERR'
trap - USR1 ERR
( PATH=/bin:/usr/bin
( builtin getconf && PATH=$(getconf PATH)
dot=$(cat <<-EOF
$(ls -d .)
EOF

View file

@ -745,7 +745,7 @@ do exp="$cmd ok"
rm -f $cmd
print print $exp > glean/$cmd
chmod +x glean/$cmd
got=$(set +x; CDPATH=:.. $SHELL -c "PATH=:/bin:/usr/bin; date > /dev/null; cd glean && ./$cmd" 2>&1)
got=$(set +x; CDPATH=:.. $SHELL -c "command -p date > /dev/null; cd glean && ./$cmd" 2>&1)
[[ $got == "$exp" ]] || err_exit "cd with CDPATH after PATH change failed -- expected '$exp', got '$got'"
done

View file

@ -333,7 +333,17 @@ $cc -E $tmp.c >/dev/null 2>&1 || systeminfo=
CONF_getconf=
CONF_getconf_a=
for d in /usr/bin /bin /usr/sbin /sbin
IFS=':'; set -f
for d in \
/run/current-system/sw/bin \
/usr/xpg7/bin \
/usr/xpg6/bin \
/usr/xpg4/bin \
/usr/bin \
/bin \
/usr/sbin \
/sbin \
$PATH
do if test -x $d/getconf
then case `$d/getconf --?-version 2>&1` in
*"AT&T"*"Research"*)
@ -348,6 +358,7 @@ do if test -x $d/getconf
break
fi
done
IFS=$ifs; set +f
export CONF_getconf CONF_getconf_a
case $verbose in