Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/usr.sbin/postinstall Properly find atf configuration files i...



details:   https://anonhg.NetBSD.org/src/rev/73625770ca1d
branches:  trunk
changeset: 777674:73625770ca1d
user:      jmmv <jmmv%NetBSD.org@localhost>
date:      Wed Feb 29 02:40:28 2012 +0000

description:
Properly find atf configuration files in the source tree.  My previous
change dealt properly with etc.tgz only.  Addresses PR bin/45870.

diffstat:

 usr.sbin/postinstall/postinstall |  59 +++++++++++++++++++++++++++++----------
 1 files changed, 44 insertions(+), 15 deletions(-)

diffs (88 lines):

diff -r 046d838fdfba -r 73625770ca1d usr.sbin/postinstall/postinstall
--- a/usr.sbin/postinstall/postinstall  Tue Feb 28 22:30:44 2012 +0000
+++ b/usr.sbin/postinstall/postinstall  Wed Feb 29 02:40:28 2012 +0000
@@ -1,6 +1,6 @@
 #!/bin/sh
 #
-# $NetBSD: postinstall,v 1.135 2012/02/27 17:56:14 jmmv Exp $
+# $NetBSD: postinstall,v 1.136 2012/02/29 02:40:28 jmmv Exp $
 #
 # Copyright (c) 2002-2008 The NetBSD Foundation, Inc.
 # All rights reserved.
@@ -1598,33 +1598,62 @@
 #
 #      atf
 #
-additem atf "validate the _atf to _tests user/group renaming"
+additem atf "install missing atf configuration files and validate them"
 do_atf()
 {
        [ -n "$1" ] || err 3 "USAGE: do_atf  fix|check"
        op="$1"
        failed=0
 
-       populate_dir "${op}" true \
-               "${SRC_DIR}/etc/atf" "${DEST_DIR}/etc/atf" 644 \
-               NetBSD.conf atf-run.hooks common.conf
+       # Ensure atf configuration files are in place.
+       if find_file_in_dirlist NetBSD.conf "NetBSD.conf" \
+           "${SRC_DIR}/external/bsd/atf/etc/atf" \
+           "${SRC_DIR}/etc/atf"; then
+                       # ${dir} is set by find_file_in_dirlist()
+               populate_dir "${op}" true "${dir}" "${DEST_DIR}/etc/atf" 644 \
+                   NetBSD.conf common.conf || failed=1
+       else
+               failed=1
+       fi
+       if find_file_in_dirlist atf-run.hooks "atf-run.hooks" \
+           "${SRC_DIR}/external/bsd/atf/dist/atf-run/sample" \
+           "${SRC_DIR}/etc/atf"; then
+                       # ${dir} is set by find_file_in_dirlist()
+               populate_dir "${op}" true "${dir}" "${DEST_DIR}/etc/atf" 644 \
+                   atf-run.hooks || failed=1
+       else
+               failed=1
+       fi
 
-       if grep '[^#]*unprivileged-user[ \t]*=.*_atf' \
-               "${DEST_DIR}/etc/atf/common.conf" >/dev/null
+       # Validate the _atf to _tests user/group renaming.
+       if [ -f "${DEST_DIR}/etc/atf/common.conf" ]; then
+               handle_atf_user "${op}" || failed=1
+       else
+               failed=1
+       fi
+
+       return ${failed}
+}
+
+handle_atf_user()
+{
+       local op="$1"
+       local failed=0
+
+       local conf="${DEST_DIR}/etc/atf/common.conf"
+       if grep '[^#]*unprivileged-user[ \t]*=.*_atf' "${conf}" >/dev/null
        then
                if [ "$1" = "fix" ]; then
                        sed -e \
                            "/[^#]*unprivileged-user[\ t]*=/s/_atf/_tests/" \
-                           "${DEST_DIR}/etc/atf/common.conf"\
-                           >"${DEST_DIR}/etc/atf/common.conf.new"
+                           "${conf}" >"${conf}.new"
+                       failed=$(( ${failed} + $? ))
+                       mv "${conf}.new" "${conf}"
                        failed=$(( ${failed} + $? ))
-                       mv "${DEST_DIR}/etc/atf/common.conf.new" \
-                          "${DEST_DIR}/etc/atf/common.conf"
-                       failed=$(( ${failed} + $? ))
+                       msg "Set unprivileged-user=_tests in ${conf}"
                else
-                       msg "unprivileged-user=_atf in" \
-                           "${DEST_DIR}/etc/atf/common.conf" \
-                           "should be _tests"
+                       msg "unprivileged-user=_atf in ${conf} should be" \
+                           "unprivileged-user=_tests"
                        failed=1
                fi
        fi



Home | Main Index | Thread Index | Old Index