Module Name: src Committed By: brook Date: Sun Jul 10 19:28:00 UTC 2022
Modified Files: src/doc: CHANGES src/usr.sbin/installboot: evboards.c installboot.8 installboot.c installboot.h Log Message: usr.sbin/installboot: Add a command line option (-u) to set U-Boot search paths Installboot can install U-Boot boot blocks directly into a system image. Normally, the U-Boot files are searched for in /usr/pkg/share/u-boot, under the expectation that most people will build them with pkgsrc. However, it is also possible to set an environment variable (INSTALLBOOT_UBOOT_PATHS) to a colon-separated search path to accommodate other situations. This commit adds a command line option (-u) to set the search path; if present, it overrides the environment and default. To generate a diff of this commit: cvs rdiff -u -r1.2889 -r1.2890 src/doc/CHANGES cvs rdiff -u -r1.6 -r1.7 src/usr.sbin/installboot/evboards.c cvs rdiff -u -r1.102 -r1.103 src/usr.sbin/installboot/installboot.8 cvs rdiff -u -r1.40 -r1.41 src/usr.sbin/installboot/installboot.c cvs rdiff -u -r1.42 -r1.43 src/usr.sbin/installboot/installboot.h Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Modified files: Index: src/doc/CHANGES diff -u src/doc/CHANGES:1.2889 src/doc/CHANGES:1.2890 --- src/doc/CHANGES:1.2889 Thu Jun 30 11:03:07 2022 +++ src/doc/CHANGES Sun Jul 10 19:28:00 2022 @@ -1,4 +1,4 @@ -# LIST OF CHANGES FROM LAST RELEASE: <$Revision: 1.2889 $> +# LIST OF CHANGES FROM LAST RELEASE: <$Revision: 1.2890 $> # # # [Note: This file does not mention every change made to the NetBSD source tree. @@ -621,3 +621,5 @@ Changes from NetBSD 9.0 to NetBSD 10.0: [christos 20220627] uintuos(4): Add a driver for Wacom Intuos drawing tablets. [yhardy 20220630] + installboot(8): Add -u option to set U-Boot search paths. + [brook 20220710] Index: src/usr.sbin/installboot/evboards.c diff -u src/usr.sbin/installboot/evboards.c:1.6 src/usr.sbin/installboot/evboards.c:1.7 --- src/usr.sbin/installboot/evboards.c:1.6 Fri Aug 6 07:55:13 2021 +++ src/usr.sbin/installboot/evboards.c Sun Jul 10 19:28:00 2022 @@ -1,4 +1,4 @@ -/* $NetBSD: evboards.c,v 1.6 2021/08/06 07:55:13 andvar Exp $ */ +/* $NetBSD: evboards.c,v 1.7 2022/07/10 19:28:00 brook Exp $ */ /*- * Copyright (c) 2019 The NetBSD Foundation, Inc. @@ -35,7 +35,7 @@ #include <sys/cdefs.h> #if !defined(__lint) -__RCSID("$NetBSD: evboards.c,v 1.6 2021/08/06 07:55:13 andvar Exp $"); +__RCSID("$NetBSD: evboards.c,v 1.7 2022/07/10 19:28:00 brook Exp $"); #endif /* !__lint */ #include <sys/types.h> @@ -152,8 +152,9 @@ __RCSID("$NetBSD: evboards.c,v 1.6 2021/ * * /usr/pkg/share/u-boot * - * This can be overridden with the INSTALLBOOT_UBOOT_PATHS environment - * variable, which contains a colon-separated list of directories, e.g.: + * This can be overridden with either the INSTALLBOOT_UBOOT_PATHS + * environment variable or the command line option -u, which contains + * a colon-separated list of directories, e.g.: * * /usr/pkg/share/u-boot:/home/jmcneill/hackityhack/u-boot * @@ -441,16 +442,6 @@ make_path(char *buf, size_t bufsize, con static const char evb_db_base_location[] = EVBOARDS_PLIST_BASE "/share/installboot"; -#ifndef DEFAULT_UBOOT_PKG_PATH -#define DEFAULT_UBOOT_PKG_PATH "/usr/pkg/share/u-boot" -#endif - -#ifndef UBOOT_PATHS_ENV_VAR -#define UBOOT_PATHS_ENV_VAR "INSTALLBOOT_UBOOT_PATHS" -#endif - -static const char evb_uboot_pkg_path[] = DEFAULT_UBOOT_PKG_PATH; - /* * evb_db_base_path -- * Returns the path to the base board db file. @@ -483,9 +474,8 @@ evb_uboot_pkg_paths(ib_params *params, i int i, count; char *cp, *startcp; - pathspec = getenv(UBOOT_PATHS_ENV_VAR); - if (pathspec == NULL) - pathspec = evb_uboot_pkg_path; + pathspec = params->uboot_paths; + assert(pathspec != NULL); if (strlen(pathspec) == 0) goto out; Index: src/usr.sbin/installboot/installboot.8 diff -u src/usr.sbin/installboot/installboot.8:1.102 src/usr.sbin/installboot/installboot.8:1.103 --- src/usr.sbin/installboot/installboot.8:1.102 Sun Dec 5 04:46:33 2021 +++ src/usr.sbin/installboot/installboot.8 Sun Jul 10 19:28:00 2022 @@ -1,4 +1,4 @@ -.\" $NetBSD: installboot.8,v 1.102 2021/12/05 04:46:33 msaitoh Exp $ +.\" $NetBSD: installboot.8,v 1.103 2022/07/10 19:28:00 brook Exp $ .\" .\" Copyright (c) 2002-2019 The NetBSD Foundation, Inc. .\" All rights reserved. @@ -42,6 +42,7 @@ .Op Fl m Ar machine .Op Fl o Ar options .Op Fl t Ar fstype +.Op Fl u Ar U-boot-paths .Ar filesystem .Ar primary .Op Ar secondary @@ -407,6 +408,23 @@ be provided with .Fl B Ar s2bno . .El . +.It Fl u Ar U-boot-paths +.Ar U-boot-paths +is a colon-separated list of search paths to scan for +.Sy U-boot +packages with +.Nm installboot +installation overlays. +If multiple overlays are found, overlays from paths closer to the front +of the list take precedence. +If not specified, environment variable +.Ev INSTALLBOOT_UBOOT_PATHS +is used if defined; otherwise, the default path is +.Pa /usr/pkg/share/u-boot . +This option is only used on platforms that support +using +.Sy U-boot . +. .It Fl v Verbose operation. . @@ -485,8 +503,7 @@ If not specified, the default path is .Pa /usr/pkg/share/u-boot . This environment variable is only used on platforms that support using -.Sy U-boot : -.Sy evbarm . +.Sy U-boot . . .It Ev MACHINE Default value for Index: src/usr.sbin/installboot/installboot.c diff -u src/usr.sbin/installboot/installboot.c:1.40 src/usr.sbin/installboot/installboot.c:1.41 --- src/usr.sbin/installboot/installboot.c:1.40 Tue May 7 05:02:42 2019 +++ src/usr.sbin/installboot/installboot.c Sun Jul 10 19:28:00 2022 @@ -1,4 +1,4 @@ -/* $NetBSD: installboot.c,v 1.40 2019/05/07 05:02:42 thorpej Exp $ */ +/* $NetBSD: installboot.c,v 1.41 2022/07/10 19:28:00 brook Exp $ */ /*- * Copyright (c) 2002 The NetBSD Foundation, Inc. @@ -35,7 +35,7 @@ #include <sys/cdefs.h> #if !defined(__lint) -__RCSID("$NetBSD: installboot.c,v 1.40 2019/05/07 05:02:42 thorpej Exp $"); +__RCSID("$NetBSD: installboot.c,v 1.41 2022/07/10 19:28:00 brook Exp $"); #endif /* !__lint */ #include <sys/param.h> @@ -60,6 +60,7 @@ __RCSID("$NetBSD: installboot.c,v 1.40 2 static void getmachine(ib_params *, const char *, const char *); static void getfstype(ib_params *, const char *, const char *); +static void getubootpaths(ib_params *, const char *); static void parseoptions(ib_params *, const char *); __dead static void usage(void); static void options_usage(void); @@ -103,6 +104,14 @@ const struct option { #define DFL_SECSIZE 512 /* Don't use DEV_BSIZE. It's host's value. */ +#ifndef DEFAULT_UBOOT_PKG_PATH +#define DEFAULT_UBOOT_PKG_PATH "/usr/pkg/share/u-boot" +#endif + +#ifndef UBOOT_PATHS_ENV_VAR +#define UBOOT_PATHS_ENV_VAR "INSTALLBOOT_UBOOT_PATHS" +#endif + int main(int argc, char *argv[]) { @@ -126,8 +135,12 @@ main(int argc, char *argv[]) params->s1fd = -1; if ((p = getenv("MACHINE")) != NULL) getmachine(params, p, "$MACHINE"); + getubootpaths(params, DEFAULT_UBOOT_PKG_PATH); + if ((p = getenv(UBOOT_PATHS_ENV_VAR)) != NULL) { + getubootpaths(params, p); + } - while ((ch = getopt(argc, argv, "b:B:cefm:no:t:v")) != -1) { + while ((ch = getopt(argc, argv, "b:B:cefm:no:t:u:v")) != -1) { switch (ch) { case 'b': @@ -176,6 +189,10 @@ main(int argc, char *argv[]) getfstype(params, optarg, "-t"); break; + case 'u': + getubootpaths(params, optarg); + break; + case 'v': params->flags |= IB_VERBOSE; break; @@ -602,6 +619,15 @@ fstype_usage(void) } static void +getubootpaths(ib_params *param, const char *paths) +{ + assert(param != NULL); + assert(paths != NULL); + + param->uboot_paths = paths; +} + +static void usage(void) { const char *prog; @@ -609,7 +635,7 @@ usage(void) prog = getprogname(); fprintf(stderr, "usage: %s [-fnv] [-B s2bno] [-b s1bno] [-m machine] [-o options]\n" -"\t\t [-t fstype] filesystem primary [secondary]\n" +"\t\t [-t fstype] [-u uboot-paths] filesystem primary [secondary]\n" "usage: %s -c [-fnv] [-m machine] [-o options] [-t fstype] filesystem\n" "usage: %s -e [-fnv] [-m machine] [-o options] bootstrap\n", prog, prog, prog); Index: src/usr.sbin/installboot/installboot.h diff -u src/usr.sbin/installboot/installboot.h:1.42 src/usr.sbin/installboot/installboot.h:1.43 --- src/usr.sbin/installboot/installboot.h:1.42 Sun Jun 21 17:17:02 2020 +++ src/usr.sbin/installboot/installboot.h Sun Jul 10 19:28:00 2022 @@ -1,4 +1,4 @@ -/* $NetBSD: installboot.h,v 1.42 2020/06/21 17:17:02 thorpej Exp $ */ +/* $NetBSD: installboot.h,v 1.43 2022/07/10 19:28:00 brook Exp $ */ /*- * Copyright (c) 2002 The NetBSD Foundation, Inc. @@ -94,6 +94,7 @@ typedef struct { const char *stage2; /* name of stage2 bootstrap */ uint64_t s2start; /* start block of stage2 */ uint32_t sectorsize; /* sector size of target fs */ + const char *uboot_paths; /* u-boot paths */ /* parsed -o option=value data */ const char *command; /* name of command string */ const char *console; /* name of console */