Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/usr.sbin/config Keeping my kernel config files under RCS con...
details: https://anonhg.NetBSD.org/src/rev/0d40b2086aa4
branches: trunk
changeset: 481149:0d40b2086aa4
user: hubertf <hubertf%NetBSD.org@localhost>
date: Sun Jan 23 23:37:42 2000 +0000
description:
Keeping my kernel config files under RCS control, I always wished to
have a way to embed the revision number into the kernel's "uname -v"
output. The patch below does this, by generating a new keyword "ident"
that can be followed by any string, e.g.
ident "NOON-$Revision$"
will lead to
vvvvvvvvvvvvvvvvvvvvvv
char version[] = "NetBSD 1.4P (NOON-$Revision: 1.21 $) #37: Thu Jan
20 02:01:23 MET 2000\n feyrer@noon:/usr/cvs.local/src-current/sys/arch/i386/c
ompile/NOON\n";
This will lead to a version of "MYMACHINE-$Revision$" instead of the
kernel config file name. If "ident" is not present, the current behaviour
of using the kernel config file's name as identifier is used.
Implement by writing the ident to a file ("ident") in the compile dir,
which newvers.sh will pick up for generating the ident.
diffstat:
usr.sbin/config/config.h | 3 ++-
usr.sbin/config/gram.y | 5 +++--
usr.sbin/config/main.c | 34 ++++++++++++++++++++++++++++++++--
usr.sbin/config/scan.l | 3 ++-
usr.sbin/config/sem.c | 9 ++++++++-
usr.sbin/config/sem.h | 3 ++-
6 files changed, 49 insertions(+), 8 deletions(-)
diffs (168 lines):
diff -r b682b3aa8310 -r 0d40b2086aa4 usr.sbin/config/config.h
--- a/usr.sbin/config/config.h Sun Jan 23 22:19:27 2000 +0000
+++ b/usr.sbin/config/config.h Sun Jan 23 23:37:42 2000 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: config.h,v 1.46 1999/09/22 14:23:03 ws Exp $ */
+/* $NetBSD: config.h,v 1.47 2000/01/23 23:37:42 hubertf Exp $ */
/*
* Copyright (c) 1992, 1993
@@ -316,6 +316,7 @@
const char *srcdir; /* path to source directory (rel. to build) */
const char *builddir; /* path to build directory */
const char *defbuilddir; /* default build directory */
+const char *ident; /* kernel "ident"ification string */
int errors; /* counts calls to error() */
int minmaxusers; /* minimum "maxusers" parameter */
int defmaxusers; /* default "maxusers" parameter */
diff -r b682b3aa8310 -r 0d40b2086aa4 usr.sbin/config/gram.y
--- a/usr.sbin/config/gram.y Sun Jan 23 22:19:27 2000 +0000
+++ b/usr.sbin/config/gram.y Sun Jan 23 23:37:42 2000 +0000
@@ -1,5 +1,5 @@
%{
-/* $NetBSD: gram.y,v 1.27 1999/07/09 06:44:58 thorpej Exp $ */
+/* $NetBSD: gram.y,v 1.28 2000/01/23 23:37:42 hubertf Exp $ */
/*
* Copyright (c) 1992, 1993
@@ -103,7 +103,7 @@
%token AND AT ATTACH BUILD CINCLUDE COMPILE_WITH CONFIG DEFFS DEFINE DEFOPT
%token DEFPARAM DEFFLAG DEFPSEUDO DEVICE DEVCLASS DUMPS ENDFILE XFILE XOBJECT
-%token FILE_SYSTEM FLAGS INCLUDE XMACHINE MAJOR MAKEOPTIONS
+%token FILE_SYSTEM FLAGS IDENT INCLUDE XMACHINE MAJOR MAKEOPTIONS
%token MAXUSERS MAXPARTITIONS MINOR ON OPTIONS PREFIX PSEUDO_DEVICE ROOT
%token SOURCE TYPE WITH NEEDS_COUNT NEEDS_FLAG
%token <val> NUMBER
@@ -386,6 +386,7 @@
OPTIONS opt_list |
MAKEOPTIONS mkopt_list |
MAXUSERS NUMBER { setmaxusers($2); } |
+ IDENT WORD { setident($2); } |
CONFIG conf root_spec sysparam_list
{ addconf(&conf); } |
PSEUDO_DEVICE WORD npseudo { addpseudo($2, $3); } |
diff -r b682b3aa8310 -r 0d40b2086aa4 usr.sbin/config/main.c
--- a/usr.sbin/config/main.c Sun Jan 23 22:19:27 2000 +0000
+++ b/usr.sbin/config/main.c Sun Jan 23 23:37:42 2000 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: main.c,v 1.44 1999/09/24 04:23:36 enami Exp $ */
+/* $NetBSD: main.c,v 1.45 2000/01/23 23:37:42 hubertf Exp $ */
/*
* Copyright (c) 1992, 1993
@@ -86,6 +86,7 @@
static int badstar __P((void));
int main __P((int, char **));
static int mksymlinks __P((void));
+static int mkident __P((void));
static int hasparent __P((struct devi *));
static int cfcrosscheck __P((struct config *, const char *,
struct nvlist *));
@@ -185,6 +186,7 @@
initintern();
initfiles();
initsem();
+ ident=NULL;
devbasetab = ht_new();
devatab = ht_new();
selecttab = ht_new();
@@ -275,7 +277,7 @@
* Ready to go. Build all the various files.
*/
if (mksymlinks() || mkmakefile() || mkheaders() || mkswap() ||
- mkioconf())
+ mkioconf() || mkident())
stop();
(void)printf("Don't forget to run \"make depend\"\n");
exit(0);
@@ -959,3 +961,31 @@
exit(2);
}
}
+
+/*
+ * Write identifier from "ident" directive into file, for
+ * newvers.sh to pick it up.
+ */
+int
+mkident()
+{
+ FILE *fp;
+
+ (void)unlink("ident");
+
+ if (ident == NULL)
+ return (0);
+
+ if ((fp = fopen("ident", "w")) == NULL) {
+ (void)fprintf(stderr, "config: cannot write ident: %s\n",
+ strerror(errno));
+ return (1);
+ }
+ if (vflag)
+ (void)printf("using ident '%s'\n", ident);
+ if (fprintf(fp, "%s\n", ident) < 0)
+ return (1);
+ (void)fclose(fp);
+
+ return (0);
+}
diff -r b682b3aa8310 -r 0d40b2086aa4 usr.sbin/config/scan.l
--- a/usr.sbin/config/scan.l Sun Jan 23 22:19:27 2000 +0000
+++ b/usr.sbin/config/scan.l Sun Jan 23 23:37:42 2000 +0000
@@ -1,5 +1,5 @@
%{
-/* $NetBSD: scan.l,v 1.26 2000/01/05 11:24:02 drochner Exp $ */
+/* $NetBSD: scan.l,v 1.27 2000/01/23 23:37:42 hubertf Exp $ */
/*
* Copyright (c) 1992, 1993
@@ -101,6 +101,7 @@
file return XFILE;
file-system return FILE_SYSTEM;
flags return FLAGS;
+ident return IDENT;
include return INCLUDE;
machine return XMACHINE;
major return MAJOR;
diff -r b682b3aa8310 -r 0d40b2086aa4 usr.sbin/config/sem.c
--- a/usr.sbin/config/sem.c Sun Jan 23 22:19:27 2000 +0000
+++ b/usr.sbin/config/sem.c Sun Jan 23 23:37:42 2000 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: sem.c,v 1.23 1999/09/21 15:50:19 is Exp $ */
+/* $NetBSD: sem.c,v 1.24 2000/01/23 23:37:42 hubertf Exp $ */
/*
* Copyright (c) 1992, 1993
@@ -175,6 +175,13 @@
}
}
+void
+setident(i)
+ const char *i;
+{
+ ident=intern(i);
+}
+
/*
* Define an attribute, optionally with an interface (a locator list).
* Since an empty locator list is logically different from "no interface",
diff -r b682b3aa8310 -r 0d40b2086aa4 usr.sbin/config/sem.h
--- a/usr.sbin/config/sem.h Sun Jan 23 22:19:27 2000 +0000
+++ b/usr.sbin/config/sem.h Sun Jan 23 23:37:42 2000 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: sem.h,v 1.11 1998/02/16 22:05:37 thorpej Exp $ */
+/* $NetBSD: sem.h,v 1.12 2000/01/23 23:37:43 hubertf Exp $ */
/*
* Copyright (c) 1992, 1993
@@ -48,6 +48,7 @@
void setdefmaxusers __P((int, int, int));
void setmaxusers __P((int));
+void setident __P((const char *));
int defattr __P((const char *, struct nvlist *, int));
void defdev __P((struct devbase *, struct nvlist *,
struct nvlist *, int));
Home |
Main Index |
Thread Index |
Old Index