From owner-dev-commits-src-all@freebsd.org Fri Mar 26 15:44:16 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 640DF57A89A; Fri, 26 Mar 2021 15:44:16 +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 4F6R9D2RcZz4q49; Fri, 26 Mar 2021 15:44:16 +0000 (UTC) (envelope-from git@FreeBSD.org) 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 423521C5CA; Fri, 26 Mar 2021 15:44:16 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 12QFiGkP048833; Fri, 26 Mar 2021 15:44:16 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 12QFiGY1048832; Fri, 26 Mar 2021 15:44:16 GMT (envelope-from git) Date: Fri, 26 Mar 2021 15:44:16 GMT Message-Id: <202103261544.12QFiGY1048832@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Nathan Whitehorn Subject: git: 5140034cc077 - main - Add a new mode to the scripted partition editor for variant disk names. MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: nwhitehorn X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 5140034cc077c416690b4fdb79a96744fe0af0e6 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 26 Mar 2021 15:44:16 -0000 The branch main has been updated by nwhitehorn: URL: https://cgit.FreeBSD.org/src/commit/?id=5140034cc077c416690b4fdb79a96744fe0af0e6 commit 5140034cc077c416690b4fdb79a96744fe0af0e6 Author: Nathan Whitehorn AuthorDate: 2021-03-26 15:39:12 +0000 Commit: Nathan Whitehorn CommitDate: 2021-03-26 15:43:47 +0000 Add a new mode to the scripted partition editor for variant disk names. If the disk parameter "DEFAULT" is set in place of an actual device name, or no disk is specified for the PARTITIONS parameter, the installer will follow the logic used in the automatic-partitioning mode, in which it will either provide a selection dialog for one of several disks if several are present or automatically select it if there is only one. This simplifies the creation of fully-automatic installation media for hardware or VMs with varying disk names. Suggested by: Egoitz Aurrekoetxea MFC after: 3 weeks Relnotes: yes --- usr.sbin/bsdinstall/bsdinstall.8 | 20 ++++++++++++++++---- usr.sbin/bsdinstall/partedit/part_wizard.c | 7 +++---- usr.sbin/bsdinstall/partedit/partedit.h | 1 + usr.sbin/bsdinstall/partedit/scripted.c | 10 +++++++--- 4 files changed, 27 insertions(+), 11 deletions(-) diff --git a/usr.sbin/bsdinstall/bsdinstall.8 b/usr.sbin/bsdinstall/bsdinstall.8 index c58f6636493a..e9f7dd808f73 100644 --- a/usr.sbin/bsdinstall/bsdinstall.8 +++ b/usr.sbin/bsdinstall/bsdinstall.8 @@ -25,7 +25,7 @@ .\" .\" $FreeBSD$ .\" -.Dd March 22, 2021 +.Dd March 26, 2021 .Dt BSDINSTALL 8 .Os .Sh NAME @@ -158,7 +158,13 @@ Multiple disk setups are separated by semicolons. The .Ar disk argument specifies the disk on which to operate (which will be erased), -while the +or the special value +.Em DEFAULT , +which will result in either a selection window (as in +.Cm autopart ) +for the destination disk or, if there is only one possible disk, will +automatically select it. +The .Ar scheme argument specifies the .Xr gpart 8 @@ -208,6 +214,10 @@ A shorter invocation to use the default partitioning (as would have used) on the same disk: .Pp bsdinstall scriptedpart ada0 +.Pp +or, even shorter: +.Pp +bsdinstall scriptedpart DEFAULT .It Cm mount Mounts the file systems previously configured by .Cm autopart , @@ -279,7 +289,9 @@ See of the .Sx TARGETS -section for format details. +section for format details. If this variable is unset, the installer will +use the default partitioning as in +.Cm autopart . Default: unset .It Ev BSDINSTALL_DISTDIR The directory in which the distribution files can be found (or to which they @@ -454,7 +466,7 @@ the interpreter for the setup script. .Pp A typical bsdinstall script looks like this: .Bd -literal -offset indent -PARTITIONS=ada0 +PARTITIONS=DEFAULT DISTRIBUTIONS="kernel.txz base.txz" #!/bin/sh diff --git a/usr.sbin/bsdinstall/partedit/part_wizard.c b/usr.sbin/bsdinstall/partedit/part_wizard.c index 3160e1f049ea..9f7158a4801e 100644 --- a/usr.sbin/bsdinstall/partedit/part_wizard.c +++ b/usr.sbin/bsdinstall/partedit/part_wizard.c @@ -44,7 +44,6 @@ #define MIN_FREE_SPACE (1024*1024*1024) /* 1 GB */ #define SWAP_SIZE(available) MIN(available/20, 4*1024*1024*1024LL) -static char *boot_disk(struct gmesh *mesh); static char *wizard_partition(struct gmesh *mesh, const char *disk); int @@ -65,7 +64,7 @@ startwizard: dlg_put_backtitle(); error = geom_gettree(&mesh); - disk = boot_disk(&mesh); + disk = boot_disk_select(&mesh); if (disk == NULL) return (1); @@ -91,8 +90,8 @@ startwizard: return (0); } -static char * -boot_disk(struct gmesh *mesh) +char * +boot_disk_select(struct gmesh *mesh) { struct gclass *classp; struct gconfig *gc; diff --git a/usr.sbin/bsdinstall/partedit/partedit.h b/usr.sbin/bsdinstall/partedit/partedit.h index e989decc2359..20d2047c1408 100644 --- a/usr.sbin/bsdinstall/partedit/partedit.h +++ b/usr.sbin/bsdinstall/partedit/partedit.h @@ -60,6 +60,7 @@ void delete_part_metadata(const char *name); int part_wizard(const char *fstype); int scripted_editor(int argc, const char **argv); +char *boot_disk_select(struct gmesh *mesh); int wizard_makeparts(struct gmesh *mesh, const char *disk, const char *fstype, int interactive); diff --git a/usr.sbin/bsdinstall/partedit/scripted.c b/usr.sbin/bsdinstall/partedit/scripted.c index 57dcbca816a3..37ac6de131b5 100644 --- a/usr.sbin/bsdinstall/partedit/scripted.c +++ b/usr.sbin/bsdinstall/partedit/scripted.c @@ -183,10 +183,14 @@ int parse_disk_config(char *input) } } while (input != NULL && *input != 0); - if (disk != NULL) - return (part_config(disk, scheme, partconfig)); + if (disk == NULL || strcmp(disk, "DEFAULT") == 0) { + struct gmesh mesh; + geom_gettree(&mesh); + disk = boot_disk_select(&mesh); + geom_deletetree(&mesh); + } - return (0); + return (part_config(disk, scheme, partconfig)); } int