Sun Aug 10 07:00:05 2014 UTC ()
Rebase.


(tls)
diff -r1.165 -r1.165.2.1 src/usr.sbin/postinstall/postinstall

cvs diff -r1.165 -r1.165.2.1 src/usr.sbin/postinstall/Attic/postinstall (expand / switch to unified diff)

--- src/usr.sbin/postinstall/Attic/postinstall 2014/03/08 16:36:24 1.165
+++ src/usr.sbin/postinstall/Attic/postinstall 2014/08/10 07:00:04 1.165.2.1
@@ -1,16 +1,16 @@ @@ -1,16 +1,16 @@
1#!/bin/sh 1#!/bin/sh
2# 2#
3# $NetBSD: postinstall,v 1.165 2014/03/08 16:36:24 martin Exp $ 3# $NetBSD: postinstall,v 1.165.2.1 2014/08/10 07:00:04 tls Exp $
4# 4#
5# Copyright (c) 2002-2008 The NetBSD Foundation, Inc. 5# Copyright (c) 2002-2008 The NetBSD Foundation, Inc.
6# All rights reserved. 6# All rights reserved.
7# 7#
8# This code is derived from software contributed to The NetBSD Foundation 8# This code is derived from software contributed to The NetBSD Foundation
9# by Luke Mewburn. 9# by Luke Mewburn.
10# 10#
11# Redistribution and use in source and binary forms, with or without 11# Redistribution and use in source and binary forms, with or without
12# modification, are permitted provided that the following conditions 12# modification, are permitted provided that the following conditions
13# are met: 13# are met:
14# 1. Redistributions of source code must retain the above copyright 14# 1. Redistributions of source code must retain the above copyright
15# notice, this list of conditions and the following disclaimer. 15# notice, this list of conditions and the following disclaimer.
16# 2. Redistributions in binary form must reproduce the above copyright 16# 2. Redistributions in binary form must reproduce the above copyright
@@ -48,26 +48,28 @@ @@ -48,26 +48,28 @@
48# and real failures 48# and real failures
49# - install moduli into usr/share/examples/ssh and use from there? 49# - install moduli into usr/share/examples/ssh and use from there?
50# - differentiate between "needs fix" versus "can't fix" issues 50# - differentiate between "needs fix" versus "can't fix" issues
51# 51#
52 52
53# This script is executed as part of a cross build. Allow the build 53# This script is executed as part of a cross build. Allow the build
54# environment to override the locations of some tools. 54# environment to override the locations of some tools.
55: ${AWK:=awk} 55: ${AWK:=awk}
56: ${DB:=db} 56: ${DB:=db}
57: ${GREP:=grep} 57: ${GREP:=grep}
58: ${HOST_SH:=sh} 58: ${HOST_SH:=sh}
59: ${MAKE:=make} 59: ${MAKE:=make}
60: ${PWD_MKDB:=/usr/sbin/pwd_mkdb} 60: ${PWD_MKDB:=/usr/sbin/pwd_mkdb}
 61: ${SED:=sed}
 62: ${SORT:=sort}
61: ${STAT:=stat} 63: ${STAT:=stat}
62 64
63# 65#
64# helper functions 66# helper functions
65# 67#
66 68
67err() 69err()
68{ 70{
69 exitval=$1 71 exitval=$1
70 shift 72 shift
71 echo 1>&2 "${PROGNAME}: $*" 73 echo 1>&2 "${PROGNAME}: $*"
72 if [ -n "${SCRATCHDIR}" ]; then 74 if [ -n "${SCRATCHDIR}" ]; then
73 /bin/rm -rf "${SCRATCHDIR}" 75 /bin/rm -rf "${SCRATCHDIR}"
@@ -100,42 +102,91 @@ mkdtemp() @@ -100,42 +102,91 @@ mkdtemp()
100 _serial=$((${_serial} + 1)) 102 _serial=$((${_serial} + 1))
101 done 103 done
102 echo "${_dir}" 104 echo "${_dir}"
103} 105}
104 106
105# Quote args to make them safe in the shell. 107# Quote args to make them safe in the shell.
106# Usage: quotedlist="$(shell_quote args...)" 108# Usage: quotedlist="$(shell_quote args...)"
107# 109#
108# After building up a quoted list, use it by evaling it inside 110# After building up a quoted list, use it by evaling it inside
109# double quotes, like this: 111# double quotes, like this:
110# eval "set -- $quotedlist" 112# eval "set -- $quotedlist"
111# or like this: 113# or like this:
112# eval "\$command $quotedlist \$filename" 114# eval "\$command $quotedlist \$filename"
 115#
113shell_quote() 116shell_quote()
114{ 117{(
115 local result='' 118 local result=''
116 local arg 119 local arg qarg
 120 LC_COLLATE=C ; export LC_COLLATE # so [a-zA-Z0-9] works in ASCII
117 for arg in "$@" ; do 121 for arg in "$@" ; do
118 # Append a space if necessary 122 case "${arg}" in
119 result="${result}${result:+ }" 123 '')
120 # Convert each embedded ' to '\'', 124 qarg="''"
121 # then insert ' at the beginning of the first line, 125 ;;
122 # and append ' at the end of the last line. 126 *[!-./a-zA-Z0-9]*)
123 result="${result}$(printf "%s\n" "$arg" | \ 127 # Convert each embedded ' to '\'',
124 sed -e "s/'/'\\\\''/g" -e "1s/^/'/" -e "\$s/\$/'/")" 128 # then insert ' at the beginning of the first line,
 129 # and append ' at the end of the last line.
 130 # Finally, elide unnecessary '' pairs at the
 131 # beginning and end of the result and as part of
 132 # '\'''\'' sequences that result from multiple
 133 # adjacent quotes in he input.
 134 qarg="$(printf "%s\n" "$arg" | \
 135 ${SED:-sed} -e "s/'/'\\\\''/g" \
 136 -e "1s/^/'/" -e "\$s/\$/'/" \
 137 -e "1s/^''//" -e "\$s/''\$//" \
 138 -e "s/'''/'/g"
 139 )"
 140 ;;
 141 *)
 142 # Arg is not the empty string, and does not contain
 143 # any unsafe characters. Leave it unchanged for
 144 # readability.
 145 qarg="${arg}"
 146 ;;
 147 esac
 148 result="${result}${result:+ }${qarg}"
125 done 149 done
126 printf "%s\n" "$result" 150 printf "%s\n" "$result"
127} 151)}
128 152
 153# Convert arg $1 to a basic regular expression (as in sed)
 154# that will match the arg. This works by inserting backslashes
 155# before characters that are special in basic regular expressions.
 156# It also inserts backslashes before the extra characters specified
 157# in $2 (which defaults to "/,").
 158# XXX: Does not handle embedded newlines.
 159# Usage: regex="$(bre_quote "${string}")"
 160bre_quote()
 161{
 162 local arg="$1"
 163 local extra="${2-/,}"
 164 printf "%s\n" "${arg}" | ${SED} -e 's/[][^$.*\\'"${extra}"']/\\&/g'
 165}
 166
 167# unprefix dir
 168# Remove any dir prefix from a list of paths on stdin,
 169# and write the result to stdout. Useful for converting
 170# from ${DEST_DIR}/path to /path.
 171#
 172unprefix()
 173{
 174 [ $# -eq 1 ] || err 3 "USAGE: unprefix dir"
 175 local prefix="${1%/}"
 176 prefix="$(bre_quote "${prefix}")"
 177
 178 ${SED} -e "s,^${prefix}/,/,"
 179}
129 180
130# additem item description 181# additem item description
131# Add item to list of supported items to check/fix, 182# Add item to list of supported items to check/fix,
132# which are checked/fixed by default if no item is requested by user. 183# which are checked/fixed by default if no item is requested by user.
133# 184#
134additem() 185additem()
135{ 186{
136 [ $# -eq 2 ] || err 3 "USAGE: additem item description" 187 [ $# -eq 2 ] || err 3 "USAGE: additem item description"
137 defaultitems="${defaultitems}${defaultitems:+ }$1" 188 defaultitems="${defaultitems}${defaultitems:+ }$1"
138 eval desc_$1=\"$2\" 189 eval desc_$1=\"$2\"
139} 190}
140 191
141# adddisableditem item description 192# adddisableditem item description
@@ -438,28 +489,28 @@ file_exists_exact() @@ -438,28 +489,28 @@ file_exists_exact()
438 while [ "${_path}" != "/" ] ; do 489 while [ "${_path}" != "/" ] ; do
439 _dirname="$(dirname "${_path}" 2>/dev/null)" 490 _dirname="$(dirname "${_path}" 2>/dev/null)"
440 _basename="$(basename "${_path}" 2>/dev/null)" 491 _basename="$(basename "${_path}" 2>/dev/null)"
441 ls -fa "${DEST_DIR}${_dirname}" 2> /dev/null \ 492 ls -fa "${DEST_DIR}${_dirname}" 2> /dev/null \
442 | ${GREP} -F -x "${_basename}" >/dev/null \ 493 | ${GREP} -F -x "${_basename}" >/dev/null \
443 || return 1 494 || return 1
444 _path="${_dirname}" 495 _path="${_dirname}"
445 done 496 done
446 return 0 497 return 0
447} 498}
448 499
449# obsolete_paths op 500# obsolete_paths op
450# Obsolete the list of paths provided on stdin. 501# Obsolete the list of paths provided on stdin.
451# Each path is relative to ${DEST_DIR}, and should 502# Each path should start with '/' or './', and
452# be an absolute path or start with `./'. 503# will be interpreted relative to ${DEST_DIR}.
453# 504#
454obsolete_paths() 505obsolete_paths()
455{ 506{
456 [ -n "$1" ] || err 3 "USAGE: obsolete_paths fix|check" 507 [ -n "$1" ] || err 3 "USAGE: obsolete_paths fix|check"
457 op="$1" 508 op="$1"
458 509
459 failed=0 510 failed=0
460 while read ofile; do 511 while read ofile; do
461 if ! file_exists_exact "${ofile}"; then 512 if ! file_exists_exact "${ofile}"; then
462 continue 513 continue
463 fi 514 fi
464 ofile="${DEST_DIR}${ofile#.}" 515 ofile="${DEST_DIR}${ofile#.}"
465 cmd="rm" 516 cmd="rm"
@@ -551,26 +602,57 @@ function checklib(results, line, regex)  @@ -551,26 +602,57 @@ function checklib(results, line, regex)
551 checklib(found, $0, "^lib.*\\.so\\.[0-9]+\\.") 602 checklib(found, $0, "^lib.*\\.so\\.[0-9]+\\.")
552} 603}
553 604
554/^lib.*\.so\.[0-9]+$/ { 605/^lib.*\.so\.[0-9]+$/ {
555 if (AllLibs) 606 if (AllLibs)
556 checklib(major, $0, "^lib.*\\.so\\.") 607 checklib(major, $0, "^lib.*\\.so\\.")
557} 608}
558 609
559#}' 610#}'
560  611
561 ) 612 )
562} 613}
563 614
 615# obsolete_stand dir
 616# Prints the names of all obsolete files and subdirs below the
 617# provided dir. dir should be something like /stand/${MACHINE}.
 618# The input dir and all output paths are interpreted
 619# relative to ${DEST_DIR}.
 620#
 621# Assumes that the numerically largest subdir is current, and all
 622# others are obsolete.
 623#
 624obsolete_stand()
 625{
 626 [ $# -eq 1 ] || err 3 "USAGE: obsolete_stand dir"
 627 local dir="$1"
 628 local subdir
 629
 630 if ! [ -d "${DEST_DIR}/${dir}" ]; then
 631 msg "${DEST_DIR}${dir} doesn't exist; can't check for obsolete files"
 632 return 1
 633 fi
 634
 635 ( cd "${DEST_DIR}${dir}" && ls -1d [0-9]*[0-9]/. ) \
 636 | ${GREP} -v '[^0-9./]' \
 637 | sort -t. -r -k1n -k2n -k3n \
 638 | tail -n +2 \
 639 | while read subdir ; do
 640 subdir="${subdir%/.}"
 641 find "${DEST_DIR}/${dir#/}/${subdir}" -depth -print
 642 done \
 643 | unprefix "${DEST_DIR}"
 644}
 645
564# modify_file op srcfile scratchfile awkprog 646# modify_file op srcfile scratchfile awkprog
565# Apply awkprog to srcfile sending output to scratchfile, and 647# Apply awkprog to srcfile sending output to scratchfile, and
566# if appropriate replace srcfile with scratchfile. 648# if appropriate replace srcfile with scratchfile.
567# 649#
568modify_file() 650modify_file()
569{ 651{
570 [ $# -eq 4 ] || err 3 "USAGE: modify_file op file scratch awkprog" 652 [ $# -eq 4 ] || err 3 "USAGE: modify_file op file scratch awkprog"
571 653
572 _mfop="$1" 654 _mfop="$1"
573 _mffile="$2" 655 _mffile="$2"
574 _mfscratch="$3" 656 _mfscratch="$3"
575 _mfprog="$4" 657 _mfprog="$4"
576 _mffailed=0 658 _mffailed=0
@@ -708,29 +790,29 @@ do_ddbonpanic() @@ -708,29 +790,29 @@ do_ddbonpanic()
708 [ -n "$1" ] || err 3 "USAGE: do_ddbonpanic fix|check" 790 [ -n "$1" ] || err 3 "USAGE: do_ddbonpanic fix|check"
709 791
710 if ${GREP} -E '^#*[[:space:]]*ddb\.onpanic[[:space:]]*\??=[[:space:]]*[[:digit:]]+' \ 792 if ${GREP} -E '^#*[[:space:]]*ddb\.onpanic[[:space:]]*\??=[[:space:]]*[[:digit:]]+' \
711 "${DEST_DIR}/etc/sysctl.conf" >/dev/null 2>&1 793 "${DEST_DIR}/etc/sysctl.conf" >/dev/null 2>&1
712 then 794 then
713 result=0 795 result=0
714 else 796 else
715 if [ "$1" = check ]; then 797 if [ "$1" = check ]; then
716 msg \ 798 msg \
717 "The ddb.onpanic behaviour is not explicitly specified in /etc/sysctl.conf" 799 "The ddb.onpanic behaviour is not explicitly specified in /etc/sysctl.conf"
718 result=1 800 result=1
719 else 801 else
720 echo >> "${DEST_DIR}/etc/sysctl.conf" 802 echo >> "${DEST_DIR}/etc/sysctl.conf"
721 sed < "${SRC_DIR}/etc/sysctl.conf" \ 803 ${SED} < "${SRC_DIR}/etc/sysctl.conf" \
722 -e '/^ddb\.onpanic/q' | \ 804 -e '/^ddb\.onpanic/q' | \
723 sed -e '1,/^$/d' >> \ 805 ${SED} -e '1,/^$/d' >> \
724 "${DEST_DIR}/etc/sysctl.conf" 806 "${DEST_DIR}/etc/sysctl.conf"
725 result=$? 807 result=$?
726 fi 808 fi
727 fi 809 fi
728 return ${result} 810 return ${result}
729} 811}
730 812
731# 813#
732# defaults 814# defaults
733# 815#
734additem defaults "/etc/defaults/ being up to date" 816additem defaults "/etc/defaults/ being up to date"
735do_defaults() 817do_defaults()
736{ 818{
@@ -1026,39 +1108,39 @@ do_makedev() @@ -1026,39 +1108,39 @@ do_makedev()
1026# 1108#
1027additem motd "contents of motd" 1109additem motd "contents of motd"
1028do_motd() 1110do_motd()
1029{ 1111{
1030 [ -n "$1" ] || err 3 "USAGE: do_motd fix|check" 1112 [ -n "$1" ] || err 3 "USAGE: do_motd fix|check"
1031 1113
1032 if ${GREP} -i 'http://www.NetBSD.org/Misc/send-pr.html' \ 1114 if ${GREP} -i 'http://www.NetBSD.org/Misc/send-pr.html' \
1033 "${DEST_DIR}/etc/motd" >/dev/null 2>&1 \ 1115 "${DEST_DIR}/etc/motd" >/dev/null 2>&1 \
1034 || ${GREP} -i 'http://www.NetBSD.org/support/send-pr.html' \ 1116 || ${GREP} -i 'http://www.NetBSD.org/support/send-pr.html' \
1035 "${DEST_DIR}/etc/motd" >/dev/null 2>&1 1117 "${DEST_DIR}/etc/motd" >/dev/null 2>&1
1036 then 1118 then
1037 tmp1="$(mktemp /tmp/postinstall.motd.XXXXXXXX)" 1119 tmp1="$(mktemp /tmp/postinstall.motd.XXXXXXXX)"
1038 tmp2="$(mktemp /tmp/postinstall.motd.XXXXXXXX)" 1120 tmp2="$(mktemp /tmp/postinstall.motd.XXXXXXXX)"
1039 sed '1,2d' <"${SRC_DIR}/etc/motd" >"${tmp1}" 1121 ${SED} '1,2d' <"${SRC_DIR}/etc/motd" >"${tmp1}"
1040 sed '1,2d' <"${DEST_DIR}/etc/motd" >"${tmp2}" 1122 ${SED} '1,2d' <"${DEST_DIR}/etc/motd" >"${tmp2}"
1041 1123
1042 if [ "$1" = check ]; then 1124 if [ "$1" = check ]; then
1043 cmp -s "${tmp1}" "${tmp2}" 1125 cmp -s "${tmp1}" "${tmp2}"
1044 result=$? 1126 result=$?
1045 if [ "${result}" -ne 0 ]; then 1127 if [ "${result}" -ne 0 ]; then
1046 msg \ 1128 msg \
1047 "Bug reporting messages do not seem to match the installed release" 1129 "Bug reporting messages do not seem to match the installed release"
1048 fi 1130 fi
1049 else 1131 else
1050 head -n 2 "${DEST_DIR}/etc/motd" >"${tmp1}" 1132 head -n 2 "${DEST_DIR}/etc/motd" >"${tmp1}"
1051 sed '1,2d' <"${SRC_DIR}/etc/motd" >>"${tmp1}" 1133 ${SED} '1,2d' <"${SRC_DIR}/etc/motd" >>"${tmp1}"
1052 cp "${tmp1}" "${DEST_DIR}/etc/motd" 1134 cp "${tmp1}" "${DEST_DIR}/etc/motd"
1053 result=0 1135 result=0
1054 fi 1136 fi
1055 1137
1056 rm -f "${tmp1}" "${tmp2}" 1138 rm -f "${tmp1}" "${tmp2}"
1057 else 1139 else
1058 result=0 1140 result=0
1059 fi 1141 fi
1060 1142
1061 return ${result} 1143 return ${result}
1062} 1144}
1063 1145
1064# 1146#
@@ -1248,27 +1330,27 @@ do_rc() @@ -1248,27 +1330,27 @@ do_rc()
1248 rtsold rwho \ 1330 rtsold rwho \
1249 savecore screenblank securelevel sshd \ 1331 savecore screenblank securelevel sshd \
1250 staticroute swap1 swap2 sysctl sysdb syslogd \ 1332 staticroute swap1 swap2 sysctl sysdb syslogd \
1251 timed tpctl ttys \ 1333 timed tpctl ttys \
1252 veriexec virecover wdogctl wpa_supplicant wscons wsmoused \ 1334 veriexec virecover wdogctl wpa_supplicant wscons wsmoused \
1253 ypbind yppasswdd ypserv \ 1335 ypbind yppasswdd ypserv \
1254 ${extra_scripts} 1336 ${extra_scripts}
1255 failed=$(( ${failed} + $? )) 1337 failed=$(( ${failed} + $? ))
1256 1338
1257 if $SOURCEMODE && [ -n "${generated_scripts}" ]; then 1339 if $SOURCEMODE && [ -n "${generated_scripts}" ]; then
1258 # generate scripts 1340 # generate scripts
1259 mkdir "${SCRATCHDIR}/rc" 1341 mkdir "${SCRATCHDIR}/rc"
1260 for f in ${generated_scripts}; do 1342 for f in ${generated_scripts}; do
1261 sed -e "s,@X11ROOTDIR@,${X11ROOTDIR},g" \ 1343 ${SED} -e "s,@X11ROOTDIR@,${X11ROOTDIR},g" \
1262 < "${SRC_DIR}/etc/rc.d/${f}.in" \ 1344 < "${SRC_DIR}/etc/rc.d/${f}.in" \
1263 > "${SCRATCHDIR}/rc/${f}" 1345 > "${SCRATCHDIR}/rc/${f}"
1264 done 1346 done
1265 compare_dir "${op}" "${SCRATCHDIR}/rc" \ 1347 compare_dir "${op}" "${SCRATCHDIR}/rc" \
1266 "${DEST_DIR}/etc/rc.d" 555 \ 1348 "${DEST_DIR}/etc/rc.d" 555 \
1267 ${generated_scripts} 1349 ${generated_scripts}
1268 failed=$(( ${failed} + $? )) 1350 failed=$(( ${failed} + $? ))
1269 fi 1351 fi
1270 1352
1271 # check for obsolete rc.d files 1353 # check for obsolete rc.d files
1272 for f in NETWORK btattach btconfig btcontrol btdevctl bthcid btuartd \ 1354 for f in NETWORK btattach btconfig btcontrol btdevctl bthcid btuartd \
1273 fsck.sh kerberos nfsiod sdpd servers \ 1355 fsck.sh kerberos nfsiod sdpd servers \
1274 systemfs daemon gated login poffd portmap sunndd xntpd; do 1356 systemfs daemon gated login poffd portmap sunndd xntpd; do
@@ -1307,31 +1389,33 @@ do_sendmail() @@ -1307,31 +1389,33 @@ do_sendmail()
1307 [ -n "$1" ] || err 3 "USAGE: do_sendmail fix|check" 1389 [ -n "$1" ] || err 3 "USAGE: do_sendmail fix|check"
1308 op="$1" 1390 op="$1"
1309 failed=0 1391 failed=0
1310 1392
1311 # Don't complain if the "sendmail" package is installed because the 1393 # Don't complain if the "sendmail" package is installed because the
1312 # files might still be in use. 1394 # files might still be in use.
1313 if /usr/sbin/pkg_info -qe sendmail >/dev/null 2>&1; then 1395 if /usr/sbin/pkg_info -qe sendmail >/dev/null 2>&1; then
1314 return 0 1396 return 0
1315 fi 1397 fi
1316 1398
1317 for f in /etc/mail/helpfile /etc/mail/local-host-names \ 1399 for f in /etc/mail/helpfile /etc/mail/local-host-names \
1318 /etc/mail/sendmail.cf /etc/mail/submit.cf /etc/rc.d/sendmail \ 1400 /etc/mail/sendmail.cf /etc/mail/submit.cf /etc/rc.d/sendmail \
1319 /etc/rc.d/smmsp /usr/share/misc/sendmail.hf \ 1401 /etc/rc.d/smmsp /usr/share/misc/sendmail.hf \
1320 $(find "${DEST_DIR}/usr/share/sendmail" -type f) \ 1402 $( ( find "${DEST_DIR}/usr/share/sendmail" -type f ; \
1321 $(find "${DEST_DIR}/usr/share/sendmail" -type d) \ 1403 find "${DEST_DIR}/usr/share/sendmail" -type d \
1322 "${DEST_DIR}/var/log/sendmail.st" \ 1404 ) | unprefix "${DEST_DIR}" ) \
1323 "${DEST_DIR}/var/spool/clientmqueue" \ 1405 /var/log/sendmail.st \
1324 "${DEST_DIR}/var/spool/mqueue"; do 1406 /var/spool/clientmqueue \
 1407 /var/spool/mqueue
 1408 do
1325 [ -e "${DEST_DIR}${f}" ] && echo "${f}" 1409 [ -e "${DEST_DIR}${f}" ] && echo "${f}"
1326 done | obsolete_paths "${op}" 1410 done | obsolete_paths "${op}"
1327 failed=$(( ${failed} + $? )) 1411 failed=$(( ${failed} + $? ))
1328 1412
1329 return ${failed} 1413 return ${failed}
1330} 1414}
1331 1415
1332# 1416#
1333# mailerconf 1417# mailerconf
1334# 1418#
1335adddisableditem mailerconf "update /etc/mailer.conf after sendmail removal" 1419adddisableditem mailerconf "update /etc/mailer.conf after sendmail removal"
1336do_mailerconf() 1420do_mailerconf()
1337{ 1421{
@@ -1560,27 +1644,27 @@ ${pcpath} was a directory, should be a f @@ -1560,27 +1644,27 @@ ${pcpath} was a directory, should be a f
1560 _notfixed="" 1644 _notfixed=""
1561 if [ "${op}" = "fix" ]; then 1645 if [ "${op}" = "fix" ]; then
1562 _notfixed="${NOT_FIXED}" 1646 _notfixed="${NOT_FIXED}"
1563 fi 1647 fi
1564 1648
1565 if [ ! -d "${DEST_DIR}${pcpath}" ]; then 1649 if [ ! -d "${DEST_DIR}${pcpath}" ]; then
1566 return 0 1650 return 0
1567 fi 1651 fi
1568 1652
1569 # Delete obsolete files in the directory, and the directory 1653 # Delete obsolete files in the directory, and the directory
1570 # itself. If the directory contains unexpected extra files 1654 # itself. If the directory contains unexpected extra files
1571 # then it will not be deleted. 1655 # then it will not be deleted.
1572 ( [ -f "${DEST_DIR}"/var/db/obsolete/xbase ] \ 1656 ( [ -f "${DEST_DIR}"/var/db/obsolete/xbase ] \
1573 && sort -ru "${DEST_DIR}"/var/db/obsolete/xbase \ 1657 && ${SORT} -ru "${DEST_DIR}"/var/db/obsolete/xbase \
1574 | ${GREP} -E "^\\.?${pcpath}/" ; 1658 | ${GREP} -E "^\\.?${pcpath}/" ;
1575 echo "${pcpath}" ) \ 1659 echo "${pcpath}" ) \
1576 | obsolete_paths "${op}" 1660 | obsolete_paths "${op}"
1577 failed=$(( ${failed} + $? )) 1661 failed=$(( ${failed} + $? ))
1578 1662
1579 # If the directory was removed above, then try to replace it with 1663 # If the directory was removed above, then try to replace it with
1580 # a file. 1664 # a file.
1581 if [ -d "${DEST_DIR}${pcpath}" ]; then 1665 if [ -d "${DEST_DIR}${pcpath}" ]; then
1582 msg "${filemsg}${_notfixed}" 1666 msg "${filemsg}${_notfixed}"
1583 failed=$(( ${failed} + 1 )) 1667 failed=$(( ${failed} + 1 ))
1584 else 1668 else
1585 if ! find_file_in_dirlist pc "${pcpath}" \ 1669 if ! find_file_in_dirlist pc "${pcpath}" \
1586 "${pcsrcdir}" "${SRC_DIR}${pcpath%/*}" 1670 "${pcsrcdir}" "${SRC_DIR}${pcpath%/*}"
@@ -1687,27 +1771,27 @@ do_atf() @@ -1687,27 +1771,27 @@ do_atf()
1687 1771
1688 return ${failed} 1772 return ${failed}
1689} 1773}
1690 1774
1691handle_atf_user() 1775handle_atf_user()
1692{ 1776{
1693 local op="$1" 1777 local op="$1"
1694 local failed=0 1778 local failed=0
1695 1779
1696 local conf="${DEST_DIR}/etc/atf/common.conf" 1780 local conf="${DEST_DIR}/etc/atf/common.conf"
1697 if grep '[^#]*unprivileged-user[ \t]*=.*_atf' "${conf}" >/dev/null 1781 if grep '[^#]*unprivileged-user[ \t]*=.*_atf' "${conf}" >/dev/null
1698 then 1782 then
1699 if [ "$1" = "fix" ]; then 1783 if [ "$1" = "fix" ]; then
1700 sed -e \ 1784 ${SED} -e \
1701 "/[^#]*unprivileged-user[\ t]*=/s/_atf/_tests/" \ 1785 "/[^#]*unprivileged-user[\ t]*=/s/_atf/_tests/" \
1702 "${conf}" >"${conf}.new" 1786 "${conf}" >"${conf}.new"
1703 failed=$(( ${failed} + $? )) 1787 failed=$(( ${failed} + $? ))
1704 mv "${conf}.new" "${conf}" 1788 mv "${conf}.new" "${conf}"
1705 failed=$(( ${failed} + $? )) 1789 failed=$(( ${failed} + $? ))
1706 msg "Set unprivileged-user=_tests in ${conf}" 1790 msg "Set unprivileged-user=_tests in ${conf}"
1707 else 1791 else
1708 msg "unprivileged-user=_atf in ${conf} should be" \ 1792 msg "unprivileged-user=_atf in ${conf} should be" \
1709 "unprivileged-user=_tests" 1793 "unprivileged-user=_tests"
1710 failed=1 1794 failed=1
1711 fi 1795 fi
1712 fi 1796 fi
1713 1797
@@ -1780,26 +1864,31 @@ do_catpages() @@ -1780,26 +1864,31 @@ do_catpages()
1780additem ptyfsoldnodes "remove legacy device nodes when using ptyfs" 1864additem ptyfsoldnodes "remove legacy device nodes when using ptyfs"
1781do_ptyfsoldnodes() 1865do_ptyfsoldnodes()
1782{ 1866{
1783 [ -n "$1" ] || err 3 "USAGE: do_ptyfsoldnodes fix|check" 1867 [ -n "$1" ] || err 3 "USAGE: do_ptyfsoldnodes fix|check"
1784 _ptyfs_op="$1" 1868 _ptyfs_op="$1"
1785 1869
1786 # Check whether ptyfs is in use 1870 # Check whether ptyfs is in use
1787 failed=0; 1871 failed=0;
1788 if ! ${GREP} -E "^ptyfs" "${DEST_DIR}/etc/fstab" > /dev/null; then 1872 if ! ${GREP} -E "^ptyfs" "${DEST_DIR}/etc/fstab" > /dev/null; then
1789 msg "ptyfs is not in use" 1873 msg "ptyfs is not in use"
1790 return 0 1874 return 0
1791 fi 1875 fi
1792 1876
 1877 if [ ! -e "${DEST_DIR}/dev/pts" ]; then
 1878 msg "ptyfs is not properly configured: missing /dev/pts"
 1879 return 1
 1880 fi
 1881
1793 # Find the device major numbers for the pty master and slave 1882 # Find the device major numbers for the pty master and slave
1794 # devices, by parsing the output from "MAKEDEV -s pty0". 1883 # devices, by parsing the output from "MAKEDEV -s pty0".
1795 # 1884 #
1796 # Output from MAKEDEV looks like this: 1885 # Output from MAKEDEV looks like this:
1797 # ./ttyp0 type=char device=netbsd,5,0 mode=666 gid=0 uid=0 1886 # ./ttyp0 type=char device=netbsd,5,0 mode=666 gid=0 uid=0
1798 # ./ptyp0 type=char device=netbsd,6,0 mode=666 gid=0 uid=0 1887 # ./ptyp0 type=char device=netbsd,6,0 mode=666 gid=0 uid=0
1799 # 1888 #
1800 # Output from awk, used in the eval statement, looks like this: 1889 # Output from awk, used in the eval statement, looks like this:
1801 # maj_ptym=6; maj_ptys=5; 1890 # maj_ptym=6; maj_ptys=5;
1802 # 1891 #
1803 eval "$( 1892 eval "$(
1804 ${HOST_SH} "${DEST_DIR}/dev/MAKEDEV" -s pty0 2>/dev/null \ 1893 ${HOST_SH} "${DEST_DIR}/dev/MAKEDEV" -s pty0 2>/dev/null \
1805 | ${AWK} '\ 1894 | ${AWK} '\
@@ -1878,39 +1967,54 @@ do_varshm() @@ -1878,39 +1967,54 @@ do_varshm()
1878 failed=1 1967 failed=1
1879 msg "No /var/shm mount found in ${DEST_DIR}/etc/fstab" 1968 msg "No /var/shm mount found in ${DEST_DIR}/etc/fstab"
1880 elif [ "${op}" = "fix" ]; then 1969 elif [ "${op}" = "fix" ]; then
1881 printf '\ntmpfs\t/var/shm\ttmpfs\trw,-m1777,-sram%%25\n' \ 1970 printf '\ntmpfs\t/var/shm\ttmpfs\trw,-m1777,-sram%%25\n' \
1882 >> "${DEST_DIR}/etc/fstab" 1971 >> "${DEST_DIR}/etc/fstab"
1883 msg "Added tmpfs with 25% ram limit as /var/shm" 1972 msg "Added tmpfs with 25% ram limit as /var/shm"
1884 1973
1885 fi 1974 fi
1886 fi 1975 fi
1887 1976
1888 return ${failed} 1977 return ${failed}
1889} 1978}
1890 1979
 1980#
 1981# obsolete_stand
 1982#
 1983adddisableditem obsolete_stand "remove obsolete files from /stand"
 1984do_obsolete_stand()
 1985{
 1986 [ -n "$1" ] || err 3 "USAGE: do_obsolete_stnd fix|check"
 1987 op="$1"
 1988 failed=0
 1989
 1990 obsolete_stand "/stand/${MACHINE}" | obsolete_paths "${op}"
 1991 failed=$(( ${failed} + $? ))
 1992
 1993 return ${failed}
 1994}
1891 1995
1892# 1996#
1893# obsolete 1997# obsolete
1894# (this item is last to allow other items to move obsolete files) 1998# (this item is last to allow other items to move obsolete files)
1895# 1999#
1896additem obsolete "remove obsolete file sets and minor libraries" 2000additem obsolete "remove obsolete file sets and minor libraries"
1897do_obsolete() 2001do_obsolete()
1898{ 2002{
1899 [ -n "$1" ] || err 3 "USAGE: do_obsolete fix|check" 2003 [ -n "$1" ] || err 3 "USAGE: do_obsolete fix|check"
1900 op="$1" 2004 op="$1"
1901 failed=0 2005 failed=0
1902 2006
1903 sort -ru "${DEST_DIR}"/var/db/obsolete/* | obsolete_paths "${op}" 2007 ${SORT} -ru "${DEST_DIR}"/var/db/obsolete/* | obsolete_paths "${op}"
1904 failed=$(( ${failed} + $? )) 2008 failed=$(( ${failed} + $? ))
1905 2009
1906 ( 2010 (
1907 obsolete_libs /lib 2011 obsolete_libs /lib
1908 obsolete_libs /usr/lib 2012 obsolete_libs /usr/lib
1909 obsolete_libs /usr/lib/i18n 2013 obsolete_libs /usr/lib/i18n
1910 obsolete_libs /usr/X11R6/lib 2014 obsolete_libs /usr/X11R6/lib
1911 obsolete_libs /usr/X11R7/lib 2015 obsolete_libs /usr/X11R7/lib
1912 [ "$MACHINE" = "amd64" ] && obsolete_libs /usr/lib/i386 2016 [ "$MACHINE" = "amd64" ] && obsolete_libs /usr/lib/i386
1913 [ "$MACHINE" = "sparc64" ] && obsolete_libs /usr/lib/sparc 2017 [ "$MACHINE" = "sparc64" ] && obsolete_libs /usr/lib/sparc
1914 ) | obsolete_paths "${op}" 2018 ) | obsolete_paths "${op}"
1915 failed=$(( ${failed} + $? )) 2019 failed=$(( ${failed} + $? ))
1916 2020