Subject: Versioning config files
To: None <tech-kern@netbsd.org>
From: Quentin Garnier <cube@cubidou.net>
List: tech-kern
Date: 10/02/2005 19:19:11
--i7KxW38SoMauyveo
Content-Type: multipart/mixed; boundary="aIbcA3MSwnGacr4f"
Content-Disposition: inline
--aIbcA3MSwnGacr4f
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
Content-Transfer-Encoding: quoted-printable
Hi,
I'd like to version config files. I feel a bit tired of the recurrent
"bug" report of syntax errors inside pf.files. I'm well aware that
whatever change I do know won't solve that issue, but I'm sure it will
make it more meaningful.
The attached patch implements a versioning scheme based on a number
that is supposed to grow. I think the ISO date format is the most
suitable for the job.
You should note that it will tolerate a whole range of values, instead
of a single one. That way, using a more recent config(1) on an older
tree will be possible, as we might introduce some kind of backward
compatibility. I will not object if people think it is a bad idea,
though (the user should always use a toolchain that match the source
tree, period).
On the other hand, accepting version 0 for the moment allows me to
commit the code and not add a 'version XXXX' to sys/conf/files until
the next actual version change. E.g., when/if people decide on using
a 'no device' or whatever in our config files, they can add a version
statement in the said config file, so that users using the old config
will get a syntax error at the line that says 'version XXXX' instead.
Another note is that 'version XXXX' is allowed several times, which
means parts of the config files might refer to different styles (again,
with some idea of backward compatibility).
Comments?
--=20
Quentin Garnier - cube@cubidou.net - cube@NetBSD.org
"When I find the controls, I'll go where I like, I'll know where I want
to be, but maybe for now I'll stay right here on a silent sea."
KT Tunstall, Silent Sea, Eye to the Telescope, 2004.
--aIbcA3MSwnGacr4f
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment; filename="config.diff"
Content-Transfer-Encoding: quoted-printable
Index: defs.h
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
RCS file: /rep/NetBSD-src/cvs/src/usr.bin/config/defs.h,v
retrieving revision 1.4
diff -u -r1.4 defs.h
--- defs.h 2005/10/01 23:30:37 1.4
+++ defs.h 2005/10/02 17:04:11
@@ -95,6 +95,13 @@
#define ARRCHR '#'
=20
/*
+ * 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 20051003
+#define CONFIG_MINVERSION 0
+
+/*
* Name/value lists. Values can be strings or pointers and/or can carry
* integers. The names can be NULL, resulting in simple value lists.
*/
@@ -361,6 +368,7 @@
int maxmaxusers; /* default "maxusers" parameter */
int maxusers; /* configuration's "maxusers" parameter */
int maxpartitions; /* configuration's "maxpartitions" parameter */
+int version; /* version of the configuration file */
struct nvlist *options; /* options */
struct nvlist *fsoptions; /* filesystems */
struct nvlist *mkoptions; /* makeoptions */
Index: gram.y
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
RCS file: /rep/NetBSD-src/cvs/src/usr.bin/config/gram.y,v
retrieving revision 1.3
diff -u -r1.3 gram.y
--- gram.y 2005/09/30 22:51:46 1.3
+++ gram.y 2005/10/02 12:37:56
@@ -114,6 +114,7 @@
%token ROOT
%token SOURCE
%token TYPE
+%token VERSION
%token WITH
%token <num> NUMBER
%token <str> PATHNAME QSTRING WORD EMPTY
@@ -171,7 +172,7 @@
topthings /* dirspecs, include "std.arch" */
machine_spec /* "machine foo" from machine descr. */
dev_defs ENDDEFS /* all machine definition files */
- { check_maxpart(); }
+ { check_maxpart(); check_version(); }
specs; /* rest of machine description */
=20
topthings:
@@ -292,7 +293,8 @@
MAKEOPTIONS condmkopt_list |
DEFPSEUDO devbase interface_opt attrs_opt
{ defdev($2, $3, $4, 1); } |
- MAJOR '{' majorlist '}';
+ MAJOR '{' majorlist '}' |
+ VERSION NUMBER { setversion($2.val); };
=20
atlist:
atlist ',' atname { $$ =3D new_nx($3, $1); } |
@@ -652,6 +654,17 @@
if (maxpartitions <=3D 0) {
stop("cannot proceed without maxpartitions specifier");
}
+}
+
+static void
+check_version(void)
+{
+ /*
+ * In essence, version is 0 and is not supported anymore
+ */
+ if (version < CONFIG_MINVERSION)
+ stop("unsupported config file version. Please upgrade "
+ "config(1)");
}
=20
static void
Index: scan.l
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
RCS file: /rep/NetBSD-src/cvs/src/usr.bin/config/scan.l,v
retrieving revision 1.2
diff -u -r1.2 scan.l
--- scan.l 2005/09/10 15:38:46 1.2
+++ scan.l 2005/10/02 10:47:37
@@ -125,6 +125,7 @@
root return ROOT;
source return SOURCE;
type return TYPE;
+version return VERSION;
with return WITH;
=20
\+=3D return PLUSEQ;
Index: sem.c
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
RCS file: /rep/NetBSD-src/cvs/src/usr.bin/config/sem.c,v
retrieving revision 1.9
diff -u -r1.9 sem.c
--- sem.c 2005/10/02 00:18:09 1.9
+++ sem.c 2005/10/02 16:48:48
@@ -1730,3 +1730,13 @@
}
return (lp);
}
+
+void
+setversion(int newver)
+{
+ if (newver > CONFIG_VERSION || newver < CONFIG_MINVERSION)
+ error("unsupported config file version (%d). "
+ "Please upgrade config(1).", newver);
+ else
+ version =3D newver;
+}
Index: sem.h
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
RCS file: /rep/NetBSD-src/cvs/src/usr.bin/config/sem.h,v
retrieving revision 1.3
diff -u -r1.3 sem.h
--- sem.h 2005/10/01 23:30:37 1.3
+++ sem.h 2005/10/02 10:53:40
@@ -42,6 +42,7 @@
=20
void enddefs(void);
=20
+void setversion(int);
void setdefmaxusers(int, int, int);
void setmaxusers(int);
void setident(const char *);
--aIbcA3MSwnGacr4f--
--i7KxW38SoMauyveo
Content-Type: application/pgp-signature
Content-Disposition: inline
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.6 (NetBSD)
iQEVAwUBQ0AWj9goQloHrPnoAQKRDwf+KiQUhM77qQurKDpOJLVDHedE5CgEWSHr
ylcgi8yAoyfZAsgfuNk0fZK01dyOK9h/Gs/u/T10aaIraR+0QwOaSRAQo3lVto5I
hFs0XT9qc20yXPEWEKe55fEModOo5vlEUJ+w8Juo0sRhzGXR1V6KHlkxiwS93uL/
mLmJU0v/ChW8uWb2INzqVIUR/aE9FOuOae19sEpo95/lJ75BWKhkOFSJsqYAWYPG
Olfc0JO5UGADQcqf+ZeGze7fcSv5KLMBr+q5p2o2muPShA/1t1pyLwDSjZfIgQRN
gOxaWqD+WvNLKAk2g+oKlpQrxlqXDsavSyH1c7PhcMoOvCLny4oVcg==
=OQ+z
-----END PGP SIGNATURE-----
--i7KxW38SoMauyveo--