Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src usr.sbin/installboot: Add a command line option (-u) to set ...



details:   https://anonhg.NetBSD.org/src/rev/6c22bd72d53b
branches:  trunk
changeset: 368423:6c22bd72d53b
user:      brook <brook%NetBSD.org@localhost>
date:      Sun Jul 10 19:28:00 2022 +0000

description:
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.

diffstat:

 doc/CHANGES                        |   4 +++-
 usr.sbin/installboot/evboards.c    |  24 +++++++-----------------
 usr.sbin/installboot/installboot.8 |  23 ++++++++++++++++++++---
 usr.sbin/installboot/installboot.c |  34 ++++++++++++++++++++++++++++++----
 usr.sbin/installboot/installboot.h |   3 ++-
 5 files changed, 62 insertions(+), 26 deletions(-)

diffs (233 lines):

diff -r c9d701ef1c47 -r 6c22bd72d53b doc/CHANGES
--- a/doc/CHANGES       Sun Jul 10 18:52:34 2022 +0000
+++ b/doc/CHANGES       Sun Jul 10 19:28:00 2022 +0000
@@ -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 @@
                [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]
diff -r c9d701ef1c47 -r 6c22bd72d53b usr.sbin/installboot/evboards.c
--- a/usr.sbin/installboot/evboards.c   Sun Jul 10 18:52:34 2022 +0000
+++ b/usr.sbin/installboot/evboards.c   Sun Jul 10 19:28:00 2022 +0000
@@ -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 @@
  *
  *     /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 @@
 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 @@
        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;
diff -r c9d701ef1c47 -r 6c22bd72d53b usr.sbin/installboot/installboot.8
--- a/usr.sbin/installboot/installboot.8        Sun Jul 10 18:52:34 2022 +0000
+++ b/usr.sbin/installboot/installboot.8        Sun Jul 10 19:28:00 2022 +0000
@@ -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 @@
 .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 @@
 .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
diff -r c9d701ef1c47 -r 6c22bd72d53b usr.sbin/installboot/installboot.c
--- a/usr.sbin/installboot/installboot.c        Sun Jul 10 18:52:34 2022 +0000
+++ b/usr.sbin/installboot/installboot.c        Sun Jul 10 19:28:00 2022 +0000
@@ -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 @@
 
 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 @@
 
 #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 @@
        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 @@
                        getfstype(params, optarg, "-t");
                        break;
 
+               case 'u':
+                       getubootpaths(params, optarg);
+                       break;
+
                case 'v':
                        params->flags |= IB_VERBOSE;
                        break;
@@ -602,6 +619,15 @@
 }
 
 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 @@
        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);
diff -r c9d701ef1c47 -r 6c22bd72d53b usr.sbin/installboot/installboot.h
--- a/usr.sbin/installboot/installboot.h        Sun Jul 10 18:52:34 2022 +0000
+++ b/usr.sbin/installboot/installboot.h        Sun Jul 10 19:28:00 2022 +0000
@@ -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 @@
        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 */



Home | Main Index | Thread Index | Old Index