/* grub-check-version.c - compare grub versioning information. */
/*
* GRUB -- GRand Unified Bootloader
*
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* GRUB is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with GRUB. If not, see <http://www.gnu.org/licenses/>.
*/
#include <config.h>
#include <ctype.h>
#include <errno.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <getopt.h>
#include "progname.h"
{
{0, 0, 0, 0}
};
{
};
static void
{
if (status)
"Try ``%s --help'' for more information.\n", program_name);
else
printf ("\
Usage: %s [PATH]\n\
\n\
Compares grub versioning information..\n\
\n\
-s, --source=FILE read version.lst from FILE.\n\
-d, --dest=FILE read version.lst to compare to from FILE.\n\
-t, --type=(solaris_grub_version, module_interface_version)\n\
versioning scheme to check.\n\
-h, --help display this message and exit\n\
-p, --print print the version obtained from source file (give with -s)\n\
-V, --version print version information and exit\n\
-v, --verbose print the script as it is being processed\n\
\n\
Report bugs to <%s>.\n\
", program_name,
}
static char *
{
return NULL;
if (version_type == NULL)
return NULL;
/*
* Loop through the various version entries looking for the requested one.
* Keep looping after finding the first occurrence because the last present
* entry overrides the previous ones.
*/
{
char *p;
if (!p)
continue;
*p++ = '\0';
/* Is this the version we want? */
continue;
while (*p && isspace (*p))
p++;
if (! *p)
continue;
}
return version;
}
int
{
char *argument;
int i = 0;
int verbose = 0;
int found_input = 0;
int do_print_only = 0;
char *source_version;
char *dest_version;
set_program_name (argv[0]);
/* Check for options. */
while (1)
{
if (c == -1)
break;
else
switch (c)
{
case 's':
break;
case 'd':
break;
case 't':
break;
case 'h':
usage (0);
break;
case 'p':
do_print_only = 1;
break;
case 'V':
return 0;
case 'v':
verbosity++;
break;
default:
usage (1);
break;
}
}
if (versioning_type == NULL)
grub_util_error (_("no versioning scheme specified"));
break;
grub_util_error (_("unsupported versioning scheme specified"));
else
if (do_print_only)
{
if (source_version == NULL)
{
grub_util_info ("could not find source matching type");
exit(1);
}
exit (0);
}
{
if (verp->compulsory)
{
printf("no\n");
return 0;
}
if (source_version == NULL)
grub_util_info("source was NULL");
if (dest_version == NULL)
grub_util_info("dest was NULL");
printf("no\n");
printf("yes\n");
else /* both are NULL */
printf("no\n");
}
else
{
printf("yes\n");
else
printf("no\n");
}
return 0;
}
static int
compare_modintf_version (const char *a, const char *b)
{
errno = 0;
if (errno != 0)
return -1;
return -1;
return 0;
}
/* 2 levels of macros are needed to stringify the numeric constant in
GRUB_MODULE_INTERFACE_VERSION */
#define STRINGIFY2(x) #x
{
"module_interface_version",
1
};