Module Name: src
Committed By: uebayasi
Date: Fri Oct 31 07:38:36 UTC 2014
Modified Files:
src/sys/conf: files std
src/tests/usr.bin/config: t_config.sh
src/tests/usr.bin/config/support/conf: files
src/usr.bin/config: config.5 defs.h gram.y main.c scan.l sem.c sem.h
Log Message:
config(1), config(5): Introduce "select"
o Introduce a new selection directive "select" to select an attribute (as a
module) and its dependencies.
o Support "no select" too.
o Stop abusing "options" to select an attribute.
o Bump config(1) version.
To generate a diff of this commit:
cvs rdiff -u -r1.1120 -r1.1121 src/sys/conf/files
cvs rdiff -u -r1.19 -r1.20 src/sys/conf/std
cvs rdiff -u -r1.3 -r1.4 src/tests/usr.bin/config/t_config.sh
cvs rdiff -u -r1.1 -r1.2 src/tests/usr.bin/config/support/conf/files
cvs rdiff -u -r1.24 -r1.25 src/usr.bin/config/config.5
cvs rdiff -u -r1.59 -r1.60 src/usr.bin/config/defs.h
cvs rdiff -u -r1.44 -r1.45 src/usr.bin/config/gram.y
cvs rdiff -u -r1.70 -r1.71 src/usr.bin/config/main.c
cvs rdiff -u -r1.20 -r1.21 src/usr.bin/config/scan.l
cvs rdiff -u -r1.65 -r1.66 src/usr.bin/config/sem.c
cvs rdiff -u -r1.16 -r1.17 src/usr.bin/config/sem.h
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
Modified files:
Index: src/sys/conf/files
diff -u src/sys/conf/files:1.1120 src/sys/conf/files:1.1121
--- src/sys/conf/files:1.1120 Sun Oct 12 04:30:42 2014
+++ src/sys/conf/files Fri Oct 31 07:38:36 2014
@@ -1,7 +1,7 @@
-# $NetBSD: files,v 1.1120 2014/10/12 04:30:42 uebayasi Exp $
+# $NetBSD: files,v 1.1121 2014/10/31 07:38:36 uebayasi Exp $
# @(#)files.newconf 7.5 (Berkeley) 5/10/93
-version 20141010
+version 20141030
#
# device classes
Index: src/sys/conf/std
diff -u src/sys/conf/std:1.19 src/sys/conf/std:1.20
--- src/sys/conf/std:1.19 Fri Oct 10 12:46:32 2014
+++ src/sys/conf/std Fri Oct 31 07:38:36 2014
@@ -1,4 +1,4 @@
-# $NetBSD: std,v 1.19 2014/10/10 12:46:32 uebayasi Exp $
+# $NetBSD: std,v 1.20 2014/10/31 07:38:36 uebayasi Exp $
#
# standard MI 'options'
#
@@ -9,7 +9,9 @@
# Always include "kern" attribute (module). Other attributes don't need to
# depend on "kern".
#
-options KERN
+select kern
+
+select net # XXX Clean up dependency
# the following options are on-by-default to keep
# kernel config file compatibility.
@@ -22,8 +24,6 @@ options COREDUMP # allow processes to co
options AIO # POSIX asynchronous I/O
options MQUEUE # POSIX message queues
-options NET # XXX Clean up dependency
-
#
# Security model.
#
Index: src/tests/usr.bin/config/t_config.sh
diff -u src/tests/usr.bin/config/t_config.sh:1.3 src/tests/usr.bin/config/t_config.sh:1.4
--- src/tests/usr.bin/config/t_config.sh:1.3 Fri Oct 31 04:54:17 2014
+++ src/tests/usr.bin/config/t_config.sh Fri Oct 31 07:38:36 2014
@@ -1,4 +1,4 @@
-# $NetBSD: t_config.sh,v 1.3 2014/10/31 04:54:17 uebayasi Exp $
+# $NetBSD: t_config.sh,v 1.4 2014/10/31 07:38:36 uebayasi Exp $
#
# Copyright (c) 2008, 2010 The NetBSD Foundation, Inc.
# All rights reserved.
@@ -62,6 +62,22 @@ run_and_check_fail()
config -s "${supportdir}" -b "compile/${name}" "${config}"
}
+test_output()
+{
+ local name="${1}"; shift
+ local res=1
+
+ run_and_check_prep "${name}"
+
+ config -s "${supportdir}" -b compile/"${name}" "${config}" >/dev/null &&
+ cd compile/"${name}" &&
+ check_${name} &&
+ cd $OLDPWD &&
+ res=0
+
+ atf_check test $res -eq 0
+}
+
# Defines a test case for config(1).
test_case()
{
@@ -108,7 +124,50 @@ no options UNDEFINED
test_case no_undefined_opt pass \
"Checks that config allows a negation for an undefined options"
+# Attribute selection
+test_case select pass "Attribute selection"
+select_config_str='
+include "../d_min"
+select c
+'
+check_select()
+{
+ local f=Makefile
+
+ grep -q '^a\.o:' $f &&
+ grep -q '^b\.o:' $f &&
+ grep -q '^c\.o:' $f &&
+ :
+}
+select_body() {
+ test_output select
+}
+
+# Attribute negation
+test_case no_select pass "Attribute negation"
+no_select_config_str='
+include "../d_min"
+select c
+no select a
+'
+check_no_select()
+{
+ local f=Makefile
+
+ : >tmp
+ grep -q '^a\.o:' $f >>tmp
+ grep -q '^b\.o:' $f >>tmp
+ grep -q '^c\.o:' $f >>tmp
+
+ [ ! -s tmp ] &&
+ :
+}
+no_select_body() {
+ test_output no_select
+}
+
# Check minimal kernel config(1) output
+test_case min pass "Minimal config"
check_min_files()
{
test -e Makefile &&
@@ -122,7 +181,6 @@ check_min_files()
test -h regress &&
:
}
-
check_min_makefile()
{
local f=Makefile
@@ -136,26 +194,14 @@ check_min_makefile()
[ ! -s tmp.template ] &&
:
}
-
-test_min()
+check_min()
{
- local res=1
-
- run_and_check_prep min
-
- config -s "${supportdir}" -b compile/min "${config}" >/dev/null &&
- cd compile/min &&
check_min_files &&
check_min_makefile &&
- cd $OLDPWD &&
- res=0
-
- atf_check test $res -eq 0
+ :
}
-
-test_case min pass "Minimal config"
min_body() {
- test_min
+ test_output min
}
atf_init_test_cases()
@@ -169,5 +215,7 @@ atf_init_test_cases()
atf_add_test_case deffs_redef
atf_add_test_case undefined_opt
atf_add_test_case no_undefined_opt
+ atf_add_test_case select
+ atf_add_test_case no_select
atf_add_test_case min
}
Index: src/tests/usr.bin/config/support/conf/files
diff -u src/tests/usr.bin/config/support/conf/files:1.1 src/tests/usr.bin/config/support/conf/files:1.2
--- src/tests/usr.bin/config/support/conf/files:1.1 Sat Mar 17 16:33:12 2012
+++ src/tests/usr.bin/config/support/conf/files Fri Oct 31 07:38:36 2014
@@ -24,3 +24,12 @@ device loopbaby
attach loopbaby at loopchild
defpseudo pseudodev: hook
+
+define a
+file a.c a
+
+define b: a
+file b.c b
+
+define c: b
+file c.c c
Index: src/usr.bin/config/config.5
diff -u src/usr.bin/config/config.5:1.24 src/usr.bin/config/config.5:1.25
--- src/usr.bin/config/config.5:1.24 Thu May 29 08:13:17 2014
+++ src/usr.bin/config/config.5 Fri Oct 31 07:38:36 2014
@@ -1,4 +1,4 @@
-.\" $NetBSD: config.5,v 1.24 2014/05/29 08:13:17 wiz Exp $
+.\" $NetBSD: config.5,v 1.25 2014/10/31 07:38:36 uebayasi Exp $
.\"
.\" Copyright (c) 2006, 2007 The NetBSD Foundation.
.\" All rights reserved.
@@ -24,7 +24,7 @@
.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
.\" POSSIBILITY OF SUCH DAMAGE.
.\"
-.Dd May 29, 2014
+.Dd October 30, 2014
.Dt CONFIG 5
.Os
.Sh NAME
@@ -620,8 +620,10 @@ Un-selects the option
If option
.Ar name
has not been previously selected, the statement produces an error.
-.It Oo Ic no Oc Ic file-system Ar name Op , Ar name Op , Ar ...
-Adds or removes support for all the listed file-systems.
+.It Ic file-system Ar name Op , Ar name Op , Ar ...
+Adds support for all the listed file-systems.
+.It Ic no file-system Ar name Op , Ar name Op , Ar ...
+Removes support for all the listed file-systems.
.It Ic config Ar name Ic root on Ar device Oo Ic type Ar fs Oc Op Ic dumps on \
Ar device
Adds
@@ -696,6 +698,10 @@ again.
.It Ic no makeoptions Ar name Op , Ar name Op , Ar ...
Removes one or more definitions from the generated
.Pa Makefile .
+.It Ic select Ar name
+Adds the specified attribute and its dependencies.
+.It Ic no select Ar name
+Removes the specified attribute and all the attributes which depend on it.
.El
.Sh FILES
The files are relative to the kernel source top directory (e.g.,
Index: src/usr.bin/config/defs.h
diff -u src/usr.bin/config/defs.h:1.59 src/usr.bin/config/defs.h:1.60
--- src/usr.bin/config/defs.h:1.59 Wed Oct 29 17:14:50 2014
+++ src/usr.bin/config/defs.h Fri Oct 31 07:38:36 2014
@@ -1,4 +1,4 @@
-/* $NetBSD: defs.h,v 1.59 2014/10/29 17:14:50 christos Exp $ */
+/* $NetBSD: defs.h,v 1.60 2014/10/31 07:38:36 uebayasi Exp $ */
/*
* Copyright (c) 1992, 1993
@@ -107,7 +107,7 @@ extern const char *progname;
* The next two lines define the current version of the config(1) binary,
* and the minimum version of the configuration files it supports.
*/
-#define CONFIG_VERSION 20141010
+#define CONFIG_VERSION 20141030
#define CONFIG_MINVERSION 0
/*
Index: src/usr.bin/config/gram.y
diff -u src/usr.bin/config/gram.y:1.44 src/usr.bin/config/gram.y:1.45
--- src/usr.bin/config/gram.y:1.44 Wed Oct 29 17:14:50 2014
+++ src/usr.bin/config/gram.y Fri Oct 31 07:38:36 2014
@@ -1,5 +1,5 @@
%{
-/* $NetBSD: gram.y,v 1.44 2014/10/29 17:14:50 christos Exp $ */
+/* $NetBSD: gram.y,v 1.45 2014/10/31 07:38:36 uebayasi Exp $ */
/*
* Copyright (c) 1992, 1993
@@ -42,7 +42,7 @@
*/
#include <sys/cdefs.h>
-__RCSID("$NetBSD: gram.y,v 1.44 2014/10/29 17:14:50 christos Exp $");
+__RCSID("$NetBSD: gram.y,v 1.45 2014/10/31 07:38:36 uebayasi Exp $");
#include <sys/types.h>
#include <sys/param.h>
@@ -181,7 +181,7 @@ static struct loclist *namelocvals(const
%token XOBJECT OBSOLETE ON OPTIONS
%token PACKAGE PLUSEQ PREFIX PSEUDO_DEVICE PSEUDO_ROOT
%token ROOT
-%token SINGLE SOURCE
+%token SELECT SINGLE SOURCE
%token TYPE
%token VECTOR VERSION
%token WITH
@@ -705,6 +705,8 @@ selections:
/* One config item. */
selection:
definition
+ | select_attr
+ | select_no_attr
| select_no_filesystems
| select_filesystems
| select_no_makeoptions
@@ -725,6 +727,14 @@ selection:
| select_device_instance
;
+select_attr:
+ SELECT WORD { addattr($2); }
+;
+
+select_no_attr:
+ NO SELECT WORD { delattr($3); }
+;
+
select_no_filesystems:
NO FILE_SYSTEM no_fs_list
;
Index: src/usr.bin/config/main.c
diff -u src/usr.bin/config/main.c:1.70 src/usr.bin/config/main.c:1.71
--- src/usr.bin/config/main.c:1.70 Wed Oct 29 17:14:50 2014
+++ src/usr.bin/config/main.c Fri Oct 31 07:38:36 2014
@@ -1,4 +1,4 @@
-/* $NetBSD: main.c,v 1.70 2014/10/29 17:14:50 christos Exp $ */
+/* $NetBSD: main.c,v 1.71 2014/10/31 07:38:36 uebayasi Exp $ */
/*
* Copyright (c) 1992, 1993
@@ -45,7 +45,7 @@
#endif
#include <sys/cdefs.h>
-__RCSID("$NetBSD: main.c,v 1.70 2014/10/29 17:14:50 christos Exp $");
+__RCSID("$NetBSD: main.c,v 1.71 2014/10/31 07:38:36 uebayasi Exp $");
#ifndef MAKE_BOOTSTRAP
#include <sys/cdefs.h>
@@ -992,13 +992,6 @@ addoption(const char *name, const char *
n = strtolower(name);
(void)ht_insert(selecttab, n, (void *)__UNCONST(n));
CFGDBG(3, "option selected `%s'", n);
-
- /*
- * Select attribute if one exists.
- */
- struct attr *a;
- if ((a = ht_lookup(attrtab, n)) != NULL)
- selectattr(a);
}
void
Index: src/usr.bin/config/scan.l
diff -u src/usr.bin/config/scan.l:1.20 src/usr.bin/config/scan.l:1.21
--- src/usr.bin/config/scan.l:1.20 Wed Oct 29 19:10:18 2014
+++ src/usr.bin/config/scan.l Fri Oct 31 07:38:36 2014
@@ -1,5 +1,5 @@
%{
-/* $NetBSD: scan.l,v 1.20 2014/10/29 19:10:18 christos Exp $ */
+/* $NetBSD: scan.l,v 1.21 2014/10/31 07:38:36 uebayasi Exp $ */
/*
* Copyright (c) 1992, 1993
@@ -42,7 +42,7 @@
*/
#include <sys/cdefs.h>
-__RCSID("$NetBSD: scan.l,v 1.20 2014/10/29 19:10:18 christos Exp $");
+__RCSID("$NetBSD: scan.l,v 1.21 2014/10/31 07:38:36 uebayasi Exp $");
#include <sys/param.h>
#include <errno.h>
@@ -167,6 +167,7 @@ prefix return PREFIX;
pseudo-device return PSEUDO_DEVICE;
pseudo-root return PSEUDO_ROOT;
root return ROOT;
+select return SELECT;
single return SINGLE;
source return SOURCE;
type return TYPE;
Index: src/usr.bin/config/sem.c
diff -u src/usr.bin/config/sem.c:1.65 src/usr.bin/config/sem.c:1.66
--- src/usr.bin/config/sem.c:1.65 Wed Oct 29 17:14:50 2014
+++ src/usr.bin/config/sem.c Fri Oct 31 07:38:36 2014
@@ -1,4 +1,4 @@
-/* $NetBSD: sem.c,v 1.65 2014/10/29 17:14:50 christos Exp $ */
+/* $NetBSD: sem.c,v 1.66 2014/10/31 07:38:36 uebayasi Exp $ */
/*
* Copyright (c) 1992, 1993
@@ -45,7 +45,7 @@
#endif
#include <sys/cdefs.h>
-__RCSID("$NetBSD: sem.c,v 1.65 2014/10/29 17:14:50 christos Exp $");
+__RCSID("$NetBSD: sem.c,v 1.66 2014/10/31 07:38:36 uebayasi Exp $");
#include <sys/param.h>
#include <ctype.h>
@@ -1305,6 +1305,7 @@ remove_devi(struct devi *i)
struct devi *f, *j, **ppi;
struct deva *iba;
+ CFGDBG(5, "removing devi `%s'", i->i_name);
f = ht_lookup(devitab, i->i_name);
if (f == NULL)
panic("remove_devi(): instance %s disappeared from devitab",
@@ -1948,11 +1949,30 @@ split(const char *name, size_t nlen, cha
}
void
+addattr(const char *name)
+{
+ struct attr *a;
+
+ a = refattr(name);
+ selectattr(a);
+}
+
+void
+delattr(const char *name)
+{
+ struct attr *a;
+
+ a = refattr(name);
+ deselectattr(a);
+}
+
+void
selectattr(struct attr *a)
{
struct attrlist *al;
struct attr *dep;
+ CFGDBG(5, "selecting attr `%s'", a->a_name);
for (al = a->a_deps; al != NULL; al = al->al_next) {
dep = al->al_this;
selectattr(dep);
@@ -1962,6 +1982,26 @@ selectattr(struct attr *a)
}
static int
+deselectattrcb2(const char *name1, const char *name2, void *v, void *arg)
+{
+ const char *name = arg;
+
+ if (strcmp(name, name2) == 0)
+ delattr(name1);
+ return 0;
+}
+
+void
+deselectattr(struct attr *a)
+{
+
+ CFGDBG(5, "deselecting attr `%s'", a->a_name);
+ ht_enumerate2(attrdeptab, deselectattrcb2, __UNCONST(a->a_name));
+ (void)ht_remove(selecttab, a->a_name);
+ CFGDBG(3, "attr deselected `%s'", a->a_name);
+}
+
+static int
dumpattrdepcb2(const char *name1, const char *name2, void *v, void *arg)
{
Index: src/usr.bin/config/sem.h
diff -u src/usr.bin/config/sem.h:1.16 src/usr.bin/config/sem.h:1.17
--- src/usr.bin/config/sem.h:1.16 Wed Oct 29 17:14:50 2014
+++ src/usr.bin/config/sem.h Fri Oct 31 07:38:36 2014
@@ -1,4 +1,4 @@
-/* $NetBSD: sem.h,v 1.16 2014/10/29 17:14:50 christos Exp $ */
+/* $NetBSD: sem.h,v 1.17 2014/10/31 07:38:36 uebayasi Exp $ */
/*
* Copyright (c) 1992, 1993
@@ -60,7 +60,10 @@ struct attr *getattr(const char *);
struct attr *refattr(const char *);
int getrefattr(const char *, struct attr **);
void expandattr(struct attr *, void (*)(struct attr *));
+void addattr(const char *);
+void delattr(const char *);
void selectattr(struct attr *);
+void deselectattr(struct attr *);
void dependattrs(void);
void setmajor(struct devbase *, int);
void addconf(struct config *);