Source-Changes-HG archive

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

[src/netbsd-6]: src/usr.sbin/postinstall Pull up following revision(s) (reque...



details:   https://anonhg.NetBSD.org/src/rev/4f0ab10bb5df
branches:  netbsd-6
changeset: 774334:4f0ab10bb5df
user:      riz <riz%NetBSD.org@localhost>
date:      Mon Jul 16 22:08:03 2012 +0000

description:
Pull up following revision(s) (requested by jmmv in ticket #419):
        usr.sbin/postinstall/postinstall: revision 1.136
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 |  54 +++++++++++++++++++++++++++++++--------
 1 files changed, 43 insertions(+), 11 deletions(-)

diffs (84 lines):

diff -r 4375563309e6 -r 4f0ab10bb5df usr.sbin/postinstall/postinstall
--- a/usr.sbin/postinstall/postinstall  Mon Jul 16 22:04:45 2012 +0000
+++ b/usr.sbin/postinstall/postinstall  Mon Jul 16 22:08:03 2012 +0000
@@ -1,6 +1,6 @@
 #!/bin/sh
 #
-# $NetBSD: postinstall,v 1.129.2.6 2012/06/11 23:09:24 riz Exp $
+# $NetBSD: postinstall,v 1.129.2.7 2012/07/16 22:08:03 riz Exp $
 #
 # Copyright (c) 2002-2008 The NetBSD Foundation, Inc.
 # All rights reserved.
@@ -1595,30 +1595,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 ${DEST_DIR}/etc/atf/common.conf.new ${DEST_DIR}/etc/atf/common.conf
+                       mv "${conf}.new" "${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