Commit 75d38aca authored by matt's avatar matt
Browse files

Use filename like megagrrl_<hwver>_<type>_<version>.mgu if --outfile is unset

Example filenames:
- megagrrl_d_app_v0.98dev-test.mgu
- megagrrl_d_app+updater_v0.98dev-test.mgu
- megagrrl_d_updater_v0.97dev-103-gbbbc2ddf-dirty.mgu
parent 2e5d4f4f
......@@ -33,8 +33,8 @@ GetOptions(
(!(defined($app) && defined($updater) && $app eq $updater))
or help('--app and --updater must be different files');
(defined($outfile) && ($outfile =~ /.+\.mgu$/) && !(-e $outfile))
or help('--outfile must be set, end in .mgu, and not exist');
(!defined($outfile) || (($outfile =~ /.+\.mgu$/) && !(-e $outfile)))
or help('--outfile, if set, must end in .mgu and not exist');
if (defined($hw)) {
($hw =~ /^[a-z0-9]{1}$/i)
......@@ -71,9 +71,22 @@ else {
die('unable to extract version from firmware(s) and --version is not set');
# use the hw type, firmware type(s), and version as the basis for an output filename if one hasn't been explicitly specified
if (!defined($outfile)) {
my @type;
and push(@type, 'app');
and push(@type, 'updater');
$outfile = sprintf('megagrrl_%s_%s_%s.mgu', $hw, join('+', @type), $mgu_version);
(-e $outfile)
and die('automatically generated output filename ' . $outfile . ' already exists, not overwriting')
print("writing packed firmware to $outfile...\n\n");
my $outfh = FileHandle->new($outfile, 'w')
my $outfh = FileHandle->new($outfile, O_WRONLY|O_CREAT|O_EXCL)
or die("failed to open $outfile: $!");
$outfh->binmode(); # if we're on windows for some reason
......@@ -240,7 +253,7 @@ sub help {
print STDERR ("--updater=<updater_file.bin> - (optional) the updater portion of the firmware (built with #define FWUPDATE)\n");
print STDERR ("--version=some-firmware-version - (optional) the firmware version. if not specified, it will be preferentially extracted from app_file.bin, or updater_file.bin\n");
print STDERR ("--hw=<d|p> - (optional) the hardware version, typically one of 'd' for desktop or 'p' for portable. defaults to desktop\n");
print STDERR ("--outfile=<output_file.mgu> (required) filename to write the packed (.mgu) firmware to\n");
print STDERR ("--outfile=<output_file.mgu> (optional) filename to write the packed (.mgu) firmware to. autogenerated if unset\n");
print STDERR ("--help - this message\n");
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment