From nobody Wed Sep 18 17:02:49 2024 X-Original-To: dev-commits-src-all@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4X84hp0TzSz5WpVJ; Wed, 18 Sep 2024 17:02:50 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R11" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4X84hn6rj4z4Wxr; Wed, 18 Sep 2024 17:02:49 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1726678970; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=g4DDGUhkYxzIbKh0WQvtJqLF7Y0dFSNuqwTOTq1wVFE=; b=lg8bd2Fr4scfKBFMeOz6cuiFAWBrIINet0AlaNXwkydRP1IxaelTMeq7ahUerToT2j4edu Z/b3wEE68WDAN0878oj4lHzuBGnkGv2uvcmwxgY2Yva1wwsz6DTmBoxZeu+Tdn9DefYpnn KWtRVGF/xpT8TLYjasMTptBTZozThnLGLZ68+gAZtRh+9F2V+hmmHYPIVb0lVVQUQiKYr+ gIbmgvuczpP+yW1Db3pHXFfwz1aRssmJW6OXLB88xmK029zmMyPt3DiPtkpvakQStS/hZ7 6w/MG2+PtyDoRqb2Fc9/U5Usu/00+g9IR47ssOu8NRTJdDcLPlxKxsj92Nas0g== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1726678970; a=rsa-sha256; cv=none; b=gMeDSwTcePT69G8OTNuan/UXkcfrkyz+Ue+HU0B2MtDffol/8MCKNiIYPaszP10U6wK7fO CiTtr+lEeI3NL/vDRtmRQJWGdCC4lnaDLknER19ahneW/tDLlhbisX34+MDTWIBSQoNc62 XIPlkkXwLkyICbx9fZZ6sCPDsFdQvR1F/tdKJRHOJmy9Kzrgo0Mb5LWXd3RganASi2TD3P fQCS5eCJNiNeTNGORBEBwAoi1yi6QTZFk9v2lckxBNShPaBnLlkhAL6+bTWCV48P9Jzy0A 0e/NcFYjpaAxRobpAPWjms+aICG84TFEjAOFokRwcChYhRAJAv7pnGKcXRt1SQ== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1726678970; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=g4DDGUhkYxzIbKh0WQvtJqLF7Y0dFSNuqwTOTq1wVFE=; b=OC0BGjlVa+ZD9t5Kv1zwEsczUw+lfzu1g9IQQVq0uwvYUenwNRc8V+AQfncFGMf7+3q9wA Z2g+Euy5L5Wh2B2XfdOkTiGXJATSuO/Y8sKrv/Wnva7aruzTsPsKz3oxNc8ZS6U5/Wd1/0 BBVsKMVqfztau4kr9/Y9mHsAWTYqfunIaMdYDz142gO4lIaVQzPVn0/q9v3JcCnNrPRcJC KR0qtZij9V6Mea7TM36+5alur5cZkncRwNlyV6Ybf7/ZOQN4d+JtIYnJkYQ/e7bi8NFbSM d8TxhvNPBd2TN8JY/gyA7NKfyNB4e7Mip+VPz2l8KZUB/br51KCIMg2AgVsKFg== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 4X84hn6PFDzVnB; Wed, 18 Sep 2024 17:02:49 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.18.1/8.18.1) with ESMTP id 48IH2ndv059239; Wed, 18 Sep 2024 17:02:49 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.18.1/8.18.1/Submit) id 48IH2nM7059236; Wed, 18 Sep 2024 17:02:49 GMT (envelope-from git) Date: Wed, 18 Sep 2024 17:02:49 GMT Message-Id: <202409181702.48IH2nM7059236@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: "Stephen J. Kiernan" Subject: git: 9e2b87207ba1 - main - Allow additional "options" files to be specified in kernel config List-Id: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: X-BeenThere: dev-commits-src-all@freebsd.org Sender: owner-dev-commits-src-all@FreeBSD.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: stevek X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 9e2b87207ba1949f402e169416f63ab5cdbf3dd4 Auto-Submitted: auto-generated The branch main has been updated by stevek: URL: https://cgit.FreeBSD.org/src/commit/?id=9e2b87207ba1949f402e169416f63ab5cdbf3dd4 commit 9e2b87207ba1949f402e169416f63ab5cdbf3dd4 Author: Stephen J. Kiernan AuthorDate: 2024-09-18 17:02:42 +0000 Commit: Stephen J. Kiernan CommitDate: 2024-09-18 17:02:42 +0000 Allow additional "options" files to be specified in kernel config The "includeoptions" directive can be used to specify an additional options file to be used. This is useful in conjunction with the "files" directive for build environments to be able to add custom files and options. Add "-v" flag to enable verbose mode. Added some additional error messages when in verbose mode. Obtained from: Juniper Networks, Inc. Reviewed by: imp Differential Revision: https://reviews.freebsd.org/D39540 --- usr.sbin/config/config.5 | 9 +++++++++ usr.sbin/config/config.8 | 4 +++- usr.sbin/config/config.h | 2 ++ usr.sbin/config/config.y | 22 ++++++++++++++++++++++ usr.sbin/config/lang.l | 1 + usr.sbin/config/main.cc | 7 ++++++- usr.sbin/config/mkoptions.cc | 21 +++++++++++++++++++-- 7 files changed, 62 insertions(+), 4 deletions(-) diff --git a/usr.sbin/config/config.5 b/usr.sbin/config/config.5 index f77b79a31510..8c2c62b706bd 100644 --- a/usr.sbin/config/config.5 +++ b/usr.sbin/config/config.5 @@ -239,6 +239,15 @@ Read subsequent text from file and return to the current file after .Ar filename is successfully processed. +.\" -------- INCLUDEOPTIONS -------- +.Pp +.It .Ic includeoptions Ar filename +Specifies a file containing a list of additional options +specific to that kernel configuration file. +This is useful for build environments that need to add +custom options and is often used in conjunction with the +.Ic makeoption +directive. .\" -------- MACHINE -------- .Pp .It Ic machine Ar arch Op Ar cpuarch diff --git a/usr.sbin/config/config.8 b/usr.sbin/config/config.8 index ccb61cdf2786..e0912a4bc104 100644 --- a/usr.sbin/config/config.8 +++ b/usr.sbin/config/config.8 @@ -33,7 +33,7 @@ .Nd build system configuration files .Sh SYNOPSIS .Nm -.Op Fl CVgp +.Op Fl CVgpv .Op Fl I Ar path .Op Fl d Ar destdir .Op Fl s Ar srcdir @@ -99,6 +99,8 @@ file. This option makes sense only if .Cd "options INCLUDE_CONFIG_FILE" entry was present in your configuration file. +.It Fl v +Turns on verbose output. .It Ar SYSTEM_NAME Specify the name of the system configuration file containing device specifications, configuration options diff --git a/usr.sbin/config/config.h b/usr.sbin/config/config.h index 16562a7f8210..6085c52d1b95 100644 --- a/usr.sbin/config/config.h +++ b/usr.sbin/config/config.h @@ -260,9 +260,11 @@ extern const char *yyfile; extern STAILQ_HEAD(file_list_head, file_list) ftab; extern STAILQ_HEAD(files_name_head, files_name) fntab; +extern STAILQ_HEAD(options_files_name_head, files_name) optfntab; extern int debugging; extern int found_defaults; +extern int verbose; extern int maxusers; extern int versreq; diff --git a/usr.sbin/config/config.y b/usr.sbin/config/config.y index 4120ffa54b1c..15139197dbb6 100644 --- a/usr.sbin/config/config.y +++ b/usr.sbin/config/config.y @@ -24,6 +24,7 @@ %token NOMAKEOPTION %token SEMICOLON %token INCLUDE +%token INCLUDEOPTIONS %token FILES %token ENVLINE @@ -83,6 +84,7 @@ int yyline; const char *yyfile; struct file_list_head ftab; struct files_name_head fntab; +struct options_files_name_head optfntab; char errbuf[80]; int maxusers; @@ -93,6 +95,7 @@ int yywrap(void); static void newdev(char *name); static void newfile(char *name); +static void newoptionsfile(char *name); static void newenvvar(char *name, bool is_file); static void rmdev_schedule(struct device_head *dh, char *name); static void newopt(struct opt_head *list, char *name, char *value, int append, int dupe); @@ -135,6 +138,10 @@ Spec: include($2, 0); }; | + INCLUDEOPTIONS PATH SEMICOLON { newoptionsfile($2); }; + | + INCLUDEOPTIONS ID SEMICOLON { newoptionsfile($2); }; + | FILES ID SEMICOLON { newfile($2); }; | SEMICOLON @@ -335,6 +342,21 @@ newfile(char *name) STAILQ_INSERT_TAIL(&fntab, nl, f_next); } +/* + * Add a new options file to the list of options files. + */ +static void +newoptionsfile(char *name) +{ + struct files_name *nl; + + nl = (struct files_name *) calloc(1, sizeof *nl); + if (nl == NULL) + err(EXIT_FAILURE, "calloc"); + nl->f_name = name; + STAILQ_INSERT_TAIL(&optfntab, nl, f_next); +} + static void newenvvar(char *name, bool is_file) { diff --git a/usr.sbin/config/lang.l b/usr.sbin/config/lang.l index a6558237db5a..2052d98d1fdd 100644 --- a/usr.sbin/config/lang.l +++ b/usr.sbin/config/lang.l @@ -80,6 +80,7 @@ struct kt { { "nooption", NOOPTION }, { "nooptions", NOOPTION }, { "include", INCLUDE }, + { "includeoptions", INCLUDEOPTIONS }, { "files", FILES }, { 0, 0 }, }; diff --git a/usr.sbin/config/main.cc b/usr.sbin/config/main.cc index 0c0b9bb27dc3..1e89cbf3230a 100644 --- a/usr.sbin/config/main.cc +++ b/usr.sbin/config/main.cc @@ -78,6 +78,7 @@ char srcdir[MAXPATHLEN]; int debugging; int found_defaults; int incignore; +int verbose; /* * Preserve old behaviour in INCLUDE_CONFIG_FILE handling (files are included @@ -130,7 +131,8 @@ main(int argc, char **argv) STAILQ_INIT(&ftab); STAILQ_INIT(&hints); STAILQ_INIT(&envvars); - while ((ch = getopt(argc, argv, "Cd:gI:mps:Vx:")) != -1) + STAILQ_INIT(&optfntab); + while ((ch = getopt(argc, argv, "Cd:gI:mps:Vvx:")) != -1) switch (ch) { case 'C': filebased = 1; @@ -165,6 +167,9 @@ main(int argc, char **argv) case 'V': printf("%d\n", CONFIGVERS); exit(0); + case 'v': + verbose++; + break; case 'x': kernfile = optarg; break; diff --git a/usr.sbin/config/mkoptions.cc b/usr.sbin/config/mkoptions.cc index 1580700dc08d..3b5ed17e455c 100644 --- a/usr.sbin/config/mkoptions.cc +++ b/usr.sbin/config/mkoptions.cc @@ -38,6 +38,7 @@ #include #include #include +#include #include #include "config.h" #include "y.tab.h" @@ -71,7 +72,9 @@ options(void) } if (maxusers == 0) { - /* fprintf(stderr, "maxusers not specified; will auto-size\n"); */ + if (verbose) + fprintf(stderr, + "maxusers not specified; will auto-size\n"); } else if (maxusers < users.u_min) { fprintf(stderr, "minimum of %d maxusers assumed\n", users.u_min); @@ -363,8 +366,15 @@ read_option_file(const char *fname, int flags) char genopt[MAXPATHLEN]; fp = fopen(fname, "r"); - if (fp == NULL) + if (fp == NULL) { + if (verbose) { + getcwd(genopt, sizeof(genopt)); + fprintf(stderr, "Unable to open options file: %s\n", + fname); + fprintf(stderr, "CWD: %s\n", genopt); + } return (0); + } while (!(wd = get_word(fp)).eof()) { if (wd.eol()) continue; @@ -417,6 +427,7 @@ static void read_options(void) { char fname[MAXPATHLEN]; + struct files_name *nl, *tnl; SLIST_INIT(&otab); read_option_file("../../conf/options", 0); @@ -426,6 +437,12 @@ read_options(void) (void)snprintf(fname, sizeof fname, "options.%s", machinename); read_option_file(fname, 0); } + for (nl = STAILQ_FIRST(&optfntab); nl != NULL; nl = tnl) { + read_option_file(nl->f_name, 0); + tnl = STAILQ_NEXT(nl, f_next); + free(nl->f_name); + free(nl); + } read_option_file("../../conf/options-compat", OL_ALIAS); }