Warning: there may be occasional oddness due to css and blog edits. **KNOWN ISSUE: possible hidden text**
Showing posts with label bsddialog. Show all posts
Showing posts with label bsddialog. Show all posts

Thursday, March 14, 2024

Another dialog change

Already included in FreeBSD 14.0, bsddialog will replace dialog.  I was looking at the 15.0 release notes and UPDATING files to see what new thing I could switch to using early as I did with portdialog.  This one appears to be a much more developer-oriented item, so I will have to create some examples as I go, on the commmandline to give you something to see here.

% bsddialog
Error: expected a --<dialog>.

See 'bsddialog --help' or 'man 1 bsddialog' for more information.
%

I really like this as feedback from attempting to use it without knowing how or what to do, it gives both the built-in help as below, plus informs about the much more verbose manpage option.

% bsddialog --help
usage: bsddialog --help
       bsddialog --version
       bsddialog [--<opt>] --<dialog> <text> <rows> <cols> [<arg>]
       bsddialog --<dialog1> ...  [--and-dialog --<dialog2> ...] ...

Options:
 --alternate-screen, --ascii-lines, --backtitle <backtitle>, --begin-x <x>,
 --begin-y <y>, --bikeshed, --calendar, --cancel-label <label>, --clear-dialog,
 --clear-screen, --colors, --columns-per-row <columns>, --cr-wrap,
 --date-format <format>, --default-button <label>, --default-item <name>,
 --default-no, --disable-esc, --esc-return-cancel, --exit-label <label>,
 --extra-button, --extra-label <label>, --generic-button1 <label>,
 --generic-button2 <label>, --help-button, --help-label <label>,
 --help-print-name, --help-status, --hfile <file>, --hline <string>,
 --hmsg <string>, --ignore, --insecure, --item-bottom-desc, --item-depth,
 --item-prefix, --load-theme <file>, --max-input <size>, --no-cancel,
 --no-descriptions, --no-label <label>, --no-lines, --no-names, --no-ok,
 --no-shadow, --normal-screen, --ok-label <label>, --output-fd <fd>,
 --output-separator <sep>, --print-maxsize, --print-size, --print-version,
 --quoted, --save-theme <file>, --separate-output, --separator <sep>, --shadow,
 --single-quoted, --sleep <secs>, --stderr, --stdout, --tab-escape,
 --tab-len <spaces>, --text-unchanged, --switch-buttons,
 --theme <blackwhite|bsddialog|flat|dialog>, --time-format <format>,
 --title <title>, --yes-label <label>.

Dialogs:
 --calendar <text> <rows> <cols> [<dd> <mm> <yy>]
 --checklist <text> <rows> <cols> <menurows> [<name> <desc> <on|off>] ...
 --datebox <text> <rows> <cols> [<dd> <mm> <yy>]
 --form <text> <rows> <cols> <formrows> [<label> <ylabel> <xlabel> <init> <yfield> <xfield> <fieldlen> <maxletters>] ...
 --gauge <text> <rows> <cols> [<perc>]
 --infobox <text> <rows> <cols>
 --inputbox <text> <rows> <cols> [init]
 --menu <text> <rows> <cols> <menurows> [<name> <desc>] ...
 --mixedform <text> <rows> <cols> <formrows> [<label> <ylabel> <xlabel> <init> <yfield> <xfield> <fieldlen> <maxletters> <0|1|2>] ...
 --mixedgauge <text> <rows> <cols> <mainperc> [<minilabel> <miniperc>] ...
 --msgbox <text> <rows> <cols>
 --passwordbox <text> <rows> <cols> [init]
 --passwordform <text> <rows> <cols> <formrows> [<label> <ylabel> <xlabel> <init> <yfield> <xfield> <fieldlen> <maxletters>] ...
 --pause <text> <rows> <cols> <secs>
 --radiolist <text> <rows> <cols> <menurows> [<name> <desc> <on|off>] ...
 --rangebox <text> <rows> <cols> <min> <max> [<init>]
 --textbox <file> <rows> <cols>
 --timebox <text> <rows> <cols> [<hh> <mm> <ss>]
 --treeview <text> <rows> <cols> <menurows> [<depth> <name> <desc> <on|off>] ...
 --yesno <text> <rows> <cols>

See 'man 1 bsddialog' for more information.
%

Here are some examples of what this tool can provide:

% bsddialog --calendar "Example calendar" 20 38 14 03



┌────────────────────────────────────┐  
│ Example calendar                   │  
│                                    │  
│                                    │  
│ Month            Year              │  
│ ┌───────────────┐┌───────────────┐ │  
│ │          March││           2024│ │  
│ └───────────────┘└───────────────┘ │  
│ ┌────────────────────────────────┐ │  
│ │    Sun Mon Tue Wed Thu Fri Sat │ │  
│ │                         1   2  │ │  
│ │     3   4   5   6   7   8   9  │ │  
│ │    10  11  12  13  14  15  16  │ │  
│ │    17  18  19  20  21  22  23  │ │  
│ │    24  25  26  27  28  29  30  │ │  
│ │    31                          │ │  
│ └────────────────────────────────┘ │  
├────────────────────────────────────┤  
[  OK  ]     [Cancel]       │  
└────────────────────────────────────┘  
                                        

% bsddialog --inputbox "an inputbox" 8 20


┌──────────────────┐  
│ an inputbox      │  
│ ┌──────────────┐ │  
│ │              │ │  
│ └──────────────┘ │  
├──────────────────┤  
[  OK  ] [Cancel]│  
└──────────────────┘  
                      

% bsddialog --timebox "timebox" 8 20 10 27 05


┌──────────────────┐  
│ timebox          │  
│  ┌──┐ ┌──┐ ┌──┐  │  
│  │10│:│27│:│05│  │  
│  └──┘ └──┘ └──┘  │  
├──────────────────┤  
[  OK  ] [Cancel]│  
└──────────────────┘  
                      

% bsddialog --infobox "This is an infobox for giving info to the reader" 5 24


┌──────────────────────┐  
│ This is an infobox   │  
│ for giving info to   │  
│ the reader           │  
└──────────────────────┘  
                          

bsddialog --menu "Choose what to do:" 12 40 3 "Leave" "Hit the road" "Stay"
"Take a load off" "Think" "Ponder other options"


┌──────────────────────────────────────┐  
│ Choose what to do:                   │  
│                                      │  
│                                      │  
│ ┌──────────────────────────────────┐ │  
│ │    Leave Hit the road            │ │  
│ │    Stay  Take a load off         │ │  
│ │    Think Ponder other options    │ │  
│ └──────────────────────────────────┘ │  
├──────────────────────────────────────┤  
[  OK  ]     [Cancel]        │  
└──────────────────────────────────────┘  
                                          

These examples do not touch the large number of possible customizations.  I used a few of the pre-designed options which you may notice has any text within quotes.  When I tested the calendar it seems like the expected input might actually be a 4-digit year.  You will get feedback if the content would not fit within the rows and columns defined, some of the needed space is for the default output which might not be known before you test with an extra large row/column value.  Since this works within an xterm, I expect that the NO_COLOR environment variable would affect it as well, I am not sure that this has the other display options which portdialog has, possibly those would be good additions to it.

Since the dialog manpage is quite extensive I will provide the information about compatibility to the end of the manpage for both.  One thing to note about dialog is that it is actually an X application, rather than a terminal program, and bsddialog is a TUI.  The manpage excerpts are below.

DIALOG(1)		    General Commands Manual		     DIALOG(1)
COMPATIBILITY
       You may want to write scripts which run with other dialog "clones".

   Original Dialog
       First, there is the "original" dialog program to	consider (versions 0.3
       to 0.9).	 It had	some misspelled	(or inconsistent) options.  The	dialog
       program	maps  those  deprecated	 options  to the preferred ones.  They
       include:
	      Option	     Treatment
	      ---------------------------------
	      --beep-after   ignored
	      --guage	     mapped to --gauge
	      ---------------------------------

   Xdialog
       This is an X application, rather	than a terminal	 program.   With  some
       care,  it  is  possible	to  write  useful  scripts that	work with both
       Xdialog and dialog.

       The dialog program  ignores  these  options  which  are	recognized  by
       Xdialog:
	      Option		 Treatment
	      -----------------------------------------------
	      --allow-close	 ignored
	      --auto-placement	 ignored
	      --fixed-font	 ignored
	      --icon		 ignored
	      --keep-colors	 ignored
	      --no-close	 ignored
	      --no-cr-wrap	 ignored
	      --screen-center	 ignored
	      --separator	 mapped	to --separate-output
	      --smooth		 ignored
	      --under-mouse	 ignored
	      --wmclass		 ignored
	      -----------------------------------------------

       Xdialog's  manpage  has	a  section  discussing	its compatibility with
       dialog.	There are some differences not	shown  in  the	manpage.   For
       example,	the html documentation states

	      Note:  former  Xdialog  releases	used the "\n" (line feed) as a
	      results separator	 for  the  checklist  widget;  this  has  been
	      changed  to  "/"	in  Xdialog  v1.5.0 to make it compatible with
	      (c)dialog.  In your old scripts using the	Xdialog	checklist, you
	      will then	have to	add the	--separate-output  option  before  the
	      --checklist one.

       Dialog  has  not	 used a	different separator; the difference was	likely
       due to confusion	regarding some script.

   Whiptail
       Then there is whiptail.	For practical purposes,	it  is	maintained  by
       Debian  (very  little  work  is	done by	its upstream developers).  Its
       documentation (README.whiptail) claims

	      whiptail(1) is a lightweight replacement for dialog(1),
	      to provide dialog	boxes for shell	scripts.
	      It is built on the
	      newt windowing library rather than the ncurses library, allowing
	      it to be smaller in embedded environments	such as	installers,
	      rescue disks, etc.

	      whiptail is designed to be drop-in compatible with dialog, but
	      has less features: some dialog boxes are not implemented,	such
	      as tailbox, timebox, calendarbox,	etc.

       Comparing actual	sizes (Debian testing, 2007/1/10): The total of	 sizes
       for  whiptail,  the  newt,  popt	 and  slang  libraries is 757 KB.  The
       comparable number for dialog (counting ncurses) is  520 KB.   Disregard
       the first paragraph.

       The  second  paragraph is misleading, since whiptail also does not work
       for common options of dialog, such as the gauge box.  whiptail is  less
       compatible with dialog than the original	mid-1990s dialog 0.4 program.

       whiptail's  manpage borrows features from dialog, e.g., but oddly cites
       only dialog versions up to 0.4  (1994)  as  a  source.	That  is,  its
       manpage	refers	to  features  which  were  borrowed  from  more	recent
       versions	of dialog, e.g.,

       o   --gauge (from 0.5)

       o   --passwordbox (from Debian changes in 1999),

       o   --default-item (from	dialog 2000/02/22),

       o   --output-fd (from dialog 2002/08/14).

       Somewhat	humorously, one	may note that the popt	feature	 (undocumented
       in its manpage) of using	a "--" as an escape was	documented in dialog's
       manpage	about  a  year	before it was mentioned	in whiptail's manpage.
       whiptail's manpage  incorrectly	attributes  that  to  getopt  (and  is
       inaccurate anyway).

       Debian uses whiptail for	the official dialog variation.

       The  dialog  program ignores or maps these options which	are recognized
       by whiptail:
	      Option		Treatment
	      -------------------------------------------
	      --cancel-button	mapped to --cancel-label
	      --fb		ignored
	      --fullbutton	ignored
	      --no-button	mapped to --no-label
	      --nocancel	mapped to --no-cancel
	      --noitem		mapped to --no-items
	      --notags		mapped to --no-tags
	      --ok-button	mapped to --ok-label
	      --scrolltext	mapped to --scrollbar
	      --topleft		mapped to --begin 0 0
	      --yes-button	mapped to --yes-label
	      -------------------------------------------

       There are visual	differences which are not  addressed  by  command-line
       options:

       o   dialog  centers  lists  within the window.  whiptail	typically puts
	   lists against the left margin.

       o   whiptail uses angle brackets	("<" and  ">")	for  marking  buttons.
	   dialog uses square brackets.

       o   whiptail  marks the limits of subtitles with	vertical bars.	dialog
	   does	not mark the limits.

       o   whiptail attempts to	mark the top/bottom cells of a scrollbar  with
	   up/down  arrows.  When it cannot do this, it	fills those cells with
	   the background color	of  the	 scrollbar  and	 confusing  the	 user.
	   dialog  uses	 the  entire  scrollbar	 space,	thereby	getting	better
	   resolution.

BUGS
       Perhaps.

AUTHOR
       Thomas E.  Dickey	(updates for 0.9b and beyond)

CONTRIBUTORS
       Kiran Cherupally	- the mixed form and mixed gauge widgets.

       Tobias C.  Rittweiler

       Valery Reznic - the form	and progressbox	widgets.

       Yura Kalinichenko adapted the gauge widget as "pause".

       This is a rewrite (except as needed to provide  compatibility)  of  the
       earlier version of dialog 0.9a, which lists as authors:

       o   Savio Lam - version 0.3, "dialog"

       o   Stuart Herbert - patch for version 0.4

       o   Marc	Ewing -	the gauge widget.

       o   Pasquale De Marco "Pako" - version 0.9a, "cdialog"

$Date: 2021/01/17 17:25:01 $					     DIALOG(1)

And in comparison, bsddialog which being less extensive and purely a TUI.  It can still be contained by an Xterm without need of direct interaction with X itself, and so very likely is a bit less hefty, could be speedier, or take up less space installed.

BSDDIALOG(1)		    General Commands Manual		  BSDDIALOG(1)
COMPATIBILITY
       Outdated	 options  are  retained	for compatibility, properly equivalent
       options are used:
	     Obsolete			  Equivalent
	     --and-widget		  --and-dialog
	     --calendar	<text> 2 <cols>	  --calendar <text> 0 <cols>
	     --clear			  --clear-screen
	     --defaultno		  --default-no
	     --exit-label		  --ok-label
	     --help-tags		  --help-print-name
	     --item-help		  --item-bottom-desc
	     --keep-tite		  --alternate-screen
	     --no-items			  --no-descriptions
	     --no-label			  --cancel-label
	     --no-tags			  --no-names
	     --nocancel			  --no-cancel
	     --nook			  --no-ok
	     --separator		  --output-separator
	     --yes-label		  --ok-label

SEE ALSO
       bsddialog(3)

HISTORY
       The bsddialog utility first appeared in FreeBSD 14.0.

AUTHORS
       bsddialog    was	   written     by     Alfonso	  Sabato     Siciliano
       <asiciliano@FreeBSD.org>.

       bsddialog  provides  a  subset  of  the	functionality described	in the
       dialog manual.  The following features were reimplemented:

       Options:	 --and-widget,	--ascii-lines,	--backtitle,   --cancel-label,
       --clear,	    --colors,	  --cr-wrap,	--date-format,	  --defaultno,
       --default-button,    --default-no,    --default-item,	 --exit-label,
       --extra-button,	--extra-label,	--help,	 --help-button,	 --help-label,
       --help-status, --help-tags,  --hfile,  --hline,	--ignore,  --insecure,
       --item-help,   --keep-tite,   --max-input,   --no-cancel,   --nocancel,
       --no-items,  --no-label,	 --no-lines,  --no-ok,	--nook,	  --no-shadow,
       --no-tags,	--ok-label,	 --output-fd,	   --output-separator,
       --print-maxsize,	    --print-size,      --print-version,	     --quoted,
       --separate-output,  --separator,	 --shadow,  --single-quoted,  --sleep,
       --stderr,  --stdout,  --tab-len,	 --time-format,	 --title,   --version,
       --yes-label.

       Dialogs:	  --calendar,	--checklist,   --form,	 --gauge,   --infobox,
       --inputbox, --menu, --mixedform,	--mixedgauge, --msgbox,	--passwordbox,
       --passwordform, --pause,	--radiolist, --rangebox, --textbox, --timebox,
       --treeview, --yesno.

       Some feature differs in input, output, or behavior.   Compatibility  is
       not a priority for future development.

THANKS TO
       Baptiste	 Daroussin  <bapt@FreeBSD.org>,	 Ed Maste <emaste@FreeBSD.org>
       and Juraj Lutter	<otis@FreeBSD.org> for suggestions, help, and testing.

FreeBSD	13.2		      September	23, 2022		  BSDDIALOG(1)

Aside from a functionally similar tool and some things partly compatible, it is not truly a drop-in replacement as switching to portdialog from dialiog4 ports.  There are some notable mentions in UPDATING which should be considered.

From UPDATING:

20231010:
	dialog(1) has been replaced in base by bsddialog(1), while most of the
	time replacing a dialog(1) call by a bsddialog(1) call works out of the
	box, bsddialog(1) is not considered as a drop-in replacement for
	dialog(1).

	If you do depend on dialog(1) functionality, please install cdialog
	from ports:

	pkg install cdialog

From RELNOTES: (for FreeBSD 15.0.)

ff01d71e48d4:
	dialog(1) has been replaced by bsddialog(1)

This looks like a cool new thing for us to have available, bsddialog offers more flexibility to ease a greater variety of dialog types.  I might consider some rewrites to some of my scripts to include bsddialog if it is possible (I suspect so) which would make them even more friendly and easy to use I believe.  Look into what bsddialog is on your FreeBSD 14.0 system or CURRENT (aka 15.0) to see how you might take advantage of this interesting flexible dialog creation tool.

PS. This has been an effort for GPLinBase for removal of those items so licensed (few remain), bsddialog is one completed for that project.

Saturday, February 20, 2021

make doesn't config

Clearly something is broken but I do not know precisely how or exactly what.  All that I do know is that when I try to configure a port, by going to that port directory, such as for minetest, or use the command as below,

make -C /usr/ports/games/minetest config

all I get is this.

===> Options unchanged

I am not aware of any of the myriad of changes I have ever made to my system which would result in such a bizarre error.  My extensive make.conf permits me the ability to adjust options but it is a far more tedious method, especially since I must first look at the Makefile or freshports.org to parse out the possible options.

Prior to this recent very strange issue, I had another, which I may have partially resolved more by avoiding certain ports than by curing the weird dependency issue.  Yes, for surely the second time my system claims a vast number of dependencies which are inaccurate.  Previously it was rust which somehow gained the excess dependents and now it is openjdk7 which has remained wrong even with kernel and world update, and various attempts to solve the issue.  My seeming quasi-solution was to discover by close monitoring, which port was the first of the series which suddenly required openjdk7.  I also gathered the list of ports which failed when openjdk7 itself failed to build and by failing made it very easy to see all the dependents.  I then tweaked the option config for each of the ports in turn, and in the process also discovered that for ages I have had kerberos installed but never used.  The initial lynchpin was apr.  The additional peculiarity is that the dependency issue seems to somehow very strangely be limited to poudriere bulk port builds as individual semi-automated make builds seem to be immune in some way while even after succeeding outside of poudriere, within its jail the dependency issue remained.

So it is very likely that this whole dependency issue (attempts to repair it) is what provoked some other modification to my system which has finally broken my ability to configure ports the normal way within the ports tree.

I could say "the fun part about.." but I'm not sure this is really fun as it is rather frustrating and there doesn't seem to be any documentation about how to extricate my system from this pickle.  What is needed to be able to configure a port?  There is no such list, no steps to enable, nothing.  The same goes for my prior dependency issue, there is no tool or method to solve it or to reset the mess to get things working properly again.  Lucky for you, if I ever solve it for myself there will be this blog post to reference if you somehow manage to accidentally follow in my footsteps.

I cannot be certain yet if anything regarding the dependency issue has changed, but I discovered that I can obtain an index file by make -C /usr/ports fetchindex though when I attempted this it failed due I suspect to ssl or cert issues.  I simply used the url with fetch and adjusted for no ssl.  The file was obtained in bzip2 format so I unpacked it.  I used my recert alias which is set to make -C /usr/ports/security/ca_root_nss reinstall clean to update my local certs after.

Since I can survive tediously without the ability to adjust port configs the usual way, I am rebuilding all my ports with poudriere.  It seems that I may have squashed the openjdk7 dependency issue afterall, as there have not yet been 1200 skipped ports due to openjdk7 failing to build, thus proving it.  I could be wrong, but the series of skipped ports usually appeared near the beginning of the over 2000 port bulk build.  Once that finishes and the installed packages are updated/installed, I can resume beating my head against the 'make config' wall.

How about I list the things I know that I did to possibly resolve the dependency issue?  Maybe some or all of it caused the present issue.  In approximate order mostly:

  • removed the /var/db/ports directory
  • reinstalled as many ports as would successfully build (though my script iterated a list):
    make -C /usr/ports/port/origin install clean
  • erased the /var/db/pkg files: FreeBSD.meta, local.sqlite, poudriere.meta, repo-FreeBSD.sqlite, repo-poudriere.sqlite
  • removed the /usr/ports/INDEX-12 file
  1. reinstalled pkg
    make -C /usr/ports/ports-mgmt/pkg deinstall reinstall clean
  2. (rebootstrapped pkg)
    pkg bootstrap -f
  3. attempted to find missing dependencies
    pkg check -Ba
  4. re-created the poudriere repo:
    pkg repo /usr/local/poudriere/data/packages/13amd64-default
  5. updated /usr/src, rebuilt and reinstalled kernel and world
  6. updated the poudriere 13amd64 jail
  7. re-created the poudriere repo:
    pkg repo /usr/local/poudriere/data/packages/13amd64-default
  8. copied a fresh /etc/pkg.conf from /etc/pkg.conf.sample and revised it to match my former revised pkg.conf

I keep thinking (now) that the one thing I have not yet touched is also directly related to make, the /etc/make.conf but if it had some sort of syntax error surely it would be noticed, caught automatically by shell or make itself.  Once my latest round of poudriere bulk port builds are finished, I can stash the extensive make.conf and see if that solves the configuration issue.  The make.conf is copied to an appropriately named poudriere make.conf file name, so it could affect both methods of build somehow.  However, as well as I can remember, outside of the poudriere jail ports did not have inordinate dependence upon openjdk7.  Stashing the make.conf did not solve the issue.

Finally, I managed to type the right search terms which found an old FreeBSD forum post that helped solve my issue.

make -C /usr/ports/ports-mgmt/dialog4ports install clean

Exactly why ports-mgmt/dialog4ports is not a dependency somewhere, or automatically installed by make config in any port directory, or at least mentioned in man ports is a complete mystery to me.  Instead, it appears that I am blind, below is a subsection of man 7 ports.

     The following targets will be run automatically by each proceeding target
     in order.  That is, build will be run (if necessary) by install, and so
     on all the way to fetch.  Usually, you will only use the install target.

     config         Configure OPTIONS for this port using dialog4ports(1).

     fetch          Fetch all of the files needed to build this port from the
                    sites listed in MASTER_SITES and PATCH_SITES.  See
                    FETCH_CMD, MASTER_SITE_OVERRIDE and MASTER_SITE_BACKUP.

     checksum       Verify that the fetched distfile's checksum matches the
                    one the port was tested against.  If the distfile's
                    checksum does not match, it also fetches the distfiles
                    which are missing or failed the checksum calculation.
                    Defining NO_CHECKSUM will skip this step.

     depends        Install (or compile if only compilation is necessary) any
                    dependencies of the current port.  When called by the
                    extract or fetch targets, this is run in piecemeal as
                    fetch-depends, build-depends, etc.  Defining NO_DEPENDS
                    will skip this step.

     extract        Expand the distfile into a work directory.

     patch          Apply any patches that are necessary for the port.

     configure      Configure the port.  Some ports will ask you questions
                    during this stage.  See INTERACTIVE and BATCH.

     build          Build the port.  This is the same as calling the all
                    target.

     install        Install the port and register it with the package system.
                    This is all you really need to do.

     The following targets are not run during the normal install process.

     showconfig           Display OPTIONS config for this port.

     showconfig-recursive
                          Display OPTIONS config for this port and all its
                          dependencies.

     rmconfig             Remove OPTIONS config for this port.

     rmconfig-recursive   Remove OPTIONS config for this port and all its
                          dependencies.

     config-conditional   Skip the ports which have already had their OPTIONS
                          configured.

     config-recursive     Configure OPTIONS for this port and all its
                          dependencies using dialog4ports(1).

I would strongly recommend looking at the rest of the manpage, as you may discover other interesting capabilities as yet unknown.  In particular from the manpage for ports: did you know about showconfig or config-conditional?

Frequently viewed this week