From owner-freebsd-bugs@FreeBSD.ORG Fri Aug 5 12:40:14 2005 Return-Path: X-Original-To: freebsd-bugs@hub.freebsd.org Delivered-To: freebsd-bugs@hub.freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id C594916A41F for ; Fri, 5 Aug 2005 12:40:14 +0000 (GMT) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (freefall.freebsd.org [216.136.204.21]) by mx1.FreeBSD.org (Postfix) with ESMTP id 3BCC943D48 for ; Fri, 5 Aug 2005 12:40:14 +0000 (GMT) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (gnats@localhost [127.0.0.1]) by freefall.freebsd.org (8.13.3/8.13.3) with ESMTP id j75CeDg1054282 for ; Fri, 5 Aug 2005 12:40:13 GMT (envelope-from gnats@freefall.freebsd.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.13.3/8.13.1/Submit) id j75CeDDl054281; Fri, 5 Aug 2005 12:40:13 GMT (envelope-from gnats) Resent-Date: Fri, 5 Aug 2005 12:40:13 GMT Resent-Message-Id: <200508051240.j75CeDDl054281@freefall.freebsd.org> Resent-From: FreeBSD-gnats-submit@FreeBSD.org (GNATS Filer) Resent-To: freebsd-bugs@FreeBSD.org Resent-Reply-To: FreeBSD-gnats-submit@FreeBSD.org, Kostik Belousov Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id EA34016A41F for ; Fri, 5 Aug 2005 12:39:24 +0000 (GMT) (envelope-from nobody@FreeBSD.org) Received: from www.freebsd.org (www.freebsd.org [216.136.204.117]) by mx1.FreeBSD.org (Postfix) with ESMTP id AE50A43D46 for ; Fri, 5 Aug 2005 12:39:24 +0000 (GMT) (envelope-from nobody@FreeBSD.org) Received: from www.freebsd.org (localhost [127.0.0.1]) by www.freebsd.org (8.13.1/8.13.1) with ESMTP id j75CdO4s040210 for ; Fri, 5 Aug 2005 12:39:24 GMT (envelope-from nobody@www.freebsd.org) Received: (from nobody@localhost) by www.freebsd.org (8.13.1/8.13.1/Submit) id j75CdOx5040209; Fri, 5 Aug 2005 12:39:24 GMT (envelope-from nobody) Message-Id: <200508051239.j75CdOx5040209@www.freebsd.org> Date: Fri, 5 Aug 2005 12:39:24 GMT From: Kostik Belousov To: freebsd-gnats-submit@FreeBSD.org X-Send-Pr-Version: www-2.3 Cc: Subject: conf/84581: [patch] Teach config(8) to look for kernel configuration in /etc/SYSTEM.kernconf X-BeenThere: freebsd-bugs@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Bug reports List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 05 Aug 2005 12:40:14 -0000 >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 /sys/ARCH/conf directory. This is inconvinient since configs are not controlled by the cvs. If someone do rm -rf && 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: