mail archive of the barebox mailing list
 help / color / mirror / Atom feed
* [PATCH 1/3] commands: boot: fix error code/clean up behavior when not booting
@ 2020-11-23 16:14 Ahmad Fatoum
  2020-11-23 16:14 ` [PATCH 2/3] commands: boot: display each list entry in a separate line Ahmad Fatoum
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Ahmad Fatoum @ 2020-11-23 16:14 UTC (permalink / raw)
  To: barebox; +Cc: Ahmad Fatoum

The boot command won't boot if:
  - There are no boot entries: we should still clean up before
    returning an error
  - A menu or list of found entries should be displayed: we should
    exit with success
  - We were doing a dry run: we should propagate the boot entry
    boot method's exit code

Do the necessary.

Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
---
 commands/boot.c | 13 +++++--------
 1 file changed, 5 insertions(+), 8 deletions(-)

diff --git a/commands/boot.c b/commands/boot.c
index d7795bde726b..18f4e36ec733 100644
--- a/commands/boot.c
+++ b/commands/boot.c
@@ -97,19 +97,16 @@ static int do_boot(int argc, char *argv[])
 
 	if (list_empty(&entries->entries)) {
 		printf("Nothing bootable found\n");
-		return COMMAND_ERROR;
-	}
-
-	if (do_list) {
-		bootsources_list(entries);
+		ret = COMMAND_ERROR;
 		goto out;
 	}
 
-	if (do_menu) {
+	if (do_list)
+		bootsources_list(entries);
+	else if (do_menu)
 		bootsources_menu(entries, timeout);
-		goto out;
-	}
 
+	ret = 0;
 out:
 	bootentries_free(entries);
 	free(freep);
-- 
2.29.2


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [PATCH 2/3] commands: boot: display each list entry in a separate line
  2020-11-23 16:14 [PATCH 1/3] commands: boot: fix error code/clean up behavior when not booting Ahmad Fatoum
@ 2020-11-23 16:14 ` Ahmad Fatoum
  2020-11-23 16:14 ` [PATCH 3/3] commands: boot: include blspec path name in entry title Ahmad Fatoum
  2020-11-24  8:47 ` [PATCH 1/3] commands: boot: fix error code/clean up behavior when not booting Sascha Hauer
  2 siblings, 0 replies; 4+ messages in thread
From: Ahmad Fatoum @ 2020-11-23 16:14 UTC (permalink / raw)
  To: barebox; +Cc: Ahmad Fatoum

The boot entry lines could get quite long for bootspec entries and then
follow-up commit will make them even longer, thus split the lines into
two lines and indent the second.

Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
---
 common/boot.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/common/boot.c b/common/boot.c
index 76d03c26c4f4..6e41849ee043 100644
--- a/common/boot.c
+++ b/common/boot.c
@@ -390,11 +390,10 @@ void bootsources_list(struct bootentries *bootentries)
 {
 	struct bootentry *entry;
 
-	printf("%-20s\n", "title");
-	printf("%-20s\n", "------");
+	printf("title\n------\n");
 
 	bootentries_for_each_entry(bootentries, entry)
-		printf("%-20s %s\n", entry->title, entry->description);
+		printf("%s\n\t%s\n", entry->title, entry->description);
 }
 
 BAREBOX_MAGICVAR(global.boot.default, "default boot order");
-- 
2.29.2


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [PATCH 3/3] commands: boot: include blspec path name in entry title
  2020-11-23 16:14 [PATCH 1/3] commands: boot: fix error code/clean up behavior when not booting Ahmad Fatoum
  2020-11-23 16:14 ` [PATCH 2/3] commands: boot: display each list entry in a separate line Ahmad Fatoum
@ 2020-11-23 16:14 ` Ahmad Fatoum
  2020-11-24  8:47 ` [PATCH 1/3] commands: boot: fix error code/clean up behavior when not booting Sascha Hauer
  2 siblings, 0 replies; 4+ messages in thread
From: Ahmad Fatoum @ 2020-11-23 16:14 UTC (permalink / raw)
  To: barebox; +Cc: Ahmad Fatoum

barebox linux-appendroot option having the same bootspec file in
different partitions. boot -m will display the same title though,
which doesn't help readability. Append the name of the config
file to make the menu more useful in that case.

Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
---
 common/blspec.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/common/blspec.c b/common/blspec.c
index a07343f4274e..4e4ad29eb3c8 100644
--- a/common/blspec.c
+++ b/common/blspec.c
@@ -649,7 +649,8 @@ int blspec_scan_directory(struct bootentries *bootentries, const char *root)
 				hwdevname = xstrdup(dev_name(entry->cdev->dev->parent));
 		}
 
-		entry->entry.title = xstrdup(blspec_entry_var_get(entry, "title"));
+		entry->entry.title = xasprintf("%s (%s)", blspec_entry_var_get(entry, "title"),
+					       configname);
 		entry->entry.description = basprintf("blspec entry, device: %s hwdevice: %s",
 						    devname ? devname : "none",
 						    hwdevname ? hwdevname : "none");
-- 
2.29.2


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH 1/3] commands: boot: fix error code/clean up behavior when not booting
  2020-11-23 16:14 [PATCH 1/3] commands: boot: fix error code/clean up behavior when not booting Ahmad Fatoum
  2020-11-23 16:14 ` [PATCH 2/3] commands: boot: display each list entry in a separate line Ahmad Fatoum
  2020-11-23 16:14 ` [PATCH 3/3] commands: boot: include blspec path name in entry title Ahmad Fatoum
@ 2020-11-24  8:47 ` Sascha Hauer
  2 siblings, 0 replies; 4+ messages in thread
From: Sascha Hauer @ 2020-11-24  8:47 UTC (permalink / raw)
  To: Ahmad Fatoum; +Cc: barebox

On Mon, Nov 23, 2020 at 05:14:30PM +0100, Ahmad Fatoum wrote:
> The boot command won't boot if:
>   - There are no boot entries: we should still clean up before
>     returning an error
>   - A menu or list of found entries should be displayed: we should
>     exit with success
>   - We were doing a dry run: we should propagate the boot entry
>     boot method's exit code
> 
> Do the necessary.
> 
> Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
> ---
>  commands/boot.c | 13 +++++--------
>  1 file changed, 5 insertions(+), 8 deletions(-)

Applied, thanks

Sascha

> 
> diff --git a/commands/boot.c b/commands/boot.c
> index d7795bde726b..18f4e36ec733 100644
> --- a/commands/boot.c
> +++ b/commands/boot.c
> @@ -97,19 +97,16 @@ static int do_boot(int argc, char *argv[])
>  
>  	if (list_empty(&entries->entries)) {
>  		printf("Nothing bootable found\n");
> -		return COMMAND_ERROR;
> -	}
> -
> -	if (do_list) {
> -		bootsources_list(entries);
> +		ret = COMMAND_ERROR;
>  		goto out;
>  	}
>  
> -	if (do_menu) {
> +	if (do_list)
> +		bootsources_list(entries);
> +	else if (do_menu)
>  		bootsources_menu(entries, timeout);
> -		goto out;
> -	}
>  
> +	ret = 0;
>  out:
>  	bootentries_free(entries);
>  	free(freep);
> -- 
> 2.29.2
> 
> 
> _______________________________________________
> barebox mailing list
> barebox@lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/barebox
> 

-- 
Pengutronix e.K.                           |                             |
Steuerwalder Str. 21                       | http://www.pengutronix.de/  |
31137 Hildesheim, Germany                  | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |

_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2020-11-24  8:47 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-11-23 16:14 [PATCH 1/3] commands: boot: fix error code/clean up behavior when not booting Ahmad Fatoum
2020-11-23 16:14 ` [PATCH 2/3] commands: boot: display each list entry in a separate line Ahmad Fatoum
2020-11-23 16:14 ` [PATCH 3/3] commands: boot: include blspec path name in entry title Ahmad Fatoum
2020-11-24  8:47 ` [PATCH 1/3] commands: boot: fix error code/clean up behavior when not booting Sascha Hauer

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox