blob: 9da113a29c9a2a3bf7ae14391269575e6dfc42da (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
|
#!/usr/bin/perl
use Getopt::Long;
my $gfxmenu = '/boot/gfxmenu';
my %options = (
"lang=s" => \ (my $lang),
"update-theme" => \ (my $update_theme),
"update-gfxmenu" => \ (my $update_gfxmenu),
"quiet" => \ (my $quiet),
);
GetOptions(%options) && @ARGV == 0 && ($lang || $update_theme || $update_gfxmenu) or usage();
if ($update_gfxmenu) {
$update_theme = 1;
$lang ||= eval { get_lang() };
sys('cp', '/usr/share/gfxboot/themes/Mandriva/boot/message', $gfxmenu);
}
if (!-e $gfxmenu) {
warn "$gfxmenu doesn't exist\n" if !$quiet;
exit;
}
if ($lang) {
set_lang($lang);
}
if ($update_theme) {
set_theme();
}
sub usage {
die "grub-gfxmenu [--quiet] [--lang <lang>] [--update-theme] [--update-gfxmenu]\n";
}
sub set_theme() {
my $background_dir = '/usr/share/gfxboot/themes/current';
#checking
-f "$background_dir/back.jpg" or return;
remove_file('back.jpg');
sys("echo back.jpg | (cd $background_dir ; cpio -o --quiet -O $gfxmenu --append)");
}
sub remove_file {
my ($file) = @_;
sys("cpio-filter --in-place --exclude $file $gfxmenu");
}
sub get_lang() {
require Archive::Cpio;
my $cpio = Archive::Cpio->new;
$cpio->read($gfxmenu);
my $e = $cpio->get_file('lang') or return;
my $lang = $e->{data};
chomp $lang;
$lang;
}
sub set_lang {
my ($lang) = @_;
require Archive::Cpio;
my $cpio = Archive::Cpio->new;
$cpio->read($gfxmenu);
if (my $e = $cpio->get_file('lang')) {
$e->{data} = "$lang\n";
} else {
$cpio->add_data('lang', "$lang\n");
}
$cpio->write($gfxmenu);
}
sub system_verbose { print join(' ', @_), "\n"; system(@_) }
sub sys { system(@_); $? and die }
|