Module Name: src
Committed By: tls
Date: Sun Aug 10 06:57:59 UTC 2014
Modified Files:
src/usr.bin/config [tls-earlyentropy]: config.1 config.5 defs.h files.c
gram.y main.c sem.c
Log Message:
Rebase.
To generate a diff of this commit:
cvs rdiff -u -r1.13 -r1.13.8.1 src/usr.bin/config/config.1
cvs rdiff -u -r1.22 -r1.22.2.1 src/usr.bin/config/config.5
cvs rdiff -u -r1.44 -r1.44.8.1 src/usr.bin/config/defs.h
cvs rdiff -u -r1.11 -r1.11.8.1 src/usr.bin/config/files.c
cvs rdiff -u -r1.38 -r1.38.2.1 src/usr.bin/config/gram.y
cvs rdiff -u -r1.51 -r1.51.2.1 src/usr.bin/config/main.c
cvs rdiff -u -r1.42 -r1.42.2.1 src/usr.bin/config/sem.c
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
Modified files:
Index: src/usr.bin/config/config.1
diff -u src/usr.bin/config/config.1:1.13 src/usr.bin/config/config.1:1.13.8.1
--- src/usr.bin/config/config.1:1.13 Thu Aug 30 12:42:41 2012
+++ src/usr.bin/config/config.1 Sun Aug 10 06:57:59 2014
@@ -1,4 +1,4 @@
-.\" $NetBSD: config.1,v 1.13 2012/08/30 12:42:41 wiz Exp $
+.\" $NetBSD: config.1,v 1.13.8.1 2014/08/10 06:57:59 tls Exp $
.\"
.\" Copyright (c) 1980, 1991, 1993
.\" The Regents of the University of California. All rights reserved.
@@ -29,7 +29,7 @@
.\"
.\" from: @(#)config.8 8.2 (Berkeley) 4/19/94
.\"
-.Dd August 30, 2012
+.Dd May 5, 2014
.Dt CONFIG 1
.Os
.Sh NAME
@@ -39,7 +39,9 @@
.Nm
.Op Fl Ppv
.Op Fl b Ar builddir
+.Op Fl D Ar var=value
.Op Fl s Ar srcdir
+.Op Fl U Ar value
.Op Ar config-file
.Nm
.Fl x
@@ -109,6 +111,11 @@ Use
.Ar builddir
as the kernel build directory, instead of computing and creating one
automatically.
+.It Fl D Ar var=value
+Define a makeoptions variable to the given value.
+This is equivalent to appending a
+.Li makeoptions var=value
+line to the config file.
.It Fl L
Generate a lint configuration.
See section
@@ -131,6 +138,12 @@ is used to prepare a kernel build direct
when it is used in combination with the
.Fl L
flag.
+.It Fl U Ar var
+Undefine the makeoption
+.Ar var .
+This is equivalent to appending the line
+.Li no makeoptions var
+to the config file.
.It Fl v
Increase verbosity by enabling some more warnings.
.It Fl x
Index: src/usr.bin/config/config.5
diff -u src/usr.bin/config/config.5:1.22 src/usr.bin/config/config.5:1.22.2.1
--- src/usr.bin/config/config.5:1.22 Thu Feb 13 22:36:28 2014
+++ src/usr.bin/config/config.5 Sun Aug 10 06:57:59 2014
@@ -1,4 +1,4 @@
-.\" $NetBSD: config.5,v 1.22 2014/02/13 22:36:28 wiz Exp $
+.\" $NetBSD: config.5,v 1.22.2.1 2014/08/10 06:57:59 tls 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 March 3, 2010
+.Dd May 29, 2014
.Dt CONFIG 5
.Os
.Sh NAME
@@ -587,6 +587,8 @@ prefix
Defines the indentification string of the kernel.
This statement is optional, and the name of the main configuration file will be
used as a default value.
+.It Ic no ident
+Deletes any pre-existing indentification string of the kernel.
.It Ic maxusers Ar number
Despite its name, this statement does not limit the maximum number of users on
the system.
Index: src/usr.bin/config/defs.h
diff -u src/usr.bin/config/defs.h:1.44 src/usr.bin/config/defs.h:1.44.8.1
--- src/usr.bin/config/defs.h:1.44 Fri Jun 8 08:56:45 2012
+++ src/usr.bin/config/defs.h Sun Aug 10 06:57:59 2014
@@ -1,4 +1,4 @@
-/* $NetBSD: defs.h,v 1.44 2012/06/08 08:56:45 martin Exp $ */
+/* $NetBSD: defs.h,v 1.44.8.1 2014/08/10 06:57:59 tls 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 20100430
+#define CONFIG_VERSION 20140502
#define CONFIG_MINVERSION 0
/*
Index: src/usr.bin/config/files.c
diff -u src/usr.bin/config/files.c:1.11 src/usr.bin/config/files.c:1.11.8.1
--- src/usr.bin/config/files.c:1.11 Sun Mar 11 08:21:53 2012
+++ src/usr.bin/config/files.c Sun Aug 10 06:57:59 2014
@@ -1,4 +1,4 @@
-/* $NetBSD: files.c,v 1.11 2012/03/11 08:21:53 dholland Exp $ */
+/* $NetBSD: files.c,v 1.11.8.1 2014/08/10 06:57:59 tls Exp $ */
/*
* Copyright (c) 1992, 1993
@@ -160,7 +160,9 @@ addfile(const char *path, struct condexp
TAILQ_INSERT_TAIL(&allfiles, fi, fi_next);
return;
bad:
- condexpr_destroy(optx);
+ if (optx != NULL) {
+ condexpr_destroy(optx);
+ }
}
void
Index: src/usr.bin/config/gram.y
diff -u src/usr.bin/config/gram.y:1.38 src/usr.bin/config/gram.y:1.38.2.1
--- src/usr.bin/config/gram.y:1.38 Sun Aug 11 10:37:08 2013
+++ src/usr.bin/config/gram.y Sun Aug 10 06:57:59 2014
@@ -1,5 +1,5 @@
%{
-/* $NetBSD: gram.y,v 1.38 2013/08/11 10:37:08 pooka Exp $ */
+/* $NetBSD: gram.y,v 1.38.2.1 2014/08/10 06:57:59 tls Exp $ */
/*
* Copyright (c) 1992, 1993
@@ -627,6 +627,7 @@ config_item:
| OPTIONS opt_list
| MAXUSERS NUMBER { setmaxusers($2.val); }
| IDENT stringvalue { setident($2); }
+ | NO IDENT { setident(NULL); }
| CONFIG conf root_spec sysparam_list
{ addconf(&conf); }
| NO CONFIG WORD { delconf($3); }
Index: src/usr.bin/config/main.c
diff -u src/usr.bin/config/main.c:1.51 src/usr.bin/config/main.c:1.51.2.1
--- src/usr.bin/config/main.c:1.51 Fri Nov 1 21:39:13 2013
+++ src/usr.bin/config/main.c Sun Aug 10 06:57:59 2014
@@ -1,4 +1,4 @@
-/* $NetBSD: main.c,v 1.51 2013/11/01 21:39:13 christos Exp $ */
+/* $NetBSD: main.c,v 1.51.2.1 2014/08/10 06:57:59 tls Exp $ */
/*
* Copyright (c) 1992, 1993
@@ -86,6 +86,7 @@ COPYRIGHT("@(#) Copyright (c) 1992, 1993
int vflag; /* verbose output */
int Pflag; /* pack locators */
int Lflag; /* lint config generation */
+int handling_cmdlineopts; /* currently processing -D/-U options */
int yyparse(void);
@@ -100,6 +101,7 @@ static struct nvlist **nextmkopt;
static struct nvlist **nextappmkopt;
static struct nvlist **nextcndmkopt;
static struct nvlist **nextfsopt;
+static struct nvlist *cmdlinedefs, *cmdlineundefs;
static void usage(void) __dead;
static void dependopts(void);
@@ -119,6 +121,9 @@ static int mkident(void);
static int devbase_has_dead_instances(const char *, void *, void *);
static int devbase_has_any_instance(struct devbase *, int, int, int);
static int check_dead_devi(const char *, void *, void *);
+static void add_makeopt(const char *);
+static void remove_makeopt(const char *);
+static void handle_cmdline_makeoptions(void);
static void kill_orphans(void);
static void do_kill_orphans(struct devbase *, struct attr *,
struct devbase *, int);
@@ -155,11 +160,11 @@ main(int argc, char **argv)
pflag = 0;
xflag = 0;
- while ((ch = getopt(argc, argv, "DLPgpvb:s:x")) != -1) {
+ while ((ch = getopt(argc, argv, "D:LPU:dgpvb:s:x")) != -1) {
switch (ch) {
#ifndef MAKE_BOOTSTRAP
- case 'D':
+ case 'd':
yydebug = 1;
break;
#endif
@@ -179,7 +184,7 @@ main(int argc, char **argv)
* do that for you, but you really should just
* put them in the config file.
*/
- warnx("-g is obsolete (use makeoptions DEBUG=\"-g\")");
+ warnx("-g is obsolete (use -D DEBUG=\"-g\")");
usage();
/*NOTREACHED*/
@@ -213,6 +218,14 @@ main(int argc, char **argv)
xflag = 1;
break;
+ case 'D':
+ add_makeopt(optarg);
+ break;
+
+ case 'U':
+ remove_makeopt(optarg);
+ break;
+
case '?':
default:
usage();
@@ -386,6 +399,11 @@ main(int argc, char **argv)
unlink(cname);
/*
+ * Handle command line overrides
+ */
+ handle_cmdline_makeoptions();
+
+ /*
* Detect and properly ignore orphaned devices
*/
kill_orphans();
@@ -468,7 +486,8 @@ main(int argc, char **argv)
static void
usage(void)
{
- (void)fprintf(stderr, "Usage: %s [-Ppv] [-s srcdir] [-b builddir] "
+ (void)fprintf(stderr, "Usage: %s [-Ppv] [-b builddir] [-D var=value] "
+ "[-s srcdir] [-U var] "
"[config-file]\n\t%s -x [kernel-file]\n"
"\t%s -L [-v] [-s srcdir] [config-file]\n",
getprogname(), getprogname(), getprogname());
@@ -1071,6 +1090,11 @@ undo_option(struct hashtab *ht, struct n
struct nvlist *nv;
if (ht_remove(ht, name)) {
+ /*
+ * -U command line option removals are always silent
+ */
+ if (handling_cmdlineopts)
+ return 0;
cfgerror("%s `%s' is not defined", type, name);
return (1);
}
@@ -1770,3 +1794,56 @@ kill_orphans(void)
{
ht_enumerate(devroottab, kill_orphans_cb, NULL);
}
+
+static void
+add_makeopt(const char *opt)
+{
+ struct nvlist *p;
+ char *buf = estrdup(opt);
+ char *eq = strchr(buf, '=');
+
+ if (!eq)
+ errx(EXIT_FAILURE, "-D %s is not in var=value format", opt);
+
+ *eq = 0;
+ p = newnv(estrdup(buf), estrdup(eq+1), NULL, 0, NULL);
+ free(buf);
+ p->nv_next = cmdlinedefs;
+ cmdlinedefs = p;
+}
+
+static void
+remove_makeopt(const char *opt)
+{
+ struct nvlist *p;
+
+ p = newnv(estrdup(opt), NULL, NULL, 0, NULL);
+ p->nv_next = cmdlineundefs;
+ cmdlineundefs = p;
+}
+
+static void
+handle_cmdline_makeoptions(void)
+{
+ struct nvlist *p, *n;
+
+ handling_cmdlineopts = 1;
+ for (p = cmdlineundefs; p; p = n) {
+ n = p->nv_next;
+ delmkoption(intern(p->nv_name));
+ free(__UNCONST(p->nv_name));
+ nvfree(p);
+ }
+ for (p = cmdlinedefs; p; p = n) {
+ const char *name = intern(p->nv_name);
+
+ n = p->nv_next;
+ delmkoption(name);
+ addmkoption(name, intern(p->nv_str));
+ free(__UNCONST(p->nv_name));
+ free(__UNCONST(p->nv_str));
+
+ nvfree(p);
+ }
+ handling_cmdlineopts = 0;
+}
Index: src/usr.bin/config/sem.c
diff -u src/usr.bin/config/sem.c:1.42 src/usr.bin/config/sem.c:1.42.2.1
--- src/usr.bin/config/sem.c:1.42 Sun Aug 11 10:37:08 2013
+++ src/usr.bin/config/sem.c Sun Aug 10 06:57:59 2014
@@ -1,4 +1,4 @@
-/* $NetBSD: sem.c,v 1.42 2013/08/11 10:37:08 pooka Exp $ */
+/* $NetBSD: sem.c,v 1.42.2.1 2014/08/10 06:57:59 tls Exp $ */
/*
* Copyright (c) 1992, 1993
@@ -181,7 +181,10 @@ void
setident(const char *i)
{
- ident = intern(i);
+ if (i)
+ ident = intern(i);
+ else
+ ident = NULL;
}
/*