Commit Graph

447 Commits

Author SHA1 Message Date
Devin Teske
ebd672f58f Fix package installation from physical media such as DVD.
Discussed with:	re (gjb)
MFC after:	3 days
2013-11-17 17:53:55 +00:00
Devin Teske
6ef6ba9950 Always shutdown the media when we're exiting the packages module (prevents
errors on re-entry for physical media). Also, while we're here, stop
ejecting the CDROM when we're done with it (but leave the functions for
later use so that we could perhaps -- from the installer standpoint -- use
it to eject the media after an install).

MFC after:	3 days
2013-11-17 17:48:55 +00:00
Devin Teske
ee5ef711b7 Improve debugging with f_eval_catch() introduced by SVN r257784 and also
fix a bug where "pkg update" was not getting the value of PACKAGESITE.
NB: PACKAGESITE needs to be explicitly exported in support of children.

MFC after:	3 days
2013-11-17 17:42:15 +00:00
Devin Teske
673b5bb7f7 Kick an unused orphan to the curb ;) 2013-11-17 17:35:51 +00:00
Devin Teske
84873facb2 Move function name declaration to top of function (where it is closest to
the value it needs to be), s/fname/funcname/g, and move function name usage
to within printf format string.

MFC after:	3 days
2013-11-17 17:31:07 +00:00
Devin Teske
b2b4a04e9e Comments. 2013-11-12 04:02:51 +00:00
Devin Teske
eee23b7cff Remove the env(1) but keep the var. 2013-11-11 02:02:05 +00:00
Glen Barber
6e12e3646d Unbreak the installer on head/:
When bsdinstall(8) sources the bsdconfig(8) common.subr file,
  PKG_ABI is set by calling 'pkg -vv' and searching for the ABI
  pkg(8) will use.

  When pkg(8) is run for the first time, the bootstrap process
  is run, which prompts for 'y/N' input from stdin if running with
  TERM set.

  Since TERM is set and it is the first time pkg(8) is run, which
  happens automatically, bsdinstall(8) hangs waiting for user input
  which is never displayed since a specific line is expected by
  awk(1), and stdin is expected by pkg(8).

  Set ASSUME_ALWAYS_YES=1, which will cause pkg(8) to assume the
  '-y' flag is also used for the bootstrap process, allowing
  bsdinstall(8) to proceed to the keymap lookup, otherwise
  bsdinstall(8) appears to hang after selecting 'Install' from the
  menu on first boot from CDROM.
2013-11-11 01:42:59 +00:00
Devin Teske
29b5dbe844 Use `pkg -vv' to obtain ABI for validating a chosen media server (done
prior to diving head-long into a pkg-update(8), et. al). This should
also be more future-proof than what was being done just before this.
2013-11-07 21:38:46 +00:00
Devin Teske
6451dd7e0f Fix cosmetic typos (since the typo's in the variable names were copied
and pasted, it wasn't noticed).
2013-11-07 21:16:32 +00:00
Devin Teske
632d9a080c Replace pkg-tools with pkgng. 2013-11-07 12:40:42 +00:00
Devin Teske
3d5fedd33e Fix an off-by-one error that was causing menus to look funny. 2013-11-07 11:20:50 +00:00
Devin Teske
1c6d60de93 Comments. 2013-11-07 10:48:00 +00:00
Devin Teske
0efb8b7a98 Add f_sprintf() and f_vsprintf() to go along with previously added
f_snprintf() and f_vsnprintf() (size-constraint) functions.
2013-11-07 10:47:12 +00:00
Devin Teske
62c7db8a8a Fix a bug where a format with leading `-' could be mistaken for printf
getopts argument(s).
2013-11-07 10:45:25 +00:00
Devin Teske
f1d6beba07 Comments. 2013-11-07 10:44:24 +00:00
Devin Teske
ebee96b642 Add some helpful debugging (showing the resolved host address). 2013-11-07 10:40:19 +00:00
Devin Teske
e9bd9b3f19 Fix a silly bug that would result in attempting to fetch (literally) the
URI "httpDirectory" (oops).
2013-11-07 10:36:24 +00:00
Devin Teske
91d20ba0f7 Use dialog(1) to obtain maximum-size; stty fails when running in a pipe-
chain. This allows dialogs to reach full size even when executed as an
rvalue operand to a pipe (e.g., cat file | bsdconfig -f-).
2013-11-07 10:30:20 +00:00
Devin Teske
bdf4b1764e Add an f_eval_catch() function for debugging individual commands in a
series of commands. Accepts the `-d' flag as a first argument to skip
displaying messages in a dialog box. The command is logged as it
appears to the shell prior to the first pass of parameter expansion to
allow copy/pasting into a real shell (opposed to simply echo'ing the
command which would produce debug output that has undergone at least one
pass of parameter expansion, thus no-longer copacetic for copy/paste).
Takes printf(1) style syntax and a utility identifier for error messages.
2013-11-07 10:28:12 +00:00
Devin Teske
8a316c0005 Add an f_show_err() function -- acts pretty much the same as f_show_msg()
except it stylizes the msgbox widget to indicate an Error has occurred by
setting an appropriate title and default message.
2013-11-07 10:23:37 +00:00
Devin Teske
57f3f6ee5d Add global DEBUG_INITIALIZE_FILE environment variable for controlling
whether the debugFile is truncated upon initialization (useful for when
children implicitly re-initialize debugging and you want children to
append to your existing debugFile).
2013-11-07 10:20:19 +00:00
Devin Teske
3e8cb79d0a Comments. Replace a funny syntax with f_isset() while here. 2013-11-07 10:14:40 +00:00
Devin Teske
9e2c4ab64f Whitespace. 2013-11-07 10:09:01 +00:00
Devin Teske
0a9f7376ad Fix a bug that resulted in spurious error message "f_media_shutdown_http:
not found" from /usr/libexec/bsdconfig/030.packages/packages.
2013-11-06 18:43:16 +00:00
Devin Teske
4b939b1160 Add support for dereferencing SRV records via f_host_lookup(). Takes the
media choice into consideration for determining the appropriate SRV records
to query (e.g., _http._tcp, _ftp._tcp, _nfs.tcp, _nfs.udp, etc.).
2013-11-06 18:26:38 +00:00
Simon J. Gerraty
3caf0790a8 Merge head@256284 2013-10-13 02:35:19 +00:00
Simon J. Gerraty
4fd0d10e0f New dependencies 2013-10-13 00:22:44 +00:00
Devin Teske
9acbeddc57 Fix signed integer overflow detection in f_expand_number() of strings.subr.
Approved by:	re (glebius)
2013-10-12 19:52:27 +00:00
Devin Teske
a96ea66f3d Add new f_expand_number() (shadowing expand_number(3)).
Approved by:	re (glebius)
2013-10-11 20:12:30 +00:00
Devin Teske
1bd2b932a5 Store descriptions for DEVICE_TYPE_DISK and fix static-defaults mapping.
Add a default description for bhyve block disk device while we're here.

Approved by:	re (glebius)
2013-10-11 20:10:41 +00:00
Devin Teske
0c20fe6fda Add $VAR_ZFSINTERACTIVE (zfsInteractive) and new f_zfsinteractive() for
determining when a script wants to be nonInteractive but selectively
wants ZFS operations to be *interactive* (this is analgous to already
existing $VAR_NETINTERACTIVE (netInteractive) and f_netinteractive()
used for the same purpose (script wants to be nonInteractive but wants
network operations to be *interactive*).

Approved by:	re (glebius)
2013-10-11 20:08:34 +00:00
Devin Teske
efa13f7e0b Fix a bug that would occur in application death when debugging was enabled
if you ended up in f_dialog_*_constrain() (indirectly, of course) with a
purposefully-set NULL height, width, or rows parameter (because you didn't
care to have that attribute calculated). Fix typo in a comment while here.

Approved by:	re (glebius)
2013-10-11 20:07:04 +00:00
Devin Teske
3636c2354e Add keymap.subr for presenting custom keymap dialogs (with X11 support).
Approved by:	re (glebius)
2013-10-11 18:21:05 +00:00
Devin Teske
5bd5e0c398 Add a USE_DIALOG global (analogous to USE_XDIALOG); useful for inserting
text into a prompt or command syntax iff dialog(1) is in-use.

Approved by:	re (glebius)
2013-10-11 18:14:49 +00:00
Devin Teske
fcaed0c1a5 Fix a minor bug; if strings.subr was included by itself it may not have
access to f_dprintf from common.subr -- fix this by including common.subr.

Approved by:	re (glebius)
2013-10-11 17:54:22 +00:00
Devin Teske
6bfa4a638c Add support for obtaining the capacity of disks. Add comment while here.
Approved by:	re (glebius)
2013-10-11 17:52:43 +00:00
Devin Teske
f677a9e267 Introduce centralized [X]dialog(1) exit codes to `dialog.subr' and make-use
throughout the bsdconfig(8) code. While we're here, add an explicit argument
to lvalue-seeking invocations of "return" that previously had no argument.
Also, consolidate a single instance of double-newline and remove some
comments that are no longer required (given increased readability with new
exit codes).

Approved by:	re (glebius)
2013-10-09 08:12:26 +00:00
Gavin Atkinson
582071bd52 Remove ftp5.se.f.o, as per request to -hubs@
Approved by:	re (glebius)
MFC after:	3 days
2013-09-28 13:58:21 +00:00
Brad Davis
59ecdf43de - Remove the is (Iceland) mirror per mail from the admins.
Approved by:	re
With hat: clusteradm@
2013-09-27 11:25:37 +00:00
Devin Teske
cda7fc92b7 Fix a bug in HTTP checking/fetching.
Fix a bug in HTTP checking/fetching. Add Main Site to HTTP menu. Add new
example script browse_packages_http.sh and move existing example script
browse_packages.sh -> browse_packages_ftp.sh

Reviewed by:	gjb, brd
Approved by:	re (gjb), clusteradm (brd)
MFC after:	3 days
2013-09-23 16:47:52 +00:00
Devin Teske
05f7eb31a2 Remove unnecessary mediaClose (FTP operations are done with either ftp(1)
or fetch(1), neither of which are stateful, compared to how sysinstall(8)
did FTP operations, maintaining an open session until mediaClose).
2013-09-07 03:27:13 +00:00
Devin Teske
7e9ed73522 Long URLs don't always appear even with autosizing and other tricks. So,
add some whitespace to put the URL on a line by itself, maximizing view.
2013-09-07 03:24:22 +00:00
Gavin Atkinson
9c99f4d7e7 Remove ftp2.tr.freebsd.org, it is out of date.
MFC after:	3 days
2013-07-23 12:20:27 +00:00
Devin Teske
d99d4be64a Sync-up with bsdinstall(8) FTP mirrorselect changes.
SVN r224656:
Add back ftp4, a new machine has taken its place. ftp2 and ftp8 are both
IPv6 capable mirrors.  cvsup4/ftp4 have already been added to the handbook.

NOTE: Except put IPv6 entries in IPv6 section at the top of the list

SVN r225467:
Add ftp4.se.freebsd.org to the IPv4 and IPv6 mirror lists.

SVN r235228:
Add the IPv6 tag to ftp4.fr.freebsd.org.

NOTE: Except dup entry into IPv6 section.

SVN r243832:
- Remove snapshots.se.freebsd.org [1]
- Add ftp6.se.freebsd.org

SVN r243854:
Remove snapshots.jp.freebsd.org. It stopped working years ago.

SVN r253543:
Update mirror list to more closely match
http://www.freebsd.org/doc/en_US.ISO8859-1/books/handbook/mirrors-ftp.html

MFC after:	1 week
2013-07-22 13:56:35 +00:00
Devin Teske
dde7be41df Re-implement $probe_only aspect of f_media_get_TYPE() (where TYPE is cdrom,
nfs, ftp, http, httpproxy, etc.) and f_device_get() (abstract method for
calling aforementioned f_media_get_TYPE()).

Previously, if $probe_only was present and non-NULL, the TYPE functions
would check for $file and exit with an appropriate error status (success if
the file exists and readable, failure otherwise).

While this has been retained, a pair of globals has been introduced:
$PROBE_EXIST and $PROBE_SIZE (see `/usr/share/bsdconfig/media/common.subr')

The $PROBE_EXIST global can be used where you need the functionality of
simply testing for existence (previously the _only_ functionality).

Meanwhile, the new $PROBE_SIZE global can be used to cause the TYPE function
to print the size of the file (in bytes) on standard-out (or -1) if not
found or an error occurs. NOTE: If an error occurs, it is logged with the
dprintf function, which is visible with `-d' flag or debug=1.

In many cases, where you need to get the size of a file _and_ check for its
existence, you can use the return status of a $PROBE_SIZE call.
2013-07-14 03:08:52 +00:00
Devin Teske
c0adcdb9c1 Introduce a new [yet unused] function for [efficiently] getting the path to
an executable by-name without forking or using externals.

In a performance benchmark of 10,000 runs on circa 2006 hardware, f_which
out-performed `which' with an average completion time of ~2.5 seconds versus
~56 seconds.

This should be handy for future use (not that I make it a habit to call
`which' in a loop 10,000 times).
2013-07-10 22:45:07 +00:00
Devin Teske
8a86b3cb2c Adjust comments to fit within 80-columns. 2013-07-09 23:21:57 +00:00
Devin Teske
4f8a4fa5f9 Fix conditional (der should match the comment above it).
MFC after:	1 day
2013-07-09 22:01:05 +00:00
Devin Teske
7d3a5a3b09 Do two things: First, don't obscure the backtitle. Second, read ~/.dialogrc
if it exists to determine if use_shadow is true (ON) or false (OFF).

The purpose of determining the value of use_shadow is to know how many lines
to subtract from the maximum height value in assuring that the backtitle is
not obscured.

The detriment of obscuring the backtitle is that it provides information
that is not easily obtained elsewhere. That is the command-line shortcut
used to access the current menu. As you navigate from one dialog to the
next, invariably transparently corssing module boundaries, the backtitle
represents the command-line argument used to get there. Obscuring this
information with a widget that is too-tall and/or too-wide would see that
data go unnoticed (leaving few other ways to get that information in the
same helpful context).

So despite the fact that this change reduces the standard maximum height for
all widgets, there is a trap-door to prevent this calculation. If you want
to utilize the full screen height on the terminal (remember, this adjustment
is not made for Xdialog(1)) you can set $NO_BACKTITLE to 1 (or any non-NULL
value for that matter) and this calculation will be skipped. You will be
able to draw a widget that partially obscures the backtitle if-necessary.

MFC after:	1 day
2013-07-09 21:53:57 +00:00
Devin Teske
8e37a7c8b9 Fix typos in the BSD License. 2013-07-07 18:51:44 +00:00
Devin Teske
dfe61b44b0 Be consistent with other usr.sbin programs w/respect to the copyright
wording ("All rights reserved."); I had the casing wrong on many instances.
2013-07-07 18:34:36 +00:00
Devin Teske
f8ea072a54 Be consistent with other usr.sbin programs w/respect to the copyright
wording ("All rights reserved."); I had the casing wrong on many instances.
2013-07-07 18:21:30 +00:00
Devin Teske
39c229261f Don't prevent the user from hanging their system by changing network
settings while NFS mounts are active; but DO warn them and make the
default action to do nothing. (thanks julian)
2013-07-05 23:16:56 +00:00
Devin Teske
636621d9d9 Check for INDEX file first before anything else when processing modules. 2013-07-05 22:25:40 +00:00
Devin Teske
4b97e14f62 Check menuitem before calculating tag. 2013-07-05 22:24:43 +00:00
Devin Teske
52d41f916e Add the necessary code to reinstall packages. Both scripted access
(packageReinstall) and UI access have been tested successfully with a
variation of different situations including:
+ Reinstall a package for which no other packages depend
+ Purposefully do thinks like reinstall a package that is not installed
+ Try to reinstall a package which other installed packages still depend

NOTE: There is no "force" used; if a package is required by other packages,
it will not be uninstalled (and therefore no reinstall is done).
2013-07-05 21:40:31 +00:00
Devin Teske
4254e87dbc Remove superfluous continue at end of loop. (pointy-hat) 2013-07-05 21:32:54 +00:00
Devin Teske
1da51566d5 Add support for processing add-on modules from /usr/local/libexec/bsdconfig
(this is designed to allow new modules to be installed via ports/packages).

To prevent conflict with itself (sysutils/bsdconfig) as a port (which
installs its base modules to the above directory, it was long-ago decided
that so-called `base' modules would look different than now-defined `add-on'
modules. The structure of the contents for each is the same, but the naming
convention for the module directory must be different.

Base modules are named `[0-9][0-9][0-9].*' to allow SysV-style organization
while add-on modules must avoid this naming style and are simply listed in
alphabetical order by their module directory.

For example, a hypothetical port named `bsdconfig-jails' could install
/usr/local/libexec/bsdconfig/jails and provide `bsdconfig jails' as well as
a new menu entry in the main-menu.

Add-on modules are listed in the main-menu (when bsdconfig is executed with-
out arguments) below a separator after the last base-module.

In `bsdconfig -h' output, add-on modules are listed right alongside base
modules (sorted alphabetically in columnar fashion; left-to-right).

If a base module declares a keyword used by an add-on module, the base
module will always win when given `bsdconfig keyword' syntax.

Add-on modules should avoid declaring any keyword found in `script.subr' as
a reserved-word (`Resword') since bsdconfig also supports `bsdconfig resword'
as a fall-back if no keyword is found to be declared by any module.
2013-07-05 20:13:00 +00:00
Devin Teske
c6470c75f5 Oops, r252833 was not supposed to touch this file. Back-out and recommit
this file with the rest of the files it was supposed to go with.
2013-07-05 20:01:07 +00:00
Devin Teske
e363bf2b1d Don't calculate the tag until we know that we're going to make a new menu
item entry. Also join simple NULL assignments into a single line.
2013-07-05 19:57:40 +00:00
Devin Teske
52c2fbe8a9 Oops, r252810 forgot to hook the new example file (browse_packages.sh) into
the Makefile.
2013-07-05 18:50:17 +00:00
Devin Teske
fc20233076 Adhere to 80-column width. 2013-07-05 18:31:26 +00:00
Devin Teske
e153f92628 Document remaining undocumented modules (and remove my silly place-holder
thing at the top, which I was using as a way to make sure I didn't forget
to document any modules).
2013-07-05 18:30:43 +00:00
Devin Teske
f9b9df7f0e Make a correction to the description of invocation with-versus-without
arguments, making things a bit more clear [hopefully].
2013-07-05 18:29:09 +00:00
Devin Teske
37b6146ea3 Document new -d' and -D file' debugging options. 2013-07-05 18:03:00 +00:00
Devin Teske
2a5bf6db9a Change default FTP server (s/ftp-archive/ftp/). 2013-07-05 17:56:15 +00:00
Devin Teske
f0157ce528 Add example shell script for creating a local INDEX file that can be
accessed quickly for browsing a list of available packages.
2013-07-05 17:54:08 +00:00
Devin Teske
b7df1596cf Update HISTORY. 2013-07-05 17:45:54 +00:00
Devin Teske
2902415180 Rest in peace Ron (Ron McDowell Jul.12, 1955 - Aug.26, 2012).
I'll carry-on from here. Thank you so much for your hard work.
2013-07-05 17:44:53 +00:00
Devin Teske
071e3e3997 Update e-mails. 2013-07-05 17:38:54 +00:00
Devin Teske
8c1a61f605 Since r251908, bsdconfig(8) has no direct ties to sade(8) (instead uses
`bsdinstall partedit'). Update references (s/sade/bsdinstall/) and change
the BUGS section to be based on reality.
2013-07-05 17:35:13 +00:00
Devin Teske
318645e0d2 Don't refer to a port manual. 2013-07-05 17:31:05 +00:00
Devin Teske
01dc132c3a mdoc: begin sentences on a new line. 2013-07-05 17:27:55 +00:00
Devin Teske
b07efdb566 Update date on the back of r252802. 2013-07-05 17:23:00 +00:00
Devin Teske
39346a432d Fix a typo. 2013-07-05 17:22:10 +00:00
Devin Teske
a504f1acf5 Whitespace. 2013-07-05 17:21:40 +00:00
Devin Teske
7079fc4e02 Use f_show_msg() instead of f_dialog_msgbox() where appropriate. The main
difference between these two functions:

	Usage: f_show_msg() $format_string [ $format_args ... ]
	Usage: f_dialog_msgbox() $text [ $hline ]

The former lends itself well to displaying the $msg_* i18n text, prompts,
etc. While the latter is better for text you do not control (error strings
captured as a response from external commands) -- or if you have to control
the hline.
2013-07-05 16:00:01 +00:00
Devin Teske
542dd84bad Add the necessary code to uninstall packages (re-install still pending).
Both scripted access (packageDelete) and UI access have been tested
successfully with a variation of different situations including:
+ Uninstall a package which no other installed package depends
+ Uninstall multiple packages which no other installed packages depend
+ Uninstall multiple packages which depend on each other
+ Similar to above but when ordered removal requires tracing dependencies
+ Purposefully do things like uninstall a package that is not installed
+ Try to uninstall a package which other installed packages still depend
+ Try to uninstall multiple packages which other installed packages depend
+ And many more.
2013-07-05 06:52:07 +00:00
Devin Teske
12a9a52070 Add minor debugging. 2013-07-05 06:46:11 +00:00
Devin Teske
384190f25b Prevent f_package_add() from re-performing f_package_detect_installed()
even though f_package_config() may have already detected the installed
packages.
2013-07-05 06:24:18 +00:00
Devin Teske
35925de7b6 Don't deselect a package right after installing it (this went unnoticed
because [currently] we exit after performing requests actions -- if we
ever change this to returning to the package selection screen, this would
have made an impact).
2013-07-05 06:22:25 +00:00
Devin Teske
02af913fc1 Minor debugging changes/additions. 2013-07-05 06:20:01 +00:00
Devin Teske
60fefd1e17 Fix a typo in a comment. 2013-07-05 03:12:29 +00:00
Devin Teske
38ae478b58 Add the beginnings of the old networking services functionality of
sysinstall(8). The UI for this will come later while this exposes the
functionality to the scripted interface. Tested successfully to first
install the pcnfsd package from the `Latest' repository, and second to
configure mountd_flags="-n" in rc.conf(5).
2013-07-05 01:49:20 +00:00
Devin Teske
31185df0d3 Add the necessary code to install packages (uninstall and re-install still
pending). Both scripted access (packageAdd) and UI access have been tested
successfully with a variation of different situations including:
+ Install a package with no dependencies
+ Install a package with dependencies that are already installed
+ Install a package with dependencies where some are already installed
+ Repeat each of the above from FTP and local Directory
+ Purposefully do things like try to install a package that does not exist
+ Try to install a package for which a dependency could not be loaded
+ Try to install a package that is in the INDEX bot not on the media
+ And many more.
2013-07-05 01:44:59 +00:00
Devin Teske
f687c95d86 Add debugging for each of the initialized default variables. 2013-07-05 01:38:42 +00:00
Devin Teske
0e30bd5b2e Add mustberoot.subr to the list of includes for scripts, exposing the helper
function f_mustberoot_init() to make it easy to write scripts that can more
easily transition to the super-user via sudo(8).
2013-07-05 01:37:35 +00:00
Devin Teske
dbc750a529 Remove separate processing of dependent packages from the "Review" screen
since f_package_add (packageAdd resword) processes dependencies itself.
NOTE: This is in preparation for incoming package management code.
2013-07-05 01:32:39 +00:00
Devin Teske
447dfc41b5 Get rid of place-holder in preparation for incoming package mgmt code. 2013-07-05 01:30:13 +00:00
Devin Teske
996caf2185 Comments. 2013-07-05 01:28:30 +00:00
Devin Teske
76ab5f3d5a Allow global default as general fall-back for package management routines. 2013-07-05 01:21:01 +00:00
Devin Teske
a0f49bbab3 Set name of device to directory path (displayed during package operations). 2013-07-05 01:18:54 +00:00
Devin Teske
424d0bad55 Implement $probe_only for the media access modules. sysinstall(8) was
allowed to ignore the probe_only argument of its member functions solely
because in the C language, the file accessor methods open and return a file
descriptor and reading of the data is optional. In shell, the file accessor
methods return data on stdout and that data should not be ignored (large
files could block execution).

So, we must adhere to the probe_only flags and in some cases (in the case of
FTP, for example) change the `get' strategy to simply test existence and
return an appropriate status.

This was required because the up-coming package management stuff makes heavy
use of the probe_only argument to try different package suffixes. Every
media access module must implement $probe_only for the `get' accessor.
2013-07-04 20:12:12 +00:00
Devin Teske
c9c67103c3 More whitespace. 2013-06-24 20:58:54 +00:00
Devin Teske
b19b201996 Whitespace. 2013-06-24 20:39:07 +00:00
Devin Teske
edc9198c33 Add a newline character to the end of the "Check URL again" error message
because long URLs do not induce extra height despite wrapping by dialog(1).
NOTE: For even longer lines, the cursor up/down keys work to scroll through
2013-06-23 10:51:26 +00:00
Devin Teske
47b73aa2c1 Merge r248313 from stable/9 sysinstall(8) to head bsdconfig(8):
Add support for installation directly via HTTP.

While we're here, remove the menu-item for Passive FTP (since moving to
ftp(1) and switching FTPMODE to `auto' by default -- see r251613 -- the
single remaining FTP menu-item works for both ftp.f.o and ftp-archive.f.o;
previously each requiring separately active versus passive both work with
the `auto' setting). In scripting you still have mediaSetFTPActive and
mediaSetFTPPassive but the remaining FTP menu-item uses mediaSetFTP which
defaults to `auto' (aforementioned SVN r251613).
2013-06-23 10:48:26 +00:00
Devin Teske
5ffdcd4c61 Implement the $probe_only parameter (previously unimplemented). 2013-06-23 10:04:23 +00:00
Devin Teske
6a18711a00 Fine-tune the parsing of the URL. Re-order, comment, and add debugging to
each case of unique URL format.
2013-06-23 09:41:47 +00:00
Devin Teske
a7408e5cc1 Fix a code typo that prevented the probing of the current defaultrouter
in-order to pre-populate the editor.
2013-06-22 03:54:17 +00:00
Devin Teske
24365ecc72 Oops, previous revision (r252084) broke non-full-path resolution (e.g.,
ftp://ftp.freebsd.org or ftp://ftp.freebsd.org/). Now both full-path and
non-full resolution is working regardless of trailing-slash.
2013-06-22 03:50:14 +00:00
Devin Teske
ffd2e04e32 Trim the trailing `/' from the ftp_dir when validating that the directory
exists on the FTP server. This now means that when you specify a full-path
to the repository on the FTP server that it doesn't matter whether you have
a trailing `/' or not.
2013-06-22 03:44:49 +00:00
Devin Teske
2c2a50fde6 Take advantage of the fact that f_getvar evaluates the $var_to_get parameter
within braces, allowing all manner of parameter expansions (properly quoted
or escaped, of course).
2013-06-22 02:57:52 +00:00
Devin Teske
4ef0123eb7 Fix a regression introduced by r251967, resulting in:
/usr/libexec/bsdconfig/110.mouse/mouse: 134:
Syntax error: ";;" unexpected (expecting "fi")
2013-06-22 02:51:22 +00:00
Devin Teske
a0d3f1e5bc Fix a regression introduced by r251967, resulting in:
/usr/libexec/bsdconfig/080.console/console: 136:
Syntax error: ";;" unexpected (expecting "fi")
2013-06-22 02:47:54 +00:00
Devin Teske
03104918fe Add missing local declaration. 2013-06-21 23:21:16 +00:00
Devin Teske
bb470eb314 Remove unused library include. 2013-06-21 23:18:29 +00:00
Devin Teske
1de60ff0f4 Alphabetize library includes. 2013-06-21 23:13:55 +00:00
Devin Teske
66badff968 Style. 2013-06-21 22:53:51 +00:00
Devin Teske
5b3821c01c Typo and grammar fixes to comments. 2013-06-21 22:47:31 +00:00
Devin Teske
403c4b46e0 Fix a code typo in a case-statement match expression that prevented IPv6
URLs with port designator from working properly (e.g. http://[::1]:80/).
2013-06-20 07:29:42 +00:00
Devin Teske
e269422b91 When the fall-back of a case-statement is the last thing executed in a
while-loop _and_ all prior matches in the same case-statement either break
or continue, we can safely break the fall-back out of the case-statement.
This should improve readability and allow for longer-lines by reducing the
level of indentation by-one for the fall-back case.
(a continuation of SVN r252019)
2013-06-20 05:51:44 +00:00
Devin Teske
fd3d4fec40 When the fall-back of a case-statement is the last thing executed in a
while-loop _and_ all prior matches in the same case-statement either break
or continue, we can safely break the fall-back out of the case-statement.
This should improve readability and allow for longer-lines by reducing the
level of indentation by-one for the fall-back case.
2013-06-20 05:48:08 +00:00
Devin Teske
a0b423e1f7 Remove pedanticism and consolidate some logic. 2013-06-20 05:42:21 +00:00
Devin Teske
3b1f7d9e5d Add debugging (for a case that shouldn't arise, but makes it more obvious
if a menu addition is made in one plce but forgotten in another).
2013-06-20 05:40:11 +00:00
Devin Teske
1a13494575 Style -- no ;; needed on fallback clause within case-statement. 2013-06-19 18:44:55 +00:00
Devin Teske
ba44a0d54a Whitespace. 2013-06-19 18:32:18 +00:00
Devin Teske
f4a3220ca1 Whitespace and comments. 2013-06-19 18:13:58 +00:00
Devin Teske
3daac03bb7 Alphabetize reserved-word (resword) registration. 2013-06-19 17:14:59 +00:00
Devin Teske
fa8b43c808 Alphabetize includes. 2013-06-19 17:13:16 +00:00
Devin Teske
e52257af13 Remove extra whitespace lines. 2013-06-19 00:24:08 +00:00
Devin Teske
9cd8fcc642 Change a humongous if-statement at the end of f_install_zoneinfo_file() into
an early return, allowing a huge chunk of code to be indented one-level less
2013-06-19 00:13:54 +00:00
Devin Teske
b17d3670ee Take advantage of newly updated f_dialog_{yesno,noyes}() functions from
SVN r251977 (adding an $hline parameter).
2013-06-19 00:09:21 +00:00
Devin Teske
b4dc08d45d When I first wrote the timezone module, it was in sysutils/tzdialog and it
pre-dates bsdconfig. Update the code to take advantage of f_dialog_msgbox().
2013-06-19 00:08:29 +00:00
Devin Teske
68d5c9afb9 Change the f_dialog_{yesno,noyes}() function-arguments in `dialog.subr' to
accomodate an $hline value for overriding the default. This change does
not effect any current modules as it turns out that not one single usage of
either f_dialog_yesno() or f_dialog_noyes() relied on accepting more than a
first argument (read: all occurrences quoted the first parameter; so $* was
never depended upon).

This will allow some custom invocations of --yesno and --noyes to roll over
to these functions (for example, in `timezone/timezone').
2013-06-18 23:48:05 +00:00
Devin Teske
aaeba1c1ea Perform some code consolidation and replace nested case-statements with
more logical if-else statements for each menu selection.
2013-06-18 23:18:32 +00:00
Devin Teske
fcd71b75c9 Fix a regression introduced by r251967, resulting in:
/usr/libexec/bsdconfig/140.startup/startup: 130:
Syntax error: ";;" unexpected (expecting "fi")
2013-06-18 23:14:45 +00:00
Devin Teske
229efb37dc Whitespace. 2013-06-18 23:11:36 +00:00
Devin Teske
df750a6ced Perform some code consolidation and add some additional error
checking/reporting. (similar to SVN revisions 251919 and 251928)
2013-06-18 21:44:35 +00:00
Devin Teske
7cdf48fc2c Comments. 2013-06-18 21:35:38 +00:00
Devin Teske
0071dbd1cd Comments and whitespace. 2013-06-18 09:54:09 +00:00
Devin Teske
997cf00a16 Comments. 2013-06-18 09:45:10 +00:00
Devin Teske
d7d2d8039a Perform some code consolidation and add some additional error
checking/reporting. (similar to SVN revision 251919)
2013-06-18 09:43:10 +00:00
Devin Teske
dee8ed370d Whitespace and comments. 2013-06-18 09:41:34 +00:00
Devin Teske
23fb944196 Perform some code consolidation and add some additional error
checking/reporting. (similar to SVN revisions 251905 and 251915)
2013-06-18 09:28:49 +00:00
Devin Teske
d6abc28bf4 Remove unnecessary loops, perform some code consolidation, and add some
additional error checking/reporting. (same thing going on here as SVN
r251905 -- just this time for the mouse module instead of console)
2013-06-18 09:19:59 +00:00
Devin Teske
f1edae9451 Whitespace. 2013-06-18 09:05:08 +00:00
Devin Teske
131502c303 Use newly enhanced f_dialog_msgbox() from SVN r251912. 2013-06-18 08:59:47 +00:00
Devin Teske
5a97d36067 Change the f_dialog_msgbox() arguments in `dialog.subr' to accomodate an
$hline argument for setting the --hline parameter value. This change does
not effect any current modules as it turns out that not one single usage of
f_dialog_msgbox() relied on accepting more than a first argument (read: all
occurrences quoted the first parameter; so $* was never depended upon).

This will allow some custom invocations of --msgbox to roll over to this
function (for example, in `mouse/disable').
2013-06-18 08:54:02 +00:00
Devin Teske
55bce0c120 Comments. 2013-06-18 08:40:16 +00:00
Devin Teske
c9e7fcd366 Comments. 2013-06-18 08:35:44 +00:00
Devin Teske
274282c82b Fix a typo in a comment. 2013-06-18 08:30:31 +00:00
Devin Teske
97e0eecaf3 Switch bsdconfig Disk Management' from sade(8) to bsdinstall partedit'. 2013-06-18 08:28:03 +00:00
Devin Teske
8de4fc8d23 Oops, in SVN r251905 I forgot that f_die takes the return code as the first
argument (not the format).
2013-06-18 08:22:51 +00:00
Devin Teske
6dcefcac2b Improve the INDEX format. Whitespace improvements, format improvements, typo
and grammatical fixes.
2013-06-18 08:15:56 +00:00
Devin Teske
a67f39c51a Remove unnecessary loops, perform some code consolidation, and add some
additional error checking/reporting.
2013-06-18 07:36:09 +00:00
Devin Teske
c3ffa2ba18 Whitespace improvements. 2013-06-18 07:33:45 +00:00
Devin Teske
65c7c08716 Style/comments. 2013-06-15 13:38:21 +00:00
Devin Teske
c6f73e3099 Add skeleton processing of selected packages in the order in which they
should be processed. De-select each package as we "process" (actual
processing still pending) each package so that if we get an error, we can
return to an accurate state of selected packages.
2013-06-14 19:35:30 +00:00
Devin Teske
f184cec5a9 Make the default choice for FTP media access use "auto". 2013-06-11 03:37:29 +00:00
Devin Teske
641cb9ccd9 Fix a bug introduced by r251236; product of bug was the following error in
"Startup"->"View/Edit Startup Configuration"->"Add New"->"Add From List":

[: -eq: unexpected operator

NOTE: Previously mentioned in r251557

Problem caused by removal of $retval to capture exit status of call to
f_dialog_input_rclist().

While we're here, enhance f_dialog_input_rclist() to accept a default-item
to make selecting multiple values to-add more efficient.
2013-06-09 15:36:13 +00:00
Devin Teske
d7b85d2789 Fix a bug introduced with r251190, in which a small hunk was forgotten in
the performance conversion process.

The effect of this was the following error when selecting the menu
"Startup"->"View/Edit Startup Configuration"->"Add New"->"Add From List":

[: -eq: unexpected operator

By running `bsdconfig -d' as root to enable debugging, this turns into:

DEBUG: f_getvar: var=[text] value=[
Error: Expected a number for token 4 of --menu.
Use --help to list options.] r=0
[: -eq: unexpected operator

Indicating that the fourth token for --menu which should be $height was
instead a string (the first item of $menu_list) because it was using the
old size-calculation method and $size was now null (needed to use instead
the new size variables of $height $width and $rows).
2013-06-08 21:45:32 +00:00
Devin Teske
04d380df0c Fix a bug introduced with r249751, in which a small hunk was forgotten in
the performance conversion process.

The effect of this was, when your /etc/defaults/rc.conf file changed
(based on md5(1)) and re-generating the file startup_rcconf_map.cache in
/var/run/bsdconfig/ you would get a screen-dump of its contents before the
menu would appear.
2013-06-08 21:33:09 +00:00
Devin Teske
9039c2f6f7 Fix a typo in comments. 2013-06-08 21:11:26 +00:00
Devin Teske
2d0797c6dd Don't silently ignore errors (found while
testing with `chflags schg /etc/ttys).
2013-06-08 20:47:43 +00:00
Devin Teske
f5e1223b85 Prevent getting hung-up on the following prompt (found while testing with
`chflags schg /etc/ttys'):

override rw-r--r--  root/wheel for /etc/ttys? (y/n [n])

Simply by adding `-f' flag to mv(1).
2013-06-08 20:43:13 +00:00
Devin Teske
5e66bd88c9 Fix a one-character typo. The effects of which were "Console"->"Ttys" menu
would not launch (and gave no error). This was easily diagnosed by running
`bsdconfig -d' as root and seeing the following error right after selecting
the "Ttys" sub-menu:

DEBUG: f_getvar: var=[text] value=[
Error: Expected at least 6 tokens for --menu, have 4.
Use --help to list options.] r=0

Typo was introduced by SVN r251361.
2013-06-08 20:27:16 +00:00
Devin Teske
9b897ae786 Add a prompt to the "Add User" and "Add Group" sub-menu items (under the
"Login Management" module): Use default values for all account details?

If you select "Yes" (the default is "No"), you'll jump past all the prompts
and jump straight to the review screen with all-default values.

Makes adding a lot of users/groups faster/easier if you don't need to
customize more than one or two different values from their defaults.
2013-06-08 19:13:49 +00:00
Devin Teske
528318ae53 Curb another regression (this one introduced by r251545, itself trying to
fix the regression introduced by r251544; which was trying to make things
consistent w/respect to ESC versus YES versus NO in the password disable
prompt in "Login Management".

(need stronger coffee; very sorry for the churn)

With this revision, the "YES", "NO", and implied ESC options all work as-
expected. Choosing "YES" allows you to proceed and the password will be
disabled. Choosing "NO" will bring back around to enter a password for the
account. Pressing ESC will drop you out of either user or group input and
back to the usermgmt screen.
2013-06-08 18:23:41 +00:00
Devin Teske
350db06539 Fix a regression introduced by r251544; if user chooses "NO" when being
asked if they would like to disable password authentication for the account,
loop back to prompt them for the password again.
2013-06-08 18:13:42 +00:00
Devin Teske
7ca5c4cbc6 Check for ESC as a separate choice from "NO" when asking if the operator
would like to disable password management for an account while adding either
a user or group. When being prompted to answer questions while adding a
group or user, two things are trow:

1. You can hit ENTER to blast through all the questions and in the end, the
   group or user is created with sensible defaults for all values.

2. You can press ESC during any prompt to cancel the operation as a whole.

This fix is shoring up an inconsistency in the latter (#2).
2013-06-08 18:08:17 +00:00
Devin Teske
edc6918e0b Track defaultitem in the password and account expiry menus; if the user
presses ESC or chooses Cancel/No in any of the sub-menus, we want to return
to the expiry menu with that item selected.
2013-06-08 17:46:39 +00:00
Devin Teske
3196cddc5d Fix a regression in the "Login Management" module introduced by r251242 in
which choosing to cancel the manual input of expiration time (in seconds
since the UNIX epoch) for either account expiration or password expiration
would see the original value lost.
2013-06-08 17:36:31 +00:00
Devin Teske
f82913db88 Reduce verbosity in the "Console"->"Saver" module (bsdconfig syscons_saver)
by replacing the infinitive [verb] phrase "Simply blank the screen" with a
simple description of what you get; "Blank screen".

PR:		ports/169316
2013-06-08 16:49:19 +00:00
Devin Teske
2a90fca013 Remove extraneous characters ('<<<') from `Exit' menutag in the "Security"
and "Startup"->"Misc" modules to make the menus appear more consistent with
the numerous other modules and look a little cleaner.

PR:		ports/169316
2013-06-08 16:28:08 +00:00
Devin Teske
291a501e40 Shift Console->Saver menu items to place the default item at the top, making
this menu consistent with Console->Repeat, Console->Font, Console->Screenmap
and many others which place the default choice at the top.

NOTE: SVN r249751 changed things so that these menus highlight the active
selection, so the idea that the default choice (now at top) "can be selected
immediately by hitting ENTER" is not possible unless the default choice is
the currently active setting (e.g., on first visit to the menu). However, it
is still warranted to have the default choice at the top of the menu.

PR:		bin/169316
2013-06-04 17:08:26 +00:00
Devin Teske
595e514d0d Lessen verbosity of "Exit" menutag items to appear more consistent across
menus from one module to the next.

Replacing "Exit this menu (returning to previous)" with "Exit this menu".

PR:		ports/169316
2013-06-04 16:48:23 +00:00
Devin Teske
44392705fa Use f_shell_escape() instead of forking to awk. In this case, the
replacement comes with a great performance increase (as f_shell_escape()
uses the built-in based f_replaceall() which out-performs forking to
awk(1)). This should also improve readability slightly.
2013-06-04 03:47:21 +00:00
Devin Teske
97142e6ae7 Use a case-statement instead of multiple (separate even) if-statements. 2013-06-04 03:38:16 +00:00
Devin Teske
b988241f05 Comments. 2013-06-04 03:37:35 +00:00
Devin Teske
b5bd0bacd6 Similar to r251236, r251242, and r251244. Introduce new function-pair to
dialog(1) API in dialog.subr responsible for retrieving menu-choice data
(for the --menu widget).

Add f_dialog_menuitem_store()/f_dialog_menuitem_fetch() for storing and
retrieving the menuitem (not the tag) from a --menu widget result.

The dialog --menu widget returns the `tag' from the tag/item pair of choices
for a menu list. Because the menu list is often local to the function that
is displaying it, the ability to dereference this into the item is not
possible unless you use a global. This changes things so the function (upon
successful return of dialog) dereferences the tag into the item and stores
it for later retrieval using these functions.

NOTE: Tags are dereferenced into items using f_dialog_menutag2item().
2013-06-04 03:30:44 +00:00
Devin Teske
83822902c2 Fix a code typo (missing `eval') which lead to improperly-sized menu when
displaying packages (menu was always maximum height). The problem was
introduced by SVN r251232.
2013-06-04 00:42:31 +00:00
Devin Teske
b87d5f1f1f Fix menu accenting for the package category list. The single-space indent
for duplicate initial-characters was removed for making comparisons but was
not put back.
2013-06-04 00:38:19 +00:00
Devin Teske
fe9ef40c68 Whitespace and comments. 2013-06-04 00:35:57 +00:00
Devin Teske
790062d26b Improve debugging for f_dialog_*_constrain() to print constrained rather
than unconstrained values.
2013-06-04 00:30:05 +00:00
Devin Teske
dd5cc066af Like r250701, introduce another handy function for truncating variables to a
specific byte-length. Works like vsnprintf(3).
2013-06-02 23:25:27 +00:00
Devin Teske
f8e121ed61 Fix a typo. In this case, the typo caused the f_noyes() invocation to
display a global instead of the passed-argument; however since the global
always has the same value as the passed argument, it made no difference in
the realtime operation.
2013-06-02 23:23:29 +00:00
Devin Teske
e4cb6ac115 Fix a bug in which the user's choice to Cancel was not recognized. This was
caused by the standard (and correct) behavior of the shell to discard the
return status of lvalue-operands in a pipe-chain.

The solution is to not pipe the file-acquisition directly into sort(1) but
instead store the output (allowing immediate testing of the return status)
and later sort it.
2013-06-02 23:20:46 +00:00
Devin Teske
faf9d0ce1c Fix a bug that would cause a spurious warning to appear to appear in an
edge-case. The case was that you have been through the FTP setup once before
and on the second time through, you cancel at the re-selection of a new FTP
server.

The spurious warning was "device_media: not found" and was caused because
the underlying call to f_device_network_down() did not check to see if the
network device existed before attempting to shut it down.

Add checks to make sure we don't forge ahead unless the device exists.
2013-06-02 23:18:27 +00:00
Devin Teske
538d68ea69 Fix a bug in which the user's choice to Cancel was not properly recognized. 2013-06-02 23:15:12 +00:00
Devin Teske
3b4e309862 Change the name of a couple of functions in `usermgmt/user_input.subr' to
make their purpose more clear by their names:

	f_dialog_input_change() and
	f_dialog_input_expire()

Are now (respectively):

	f_dialog_input_expire_password() and
	f_dialog_input_expire_account()

Upon revisit to this portion of code, the former names were too confusing.
2013-06-02 23:12:32 +00:00
Devin Teske
10908a6f19 Fix a copy/paste error within a comment. 2013-06-02 23:08:21 +00:00
Devin Teske
80ae9845f5 Add some additional debugging to the common media library. 2013-06-02 23:06:33 +00:00
Devin Teske
c01472c194 Make some obvious consolidations in local declaration for readability. 2013-06-02 23:05:01 +00:00
Devin Teske
51c41087d1 Standardize NULL initialization to be consistent. 2013-06-02 23:02:56 +00:00
Devin Teske
80433743e3 Use f_isset() (introduced by r250317) instead of `f_quietly f_getvar ...'. 2013-06-02 22:54:36 +00:00
Devin Teske
42ade6a964 Make proper use of locals in f_dialog_init(). 2013-06-02 22:45:54 +00:00
Devin Teske
f4844f65a9 Improvements to whitespace and comments. 2013-06-02 22:34:40 +00:00
Devin Teske
5b4765c331 Fix option processing from the library layer to address unexpected
behavior(s); e.g., `-Xd' versus `-dX' did not produce the same results.

The libraries common.subr and dialog.subr automatically process the
arguments passed to the program and enable/disable functionality without the
need to process the arguments within your program. For example, if "$@"
contains `-d', common.subr will see this and enable debugging regardless of
whether you process "$@" yourself or not (this automatic processing can
easily be disabled for custom scripts that don't want it; see the afore-
mentioned scripts for additional details).

NOTE: common.subr stores a copy of "$@" in $ARGV for convenient (and
repeated) processing by libraries such as dialog.subr which provide such
transparent functionality for the consuming script(s).

However, the libraries don't know if a program wants to accept `extra'
options. Flags are not really a problem, because the library can be
programmed to silently ignore unknown flags. The trouble comes into play
when the program wants to define an option that takes an argument.

For example:

	bsdconfig -D logfile -X

In the above example, the library uses getopts to process $ARGV and if it
doesn't know that `-D' takes an argument, the option processing will
prematurely terminate on `logfile' (this is standard/correct behavior for
getopts but is undesired in our situation where we have partially off-loaded
main argument processing).

The problem is solved by allowing the program to define an extra set of
options to be included in each library's handling of $ARGV. Only options
that require arguments are truly necessary to be pre-specified in this new
manner.
2013-06-02 22:04:39 +00:00
Devin Teske
052f89691c Standardize the way functions build their arguments leading up to a dialog
invocation. Specifically, "top-load" your arguments and in the order in-
which they will be displayed. For example, many [if not all] widgets display
information in the following order, top-to-bottom (visually):

+ backtitle (displayed behind the widget at top-left)
+ title (at the top of the `window')
+ prompt text (just below the title and above whatever widget you choose)
+ Depending on widget, _one_ of the following:
  - menu list
  - radio list
  - check list
  - text input box with initial text
  - [Xdialog(1)] 2x or 3x text input boxes
  - [dialog(1)] a multi-part form
  - progress bar
  - etc. (many more widget choices)
+ buttons (right below the selected widget)
+ [dialog(1)] the hline (displayed at bottom of `window')

NOTE: Xdialog(1) accepts and silently ignores --hline

When building local arguments for your dialog invocation, if the value can't
be cleanly loaded into a local, add "# Calculated below" to the end of the
local declaration while retaining the block order of argument declarations.

Move other local declarations that are not associated with this top-loading
the dialog arguments to right-above where they are first-used.

Also, standardize on the names of the arguments. For example, always use
$prompt (instead of sometimes $msg and sometimes $prompt); use $menu_list
or $shell_list or $radio_list for those respective widgets; ad nauseum.

While we're doing this, flush-out full arguments for many invocations that
were passing NULL strings (making it unapparent if you were staring at this
one invocation what argument that NULL string was supposed to represent).

Last, while we're in startup/rcconf let's remove the unnecessary use of a
GLOBAL (RCCONF_MENU_LIST) for the menu_list.
2013-06-02 20:02:50 +00:00
Devin Teske
775997786b Improve the dialog(1) API in dialog.subr by adding f_dialog_default_store()
and f_dialog_default_fetch(). Operating similar to functions introduced by
SVN r251236 and r251242, these functions operate as a pair for helping track
the default-item data (for the --menu, --checklist, and --radiolist
widgets).

This replaces the direct usage of a global to store the data with an
abstract method for readability and to centralize the code.
2013-06-02 09:02:12 +00:00
Devin Teske
ec7120b5b2 Similar to r251236, improve the portion of dialog(1) API in dialog.subr
responsible for retrieving stored input (for the --inputbox and --password
widgets).

When we (Ron McDowell and I) developed the first version of bsdconfig, it
used temporary files to store responses from dialog(1). That hasn't been
true for a very long time, so the need to always execute some clean-up
function is long-deprecated. The function that used to perform these clean-
up routines for these widgets was f_dialog_inputstr().

We really don't need f_dialog_inputstr() for its originally designed purpose
as all dialog invocations no longer require temporary files.

Just as in r251236, redesign f_dialog_inputstr() in the following four ways:

1. Rename f_dialog_inputstr() to f_dialog_inputstr_fetch()
2. Introduce the new first-argument of $var_to_set to reduce forking
3. Create a corresponding f_dialog_inputstr_store() to abstract storage
4. Offload the sanitization to a new function, f_dialog_line_sanitize()

It should be noted that f_dialog_line_sanitize() -- unlike its cousin from
SVN r251236, f_dialog_data_sanitize() -- trims leading/trailing whitespace
from the user's input. This helps prevent errors and common mistakes caused
by the fact that the new cdialog implementation allows the right-arrow
cursor key to go beyond the last byte of realtime input (adding whitespace
at the end of the typed value).

While we're centralizing the sanitization, let's rewrite f_dialog_input()
while we're here to likewise reduce forking. The f_dialog_input() function
now expects the first argument of $var_to_set instead of producing results
on standard-out.

These changes greatly improve readability and also improve performance.
2013-06-02 05:45:25 +00:00
Devin Teske
fd962ac699 Improve portion of the dialog(1) API in dialog.subr responsible for
retrieving stored data (for the --menu, --calendar, --timebox, --checklist,
and --radiolist widgets).

When we (Ron McDowell and I) developed the first version of bsdconfig, it
used temporary files to store responses from dialog(1). That hasn't been
true for some very long time, so the need to always store the return status
of dialog(1) and then call some function to clean-up is long-deprecated. The
function that used to do the clean-up was f_dialog_menutag().

We really don't need f_dialog_menutag() for its originally designed purpose,
as all dialog invocations (even when in a sub-shell) do not use temporary
files anymore.

However, we do need to keep f_dialog_menutag() around because it still fills
the need of being able to abstract the procedure for fetching stored data
provided by functions that display the aforementioned widgets.

In re-designing f_dialog_menutag(), four important changes are made:

1. Rename f_dialog_menutag() to f_dialog_menutag_fetch()
2. Introduce the new first-argument of $var_to_set to reduce number of forks
3. Create a corresponding f_dialog_menutag_store() to abstract the storage
4. Offload the sanitization to a new function, f_dialog_data_sanitize()

NOTE: That last one is important. Not all functions need to store their data
for later fetching, meanwhile every invocation of dialog should be sanitized
(as we learned early-on in the i18n-effort -- underlying libraries will spit
warnings to stderr for bad values of $LANG and since dialog outputs its
responses to stderr, we need to sanitize every response of these warnings).

These changes greatly improve readbaility and also improve performance by
reducing unnecessary forking.
2013-06-01 23:58:44 +00:00
Devin Teske
f416c89cb3 Fix a typo introduced by r251190. 2013-06-01 22:12:53 +00:00
Devin Teske
367a23a787 Fix a regression in the packages module introduced by recent r251190.
I somehow neglected this module in merging that API change.
2013-06-01 21:29:53 +00:00
Devin Teske
74036c4de9 Improve portion of the dialog(1) API in dialog.subr responsible for
calculating widget sizes. Instead of forking a sub-shell to calculate the
optimum size for a widget, use a byRef style call-out to set variables in
the parent namespace. For example, instead of:

	size=$( f_dialog_buttonbox_size title btitle msg )
	$DIALOG --title title --backtitle btitle --msgbox msg $size

The new API replaces the above with the following:

	f_dialog_buttonbox_size height width title btitle msg
	$DIALOG --title title --backtitle btitle --msgbox msg $height $width

This reduces the number of forks, improves performance, and makes the code
more readable by revealing the argument-order for widget sizing. It also
makes performing minor adjustments to the calculated values easier as
you no longer have to split-out the response (which required knowledge of
ordering so was counter-intuitive).
2013-05-31 19:07:17 +00:00
Devin Teske
f82ca17bbe Fix a typo in a comment. 2013-05-16 16:51:52 +00:00
Devin Teske
60d8a2b517 Add a handy function for truncating variables to a specific byte-length. It
should be noted that newlines are both preserved and included in said byte-
count. If you want to truncate single-line values without regard to line
termination, there's always f_substr() which already exists herein.
2013-05-16 16:46:02 +00:00
Devin Teske
c3755aa30c Centralize standard getopts arguments, both for convenience and to correct
a bug in which certain combinations of arguments produced unexpected results
such as `-dX' (now properly produces debugging and X11), `-XS' (now properly
produces X11 in secure mode), `-df-' (enables debugging when reading a
script from standard-input, etc. Multi-word variations such as `-d -X',
`-X -S', `-d -f-', `-d -f -', etc. also work as expected. Also tested were
variations in argument order, which are now working as expected.
2013-05-14 03:21:13 +00:00