Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 5 Aug 2005 12:39:24 GMT
From:      Kostik Belousov <kostikbel@gmail.com>
To:        freebsd-gnats-submit@FreeBSD.org
Subject:   conf/84581: [patch] Teach config(8) to look for kernel configuration in /etc/SYSTEM.kernconf
Message-ID:  <200508051239.j75CdOx5040209@www.freebsd.org>
Resent-Message-ID: <200508051240.j75CeDDl054281@freefall.freebsd.org>

next in thread | raw e-mail | index | archive | help

>Number:         84581
>Category:       conf
>Synopsis:       [patch] Teach config(8) to look for kernel configuration in /etc/SYSTEM.kernconf
>Confidential:   no
>Severity:       non-critical
>Priority:       medium
>Responsible:    freebsd-bugs
>State:          open
>Quarter:        
>Keywords:       
>Date-Required:
>Class:          change-request
>Submitter-Id:   current-users
>Arrival-Date:   Fri Aug 05 12:40:13 GMT 2005
>Closed-Date:
>Last-Modified:
>Originator:     Kostik Belousov
>Release:        7-CURRENT, 5-STABLE
>Organization:
-
>Environment:
FreeBSD deviant.zoral.local 5.4-STABLE FreeBSD 5.4-STABLE #62: Thu Jul 21 18:01:51 EEST 2005 root@deviant.zoral.local:/usr/obj/usr/src/sys/DEVIANT  i386
>Description:
The site-specific FreeBSD kernel config files are placed inside the
tree in the <src>/sys/ARCH/conf directory. This is inconvinient since
configs are not controlled by the cvs. If someone do rm -rf <src> &&
cvs get src, configs have to be backed up before rm and restored after
get. Moreover, it makes hard to deal with read-only nfs export of
sources to build machines.

I propose a patch for config(8) and Makefile.inc1 that allows to keep
configs under /etc, where local configuration supposed to be stored.

Patch allows to take configs not only from sys/ARCH/conf but also from
/etc/SYSTEM.kernconf, where SYSTEM is system name supplied to
config(8).

Patch applicable to both 7-CURRENT and 5-STABLE.

>How-To-Repeat:
      
>Fix:
Index: Makefile.inc1
===================================================================
RCS file: /usr/local/arch/ncvs/src/Makefile.inc1,v
retrieving revision 1.508
diff -u -r1.508 Makefile.inc1
--- Makefile.inc1	3 Aug 2005 20:27:06 -0000	1.508
+++ Makefile.inc1	5 Aug 2005 11:02:25 -0000
@@ -585,7 +585,7 @@
 BUILDKERNELS=
 INSTALLKERNEL=
 .for _kernel in ${KERNCONF}
-.if exists(${KERNCONFDIR}/${_kernel})
+.if exists(${KERNCONFDIR}/${_kernel}) || exists(/etc/${_kernel}.kernconf)
 BUILDKERNELS+=	${_kernel}
 .if empty(INSTALLKERNEL)
 INSTALLKERNEL= ${_kernel}
@@ -624,7 +624,7 @@
 	cd ${KRNLCONFDIR}; \
 		PATH=${TMPPATH} \
 		    config ${CONFIGARGS} -d ${KRNLOBJDIR}/${_kernel} \
-			${KERNCONFDIR}/${_kernel}
+			${_kernel}
 .endif
 .if !defined(NO_CLEAN) && !defined(NO_KERNELCLEAN)
 	@echo
Index: usr.sbin/config/config.8
===================================================================
RCS file: /usr/local/arch/ncvs/src/usr.sbin/config/config.8,v
retrieving revision 1.43
diff -u -r1.43 config.8
--- usr.sbin/config/config.8	18 Jan 2005 20:02:33 -0000	1.43
+++ usr.sbin/config/config.8	5 Aug 2005 11:04:43 -0000
@@ -97,6 +97,9 @@
 Specify the name of the system configuration file
 containing device specifications, configuration options
 and other system parameters for one system configuration.
+If the SYSTEM_NAME does not contain '/' and the file SYSTEM_NAME
+does not exist in the current directory,
+the path /etc/SYSTEM_NAME.kernconf will be tried as fallback.
 .El
 .Pp
 The
Index: usr.sbin/config/main.c
===================================================================
RCS file: /usr/local/arch/ncvs/src/usr.sbin/config/main.c,v
retrieving revision 1.64
diff -u -r1.64 main.c
--- usr.sbin/config/main.c	22 Apr 2005 17:42:50 -0000	1.64
+++ usr.sbin/config/main.c	5 Aug 2005 11:04:45 -0000
@@ -66,6 +66,7 @@
 #define	CDIR	"../compile/"
 
 char *	PREFIX;
+char *  config_file_name;
 char 	destdir[MAXPATHLEN];
 char 	srcdir[MAXPATHLEN];
 
@@ -119,8 +120,31 @@
 	if (argc != 1)
 		usage();
 
-	if (freopen(PREFIX = *argv, "r", stdin) == NULL)
-		err(2, "%s", PREFIX);
+	PREFIX = *argv;
+	config_file_name = *argv;
+	yyfile = config_file_name;
+	if (freopen(config_file_name, "r", stdin) == NULL) {
+		if (strchr(config_file_name, '/') == NULL) {
+			static const char prefix[] = "/etc/";
+			static const char suffix[] = ".kernconf";
+			char *etcname = malloc(sizeof(prefix) +
+					       sizeof(suffix) + strlen(config_file_name) - 1);
+			if (etcname == NULL)
+				err(2, NULL);
+			strcpy(etcname, prefix);
+			strcat(etcname, config_file_name);
+			strcat(etcname, suffix);
+
+			if (freopen(etcname, "r", stdin) == NULL)
+				err(2, "%s", etcname);
+			else {
+				yyfile = etcname;
+				config_file_name = etcname;
+			}
+		}
+		else
+			err(2, "%s", config_file_name);
+	}
 
 	if (*destdir != '\0') {
 		len = strlen(destdir);
@@ -144,7 +168,6 @@
 	STAILQ_INIT(&fntab);
 	SLIST_INIT(&cputype);
 	STAILQ_INIT(&ftab);
-	yyfile = *argv;
 	if (yyparse())
 		exit(3);
 	if (machinename == NULL) {
@@ -338,9 +361,9 @@
 	char *p;
 	int i;
 	
-	fi = fopen(PREFIX, "r");
+	fi = fopen(config_file_name, "r");
 	if (!fi)
-		err(2, "%s", PREFIX);
+		err(2, "%s", config_file_name);
 	fo = fopen(p=path("config.c.new"), "w");
 	if (!fo)
 		err(2, "%s", p);

>Release-Note:
>Audit-Trail:
>Unformatted:



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200508051239.j75CdOx5040209>