diff options
author | Niklas Hambüchen <mail@nh2.me> | 2020-04-23 22:42:11 +0200 |
---|---|---|
committer | Niklas Hambüchen <mail@nh2.me> | 2020-07-06 22:07:46 +0200 |
commit | 0dcad215fea89fb3af6c713e7a88ec87c4edb8b4 (patch) | |
tree | 7c00a853326f919b751cb5adb0f669da0d3746b9 /nixos | |
parent | d4d9d9c552a769fc538ed35dfe9674932b705af1 (diff) | |
download | nixpkgs-0dcad215fea89fb3af6c713e7a88ec87c4edb8b4.tar nixpkgs-0dcad215fea89fb3af6c713e7a88ec87c4edb8b4.tar.gz nixpkgs-0dcad215fea89fb3af6c713e7a88ec87c4edb8b4.tar.bz2 nixpkgs-0dcad215fea89fb3af6c713e7a88ec87c4edb8b4.tar.lz nixpkgs-0dcad215fea89fb3af6c713e7a88ec87c4edb8b4.tar.xz nixpkgs-0dcad215fea89fb3af6c713e7a88ec87c4edb8b4.tar.zst nixpkgs-0dcad215fea89fb3af6c713e7a88ec87c4edb8b4.zip |
install-grub.pl: Refactor: Extract `getList()`
Diffstat (limited to 'nixos')
-rw-r--r-- | nixos/modules/system/boot/loader/grub/install-grub.pl | 20 |
1 files changed, 11 insertions, 9 deletions
diff --git a/nixos/modules/system/boot/loader/grub/install-grub.pl b/nixos/modules/system/boot/loader/grub/install-grub.pl index 918a66866e9..ceda809a147 100644 --- a/nixos/modules/system/boot/loader/grub/install-grub.pl +++ b/nixos/modules/system/boot/loader/grub/install-grub.pl @@ -20,6 +20,16 @@ my $dom = XML::LibXML->load_xml(location => $ARGV[0]); sub get { my ($name) = @_; return $dom->findvalue("/expr/attrs/attr[\@name = '$name']/*/\@value"); } +sub getList { + my ($name) = @_; + my @list = (); + foreach my $entry ($dom->findnodes("/expr/attrs/attr[\@name = '$name']/list/string/\@value")) { + $entry = $entry->findvalue(".") or die; + push(@list, $entry); + } + return @list; +} + sub readFile { my ($fn) = @_; local $/ = undef; open FILE, "<$fn" or return undef; my $s = <FILE>; close FILE; @@ -616,15 +626,7 @@ sub readGrubState { return $grubState } -sub getDeviceTargets { - my @devices = (); - foreach my $dev ($dom->findnodes('/expr/attrs/attr[@name = "devices"]/list/string/@value')) { - $dev = $dev->findvalue(".") or die; - push(@devices, $dev); - } - return @devices; -} -my @deviceTargets = getDeviceTargets(); +my @deviceTargets = getList('devices'); my $prevGrubState = readGrubState(); my @prevDeviceTargets = split/,/, $prevGrubState->devices; |