Skip to content

Commit

Permalink
Rename unified file to platform kernel prefix
Browse files Browse the repository at this point in the history
  • Loading branch information
zdykstra committed Dec 20, 2019
1 parent 8707518 commit 946ba75
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 18 deletions.
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0.7.3
0.7.4
34 changes: 17 additions & 17 deletions bin/generate-zbm
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@
use strict;
use warnings;

our $VERSION = '0.7.3';

use Getopt::Long qw(:config no_ignore_case auto_version);
use Pod::Usage qw(pod2usage);
use File::Basename;
Expand All @@ -30,7 +28,7 @@ my $configfile = "/etc/zfsbootmenu/config.ini";
my $version_file = "/usr/share/zfsbootmenu/VERSION";

$runConf{bootdir} = "/boot";
$runConf{confd} = "/usr/share/zfsbootmenu/dracut.conf.d";
$runConf{confd} = "/usr/share/zfsbootmenu/dracut.conf.d";

GetOptions(
"version|v=s" => \$runConf{version},
Expand Down Expand Up @@ -65,11 +63,10 @@ if ( defined $config{Global}{DracutConfDir} ) {
# Sanity check that we can determine the version of zfsbootmenu
unless ( defined $runConf{version} ) {
if ( -f $version_file ) {
print "Found $version_file\n";
open(my $fh, '<', $version_file);
open( my $fh, '<', $version_file );
read $fh, $runConf{version}, -s $fh;
close($fh);
chomp($runConf{version});
chomp( $runConf{version} );
} else {
print "Unable to determine version\n";
exit;
Expand Down Expand Up @@ -103,12 +100,13 @@ if ( defined( $config{EFI}{Copies} ) and ( $config{EFI}{Copies} gt 0 ) ) {
$runConf{unified_efi} = unifiedEFI( $tempdir, $runConf{kernel}, $runConf{initramfs} );

if ( defined( $config{EFI}{Versioned} ) and ( $config{EFI}{Versioned} ) ) {
$runConf{efi_target} = sprintf( "%s/ZFSBootMenu-%s.EFI", $config{EFI}{ImageDir}, $runConf{version} );
$runConf{efi_target} =
sprintf( "%s/%s-%s.EFI", $config{EFI}{ImageDir}, $runConf{kernel_prefix}, $runConf{version} );
} else {
$runConf{efi_target} = sprintf( "%s/ZFSBootMenu.EFI", $config{EFI}{ImageDir} );
$runConf{efi_target} = sprintf( "%s/%s.EFI", $config{EFI}{ImageDir}, $runConf{kernel_prefix} );
}

my $glob = join( '/', ( $config{EFI}{ImageDir}, "ZFSBootMenu*.EFI" ) );
my $glob = sprintf( "%s/%s-*.EFI", $config{Components}{ImageDir}, $runConf{kernel_prefix} );
my @efi = sort glob($glob);

my $index = 0;
Expand All @@ -119,7 +117,7 @@ if ( defined( $config{EFI}{Copies} ) and ( $config{EFI}{Copies} gt 0 ) ) {
$index++;
}

printf "Found %s existing images, allowed to have a total of %s\n", scalar @efi, $config{EFI}{Copies};
printf "Found %s existing EFI images, allowed to have a total of %s\n", scalar @efi, $config{EFI}{Copies};
while ( scalar @efi > $config{EFI}{Copies} ) {
my $image = shift(@efi);
printf "Removing %s\n", $image;
Expand All @@ -136,16 +134,18 @@ if ( defined( $config{Components}{Copies} ) and ( $config{Components}{Copies} gt
sprintf( "%s/%s-%s", $config{Components}{ImageDir}, $runConf{kernel_prefix}, $runConf{version} );
$runConf{initramfs_target} = sprintf( "%s/initramfs-%s.img", $config{Components}{ImageDir}, $runConf{version} );

my $glob = sprintf( "%s/%s-*", $config{Components}{ImageDir}, $runConf{kernel_prefix} );
my @components = sort glob($glob);
my $glob = sprintf( "%s/%s-*", $config{Components}{ImageDir}, $runConf{kernel_prefix} );
my @listing = sort glob($glob);

# Drop the component count if the entry we're making already exists
my $index = 0;
foreach my $entry (@components) {
# Filter EFI files and our target image
my @components;
foreach my $entry (@listing) {
if ( $entry eq $runConf{kernel_target} ) {
splice @components, $index, 1;
next;
} elsif ( $entry =~ /EFI$/i ) {
next;
}
$index++;
push( @components, $entry );
}

printf "Found %s existing images, allowed to have a total of %s\n", scalar @components, $config{Components}{Copies};
Expand Down

0 comments on commit 946ba75

Please sign in to comment.