Jeremy Kerr [Fri, 28 Nov 2014 03:42:06 +0000 (11:42 +0800)]
lib/fold: fix warning with -DDEBUG
When compiling the fold code with DEBUG defined, we get:
../lib/fold/fold.c: In function 'fold_text':
../lib/fold/fold.c:37:3: error: comparison of unsigned expression >= 0 is always true [-Werror=type-limits]
assert(bytes >= 0);
^
We should be comparing with != (size_t)-1, not >= 0
Widgets running over the horizontal width of the pad will cause the
screen to blank. Expand the (non-viewable) size of the pad to prevent
blanking until shorter translations are available for nc-config.
Signed-off-by: Samuel Mendoza-Jonas <sam.mj@au1.ibm.com>
Jeremy Kerr [Thu, 18 Sep 2014 11:21:00 +0000 (19:21 +0800)]
ui/ncurses: Fix clearing a boot device UUID
Currently, we have a bug where we can't clear a boot device UUID, as we
only update config->boot_device if we're in AUTOBOOT_ONE state. This
means that the config UI can't be used to change out of "autoboot from a
single device" mode.
This sets the autoboot device unconditionally, allowing it to be
cleared.
ui/ncurses: Exit safe mode on configuration change
Selecting 'OK' in the configuration or language select screen will send
a configuration change to the server and exit safe mode.
Exit safe mode explicity and warn the user that they are about to exit
it.
Signed-off-by: Samuel Mendoza-Jonas <sam.mj@au1.ibm.com> Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
Jeremy Kerr [Wed, 23 Jul 2014 06:03:42 +0000 (14:03 +0800)]
discover: Use platform code to read sysinfo type and identifier
This change uses the platform-specific code to read the system type and
identifier, rather than the pb-sysinfo utility. We introduce a new
callback for struct platform:
int (*get_sysinfo)(struct platform *, struct system_info *);
- which populates struct system_info with appropriate information.
This means that the system-specific code is kept in one place; rather
than having powerpc-specific device-tree-reading code in the pb-sysinfo
shell script.
Jeremy Kerr [Mon, 4 Aug 2014 01:46:00 +0000 (09:46 +0800)]
discover/grub2: distinguish parser.h from grub2/parser.h
'make distcheck' will do a 'make all' srcdir == objdir, then later a
'make check' sith srcdir != objdir. Since gcc's cpp always assumes that
a source file's directory is first in the include paths, we may see
discover/parser.h included when we wanted the generated
discover/grub2/parser.h.
This change renames the grub2 lexer and parser files, to work-around
this behaviour, and fix 'make distcheck'.
Jeremy Kerr [Fri, 1 Aug 2014 03:55:45 +0000 (11:55 +0800)]
autotools: Don't link udev into everything
By default, AC_CHECK_LIB will append to $LIBS, which is used for all
link stages. Intstead, we should popuate $UDEV_LIBS, and just use that
for the single pb-discover link stage.
Jeremy Kerr [Mon, 28 Jul 2014 08:20:04 +0000 (16:20 +0800)]
autotools: Use non-recursive make
With the current testing infrastructure, we don't have a strictly
hierarchical set of dependencies. This causes problems with a recursive
make, and means we have to hack around some of the dependencies.
This change generates a single, top-level makefile from all of the
Makefile.am fragments. We still need the po/ directory as a separate
SUBDIR, but all others can be converted to non-recursive.
Jeremy Kerr [Mon, 28 Jul 2014 04:09:14 +0000 (12:09 +0800)]
discover: Add setlocale calls in discover server
We want the discover server to respect the configured language, so we'll
need to add appropriate setlocale() calls. We use the config->lang
setting to use any previously-saved language.
Jeremy Kerr [Thu, 24 Jul 2014 07:13:24 +0000 (15:13 +0800)]
ui/ncurses: Move menu initialisation to cui code
We'll want to re-initialise the petitboot main menu (when the language
is changed), which we can't do if the items are populated entirely from
the main() function.
This change moves the menu initilisation to the cui code, we we can
re-init when necessary.
Jeremy Kerr [Tue, 24 Jun 2014 05:18:03 +0000 (13:18 +0800)]
ui/ncurses: Use a separate type for help text
Because it's initialised statically, help text won't be directly
gettext()-ed. Instead, we need to perform the gettext translation at
runtime, and pass untranslated strings into the help_screen code.
Instead of trusting callers to pass the untranslated strings though, we
encapsulate the help text data into struct help_text, so we know we have
an unstranslated string.
Jeremy Kerr [Fri, 18 Jul 2014 04:28:43 +0000 (12:28 +0800)]
ui/ncurses: allow tab/backtab to skip through a widget's fields
Since we may have a long list of devices on the configuration screen,
we'd like a way to jump between widgets. This change repeats the
PREV_FIELD/NEXT_FIELD driver request on these events.
Jeremy Kerr [Mon, 21 Jul 2014 07:51:58 +0000 (15:51 +0800)]
discover: allow separate lifetimes for network interfaces and discover devices
We want the network code's network interfaces to (potentially) persist
remove events. For example, discover devices may be removed by a user
event (this happens during a udhcpc deconfig). In this case, we want the
boot options to be removed, but the struct interface needs to stay
present.
This change adds network_(un)_register_device functions, to allow the
device handler to detach from and attach to interfaces.
Jeremy Kerr [Fri, 14 Mar 2014 02:53:04 +0000 (10:53 +0800)]
version.sh: Unify version generation
This change includes a few fixes to the version.sh script, in order to
unify the versions generated from git vs. dev- versions. We unify on a
simple YYYYMMDD format, and drop the time specifier (if you're relying
on time info, you probably have the git SHAs to lookup from instead).
We also clean up the date-generation code, by using printf's %T
formatter, on git's %ct time specification, rather than trying to
transform a %ci date.
Jeff Bailey [Fri, 14 Mar 2014 00:49:10 +0000 (08:49 +0800)]
autotools: Make petitboot autoreconfable
The standard way to regenerate the autotools bits is with 'autoreconf',
but that doesn't work with our custom bootstrap script. We only need the
bootstrap script to generate the version in configure.ac, which we can
easily do with m4_esyscmd_s instead.
This change allows autoreconfiguration with `autoreconf -f -i`.
Includes changes proposed by Yann E. Morin <yann.morin.1998@free.fr>,
and modifications from the original patch from
Jeremy Kerr <jk@ozlabs.org>
Signed-off-by: Jeff Bailey <jeffbailey@google.com> Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
Jeremy Kerr [Wed, 4 Jun 2014 07:45:53 +0000 (15:45 +0800)]
grub2: fix empty file handling
Currently, we have a bug when parsing zero-length files: we subtract one
from the length to exclude the trailing NUL (added by read_file), but a
zero-length file will result in a length of -1.
This change adds an explicit exit if we're attempting to parse an empty
file.
Jeremy Kerr [Wed, 4 Jun 2014 07:22:11 +0000 (15:22 +0800)]
discover/paths: Fix wget command with https and !DEBUG
When DEBUG is undefed, we run out of wget arguments for loading https
URLs. We need an extra element in the argv array to handle all possible
arguments.
Jeremy Kerr [Thu, 22 May 2014 10:42:33 +0000 (18:42 +0800)]
discover: don't free cancelled load tasks
Currently, we have a bug when a boot task with more than one load tasks
is cancelled:
1) boot_cancel calls cleanup_cancellations, which performs a
load_url_async_cancel on all load tasks. This sets the load tasks'
states to LOAD_CANCELLED, and signals associated processes.
2) The first load task process completes, we get a load_url_process_exit
callback. This then invokes cleanup_cancellations.
3) cleanup_cancellations then (incorrectly) frees the boot task (and
hence freeing all pending load tasks) as no load tasks are in LOAD_ASYNC
state (we set them all to LOAD_CANCELLED in step 1)
4) The actual completion for the second load task attempts to reference
the now-freed task structure.
This change fixes the issue by handing the LOAD_CANCELLED state properly
- if we find a load task in this state, we consider the boot task still
pending, and delay the free until all loads are complete.
Jeff Bailey [Sun, 26 Jan 2014 00:48:24 +0000 (00:48 +0000)]
discover/yaboot: support lilo & silo for x86 and Sparc.
The yaboot.conf format is essentially the same format as silo.conf and
lilo.conf, especially if the author isn't using OF paths. This is a
cheap way of getting support for silo and lilo.
Signed-off-by: Jeff Bailey <jeffbailey@google.com> Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
Jeremy Kerr [Thu, 17 Apr 2014 03:40:09 +0000 (11:40 +0800)]
discover/udev: fix double free on udev_init failures
If the udev monitor or enumerate functions fail, we'll call the
udev_unref and udev_monitor_unref functions twice: once in the cleanup
path and once in the talloc destructor.
This change moves all cleanup to the talloc destructor, so we only do
the unrefs once.
Jeremy Kerr [Tue, 15 Apr 2014 03:48:00 +0000 (11:48 +0800)]
ui/ncurses: Always provide a key definition for backtab
Petitboot environments will probably want a basic terminfo defintion
(eg, vt220) rather than a full linux or xterm, but vt220 and friends
don't define a backtab key. Backtab can be useful for proper form
navigation, and without a key definition, we just get an escape, which
exits the current screen.
This change provides a static definition for KEY_BTAB, so we should
always have one available.
Jeremy Kerr [Tue, 15 Apr 2014 03:08:39 +0000 (11:08 +0800)]
ui/ncurses: Use a fixed-sized for small, known-length fields
Fields without O_STATIC can "scroll" horizontally, and we may miss a
left-hand section of text from the current display. This can mean that
the user can't leave a validated field with no indication why, if the
off-to-the-left data is not a valid entry.
This change adds a widgetset function to mark a field as fixed-size, so
we don't have this scrolling behaviour. This means that the entire field
contents will always be visible, and any validation errors can be seen.
Jeremy Kerr [Fri, 11 Apr 2014 08:11:51 +0000 (16:11 +0800)]
discover: Fix uninitialised var warnings
We get a couple of uninitialised var warning when compiling with certain
CFLAGS (-fprofile-arcs -ftest-coverage at this stage).
In statement_if_execute: We'll never actually use this uninitialised (as
there must be at least one conditional in the parsed statement), but we
should address the warning nonetheless.
As passed to strtok_r: strtok will initialise this, but it isn't obvious
to the compiler.
Jeremy Kerr [Thu, 13 Mar 2014 07:18:04 +0000 (15:18 +0800)]
ui/ncurses: Ensure boot option labels are displayable as menu items
ncurses' new_item() expects the name parameter to be a "printable
string", by converting it to a wchar *, and checking that each character
is printable with iswprint(). If it fails, we won't see a boot option at
all.
This change introduces a function to convert the label into something we
know is printable, and valid UTF-8. If mbstowcs fails, we replace it
with a generic 'Invalid option' label. If we encounter a valid multibyte
string with unprintable characters, we replace those with U+fffd
REPLACEMENT CHARACTER.