| Summary: | config(8) does not respect KERNCONFDIR | ||||||||
|---|---|---|---|---|---|---|---|---|---|
| Product: | Base System | Reporter: | Alan Somers <asomers> | ||||||
| Component: | kern | Assignee: | Alan Somers <asomers> | ||||||
| Status: | Closed FIXED | ||||||||
| Severity: | Affects Only Me | ||||||||
| Priority: | Normal | ||||||||
| Version: | Unspecified | ||||||||
| Hardware: | Any | ||||||||
| OS: | Any | ||||||||
| Attachments: |
|
||||||||
Responsible Changed From-To: freebsd-bugs->asomers I'll take it As will and imp suggested, this patch uses a "-I path" argument like compilers do, instead of KERNCONFDIR. Author: asomers Date: Thu Mar 20 17:30:09 2014 New Revision: 263429 URL: http://svnweb.freebsd.org/changeset/base/263429 Log: Fix kern/187712: config(8) does not respect KERNCONFDIR. The impact of this bug is that you cannot build a kernel if both of the following are true: 1) The kernel config file is in a non-default location 2) The kernel config file uses the "include" statement from config(5). usr.sbin/config/main.c usr.sbin/config/config.8 usr.sbin/config/config.h usr.sbin/config/lang.l Added a "-I path" option to config(8). By analogy to cc(1), it adds an extra path in which the "include" statement will search for files. Makefile.inc1 Pass "-I ${KERNCONFDIR}" to config(8). PR: kern/187712 Reviewed by: will, imp (previous version) MFC after: 3 weeks Sponsored by: Spectra Logic Corporation Modified: head/Makefile.inc1 head/usr.sbin/config/config.8 head/usr.sbin/config/config.h head/usr.sbin/config/lang.l head/usr.sbin/config/main.c Modified: head/Makefile.inc1 ============================================================================== --- head/Makefile.inc1 Thu Mar 20 17:13:07 2014 (r263428) +++ head/Makefile.inc1 Thu Mar 20 17:30:09 2014 (r263429) @@ -1015,7 +1015,7 @@ buildkernel: cd ${KRNLCONFDIR}; \ PATH=${TMPPATH} \ config ${CONFIGARGS} -d ${KRNLOBJDIR}/${_kernel} \ - ${KERNCONFDIR}/${_kernel} + -I ${KERNCONFDIR} ${KERNCONFDIR}/${_kernel} .endif .if !defined(NO_CLEAN) && !defined(NO_KERNELCLEAN) @echo Modified: head/usr.sbin/config/config.8 ============================================================================== --- head/usr.sbin/config/config.8 Thu Mar 20 17:13:07 2014 (r263428) +++ head/usr.sbin/config/config.8 Thu Mar 20 17:30:09 2014 (r263429) @@ -37,6 +37,7 @@ .Sh SYNOPSIS .Nm .Op Fl CVgp +.Op Fl I Ar path .Op Fl d Ar destdir .Ar SYSTEM_NAME .Nm @@ -69,6 +70,12 @@ If the INCLUDE_CONFIG_FILE is present in kernel image will contain full configuration files included literally (preserving comments). This flag is kept for backward compatibility. +.It Fl I Ar path +Search in +.Ar path +for any file included by the +.Ic include +directive. This option may be specified more than once. .It Fl d Ar destdir Use .Ar destdir Modified: head/usr.sbin/config/config.h ============================================================================== --- head/usr.sbin/config/config.h Thu Mar 20 17:13:07 2014 (r263428) +++ head/usr.sbin/config/config.h Thu Mar 20 17:30:09 2014 (r263429) @@ -144,6 +144,13 @@ struct hint { STAILQ_HEAD(hint_head, hint) hints; +struct includepath { + char *path; + SLIST_ENTRY(includepath) path_next; +}; + +SLIST_HEAD(, includepath) includepath; + /* * Tag present in the kernelconf.tmlp template file. It's mandatory for those * two strings to be the same. Otherwise you'll get into trouble. Modified: head/usr.sbin/config/lang.l ============================================================================== --- head/usr.sbin/config/lang.l Thu Mar 20 17:13:07 2014 (r263428) +++ head/usr.sbin/config/lang.l Thu Mar 20 17:30:09 2014 (r263429) @@ -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" @@ -257,6 +258,7 @@ include(const char *fname, int ateof) { FILE *fp; struct incl *in; + struct includepath* ipath; char *fnamebuf; fnamebuf = NULL; @@ -269,6 +271,17 @@ include(const char *fname, int ateof) } } if (fp == NULL) { + SLIST_FOREACH(ipath, &includepath, path_next) { + asprintf(&fnamebuf, "%s/%s", ipath->path, fname); + if (fnamebuf != NULL) { + fp = fopen(fnamebuf, "r"); + free(fnamebuf); + } + if (fp != NULL) + break; + } + } + if (fp == NULL) { yyerror("cannot open included file"); return (-1); } Modified: head/usr.sbin/config/main.c ============================================================================== --- head/usr.sbin/config/main.c Thu Mar 20 17:13:07 2014 (r263428) +++ head/usr.sbin/config/main.c Thu Mar 20 17:30:09 2014 (r263429) @@ -110,15 +110,25 @@ main(int argc, char **argv) int ch, len; char *p; char *kernfile; + struct includepath* ipath; int printmachine; printmachine = 0; kernfile = NULL; - while ((ch = getopt(argc, argv, "Cd:gmpVx:")) != -1) + SLIST_INIT(&includepath); + while ((ch = getopt(argc, argv, "CI:d:gmpVx:")) != -1) switch (ch) { case 'C': filebased = 1; break; + case 'I': + ipath = (struct includepath *) \ + calloc(1, sizeof (struct includepath)); + if (ipath == NULL) + err(EXIT_FAILURE, "calloc"); + ipath->path = optarg; + SLIST_INSERT_HEAD(&includepath, ipath, path_next); + break; case 'm': printmachine = 1; break; _______________________________________________ svn-src-all@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to "svn-src-all-unsubscribe@freebsd.org" State Changed From-To: open->patched Fixed in head by r263429 State Changed From-To: patched->closed MFCed by changes 264325 and 264326 |
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. Fix: Apply attached patch Patch attached with submission follows: 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 --------------------------------------------------------------