Add check kernel config for initrd optimization IssueID #120

master
Mike Hiretsky 14 years ago
parent b872eb8173
commit 8c4f51ec0a

@ -3,6 +3,7 @@ CHANGE LOG
1.3.7
* Remove delay on unmerge performing.
* Fix assemble of system.
* Fix initrd optimization.
1.3.6
* Fix bashrc for work with /var/lib/layman.

@ -3430,13 +3430,7 @@ sub setup{
}
#Создадим initrd-файл
if(`mount | grep -c "on /proc type proc"` <= 1) {
printmes(" ".gettext('Create new initrd file')); printmes("...");
if(!initrd_clean($data{chroot})){
beep();
printmes(" ".gettext('error')."!\n");
}
}
initrd($data{chroot});
#----------------------------------------------------------------------
# Запросим пароль root-а
@ -6397,20 +6391,62 @@ sub check_digests{
# Создадим новый initrd файл
#------------------------------------------------------------------------------
sub initrd{
return if(`mount | grep -c "on /proc type proc"` > 1);
my $chroot = $_[0];
printmes(gettext('Create new initrd file')); printmes("...");
if(!initrd_clean()){
if(`mount | grep -c "on /proc type proc"` > 1) {
printmes(" ".gettext('skip')."!\n");
return;
}
if(!initrd_clean($chroot)){
beep();
printmes(" ".gettext('error')."!\n");
}
}
#------------------------------------------------------------------------------
# Получить из конфигурации ядра список встроенных или внешних модулей
#------------------------------------------------------------------------------
sub get_kernel_config{
# первый параметр текст конфигурации ядра
# второй y или m (встроенный или внешний)
my ($kconfig,$value) = @_;
my @list=();
# получаем список опций из областей SCSI Transport,
# File systems,Pseudo filesystems,
# CDROM/DVD Filesystems, DOS/FAT/NT Filesystems
foreach($kconfig =~ m/((?:[Ff]ile[s ][sy]|SCSI Transports).*?\n\n#)/sg) {
# получаем список модулей
foreach(m/^(.*)=${value}$/gm) {
push(@list,$_."\n");
}
}
return @list;
}
#------------------------------------------------------------------------------
# Создадим урезанный по железу initrd файл
#------------------------------------------------------------------------------
sub initrd_clean{
my $chroot = $_[0];
# получим список встроенных модулей в текущем ядре
my @list_current_y=get_kernel_config(scalar `gzip -dc /proc/config.gz`,"y");
# получим имя файла конфигурации текущего ядра
my $config=`file -L $chroot$data{scratch_ws}/boot/vmlinuz`;
$config =~ s/^.*version ([^ ]+) .*$/$chroot$data{scratch_ws}\/boot\/config-\1/;
# получим список внешних модулей в ядре в chroot
my @list_chroot_m=get_kernel_config(scalar `cat $config`,"m");
# попытаемся найти одноименные модули
@hash{@list_chroot_m}=();
@filtred=grep { exists $hash{$_} } @list_current_y;
# если есть одноименные модули не делаем оптимизацию initrd
if(@filtred) {
printmes(" ".gettext('skip')); printmes(".\n");
return 1;
}
#найдем среди запущенных модулей не задействованные, которые можно удалить
my %mod_dep; #хэш зависимостей, ключ - модуль, значение - модули его использующие
my %mod_run; #хэш работающих модулей

@ -8,7 +8,7 @@ msgid ""
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: support.ru\n"
"POT-Creation-Date: 2010-02-04 15:50+0300\n"
"POT-Creation-Date: 2010-02-05 16:42+0300\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n"
@ -1049,6 +1049,9 @@ msgstr "показать список пакетов входящих в доп
msgid "show the package list incoming in the distributive file"
msgstr "показать список пакетов входящих дистрибутив"
msgid "skip"
msgstr "пропуск"
msgid "to cancel"
msgstr "для отмены"

Loading…
Cancel
Save