Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 18 Mar 2014 22:17:21 GMT
From:      Alan Somers <asomers@freebsd.org>
To:        freebsd-gnats-submit@FreeBSD.org
Subject:   kern/187712: config(8) does not respect KERNCONFDIR
Message-ID:  <201403182217.s2IMHLoO059993@cgiserv.freebsd.org>
Resent-Message-ID: <201403182220.s2IMK06O001513@freefall.freebsd.org>

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

>Number:         187712
>Category:       kern
>Synopsis:       config(8) does not respect KERNCONFDIR
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    freebsd-bugs
>State:          open
>Quarter:        
>Keywords:       
>Date-Required:
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Tue Mar 18 22:20:00 UTC 2014
>Closed-Date:
>Last-Modified:
>Originator:     Alan Somers
>Release:        11.0 CURRENT
>Organization:
Spectra Logic
>Environment:
FreeBSD alans-fbsd-head 11.0-CURRENT FreeBSD 11.0-CURRENT #40 r263266: Mon Mar 17 13:07:35 MDT 2014     alans@ns1.eng.sldomain.com:/vmpool/obj/usr/home/alans/freebsd/head/sys/GENERIC  amd64
>Description:
When doing a buildkernel, you can set the make variable KERNCONFDIR if the kernel config file is in a location other than sys/${ARCH}/conf.  However, if your kernel config file uses the "include" statement to include another config file, config(8) will not search in KERNCONFDIR to find the included file.  My patch makes config(8) aware of KERNCONFDIR when processing the "include" statement, and causes make to set KERNCONFDIR when invoking config(8).

This bug is the more general case of ports/164242.
>How-To-Repeat:
# cd /usr/src
# cp sys/amd64/conf/GENERIC  /tmp/GENERIC_dup
# echo "include GENERIC_dup" > /tmp/GENERIC2
# make KERNCONFDIR="/tmp" KERNCONF=GENERIC2 buildkernel
--------------------------------------------------------------
>Fix:
Apply attached patch

Patch attached with submission follows:

Index: Makefile.inc1
===================================================================
--- Makefile.inc1	(revision 263266)
+++ Makefile.inc1	(working copy)
@@ -1013,7 +1013,7 @@
 	@echo ">>> stage 1: configuring the kernel"
 	@echo "--------------------------------------------------------------"
 	cd ${KRNLCONFDIR}; \
-		PATH=${TMPPATH} \
+		PATH=${TMPPATH} KERNCONFDIR=${KERNCONFDIR} \
 		    config ${CONFIGARGS} -d ${KRNLOBJDIR}/${_kernel} \
 			${KERNCONFDIR}/${_kernel}
 .endif
Index: usr.sbin/config/lang.l
===================================================================
--- usr.sbin/config/lang.l	(revision 263266)
+++ usr.sbin/config/lang.l	(working copy)
@@ -34,6 +34,7 @@
 #include <assert.h>
 #include <ctype.h>
 #include <err.h>
+#include <stdlib.h>
 #include <string.h>
 #include "y.tab.h"
 #include "config.h"
@@ -258,6 +259,7 @@
 	FILE *fp;
 	struct incl *in;
 	char *fnamebuf;
+	char *kernconfdir;
 
 	fnamebuf = NULL;
 	fp = fopen(fname, "r");
@@ -269,6 +271,16 @@
 		}
 	}
 	if (fp == NULL) {
+		kernconfdir = getenv("KERNCONFDIR");
+		if (kernconfdir != NULL) {
+			asprintf(&fnamebuf, "%s/%s", kernconfdir, fname);
+			if (fnamebuf != NULL) {
+				fp = fopen(fnamebuf, "r");
+				free(fnamebuf);
+			}
+		}
+	}
+	if (fp == NULL) {
 		yyerror("cannot open included file");
 		return (-1);
 	}


>Release-Note:
>Audit-Trail:
>Unformatted:
 >>> Kernel build for GENERIC2 started on Tue Mar 18 12:13:27 MDT 2014
 --------------------------------------------------------------
 ===> GENERIC2
 mkdir -p /vmpool/obj/usr/home/alans/freebsd/head/sys
 
 --------------------------------------------------------------
 >>> stage 1: configuring the kernel
 --------------------------------------------------------------
 cd /usr/home/alans/freebsd/head/sys/amd64/conf;  PATH=/vmpool/obj/usr/home/alans/freebsd/head/tmp/legacy/usr/sbin:/vmpool/obj/usr/home/alans/freebsd/head/tmp/legacy/usr/bin:/vmpool/obj/usr/home/alans/freebsd/head/tmp/legacy/usr/games:/vmpool/obj/usr/home /alans/freebsd/head/tmp/legacy/bin:/vmpool/obj/usr/home/alans/freebsd/head/tmp/usr/sbin:/vmpool/obj/usr/home/alans/freebsd/head/tmp/usr/bin:/vmpool/obj/usr/home/alans/freebsd/head/tmp/usr/games:/sbin:/bin:/usr/sbin:/usr/bin  config  -d /vmpool/obj/usr/ho me/alans/freebsd/head/sys/GENERIC2  /tmp/GENERIC2
 config: /tmp/GENERIC2:2: cannot open included file
 *** Error code 1
 
 



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