Support UBOOT_IMGADDR override

Support UBOOT_IMGADDR override

Signed-off-by: Brendan <blc@redhat.com>
Add "const" specifier to function arguments

Functions addNewKernel() and getInitrdVal() do not modify their arguments,
so it is safe to mark them as "const". Also, the compiler can make extra
checks and optimizations this way.
Avoid string duplication calling dirname()

The dirname() function does not modify its argument, so it is uneeded to
duplicate the string passed to it.
Convert to c99 loop initializations.
Update the ubootDir default.

 Make "/boot" the default uboot directory.
 Make the kernel version an exact match to
 avoid removing the wrong uImage and
 uInitrd files, in case the baseline
 kernel is installed.

Signed-off-by: David A. Marlin <dmarlin@redhat.com>
Update the code to set the ubootAddress.

Add support for IMX-based systems.
Use regular expression pattern matching to improve flexibility.
Allow the machine value to be defaulted.

Signed-off-by: David A. Marlin <dmarlin@redhat.com>
Support systems that do not have /boot as a separate filesystem

While testing grubby on systems with a root (/) filesystem that includes
the /boot directory, it was noticed that grubby displayed the prefix (/boot)
twice.  This patch prevents printing the prefix twice on kernel and initrd
lines.

This situation was found while testing the patch "Fix for grub on SuSE
systems: lba and boot information", so this fix is also covered by the
the test on patch "Fix for grub on SuSE systems: test lba and boot info".

Signed-off-by: Cleber Rosa <crosa@redhat.com>
Fix for grub on SuSE systems: lba and boot information

This patch adds code that gets lba and boot device information on
SuSE systems, which is done by looking at the commands that were
used to install grub on that system, and match information with
grub's device.map file.

Changes from v1:
 * Fixes for issues pointed by Peter Jones <pjones@redhat.com>
 * Add support for specifying paths for SuSE configuration files
   on environment variables, to make it possible to test this

Signed-off-by: Cleber Rosa <crosa@redhat.com>
Invert "isSuseSystem()" test so the suse code is nearer the test.
Fix grub detection on SuSE systems: config file order

SuSE sytems ship with a /etc/grub.conf that is not your regular grub
configuration file, but instead a sequence of grub commands. Example:

setup --stage2=/boot/grub/stage2 --force-lba (hd0,1) (hd0,1)
quit

Because of that, the parsing of the config fails. So, try to first
use the grub config file at /boot/grub/menu.lst.

Signed-off-by: Cleber Rosa <crosa@redhat.com>
ppc64/yaboot: add support for probing the currently installed bootloader

Changes from v1:
 * Settled on simplistic check for yaboot, but left comment on how to
   do an installation check.

Signed-off-by: Cleber Rosa <crosa@redhat.com>
ia64/elilo: add support for probing the currently installed bootloader

Signed-off-by: Cleber Rosa <crosa@redhat.com>
Fix minor style issue.
test.sh: revert bash 4 only syntax change

The "|&" syntax is bash version 4 specific, and thus fails on
systems running older versions. This change was introduced by
commit af5a11b0051e53a33e20ecac0b8d73da8d33348c.

Tested on RHEL 5 system with bash-3.2-32.el5.

Signed-off-by: Cleber Rosa <crosa@redhat.com>
test.sh: enable the use of MALLOC_PERTURB_

MALLOC_CHECK_ is already set, so MALLOC_PERTURB_ makes a nice complement
to it.

For more info on MALLOC_PERTURB_: http://udrepper.livejournal.com/11429.html

Signed-off-by: Cleber Rosa <crosa@redhat.com>
1 isn't a great value for MALLOC_PERTURB_ - use $RANDOM.
Add --set-default-index feature

This pairs with --default-index, allowing the user to specify the
entry to make the default using and index rather than a kernel.

Signed-off-by: Cleber Rosa <crosa@redhat.com>
Add tests for --set-default-index feature

Signed-off-by: Cleber Rosa <crosa@redhat.com>
Fix for grub on SuSE systems: test lba and boot info

This adds a test for the code that fetches the lba and boot info
on SuSE systems. To properly test it, it's necessary to ship more
files than other existing tests.

Changes from v1:
 * Skip directories while running "parse/write comparison" tests
   so that it's not attempted on grub.12-support-files.

Signed-off-by: Cleber Rosa <crosa@redhat.com>
grubby.8: fixes for the grubby man page

Signed-off-by: Cleber Rosa <crosa@redhat.com>