From nobody Tue Apr 16 20:12:30 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 4VJwFC12B3z5H0MH; Tue, 16 Apr 2024 20:12:31 +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 "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4VJwFB6T14z4sBS; Tue, 16 Apr 2024 20:12:30 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1713298350; 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=CPi13tKyJheT2ke3He+8padx8xRuui6HRkrfFZfPK6g=; b=xd43+U+o0FPTB9GCyxb6LrCH1TFqvb5sKM3QWYN7HhMnwgCeILS8jTdU/7F2fnU2QrhPOB kKCTJX23RbOMMcgj2wMEu8yhG//yJfJHW8OWYQd5vBH/TzXegjNiLhYqRmgYtkkvGYxG2+ yqdqT4P8b2mqz2ZHh/GhhzlE3Lyd11wmNyZNpUsb0H6XsjfN/ACgDe5El7yru9guxCXkn6 trbXwYCm1qfl07hlHG98h8uLaXqBJOUaJ8iAkAJBMFM8ZdHvlkO2CIAwyapSJzDMm4+qPj 2wLKLocIh8vNmxAwpumQ5rRWXcckcjvJVmBltiQDFvCUnbwKq3P2BR3e/D1Csg== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1713298350; a=rsa-sha256; cv=none; b=rRm54gt3WF0YBXSfTkeJgsa1e3NXbbTBjo8x1Zt7pQp0PI36F7H+JPOu1D3o797iXstzvq pzQ1Ov/Ze9mCMZy9l1n+6la1SRbK36gpH4odqEDXYBXYe6WQLpOSLTRdQ8TnCqdMLLzSQM Nx4vAkSTEsPwrwPUCzCvTa5uII+XcCmkzzt9+DnbOLCkNlshfCdTXSFkvishLww/U3kQ2J SGvDDHwTN5eakF7kSPZzgZd8tcQqy5AOYh30V3lbp8TbQTXfnghQlSDeo0/L8foX+ytQsS Dnmwqcle0pAoJOWbo+iXUYFg8BvwafuhrnLT7WxXFehygPYQqklTVOoF4yV5Qg== 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=1713298350; 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=CPi13tKyJheT2ke3He+8padx8xRuui6HRkrfFZfPK6g=; b=ecRCJFoaUkIc9bFbq+yGJq6e8CCn5uBfOjVfvT/rJsbGwUkm6c5+5wuaAdnMXP5p3HOmd1 uJeVMXd2L+C+0glCRD/7vX4/FmPuQCZc5wLMCiOm213UWaGZ/FByiR01ItwIEPUuUUb6L4 ElC9lhP4AEgmBRWGH+tzOKP/Vjl8H2PrcYDH/JymrU9ksaGnwE7sbWDvnplRDgibQ+GZ8W mUUkrIH7rEmZAFVqUpkkUFCv3mQnSCxByN+XQ4iPdw+ngKEb4M5UWGBNJiAjPTvxYO5yA5 ARgUMxW8NXLVkUvxJnHnP4gAumpFrihlfymWuwKkFAAZHmwDLOVQnKYR16r1Ig== 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 4VJwFB64STzxJS; Tue, 16 Apr 2024 20:12:30 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.17.1/8.17.1) with ESMTP id 43GKCUqp037134; Tue, 16 Apr 2024 20:12:30 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.17.1/8.17.1/Submit) id 43GKCUjH037131; Tue, 16 Apr 2024 20:12:30 GMT (envelope-from git) Date: Tue, 16 Apr 2024 20:12:30 GMT Message-Id: <202404162012.43GKCUjH037131@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Warner Losh Subject: git: a25531db0fc2 - stable/14 - stand/lua: always allow overriding with local config files 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: imp X-Git-Repository: src X-Git-Refname: refs/heads/stable/14 X-Git-Reftype: branch X-Git-Commit: a25531db0fc22a82f87f6166553e9b1623c83837 Auto-Submitted: auto-generated The branch stable/14 has been updated by imp: URL: https://cgit.FreeBSD.org/src/commit/?id=a25531db0fc22a82f87f6166553e9b1623c83837 commit a25531db0fc22a82f87f6166553e9b1623c83837 Author: Stéphane Rochoy AuthorDate: 2023-12-21 14:05:58 +0000 Commit: Warner Losh CommitDate: 2024-04-16 19:54:21 +0000 stand/lua: always allow overriding with local config files Loader now also read configuration files listed in local_loader_conf_files. Files listed here are the last ones read. And /boot/loader.conf.local was moved from loader_conf_files to local_loader_conf_files leaving only loader.conf and device.hints in loader_conf_files by default. The idea is to ensure local_loader_conf_files, i.e., /boot/loader.conf.local, can always be used to override other user defined settings. So the sequencing is now as follow: 1. Bootstrap: /boot/defaults/loader.conf 2. Read loader_conf_files files: /boot/device.hints /boot/loader.conf 3. Read loader_conf_dirs files: /boot/loader.conf.d/*.conf 4. And finally, rread local_loader_conf_files files: /boot/loader.conf.local Reviewed by: imp, kevans Pull Request: https://github.com/freebsd/freebsd-src/pull/759 [[ The commit, revert, recommit has been squashed down to record the merge ]] (cherry picked from commit c475e61f66fe8fe939e18ec7821c2340569f3271) (cherry picked from commit 5fdf01dbeef1f64f8c446561498d662702451ac1) (cherry picked from commit d3d0b735571d9562812ce5b343a6e91f7a795dbe) --- UPDATING | 21 +++++++++++++++++++++ stand/defaults/loader.conf | 3 ++- stand/defaults/loader.conf.5 | 32 ++++++++++++++++++++++++++++---- stand/lua/config.lua | 15 ++++++++++++--- stand/lua/config.lua.8 | 8 ++++++-- 5 files changed, 69 insertions(+), 10 deletions(-) diff --git a/UPDATING b/UPDATING index d211814b0248..83b0d8b27cda 100644 --- a/UPDATING +++ b/UPDATING @@ -12,6 +12,27 @@ Items affecting the ports and packages system can be found in /usr/ports/UPDATING. Please read that file before updating system packages and/or ports. +20240202: + Loader now also read configuration files listed in local_loader_conf_files. + Files listed here are the last ones read. And /boot/loader.conf.local was + moved from loader_conf_files to local_loader_conf_files leaving only + loader.conf and device.hints in loader_conf_files by default. + + The following sequencing is applied: + + 1. Bootstrap: + /boot/defaults/loader.conf + + 2. Read loader_conf_files files: + /boot/device.hints + /boot/loader.conf + + 3. Read loader_conf_dirs files: + /boot/loader.conf.d/*.conf + + 4. And finally, rread local_loader_conf_files files: + /boot/loader.conf.local + 20240415: MFC e0f3dc82727f: If you have an arm64 system that uses ACPI, you will need to update your loader.efi in the ESP when you update past this diff --git a/stand/defaults/loader.conf b/stand/defaults/loader.conf index e0062bbc8149..a5d27b96b6ba 100644 --- a/stand/defaults/loader.conf +++ b/stand/defaults/loader.conf @@ -13,8 +13,9 @@ exec="echo Loading /boot/defaults/loader.conf" kernel="kernel" # /boot sub-directory containing kernel and modules bootfile="kernel" # Kernel name (possibly absolute path) kernel_options="" # Flags to be passed to the kernel -loader_conf_files="/boot/device.hints /boot/loader.conf /boot/loader.conf.local" +loader_conf_files="/boot/device.hints /boot/loader.conf" loader_conf_dirs="/boot/loader.conf.d" +local_loader_conf_files="/boot/loader.conf.local" nextboot_conf="/boot/nextboot.conf" verbose_loading="NO" # Set to YES for verbose loader output diff --git a/stand/defaults/loader.conf.5 b/stand/defaults/loader.conf.5 index 0d82a3dac9b3..e38ad865c288 100644 --- a/stand/defaults/loader.conf.5 +++ b/stand/defaults/loader.conf.5 @@ -131,6 +131,10 @@ Space separated list of directories to process for configuration files. The lua-based loader will process files with a .Dq .conf suffix that are placed in these directories. +Files found here are processed after the ones listed in +.Va loader_conf_files +but before the ones found in +.Va local_loader_conf_files . .It Ar loader_conf_files Defines additional configuration files to be processed right after the present file. @@ -138,6 +142,13 @@ present file. should be treated as write-only. One cannot depend on any value remaining in the loader environment or carried over into the kernel environment. +.It Ar local_loader_conf_files +Space separated list of additional configuration files to be processed at last, +i.e., after +.Va loader_conf_files +and +.Va loader_conf_dirs +are processed. .It Ar product_vars When set, must be a space separated list of environment variable names to walk through to guess product information. @@ -274,6 +285,14 @@ default settings can be ignored. The few of them which are important or useful are: .Bl -tag -width bootfile -offset indent +.It Va local_loader_conf_files +.Pq Dq /boot/loader.conf.local +Ensure +.Va loader.conf.local +can always be used to override settings from files found in +.Va loader_conf_files +and +.Va loader_conf_dirs . .It Va bitmap_load .Pq Dq NO If set to @@ -455,13 +474,18 @@ It is not available in the default Forth-based loader. .Sh FILES .Bl -tag -width /boot/defaults/loader.conf -compact .It Pa /boot/defaults/loader.conf -default settings \(em do not change this file. +Default settings \(em do not change this file. .It Pa /boot/loader.conf -user defined settings. +User defined settings. .It Pa /boot/loader.conf.lua -user defined settings written in lua. +User defined settings written in lua. +.It Pa /boot/loader.conf.d/*.conf +User defined settings split in separate files. +.It Pa /boot/loader.conf.d/*.lua +User defined settings written in lua and split in separate files. .It Pa /boot/loader.conf.local -machine-specific settings for sites with a common loader.conf. +Machine-specific settings for sites with a common loader.conf. Allow to override +settings defined in other files. .El .Sh SEE ALSO .Xr kenv 1 , diff --git a/stand/lua/config.lua b/stand/lua/config.lua index 210bb9338783..86f5ef6174a2 100644 --- a/stand/lua/config.lua +++ b/stand/lua/config.lua @@ -630,8 +630,7 @@ function config.readConf(file, loaded_files) return end - -- We'll process loader_conf_dirs at the top-level readConf - local load_conf_dirs = next(loaded_files) == nil + local top_level = next(loaded_files) == nil -- Are we the top-level readConf? print("Loading " .. file) -- The final value of loader_conf_files is not important, so just @@ -656,7 +655,7 @@ function config.readConf(file, loaded_files) end end - if load_conf_dirs then + if top_level then local loader_conf_dirs = getEnv("loader_conf_dirs") -- If product_vars is set, it must be a list of environment variable names @@ -682,6 +681,7 @@ function config.readConf(file, loaded_files) end end + -- Process "loader_conf_dirs" extra-directories if loader_conf_dirs ~= nil then for name in loader_conf_dirs:gmatch("[%w%p]+") do if lfs.attributes(name, "mode") ~= "directory" then @@ -700,6 +700,15 @@ function config.readConf(file, loaded_files) ::nextdir:: end end + + -- Always allow overriding with local config files, e.g., + -- /boot/loader.conf.local. + local local_loader_conf_files = getEnv("local_loader_conf_files") + if local_loader_conf_files then + for name in local_loader_conf_files:gmatch("[%w%p]+") do + config.readConf(name, loaded_files) + end + end end end diff --git a/stand/lua/config.lua.8 b/stand/lua/config.lua.8 index f9896f2aa420..b2b1122285eb 100644 --- a/stand/lua/config.lua.8 +++ b/stand/lua/config.lua.8 @@ -64,9 +64,13 @@ as a configuration file .Po e.g., as .Pa loader.conf .Pc -and then processing files listed in +and then process files listed in the .Ev loader_conf_files -variable +variable. Additionnaly, the top-level call to readConf will process files listed in the +.Ev loader_conf_dirs +and +.Ev local_loader_conf_files +variables .Po see .Xr loader.conf 5 .Pc .