From owner-freebsd-bugs@FreeBSD.ORG Tue Mar 18 22:20:00 2014 Return-Path: Delivered-To: freebsd-bugs@smarthost.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id CFB34D36 for ; Tue, 18 Mar 2014 22:20:00 +0000 (UTC) Received: from freefall.freebsd.org (freefall.freebsd.org [IPv6:2001:1900:2254:206c::16:87]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.freebsd.org (Postfix) with ESMTPS id AA722820 for ; Tue, 18 Mar 2014 22:20:00 +0000 (UTC) Received: from freefall.freebsd.org (localhost [127.0.0.1]) by freefall.freebsd.org (8.14.8/8.14.8) with ESMTP id s2IMK0lh001514 for ; Tue, 18 Mar 2014 22:20:00 GMT (envelope-from gnats@freefall.freebsd.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.14.8/8.14.8/Submit) id s2IMK06O001513; Tue, 18 Mar 2014 22:20:00 GMT (envelope-from gnats) Resent-Date: Tue, 18 Mar 2014 22:20:00 GMT Resent-Message-Id: <201403182220.s2IMK06O001513@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, Alan Somers 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 E557CB2F for ; Tue, 18 Mar 2014 22:17:21 +0000 (UTC) Received: from cgiserv.freebsd.org (cgiserv.freebsd.org [IPv6:2001:1900:2254:206a::50:4]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.freebsd.org (Postfix) with ESMTPS id D217A7F5 for ; Tue, 18 Mar 2014 22:17:21 +0000 (UTC) Received: from cgiserv.freebsd.org ([127.0.1.6]) by cgiserv.freebsd.org (8.14.8/8.14.8) with ESMTP id s2IMHLXc059997 for ; Tue, 18 Mar 2014 22:17:21 GMT (envelope-from nobody@cgiserv.freebsd.org) Received: (from nobody@localhost) by cgiserv.freebsd.org (8.14.8/8.14.8/Submit) id s2IMHLoO059993; Tue, 18 Mar 2014 22:17:21 GMT (envelope-from nobody) Message-Id: <201403182217.s2IMHLoO059993@cgiserv.freebsd.org> Date: Tue, 18 Mar 2014 22:17:21 GMT From: Alan Somers To: freebsd-gnats-submit@FreeBSD.org X-Send-Pr-Version: www-3.1 Subject: kern/187712: config(8) does not respect KERNCONFDIR X-BeenThere: freebsd-bugs@freebsd.org X-Mailman-Version: 2.1.17 Precedence: list List-Id: Bug reports List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 18 Mar 2014 22:20:00 -0000 >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 #include #include +#include #include #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