> I haven't had a chance to trace this down exactly, but when Configure tries
> to figure out hostname and domain, it gets some wierd results.
Try the appended patch.
Whoever made the module to figure out host/domain, please tell:
* Why was not `ypmatch' tried before `ypcat'? I've added it.
* Is there an `ypmatch' equivalent for `nidump hosts .' ?
I don't know the `nidump' format either, but I've assumed it's the
same as in /etc/hosts or `ypcat hosts`.
* Any reason why you used
egrep '^domain' | $sed 's/domain../.../'
instead of plain
$sed -n 's/^domain.../.../p'
? I removed it.
Problem:
The Configure fragment below fails when the *end* of the initial part of
a hostname matches $myhostname, or if more than one host matches
$myhostname, or if the hostname appears several times with different
domains on the same line, or if $myhostname appears in a comment.
$hostcat >hosts
dflt=.`$awk "/[0-9].*$myhostname/ {for(i=2; i<=NF;i++) print \\\$i}" \
hosts | $sort | $uniq | \
$sed -n -e "s/$myhostname\.\([a-zA-Z_.]\)/\1/p"`
case "$dflt" in
.) echo "(You do not have fully-qualified names in /etc/hosts)"
For example, try the fragment above on this 'hosts' file (ypcat format)
with myhostname=wups:
1.2.3.4 wups wups.ac wups.uk # wups.uk--a strange host
5.6.7.8 foreign-wups.no # just to be nasty
Result:
dflt=".foreign-no
ac
uk
uk--"
Regards,
Hallvard
--- perl5.002beta1/Configure~ Mon Nov 20 16:00:33 1995
+++ perl5.002beta1/Configure Thu Nov 23 12:21:06 1995
@@ -6697,14 +6697,37 @@
*) case "$mydomain" in
'')
- $hostcat >hosts
- dflt=.`$awk "/[0-9].*$myhostname/ {for(i=2; i<=NF;i++) print \\\$i}" \
+ {
+ : If we use NIS, try ypmatch.
+ : Is there some reason why this was not done before?
+ test "X$hostcat" = "Xypcat hosts" &&
+ ypmatch "$myhostname" hosts 2>/dev/null |\
+ $sed -e 's/$/ /' > hosts &&
+ $test -s hosts
+ } || {
+ : Extract only the relevant hosts, reducing file size,
+ : remove comments, insert trailing space for later use.
+ $hostcat | $sed -n -e "s/[ ]*#.*//; s/\$/ /
+ /[ ]$myhostname[ . ]/p" > hosts
+ }
+ tmp_re="[ . ]"
+ $test x`$awk "/[0-9].*[ ]$myhostname$tmp_re/ { sum++ }
+ END { print sum }" hosts` = x1 || tmp_re="[ ]"
+ dflt=.`$awk "/[0-9].*[ ]$myhostname$tmp_re/ {for(i=2; i<=NF;i++) print \\\$i}" \
hosts | $sort | $uniq | \
$sed -n -e "s/$myhostname\.\([a-zA-Z_.]\)/\1/p"`
- case "$dflt" in
+ case `$echo X$dflt` in
+ X*\ *) echo "(Several hosts in /etc/hosts matched hostname)"
+ dflt=.
+ ;;
.) echo "(You do not have fully-qualified names in /etc/hosts)"
+ ;;
+ esac
+ case "$dflt" in
+ .)
tans=`./loc resolv.conf X /etc /usr/etc`
if $test -f "$tans"; then
echo "(Attempting domain name extraction from $tans)"
- dflt=.`egrep '^domain' $tans | $sed 's/domain[ ]*\(.*\)/\1/' \
+ : Why was there an Egrep here, when Sed works?
+ dflt=.`$sed -n -e 's/^domain[ ]*\(.*\)/\1/p' $tans \
| ./tr '[A-Z]' '[a-z]' 2>/dev/null`
fi
> to figure out hostname and domain, it gets some wierd results.
Try the appended patch.
Whoever made the module to figure out host/domain, please tell:
* Why was not `ypmatch' tried before `ypcat'? I've added it.
* Is there an `ypmatch' equivalent for `nidump hosts .' ?
I don't know the `nidump' format either, but I've assumed it's the
same as in /etc/hosts or `ypcat hosts`.
* Any reason why you used
egrep '^domain' | $sed 's/domain../.../'
instead of plain
$sed -n 's/^domain.../.../p'
? I removed it.
Problem:
The Configure fragment below fails when the *end* of the initial part of
a hostname matches $myhostname, or if more than one host matches
$myhostname, or if the hostname appears several times with different
domains on the same line, or if $myhostname appears in a comment.
$hostcat >hosts
dflt=.`$awk "/[0-9].*$myhostname/ {for(i=2; i<=NF;i++) print \\\$i}" \
hosts | $sort | $uniq | \
$sed -n -e "s/$myhostname\.\([a-zA-Z_.]\)/\1/p"`
case "$dflt" in
.) echo "(You do not have fully-qualified names in /etc/hosts)"
For example, try the fragment above on this 'hosts' file (ypcat format)
with myhostname=wups:
1.2.3.4 wups wups.ac wups.uk # wups.uk--a strange host
5.6.7.8 foreign-wups.no # just to be nasty
Result:
dflt=".foreign-no
ac
uk
uk--"
Regards,
Hallvard
--- perl5.002beta1/Configure~ Mon Nov 20 16:00:33 1995
+++ perl5.002beta1/Configure Thu Nov 23 12:21:06 1995
@@ -6697,14 +6697,37 @@
*) case "$mydomain" in
'')
- $hostcat >hosts
- dflt=.`$awk "/[0-9].*$myhostname/ {for(i=2; i<=NF;i++) print \\\$i}" \
+ {
+ : If we use NIS, try ypmatch.
+ : Is there some reason why this was not done before?
+ test "X$hostcat" = "Xypcat hosts" &&
+ ypmatch "$myhostname" hosts 2>/dev/null |\
+ $sed -e 's/$/ /' > hosts &&
+ $test -s hosts
+ } || {
+ : Extract only the relevant hosts, reducing file size,
+ : remove comments, insert trailing space for later use.
+ $hostcat | $sed -n -e "s/[ ]*#.*//; s/\$/ /
+ /[ ]$myhostname[ . ]/p" > hosts
+ }
+ tmp_re="[ . ]"
+ $test x`$awk "/[0-9].*[ ]$myhostname$tmp_re/ { sum++ }
+ END { print sum }" hosts` = x1 || tmp_re="[ ]"
+ dflt=.`$awk "/[0-9].*[ ]$myhostname$tmp_re/ {for(i=2; i<=NF;i++) print \\\$i}" \
hosts | $sort | $uniq | \
$sed -n -e "s/$myhostname\.\([a-zA-Z_.]\)/\1/p"`
- case "$dflt" in
+ case `$echo X$dflt` in
+ X*\ *) echo "(Several hosts in /etc/hosts matched hostname)"
+ dflt=.
+ ;;
.) echo "(You do not have fully-qualified names in /etc/hosts)"
+ ;;
+ esac
+ case "$dflt" in
+ .)
tans=`./loc resolv.conf X /etc /usr/etc`
if $test -f "$tans"; then
echo "(Attempting domain name extraction from $tans)"
- dflt=.`egrep '^domain' $tans | $sed 's/domain[ ]*\(.*\)/\1/' \
+ : Why was there an Egrep here, when Sed works?
+ dflt=.`$sed -n -e 's/^domain[ ]*\(.*\)/\1/p' $tans \
| ./tr '[A-Z]' '[a-z]' 2>/dev/null`
fi