From owner-svn-src-all@FreeBSD.ORG Thu Apr 10 19:51:35 2014 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 1A24759F; Thu, 10 Apr 2014 19:51:35 +0000 (UTC) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id EE8B41BE6; Thu, 10 Apr 2014 19:51:34 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.8/8.14.8) with ESMTP id s3AJpYQx004864; Thu, 10 Apr 2014 19:51:34 GMT (envelope-from asomers@svn.freebsd.org) Received: (from asomers@localhost) by svn.freebsd.org (8.14.8/8.14.8/Submit) id s3AJpXnj004858; Thu, 10 Apr 2014 19:51:33 GMT (envelope-from asomers@svn.freebsd.org) Message-Id: <201404101951.s3AJpXnj004858@svn.freebsd.org> From: Alan Somers Date: Thu, 10 Apr 2014 19:51:33 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org Subject: svn commit: r264325 - in stable/10: . usr.sbin/config X-SVN-Group: stable-10 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.17 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 10 Apr 2014 19:51:35 -0000 Author: asomers Date: Thu Apr 10 19:51:33 2014 New Revision: 264325 URL: http://svnweb.freebsd.org/changeset/base/264325 Log: MFC r263429 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). Modified: stable/10/Makefile.inc1 stable/10/usr.sbin/config/config.8 stable/10/usr.sbin/config/config.h stable/10/usr.sbin/config/lang.l stable/10/usr.sbin/config/main.c Directory Properties: stable/10/ (props changed) Modified: stable/10/Makefile.inc1 ============================================================================== --- stable/10/Makefile.inc1 Thu Apr 10 19:15:58 2014 (r264324) +++ stable/10/Makefile.inc1 Thu Apr 10 19:51:33 2014 (r264325) @@ -1000,7 +1000,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: stable/10/usr.sbin/config/config.8 ============================================================================== --- stable/10/usr.sbin/config/config.8 Thu Apr 10 19:15:58 2014 (r264324) +++ stable/10/usr.sbin/config/config.8 Thu Apr 10 19:51:33 2014 (r264325) @@ -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: stable/10/usr.sbin/config/config.h ============================================================================== --- stable/10/usr.sbin/config/config.h Thu Apr 10 19:15:58 2014 (r264324) +++ stable/10/usr.sbin/config/config.h Thu Apr 10 19:51:33 2014 (r264325) @@ -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: stable/10/usr.sbin/config/lang.l ============================================================================== --- stable/10/usr.sbin/config/lang.l Thu Apr 10 19:15:58 2014 (r264324) +++ stable/10/usr.sbin/config/lang.l Thu Apr 10 19:51:33 2014 (r264325) @@ -34,6 +34,7 @@ #include #include #include +#include #include #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: stable/10/usr.sbin/config/main.c ============================================================================== --- stable/10/usr.sbin/config/main.c Thu Apr 10 19:15:58 2014 (r264324) +++ stable/10/usr.sbin/config/main.c Thu Apr 10 19:51:33 2014 (r264325) @@ -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;