mkrescue: Check xorriso presence before doing anything else.

mkrescue can't do anything useful without xorriso, so abort early if it's
not available.
This commit is contained in:
Vladimir Serbinenko 2017-08-07 18:05:17 +02:00
parent 435fa75e01
commit 9e962fd3c4

View file

@ -323,6 +323,7 @@ check_xorriso (const char *val)
char *buf = NULL; char *buf = NULL;
size_t len = 0; size_t len = 0;
int ret = 0; int ret = 0;
int wstatus = 0;
argv[0] = xorriso; argv[0] = xorriso;
argv[1] = "-as"; argv[1] = "-as";
@ -347,8 +348,10 @@ check_xorriso (const char *val)
} }
close (fd); close (fd);
waitpid (pid, NULL, 0); waitpid (pid, &wstatus, 0);
free (buf); free (buf);
if (!WIFEXITED (wstatus) || WEXITSTATUS(wstatus) != 0)
return 0;
return ret; return ret;
} }
@ -478,6 +481,10 @@ main (int argc, char *argv[])
if (!output_image) if (!output_image)
grub_util_error ("%s", _("output file must be specified")); grub_util_error ("%s", _("output file must be specified"));
if (!check_xorriso ("graft-points")) {
grub_util_error ("%s", _("xorriso not found"));
}
grub_init_all (); grub_init_all ();
grub_hostfs_init (); grub_hostfs_init ();
grub_host_init (); grub_host_init ();