package/petitboot: add patches to fix build errors with "opaque" ncurses
PATCH 1/1 package/petitboot: add patches to fix build errors with "opaque" ncurses
ncurses from 6.4.20231021 enables "NCUSES_OPAQUE_MENU", which hides some parts of the code away from the application. This causes petitboot to fail building in a few spots where it tries to directly access the name of the menu item.
These two patches were submitted to the petitboot mailing list by Nicholas Piggin [1] resolve this issue using accessors, or by making a new item.
This has been raised upstream but not yet applied [2].
[1]: https://lists.ozlabs.org/pipermail/petitboot/2024-February/thread.html#1545
[2]: https://github.com/open-power/petitboot/issues/106
---
Backport to 2025.05.x
--- ...pile-with-curses-opaque-menu-headers.patch | 66 +++++++++++++++++++ ...2-ui-Fix-curses-menu-item-label-leak.patch | 53 +++++++++++++++ 2 files changed, 119 insertions(+) create mode 100644 package/petitboot/0001-ui-Fix-compile-with-curses-opaque-menu-headers.patch create mode 100644 package/petitboot/0002-ui-Fix-curses-menu-item-label-leak.patch
package/petitboot/0001-ui-Fix-compile-with-curses-opaque-menu-headers.patch new file +66 -0
@@ -0,0 +1,66 @@ +Recent Debian ncurses is built with NCURSES_OPAQUE_MENU, which means +the menu item type can't be poked directly. Fix with accessors. + +One wrinkle is the item name can't be modified, new_item has to be used. + +Signed-off-by: Nicholas Piggin <npiggin at gmail.com> +Upstream: https://github.com/open-power/petitboot/issues/106 +--- + ui/ncurses/nc-menu.c | 12 ++++++++---- + ui/ncurses/nc-menu.h | 4 ++-- + 2 files changed, 10 insertions(+), 6 deletions(-) + +diff --git a/ui/ncurses/nc-menu.c b/ui/ncurses/nc-menu.c +index a90a02e..a1524b5 100644 +--- a/ui/ncurses/nc-menu.c ++++ b/ui/ncurses/nc-menu.c +@@ -141,9 +141,13 @@ int pmenu_item_update(struct pmenu_item *item, const char *name) + if (!label) + return -1; + +- i = item->nci; +- i->name.str = label; +- i->name.length = strncols(label); ++ i = new_item(label, NULL); ++ if (!i) { ++ talloc_free((char *)label); ++ return -1; ++ } ++ free_item(item->nci); ++ item->nci = i; + + return 0; + } +@@ -358,7 +362,7 @@ static int pmenu_item_get_index(const struct pmenu_item *item) + return i; + + pb_log_fn("not found: %p %s\n", item, +- (item ? item->nci->name.str : "(null)")); ++ (item ? item_name(item->nci) : "(null)")); + return -1; + } + +diff --git a/ui/ncurses/nc-menu.h b/ui/ncurses/nc-menu.h +index eb568c8..550c7e1 100644 +--- a/ui/ncurses/nc-menu.h ++++ b/ui/ncurses/nc-menu.h +@@ -126,7 +126,7 @@ static inline struct pmenu *pmenu_from_scr(struct nc_scr *scr) + + static inline void pmenu_dump_item(const ITEM *item) + { +- pb_debug("%p %s\n", item, (item ? item->name.str : "(null)")); ++ pb_debug("%p %s\n", item, (item ? item_name(item) : "(null)")); + } + + static inline void pmenu_dump_items(ITEM *const *items, unsigned int count) +@@ -135,7 +135,7 @@ static inline void pmenu_dump_items(ITEM *const *items, unsigned int count) + + for (i = 0; i < count; i++) + pb_debug("%u: %p %s\n", i, items[i], +- (items[i] ? items[i]->name.str : "(null)")); ++ (items[i] ? item_name(items[i]) : "(null)")); + } + + #endif +-- +2.42.0
package/petitboot/0002-ui-Fix-curses-menu-item-label-leak.patch new file +53 -0
53 lines not on this page · raw message
Signature · 6 lines
2.39.5 _______________________________________________ buildroot mailing list [email protected] https://lists.buildroot.org/mailman/listinfo/buildroot
Le 24/07/2025 à 16:43, Nathaniel Roach a écrit :
Quoted 148 lines
ncurses from 6.4.20231021 enables "
NCUSES_OPAQUE_MENU", which hides some parts of the code away from the application. This causes petitboot to fail building in a few spots where it tries to directly access the name of the menu item.These two patches were submitted to the petitboot mailing list by Nicholas Piggin [1] resolve this issue using accessors, or by making a new item.
This has been raised upstream but not yet applied [2].
[1]: https://lists.ozlabs.org/pipermail/petitboot/2024-February/thread.html#1545
[2]: https://github.com/open-power/petitboot/issues/106Signed-off-by Nathaniel Roach <[email protected]>---
Backport to 2025.05.xSigned-off-by Nathaniel Roach <[email protected]>--- ...pile-with-curses-opaque-menu-headers.patch | 66 +++++++++++++++++++ ...2-ui-Fix-curses-menu-item-label-leak.patch | 53 +++++++++++++++ 2 files changed, 119 insertions(+)create mode 100644
package/petitboot/0001-ui-Fix-compile-with-curses-opaque-menu-headers.patchcreate mode 100644package/petitboot/0002-ui-Fix-curses-menu-item-label-leak.patchpackage/petitboot/0001-ui-Fix-compile-with-curses-opaque-menu-headers.patch new file +66
-0@@ -0,0 +1,66 @@ +Recent Debian ncurses is built with NCURSES_OPAQUE_MENU, which means +the menu item type can't be poked directly. Fix with accessors. + +One wrinkle is the item name can't be modified, new_item has to be used. + +Signed-off-by: Nicholas Piggin <npiggin at gmail.com> +Upstream: https://github.com/open-power/petitboot/issues/106 +--- + ui/ncurses/nc-menu.c | 12 ++++++++---- + ui/ncurses/nc-menu.h | 4 ++-- + 2 files changed, 10 insertions(+), 6 deletions(-) + +diff --git a/ui/ncurses/nc-menu.c b/ui/ncurses/nc-menu.c +index a90a02e..a1524b5 100644 +--- a/ui/ncurses/nc-menu.c ++++ b/ui/ncurses/nc-menu.c +@@ -141,9 +141,13 @@ int pmenu_item_update(struct pmenu_item *item, const char *name) + if (!label) + return -1; + +- i = item->nci; +- i->name.str = label; +- i->name.length = strncols(label); ++ i = new_item(label, NULL); ++ if (!i) { ++ talloc_free((char *)label); ++ return -1; ++ } ++ free_item(item->nci); ++ item->nci = i; + + return 0; + } +@@ -358,7 +362,7 @@ static int pmenu_item_get_index(const struct pmenu_item *item) + return i; + + pb_log_fn("not found: %p %s\n", item, +- (item ? item->nci->name.str : "(null)")); ++ (item ? item_name(item->nci) : "(null)")); + return -1; + } + +diff --git a/ui/ncurses/nc-menu.h b/ui/ncurses/nc-menu.h +index eb568c8..550c7e1 100644 +--- a/ui/ncurses/nc-menu.h ++++ b/ui/ncurses/nc-menu.h +@@ -126,7 +126,7 @@ static inline struct pmenu *pmenu_from_scr(struct nc_scr *scr) + + static inline void pmenu_dump_item(const ITEM *item) + { +- pb_debug("%p %s\n", item, (item ? item->name.str : "(null)")); ++ pb_debug("%p %s\n", item, (item ? item_name(item) : "(null)")); + } + + static inline void pmenu_dump_items(ITEM *const *items, unsigned int count) +@@ -135,7 +135,7 @@ static inline void pmenu_dump_items(ITEM *const *items, unsigned int count) + + for (i = 0; i < count; i++) + pb_debug("%u: %p %s\n", i, items[i], +- (items[i] ? items[i]->name.str : "(null)")); ++ (items[i] ? item_name(items[i]) : "(null)")); + } + + #endif +-- +2.42.0package/petitboot/0002-ui-Fix-curses-menu-item-label-leak.patch new file +43
-0@@ -0,0 +1,53 @@ +When a menu item name is updated, the old label is not freed. + +Signed-off-by: Nicholas Piggin <npiggin at gmail.com> +Upstream: https://github.com/open-power/petitboot/issues/106 +--- + ui/ncurses/nc-menu.c | 4 ++++ + ui/ncurses/nc-menu.h | 1 + + 2 files changed, 5 insertions(+) + +diff --git a/ui/ncurses/nc-menu.c b/ui/ncurses/nc-menu.c +index a1524b5..70f2210 100644 +--- a/ui/ncurses/nc-menu.c ++++ b/ui/ncurses/nc-menu.c +@@ -82,6 +82,7 @@ static void pmenu_resize(struct nc_scr *scr) + static int pmenu_item_destructor(void *arg) + { + struct pmenu_item *item = arg; ++ talloc_free((char *)item->label); + free_item(item->nci); + return 0; + } +@@ -146,7 +147,9 @@ int pmenu_item_update(struct pmenu_item *item, const char *name) + talloc_free((char *)label); + return -1; + } ++ talloc_free((char *)item->label); + free_item(item->nci); ++ item->label = label; + item->nci = i; + + return 0; +@@ -168,6 +171,7 @@ struct pmenu_item *pmenu_item_create(struct pmenu *menu, const char *name) + + item->i_sig = pb_item_sig; + item->pmenu = menu; ++ item->label = label; + item->nci = new_item(label, NULL); + + if (!item->nci) { +diff --git a/ui/ncurses/nc-menu.h b/ui/ncurses/nc-menu.h +index 550c7e1..7ba45bf 100644 +--- a/ui/ncurses/nc-menu.h ++++ b/ui/ncurses/nc-menu.h
package/petitboot/0002-ui-Fix-curses-menu-item-label-leak.patch line 53
Quoted 10 lines
package/petitboot/0002-ui-Fix-curses-menu-item-label-leak.patch new file +10
-0+@@ -46,6 +46,7 @@ struct pmenu; + + struct pmenu_item { + enum pb_nc_sig i_sig; ++ const char *label; + ITEM *nci; + struct pmenu *pmenu; + void *data; +-- +2.42.0
_______________________________________________
buildroot mailing list
[email protected]
https://lists.buildroot.org/mailman/listinfo/buildroot
Julien Olivain via buildroot
AppliedQuoted 8 lines · Nathaniel Roach via buildroot
ncurses from 6.4.20231021 enables "
NCUSES_OPAQUE_MENU", which hides some parts of the code away from the application. This causes petitboot to fail building in a few spots where it tries to directly access the name of the menu item.These two patches were submitted to the petitboot mailing list by Nicholas Piggin [1] resolve this issue using accessors, or by making a new item.
Quoted 7 lines
This has been raised upstream but not yet applied [2].
[1]: https://lists.ozlabs.org/pipermail/petitboot/2024-February/thread.html#1545
[2]: https://github.com/open-power/petitboot/issues/106
Applied to master, thanks.
For info, I did few minor changes, see:
https://gitlab.com/buildroot.org/buildroot/-/commit/1575584f507d2197fb324216ff41c4a768786075
Best regards,
Julien.
_______________________________________________
buildroot mailing list
[email protected]
https://lists.buildroot.org/mailman/listinfo/buildroot