diff options
-rwxr-xr-x | draklive | 38 | ||||
-rwxr-xr-x | lib/MGA/DrakISO/BuildBoot.pm | 86 | ||||
-rwxr-xr-x | lib/MGA/DrakISO/BuildISO.pm | 42 | ||||
-rwxr-xr-x | lib/MGA/DrakISO/BuildLoop.pm | 46 | ||||
-rwxr-xr-x | lib/MGA/DrakISO/BuildRoot.pm | 166 | ||||
-rw-r--r-- | lib/MGA/DrakISO/Config.pm | 42 | ||||
-rw-r--r-- | lib/MGA/DrakISO/ISOBuild.pm | 18 | ||||
-rw-r--r-- | lib/MGA/DrakISO/LiveBuild.pm | 28 | ||||
-rw-r--r-- | lib/MGA/DrakISO/Loopback.pm | 22 | ||||
-rw-r--r-- | lib/MGA/DrakISO/Utils.pm | 12 |
10 files changed, 250 insertions, 250 deletions
@@ -43,22 +43,22 @@ use MGA::DrakISO::BuildISO; ############################################################################### sub clean { - my ($live) = @_; + my ($build) = @_; # make sure no external filesystems are mounted before cleaning - umount_external_fs($live); - rm_rf($_) foreach grep { -e $_ } $live->get_builddir, $live->get_system_root; + umount_external_fs($build); + rm_rf($_) foreach grep { -e $_ } $build->get_builddir, $build->get_system_root; } sub prepare_root { - my ($live) = @_; - MGA::DrakISO::BuildRoot::install_live_system($live); - MGA::DrakISO::BuildRoot::customise_live_system($live); + my ($build) = @_; + MGA::DrakISO::BuildRoot::install_live_system($build); + MGA::DrakISO::BuildRoot::customise_live_system($build); } sub prepare_boot { - my ($live) = @_; - MGA::DrakISO::BuildBoot::prepare_live_system_boot($live); - MGA::DrakISO::BuildBoot::prepare_iso_bootloader($live); + my ($build) = @_; + MGA::DrakISO::BuildBoot::prepare_live_system_boot($build); + MGA::DrakISO::BuildBoot::prepare_iso_bootloader($build); } ############################################################################### @@ -81,7 +81,7 @@ my @all = qw(root boot loop master); die "you must be root to run this program\n" if $>; -my $live_object = 'MGA::DrakISO::LiveBuild'->new; +my $build_object = 'MGA::DrakISO::LiveBuild'->new; my $config_root = $MGA::DrakISO::Config::default_config_root; my $config_path = $MGA::DrakISO::Config::default_config_path; my $settings_path = $MGA::DrakISO::Config::default_settings_path; @@ -90,26 +90,26 @@ GetOptions( "help" => sub { Pod::Usage::pod2usage('-verbose' => 1) }, "all" => sub { $_->{to_run} = 1 foreach grep { member($_->{name}, @all) } @actions }, (map { $_->{name} => \$_->{to_run} } @actions), - "all-regions" => sub { $live_object->{all_regions} = 1 }, + "all-regions" => sub { $build_object->{all_regions} = 1 }, "config-root=s" => \$config_root, "config=s" => \$config_path, "settings=s" => \$settings_path, - "define=s" => \%{$live_object->{settings}}, + "define=s" => \%{$build_object->{settings}}, ) or Pod::Usage::pod2usage(); require standalone; every { !$_->{to_run} } @actions and Pod::Usage::pod2usage(); - MGA::DrakISO::Config::read_config($live_object, $config_root, $config_path, $settings_path); - MGA::DrakISO::Config::check_config($live_object); - MGA::DrakISO::Config::complete_config($live_object); + MGA::DrakISO::Config::read_config($build_object, $config_root, $config_path, $settings_path); + MGA::DrakISO::Config::check_config($build_object); + MGA::DrakISO::Config::complete_config($build_object); - foreach my $region ($live_object->{all_regions} ? sort(keys %{$live_object->{regions}}) : $live_object->{settings}{region}) { + foreach my $region ($build_object->{all_regions} ? sort(keys %{$build_object->{regions}}) : $build_object->{settings}{region}) { $region and print qq(=== proceeding with region "$region"\n); - $live_object->{settings}{region} = $region; + $build_object->{settings}{region} = $region; foreach (grep { $_->{to_run} } @actions) { print qq(* entering step "$_->{name}"\n); - $_->{do}->($live_object); + $_->{do}->($build_object); print qq(* step "$_->{name}" done\n); } } @@ -184,7 +184,7 @@ See the "drakiso-live" page on the Mageia Wiki for details. =item B<--settings> Makes draklive load the next argument as a file in key=value format into -the $live->{settings} hash ($live being the global live configuration hash). +the $build->{settings} hash ($build being the global configuration hash). Built-in keys: diff --git a/lib/MGA/DrakISO/BuildBoot.pm b/lib/MGA/DrakISO/BuildBoot.pm index 52fff4f..fc0f3fa 100755 --- a/lib/MGA/DrakISO/BuildBoot.pm +++ b/lib/MGA/DrakISO/BuildBoot.pm @@ -38,29 +38,29 @@ our @EXPORT = qw(prepare_live_system_boot prepare_iso_bootloader); ############################################################################### sub prepare_live_system_boot { - my ($live) = @_; + my ($build) = @_; # Create a build directory. This will contain all the files we need to # exist in /boot on the ISO. - my $boot_dir = $live->get_builddir('boot'); + my $boot_dir = $build->get_builddir('boot'); mkdir_p($boot_dir); # Locate the kernel we want to boot. - my $kernel = $live->find_kernel; + my $kernel = $build->find_kernel; print "Using kernel $kernel->{version}\n"; # Copy the kernel into the build directory. - my $vmlinuz = $live->get_system_root . '/boot/vmlinuz-' . $kernel->{version}; + my $vmlinuz = $build->get_system_root . '/boot/vmlinuz-' . $kernel->{version}; -e $vmlinuz or die "cannot find kernel $kernel->{version} in root system\n"; cp_f($vmlinuz, $boot_dir . '/vmlinuz'); # Build an initrd suitable for Live boot. - my $initrd = $live->get_system_root . '/boot/' . $live->get_initrd_name; + my $initrd = $build->get_system_root . '/boot/' . $build->get_initrd_name; unlink($initrd); { my $bootloader = {}; - local $::prefix = $live->get_system_root; - bootloader::add_kernel($bootloader, $kernel, { label => 'linux', vga => $live->{system}{vga_mode} }, '', $live->{system}{no_initrd}); + local $::prefix = $build->get_system_root; + bootloader::add_kernel($bootloader, $kernel, { label => 'linux', vga => $build->{system}{vga_mode} }, '', $build->{system}{no_initrd}); } # Move the initrd into the build directory. @@ -72,15 +72,15 @@ sub prepare_live_system_boot { ############################################################################### sub prepare_iso_bootloader { - my ($live) = @_; + my ($build) = @_; # Create a subdirectory to hold the grub2 bootloader. - my $grub2_dir = $live->get_builddir('boot') . '/grub2'; + my $grub2_dir = $build->get_builddir('boot') . '/grub2'; mkdir_p($grub2_dir); # Locate and copy the default font for the bootloader. If we can't find a # font, don't worry - the bootloader will fall back to text mode. - my $font = $live->get_absolute_path($live->{media}{bootloader_font}); + my $font = $build->get_absolute_path($build->{media}{bootloader_font}); if (defined $font) { -e $font or die "cannot find bootloader font file $font\n"; } else { @@ -95,7 +95,7 @@ sub prepare_iso_bootloader { # Locate and copy the bootloader theme. Default to the standard Mageia # theme if the user hasn't specified one. If that's not available either, # proceed without a theme. - my $theme = $live->get_absolute_path($live->{media}{bootloader_theme}); + my $theme = $build->get_absolute_path($build->{media}{bootloader_theme}); if (defined $theme) { -d $theme or die "cannot find bootloader theme directory $theme\n"; } else { @@ -113,10 +113,10 @@ sub prepare_iso_bootloader { # If the user has provided the necessary configuration data, construct # the bootloader language and keyboard selection submenus and copy the # grub2 keyboard layout files. - my $add_lang_menu = defined $live->{media}{bootloader_langs}; - my $add_kbd_menu = defined $live->{media}{bootloader_kbds}; + my $add_lang_menu = defined $build->{media}{bootloader_langs}; + my $add_kbd_menu = defined $build->{media}{bootloader_kbds}; if ($add_lang_menu) { - my $lang_names = $live->get_absolute_path($live->{media}{bootloader_langs}); + my $lang_names = $build->get_absolute_path($build->{media}{bootloader_langs}); -e $lang_names or die "cannot find bootloader language name file $lang_names\n"; my @langs = group_by2(eval(cat_($lang_names))) or die "error in language name file $lang_names\n"; @@ -129,7 +129,7 @@ sub prepare_iso_bootloader { MDK::Common::File::output_utf8($grub2_dir . '/lang-menu.cfg', build_lang_menu_cfg(\@langs, %$kbds)); } if ($add_kbd_menu) { - my $kbd_names = $live->get_absolute_path($live->{media}{bootloader_kbds}); + my $kbd_names = $build->get_absolute_path($build->{media}{bootloader_kbds}); -e $kbd_names or die "cannot find bootloader keyboard name file $kbd_names\n"; my @kbds = group_by2(eval(cat_($kbd_names))) or die "error in keyboard name file $kbd_names\n"; @@ -141,7 +141,7 @@ sub prepare_iso_bootloader { } # Copy any message translation files the user has provided. - my $messages = $live->get_absolute_path($live->{media}{bootloader_messages}); + my $messages = $build->get_absolute_path($build->{media}{bootloader_messages}); if (defined $messages) { -d $messages or die "cannot find bootloader messages directory $messages\n"; my $locale_dir = $grub2_dir . '/locale'; @@ -151,7 +151,7 @@ sub prepare_iso_bootloader { # If the user has supplied a grub2 image for non-UEFI boot, copy that, # otherwise build one. - my $eltorito_img = $live->get_absolute_path($live->{media}{eltorito_img}); + my $eltorito_img = $build->get_absolute_path($build->{media}{eltorito_img}); if (defined $eltorito_img) { -e $eltorito_img or die "cannot find El Torito boot image $eltorito_img\n"; cp_f($eltorito_img, $grub2_dir . '/eltorito.img'); @@ -159,19 +159,19 @@ sub prepare_iso_bootloader { build_grub2_eltorito_img($grub2_dir . '/eltorito.img'); } - my $label = $live->{media}->get_media_label; + my $label = $build->{media}->get_media_label; # If the user has supplied a top-level grub2 configuration file, copy that # (replacing the "VOLUME_LABEL" template with the actual label for the ISO # image), otherwise build one. my $grub2_cfg = $grub2_dir . '/grub.cfg'; - if (defined $live->{media}{grub2_cfg}) { - my $grub_cfg_template = $live->get_absolute_path($live->{media}{grub2_cfg}); + if (defined $build->{media}{grub2_cfg}) { + my $grub_cfg_template = $build->get_absolute_path($build->{media}{grub2_cfg}); -e $grub_cfg_template or die "cannot find grub2 config file $grub_cfg_template\n"; cp_f($grub_cfg_template, $grub2_cfg); run_("sed", "-i", "s/VOLUME_LABEL/$label/g", $grub2_cfg); } else { - output($grub2_cfg, build_grub2_cfg($live, $theme_name, \@theme_fonts, $add_lang_menu, $add_kbd_menu)); + output($grub2_cfg, build_grub2_cfg($build, $theme_name, \@theme_fonts, $add_lang_menu, $add_kbd_menu)); } my $title = $label =~ s/-/ /gr; @@ -185,17 +185,17 @@ sub prepare_iso_bootloader { # If we are building a 32-bit ISO, we are done, as we don't support # 32-bit UEFI boot. - return if $live->{settings}{arch} ne 'x86_64'; + return if $build->{settings}{arch} ne 'x86_64'; # Create another build directory. This will contain all the files we need # to exist in the /EFI directory on the ISO. - my $efi_root_dir = $live->get_builddir('EFI'); + my $efi_root_dir = $build->get_builddir('EFI'); my $efi_boot_dir = $efi_root_dir . '/BOOT'; mkdir_p($efi_boot_dir); # If the user has supplied a grub2 image for UEFI boot, copy that, # otherwise build one. - my $bootx64_efi = $live->get_absolute_path($live->{media}{bootx64_efi}); + my $bootx64_efi = $build->get_absolute_path($build->{media}{bootx64_efi}); if (defined $bootx64_efi) { -e $bootx64_efi or die "cannot find EFI boot image $bootx64_efi\n"; cp_f($bootx64_efi, $efi_boot_dir . '/bootx64.efi'); @@ -205,7 +205,7 @@ sub prepare_iso_bootloader { # Build a grub2 configuration file for UEFI boot. This just chains to the # main grub2 configuration file. - output($efi_boot_dir . '/grub.cfg', build_uefi_grub2_cfg($live)); + output($efi_boot_dir . '/grub.cfg', build_uefi_grub2_cfg($build)); # If we have a theme, duplicate the theme configuration file and modify the # title string to indicate we are doing a UEFI boot. This is useful when @@ -217,7 +217,7 @@ sub prepare_iso_bootloader { } # Create another build directory for temporarily storing the ESP image. - my $images_dir = $live->get_builddir('images'); + my $images_dir = $build->get_builddir('images'); mkdir_p($images_dir); # Construct an ESP image. This is needed for USB boot. @@ -256,7 +256,7 @@ sub build_grub2_bootx64_efi { } sub build_grub2_cfg { - my ($live, $theme_name, $theme_fonts, $add_lang_menu, $add_kbd_menu) = @_; + my ($build, $theme_name, $theme_fonts, $add_lang_menu, $add_kbd_menu) = @_; my @loadfonts; if (defined $theme_name) { @@ -267,7 +267,7 @@ sub build_grub2_cfg { join("\n", "if [ -z \$initialised ] ; then", - " search --no-floppy --set=root -l '" . $live->{media}->get_media_label . "'", + " search --no-floppy --set=root -l '" . $build->{media}->get_media_label . "'", " set prefix=(\$root)/boot/grub2", "", " if loadfont \$prefix/fonts/unicode.pf2 ; then", @@ -289,8 +289,8 @@ sub build_grub2_cfg { " export initialised", "fi", "", - "set default=" . get_bootloader_default($live), - "set timeout=" . get_bootloader_timeout($live), + "set default=" . get_bootloader_default($build), + "set timeout=" . get_bootloader_timeout($build), "", if_($add_lang_menu, "export lang", @@ -305,11 +305,11 @@ sub build_grub2_cfg { my ($name, $cmdline) = @$_; join("\n", "menuentry $gettext\"$name\" {", - " linux /boot/vmlinuz " . get_default_append($live) . if_($cmdline, " $cmdline"), + " linux /boot/vmlinuz " . get_default_append($build) . if_($cmdline, " $cmdline"), " initrd /boot/initrd.gz", "}" ); - } group_by2(@{$live->{media}{bootloader_entries}})), + } group_by2(@{$build->{media}{bootloader_entries}})), if_($add_lang_menu || $add_kbd_menu, # this acts as a spacer "menuentry '________________________' {", @@ -331,24 +331,24 @@ sub build_grub2_cfg { } sub get_bootloader_default { - my ($live) = @_; - defined $live->{media}{bootloader_default} ? $live->{media}{bootloader_default} : 0; + my ($build) = @_; + defined $build->{media}{bootloader_default} ? $build->{media}{bootloader_default} : 0; } sub get_bootloader_timeout { - my ($live) = @_; - defined $live->{media}{bootloader_timeout} ? $live->{media}{bootloader_timeout} : 4; + my ($build) = @_; + defined $build->{media}{bootloader_timeout} ? $build->{media}{bootloader_timeout} : 4; } sub get_default_append { - my ($live) = @_; - my $append = $live->{system}{append}; + my ($build) = @_; + my $append = $build->{system}{append}; join(" ", - "root=mgalive:LABEL=" . $live->{media}->get_media_label, + "root=mgalive:LABEL=" . $build->{media}->get_media_label, "lang=\$lang kbd=\$kbd", if_($append, $append), - if_($live->{system}{vga_mode} && $append !~ /\bvga=\b/, - "vga=" . $live->{system}{vga_mode}), + if_($build->{system}{vga_mode} && $append !~ /\bvga=\b/, + "vga=" . $build->{system}{vga_mode}), ); } @@ -405,9 +405,9 @@ sub build_kbd_menu_cfg { } sub build_uefi_grub2_cfg { - my ($live) = @_; + my ($build) = @_; join("\n", - "search --no-floppy --set=root -l '" . $live->{media}->get_media_label . "'", + "search --no-floppy --set=root -l '" . $build->{media}->get_media_label . "'", "set prefix=(\$root)/boot/grub2", "", "set uefi=true", diff --git a/lib/MGA/DrakISO/BuildISO.pm b/lib/MGA/DrakISO/BuildISO.pm index 4198a10..eb28c6c 100755 --- a/lib/MGA/DrakISO/BuildISO.pm +++ b/lib/MGA/DrakISO/BuildISO.pm @@ -39,47 +39,47 @@ our @EXPORT = qw(build_live_iso); ############################################################################### sub build_live_iso { - my ($live) = @_; + my ($build) = @_; - my $label = $live->{media}->get_media_label or die "the source device must be described by a label\n"; + my $label = $build->{media}->get_media_label or die "the source device must be described by a label\n"; - my $mbr_image = $live->get_absolute_path($live->{media}{mbr_boot_img}) // '/usr/lib/grub/i386-pc/boot_hybrid.img'; + my $mbr_image = $build->get_absolute_path($build->{media}{mbr_boot_img}) // '/usr/lib/grub/i386-pc/boot_hybrid.img'; -e $mbr_image or die "cannot find MBR boot image $mbr_image\n"; - my $esp_image = $live->get_builddir('images') . '/esp.img'; + my $esp_image = $build->get_builddir('images') . '/esp.img'; -e $esp_image or die "cannot find ESP image $esp_image\n"; - my $dest = $live->get_builddir('dist') . '/' . $live->get_name . '.iso'; + my $dest = $build->get_builddir('dist') . '/' . $build->get_name . '.iso'; mkdir_p(dirname($dest)); build_iso_image( - $live, + $build, $dest, $label, $mbr_image, $esp_image, - '/boot=' . $live->get_builddir('boot'), - if_($live->{settings}{arch} eq 'x86_64', - '/EFI=' . $live->get_builddir('EFI'), + '/boot=' . $build->get_builddir('boot'), + if_($build->{settings}{arch} eq 'x86_64', + '/EFI=' . $build->get_builddir('EFI'), ), ( map { - '/loopbacks' . $_ . '=' . $live->get_builddir('loopbacks') . $_; - } list_selected_loopbacks($live) + '/loopbacks' . $_ . '=' . $build->get_builddir('loopbacks') . $_; + } list_selected_loopbacks($build) ), - if_($live->{media}{files}, + if_($build->{media}{files}, map { - $_ . '=' . $live->get_builddir('files') . '/' . $_; - } all($live->get_builddir('files')) + $_ . '=' . $build->get_builddir('files') . '/' . $_; + } all($build->get_builddir('files')) ), ); } sub list_selected_loopbacks { - my ($live) = @_; - my @pack = $live->{settings}{pack} ? @{$live->{packs}{$live->{settings}{pack}} || []} : (); - my @pack_modules = grep { member($_->{name}, @pack) } list_loopback_modules($live); - (map { $loop_types{$_->{type}}{is_loopback} && $_->{path} ? $_->{path} . $loop_types{$_->{type}}{extension} : () } @{$live->{mount}{dirs} || []}), + my ($build) = @_; + my @pack = $build->{settings}{pack} ? @{$build->{packs}{$build->{settings}{pack}} || []} : (); + my @pack_modules = grep { member($_->{name}, @pack) } list_loopback_modules($build); + (map { $loop_types{$_->{type}}{is_loopback} && $_->{path} ? $_->{path} . $loop_types{$_->{type}}{extension} : () } @{$build->{mount}{dirs} || []}), (map { '/modules/' . $_->{name} . $loop_types{$_->{type}}{extension} } @pack_modules); } @@ -107,7 +107,7 @@ sub list_selected_loopbacks { # initial grub2 configuration file will be located accordingly. # sub build_iso_image { - my ($live, $dest, $label, $mbr_image, $esp_image, @opts) = @_; + my ($build, $dest, $label, $mbr_image, $esp_image, @opts) = @_; run_('xorrisofs', '-pad', '-l', '-R', '-J', @@ -123,7 +123,7 @@ sub build_iso_image { '-boot-load-size', 4, '-boot-info-table', '--grub2-boot-info', - if_($live->{settings}{arch} eq 'x86_64', + if_($build->{settings}{arch} eq 'x86_64', # for DVD UEFI boot '-eltorito-alt-boot', '-e', '/EFI/BOOT/bootx64.efi', @@ -145,7 +145,7 @@ sub build_iso_image { run_({ chdir => $dir }, 'sha1sum', '>', $dest . '.sha1', $filename); run_({ chdir => $dir }, 'sha512sum', '>', $dest . '.sha512', $filename); run_({ chdir => $dir }, 'date', '>', $dir . '/DATE.txt'); - if (my $suffix = $live->get_set_suffix) { + if (my $suffix = $build->get_set_suffix) { if (my ($prefix, $ext) = $dest =~ /(.*)(\.[^.]+)$/) { my $link = $prefix . $suffix . $ext; linkf($dest, $link); diff --git a/lib/MGA/DrakISO/BuildLoop.pm b/lib/MGA/DrakISO/BuildLoop.pm index c8f3b06..9e98bd1 100755 --- a/lib/MGA/DrakISO/BuildLoop.pm +++ b/lib/MGA/DrakISO/BuildLoop.pm @@ -35,54 +35,54 @@ our @ISA = qw(Exporter); our @EXPORT = qw(build_live_loopback_files list_loopback_modules); sub build_live_loopback_files { - my ($live) = @_; + my ($build) = @_; # make sure no external filesystems are mounted before creating the loopback - umount_external_fs($live); + umount_external_fs($build); - my @excluded_files = expand_file_list($live, @{$live->{loopbacks}{exclude}{files} || []}); - my @modules_files = expand_file_list($live, @{$live->{loopbacks}{modules} || []}); + my @excluded_files = expand_file_list($build, @{$build->{loopbacks}{exclude}{files} || []}); + my @modules_files = expand_file_list($build, @{$build->{loopbacks}{modules} || []}); - foreach (grep { exists $loop_types{$_->{type}}{build} } @{$live->{mount}{dirs} || []}) { + foreach (grep { exists $loop_types{$_->{type}}{build} } @{$build->{mount}{dirs} || []}) { local $_->{exclude} = [ @excluded_files, @modules_files ]; - $loop_types{$_->{type}}{build}->($live, $_); + $loop_types{$_->{type}}{build}->($build, $_); } - foreach my $module (list_loopback_modules($live)) { - my $copy_tree = $live->get_system_root . "/tmp/draklive/loop/$module->{name}"; + foreach my $module (list_loopback_modules($build)) { + my $copy_tree = $build->get_system_root . "/tmp/draklive/loop/$module->{name}"; eval { rm_rf($copy_tree) }; - hardlink_filtered($live->get_system_root, $copy_tree, $module->{files}); + hardlink_filtered($build->get_system_root, $copy_tree, $module->{files}); my $loop = $loop_types{$module->{type}}; - $loop->{build}->($live, { path => "/modules/$module->{name}", root => $copy_tree, exclude => \@excluded_files }); + $loop->{build}->($build, { path => "/modules/$module->{name}", root => $copy_tree, exclude => \@excluded_files }); eval { rm_rf($copy_tree) }; } if (@excluded_files) { - my $excluded_tree = $live->get_system_root . "/tmp/draklive/excluded/all"; + my $excluded_tree = $build->get_system_root . "/tmp/draklive/excluded/all"; eval { rm_rf($excluded_tree) }; - hardlink_filtered($live->get_system_root, $excluded_tree, \@excluded_files); + hardlink_filtered($build->get_system_root, $excluded_tree, \@excluded_files); - foreach my $module (list_loopback_modules($live)) { - my $copy_tree = $live->get_system_root . "/tmp/draklive/excluded/$module->{name}"; + foreach my $module (list_loopback_modules($build)) { + my $copy_tree = $build->get_system_root . "/tmp/draklive/excluded/$module->{name}"; eval { rm_rf($copy_tree) }; hardlink_filtered($excluded_tree, $copy_tree, $module->{files}); my $loop = $loop_types{$module->{type}}; - $loop->{build}->($live, { path => "/modules/excluded-$module->{name}", root => $copy_tree }); + $loop->{build}->($build, { path => "/modules/excluded-$module->{name}", root => $copy_tree }); eval { rm_rf($copy_tree) }; } - my $loop = $loop_types{$live->{loopbacks}{exclude}{type}}; - $loop->{build}->($live, { path => "/excluded", root => $excluded_tree, exclude => \@modules_files }); + my $loop = $loop_types{$build->{loopbacks}{exclude}{type}}; + $loop->{build}->($build, { path => "/excluded", root => $excluded_tree, exclude => \@modules_files }); eval { rm_rf($excluded_tree) }; } } sub expand_file_list { - my ($live, @files) = @_; + my ($build, @files) = @_; map { $_->{path} ? $_->{path} : - chomp_(cat_(glob(($_->{rooted} && $live->get_system_root) . $_->{source}))); + chomp_(cat_(glob(($_->{rooted} && $build->get_system_root) . $_->{source}))); } @files; } @@ -101,16 +101,16 @@ sub hardlink_filtered { } sub list_loopback_modules { - my ($live) = @_; + my ($build) = @_; map { my $l = $_; map { my $list = $_; my $name = basename($list); $name =~ s/\.[^.]+$//; - { type => $l->{type}, name => $name, files => [ expand_file_list($live, { source => $list }) ] }; - } glob(($_->{rooted} && $live->get_system_root) . $_->{source}); - } @{$live->{loopbacks}{modules}}; + { type => $l->{type}, name => $name, files => [ expand_file_list($build, { source => $list }) ] }; + } glob(($_->{rooted} && $build->get_system_root) . $_->{source}); + } @{$build->{loopbacks}{modules}}; } 1; diff --git a/lib/MGA/DrakISO/BuildRoot.pm b/lib/MGA/DrakISO/BuildRoot.pm index a81bf0d..1924fa8 100755 --- a/lib/MGA/DrakISO/BuildRoot.pm +++ b/lib/MGA/DrakISO/BuildRoot.pm @@ -33,14 +33,14 @@ our @ISA = qw(Exporter); our @EXPORT = qw(install_live_system customise_live_system); sub install_live_system { - my ($live) = @_; + my ($build) = @_; - my $repository = $live->{settings}{repository} . '/' . $live->{settings}{arch}; + my $repository = $build->{settings}{repository} . '/' . $build->{settings}{arch}; my $drakx_in_chroot = $repository . '/misc/drakx-in-chroot'; my $remote_repository = $repository =~ m!^(ftp|http)://! && $1; if ($remote_repository) { - my $local_drakx_in_chroot = $live->get_builddir('scripts') . '/drakx-in-chroot'; + my $local_drakx_in_chroot = $build->get_builddir('scripts') . '/drakx-in-chroot'; mkdir_p(dirname($local_drakx_in_chroot)); run_('curl', '--silent', '-o', $local_drakx_in_chroot, $drakx_in_chroot) or die "unable to get drakx-in-chroot from remote repository\n"; @@ -49,144 +49,144 @@ sub install_live_system { local %ENV = ( %ENV, - (map { "DRAKLIVE_" . uc($_->[0]) => $_->[1] } group_by2(%{$live->{settings}})), - %{$live->{system}{install_env}}, + (map { "DRAKLIVE_" . uc($_->[0]) => $_->[1] } group_by2(%{$build->{settings}})), + %{$build->{system}{install_env}}, ); - $ENV{DRAKLIVE_LANGS} = join(':', $live->get_langs); - run_({ targetarch => $live->{settings}{arch} }, + $ENV{DRAKLIVE_LANGS} = join(':', $build->get_langs); + run_({ targetarch => $build->{settings}{arch} }, 'perl', $drakx_in_chroot, $repository, - $live->get_system_root, - if_($live->{system}{auto_install}, '--auto_install', $live->{settings}{config_root} . '/' . $live->{system}{auto_install}), - if_($live->{system}{patch_install}, '--defcfg', $live->{settings}{config_root} . '/' . $live->{system}{patch_install}), - if_($live->{system}{rpmsrate}, '--rpmsrate', $live->{settings}{config_root} . '/' . $live->{system}{rpmsrate}), - ($live->{system}{stage2_updates} ? (map { ('--stage2-update', $live->{settings}{config_root} . '/' . $_->[0], $_->[1]) } @{$live->{system}{stage2_updates}}) : ()), + $build->get_system_root, + if_($build->{system}{auto_install}, '--auto_install', $build->{settings}{config_root} . '/' . $build->{system}{auto_install}), + if_($build->{system}{patch_install}, '--defcfg', $build->{settings}{config_root} . '/' . $build->{system}{patch_install}), + if_($build->{system}{rpmsrate}, '--rpmsrate', $build->{settings}{config_root} . '/' . $build->{system}{rpmsrate}), + ($build->{system}{stage2_updates} ? (map { ('--stage2-update', $build->{settings}{config_root} . '/' . $_->[0], $_->[1]) } @{$build->{system}{stage2_updates}}) : ()), ) or die "unable to install system chroot\n"; } sub customise_live_system { - my ($live) = @_; + my ($build) = @_; my $previous_umask = umask; #- workaround buggy installation of directories that are not owned by any packages umask 022; - mount_system_fs($live); + mount_system_fs($build); #- copy resolv.conf for name resolution to work when adding media - cp_f("/etc/resolv.conf", $live->get_system_root . "/etc/"); + cp_f("/etc/resolv.conf", $build->get_system_root . "/etc/"); #- remove previous draklive leftovers if needed - run_({ root => $live->get_system_root }, 'urpmi.removemedia', '-a'); + run_({ root => $build->get_system_root }, 'urpmi.removemedia', '-a'); - foreach (@{$live->{system}{additional_media}}) { - run_({ root => $live->get_system_root }, 'urpmi.addmedia', if_($_->{distrib}, '--distrib'), $_->{name}, $_->{path}) + foreach (@{$build->{system}{additional_media}}) { + run_({ root => $build->get_system_root }, 'urpmi.addmedia', if_($_->{distrib}, '--distrib'), $_->{name}, $_->{path}) or die "unable to add media from $_->{path}\n"; @{$_->{packages} || []} or next; - run_({ root => $live->get_system_root, targetarch => $live->{settings}{arch} }, + run_({ root => $build->get_system_root, targetarch => $build->{settings}{arch} }, 'urpmi', '--auto', '--no-verify-rpm', if_(!$_->{distrib}, '--searchmedia', $_->{name}), @{$_->{packages}}) or die "unable to install packages from $_->{path}\n"; } #- additional rpms may have dependencies in additional media - if (@{$live->{system}{rpms} || []}) { + if (@{$build->{system}{rpms} || []}) { my $rpm_tmp_dir = '/tmp/draklive_rpms'; - mkdir_p($live->get_system_root . $rpm_tmp_dir); - cp_f((map { $live->{settings}{config_root} . '/' . $_ } @{$live->{system}{rpms}}), $live->get_system_root . $rpm_tmp_dir); - run_({ root => $live->get_system_root, targetarch => $live->{settings}{arch} }, + mkdir_p($build->get_system_root . $rpm_tmp_dir); + cp_f((map { $build->{settings}{config_root} . '/' . $_ } @{$build->{system}{rpms}}), $build->get_system_root . $rpm_tmp_dir); + run_({ root => $build->get_system_root, targetarch => $build->{settings}{arch} }, 'urpmi', '--auto', '--no-verify-rpm', - map { $rpm_tmp_dir . '/' . basename($_) } @{$live->{system}{rpms}}) + map { $rpm_tmp_dir . '/' . basename($_) } @{$build->{system}{rpms}}) or die "unable to install additional system rpms\n"; - rm_rf($live->get_system_root . $rpm_tmp_dir); + rm_rf($build->get_system_root . $rpm_tmp_dir); } #- remove urpmi media added by drakx-in-chroot and additional media, they're unusable - run_({ root => $live->get_system_root }, 'urpmi.removemedia', '-a'); + run_({ root => $build->get_system_root }, 'urpmi.removemedia', '-a'); - my $erase = join(' ', @{$live->{system}{erase_rpms} || []}); - run_({ root => $live->get_system_root, targetarch => $live->{settings}{arch} }, + my $erase = join(' ', @{$build->{system}{erase_rpms} || []}); + run_({ root => $build->get_system_root, targetarch => $build->{settings}{arch} }, 'sh', '-c', "rpm -qa $erase | xargs rpm -e ") if $erase; - run_({ root => $live->get_system_root }, 'systemctl', 'disable', $_ . '.service') foreach @{$live->{system}{disable_services}}; - run_({ root => $live->get_system_root }, 'systemctl', 'disable', $_ . '.timer') foreach @{$live->{system}{disable_timers}}; + run_({ root => $build->get_system_root }, 'systemctl', 'disable', $_ . '.service') foreach @{$build->{system}{disable_services}}; + run_({ root => $build->get_system_root }, 'systemctl', 'disable', $_ . '.timer') foreach @{$build->{system}{disable_timers}}; #- make sure harddrake is run: #- if previous HW config file is empty, we assumes DrakX has just completed the installation #- (do it in chroot, or else Storable from the build box may write an incompatible config file) - run_({ root => $live->get_system_root }, + run_({ root => $build->get_system_root }, 'perl', '-MStorable', '-e', qq(Storable::store({ UNKNOWN => {} }, '/etc/sysconfig/harddrake2/previous_hw'))); #- remove some build-machine specific configuration - clean_system_conf_file($live, $_) + clean_system_conf_file($build, $_) foreach qw(/etc/mtab /etc/iftab /etc/shorewall/interfaces /etc/mdadm.conf), - if_(!$live->{system}{skip_fstab}, '/etc/fstab'); - unlink($_) foreach map { glob($live->get_system_root . $_) } @{$live->{system}{remove_files} || []}; + if_(!$build->{system}{skip_fstab}, '/etc/fstab'); + unlink($_) foreach map { glob($build->get_system_root . $_) } @{$build->{system}{remove_files} || []}; - if ($live->{system}{modules_conf}) { - local $::prefix = $live->get_system_root; + if ($build->{system}{modules_conf}) { + local $::prefix = $build->get_system_root; local *modules::write_preload_conf = sub {}; #- FIXME, make this an option my $modules_conf = modules::any_conf->vnew; - put_in_hash($modules_conf, $live->{system}{modules_conf}); + put_in_hash($modules_conf, $build->{system}{modules_conf}); $modules_conf->write; } - my $mount_options = $live->{media}->get_media_setting('mount_options') || "defaults"; - output_with_perm($live->get_system_root . '/etc/fstab', 0644, - $live->{mount}{overlay} - ? "none / $live->{mount}{overlay} $mount_options 0 0\n" - : $live->{media}->get_media_setting('source') . " / " . $live->{media}->get_media_setting('fs') . " $mount_options 1 1\n" - ) unless $live->{system}{skip_fstab}; + my $mount_options = $build->{media}->get_media_setting('mount_options') || "defaults"; + output_with_perm($build->get_system_root . '/etc/fstab', 0644, + $build->{mount}{overlay} + ? "none / $build->{mount}{overlay} $mount_options 0 0\n" + : $build->{media}->get_media_setting('source') . " / " . $build->{media}->get_media_setting('fs') . " $mount_options 1 1\n" + ) unless $build->{system}{skip_fstab}; #- interactive mode can lead to race in initscripts #- (don't use addVarsInSh from MDK::Common, it breaks shell escapes) - substInFile { s/^PROMPT=.*/PROMPT=no/ } $live->get_system_root . '/etc/sysconfig/init'; + substInFile { s/^PROMPT=.*/PROMPT=no/ } $build->get_system_root . '/etc/sysconfig/init'; - configure_draklive_resize($live); + configure_draklive_resize($build); - if ($live->{system}{preselect_kdm_user}) { + if ($build->{system}{preselect_kdm_user}) { #- preselect specified user in kdm - my $kdm_cfg = $live->get_system_root . '/etc/kde/kdm/kdmrc'; - update_gnomekderc($kdm_cfg, 'X-:0-Greeter' => (PreselectUser => 'Default', DefaultUser => $live->{system}{preselect_kdm_user})) if -f $kdm_cfg; + my $kdm_cfg = $build->get_system_root . '/etc/kde/kdm/kdmrc'; + update_gnomekderc($kdm_cfg, 'X-:0-Greeter' => (PreselectUser => 'Default', DefaultUser => $build->{system}{preselect_kdm_user})) if -f $kdm_cfg; } #- apply patches and install files after the configuration is cleaned #- to allow special configuration files (especially modprobe.preload) - foreach (@{$live->{system}{patches}}) { - my $patch = $live->{settings}{config_root} . '/' . $_; - my @args = ('-p0', '-d', $live->get_system_root, '-i', $patch); + foreach (@{$build->{system}{patches}}) { + my $patch = $build->{settings}{config_root} . '/' . $_; + my @args = ('-p0', '-d', $build->get_system_root, '-i', $patch); run_program::run('patch', '>', '/dev/null', '--dry-run', '-f', '-R', @args) || run_('patch', @args) or die "unable to apply patch " . $patch . "\n"; } - copy_files_to($live, $live->{system}{files}, $live->get_system_root); - my @no_install_files = map { $_->[1] } grep { $_->[2] && $_->[2]{no_install} } @{$live->{system}{files}}; - output_p($live->get_system_root . '/etc/draklive-install.d/remove.d/draklive', map { "$_\n" } @no_install_files); + copy_files_to($build, $build->{system}{files}, $build->get_system_root); + my @no_install_files = map { $_->[1] } grep { $_->[2] && $_->[2]{no_install} } @{$build->{system}{files}}; + output_p($build->get_system_root . '/etc/draklive-install.d/remove.d/draklive', map { "$_\n" } @no_install_files); - eval { rm_rf($live->get_builddir('files')) }; - mkdir_p($live->get_builddir('files')); - if ($live->{media}{files}) { - copy_files_to($live, $live->{media}{files}, $live->get_builddir('files')); + eval { rm_rf($build->get_builddir('files')) }; + mkdir_p($build->get_builddir('files')); + if ($build->{media}{files}) { + copy_files_to($build, $build->{media}{files}, $build->get_builddir('files')); } - remove_files_from($live->{media}{remove_files}, $live->get_builddir('files')); + remove_files_from($build->{media}{remove_files}, $build->get_builddir('files')); - run_({ targetarch => $live->{settings}{arch} }, - "chroot", $live->get_system_root, "bash", "-c", $live->{system}{postInstall}) if $live->{system}{postInstall}; + run_({ targetarch => $build->{settings}{arch} }, + "chroot", $build->get_system_root, "bash", "-c", $build->{system}{postInstall}) if $build->{system}{postInstall}; - clean_system_conf_file($live, "/etc/resolv.conf"); - write_dist_lists($live); + clean_system_conf_file($build, "/etc/resolv.conf"); + write_dist_lists($build); - umount_external_fs($live); + umount_external_fs($build); umask $previous_umask; } sub configure_draklive_resize { - my ($live) = @_; + my ($build) = @_; - my $resizable_loopback = find { $_->{min_size} } @{$live->{mount}{dirs} || []}; + my $resizable_loopback = find { $_->{min_size} } @{$build->{mount}{dirs} || []}; if ($resizable_loopback) { my $ext = $loop_types{$resizable_loopback->{type}}{extension}; - output($live->get_system_root . '/etc/sysconfig/draklive-resize', <<EOF); + output($build->get_system_root . '/etc/sysconfig/draklive-resize', <<EOF); DRAKLIVE_RESIZE=yes LOOPBACK=/live/media/loopbacks$resizable_loopback->{path}$ext TYPE=$resizable_loopback->{fs} @@ -199,12 +199,12 @@ EOF } sub copy_files_to { - my ($live, $files, $root) = @_; + my ($build, $files, $root) = @_; foreach (@$files) { my ($source, $dest, $o_opts) = @$_; $dest = $root . '/' . $dest; mkdir_p($dest =~ m|/$| ? $dest : dirname($dest)); - my @sources = MGA::DrakISO::Utils::glob__($live->{settings}{config_root} . '/' . $source); + my @sources = MGA::DrakISO::Utils::glob__($build->{settings}{config_root} . '/' . $source); print STDERR "copying @sources to $dest\n"; cp_af(@sources, $dest); my $o_perm = $o_opts && $o_opts->{mode}; @@ -224,34 +224,34 @@ sub join_lists { } sub clean_system_conf_file { - my ($live, $file) = @_; - substInFile { undef $_ if /^[^#]/ } $live->get_system_root . $file; + my ($build, $file) = @_; + substInFile { undef $_ if /^[^#]/ } $build->get_system_root . $file; } sub write_dist_lists { - my ($live) = @_; + my ($build) = @_; - my $lists_dir = $live->get_builddir('dist'); + my $lists_dir = $build->get_builddir('dist'); mkdir_p($lists_dir); - run_("chroot " . $live->get_system_root . " rpm -qa | sort > " . - $lists_dir . '/' . $live->get_name . '.lst'); + run_("chroot " . $build->get_system_root . " rpm -qa | sort > " . + $lists_dir . '/' . $build->get_name . '.lst'); - run_("chroot " . $live->get_system_root . " rpm -qa --qf '%{name}\n' | sort > " . - $lists_dir . '/' . $live->get_name . '.lst.names'); + run_("chroot " . $build->get_system_root . " rpm -qa --qf '%{name}\n' | sort > " . + $lists_dir . '/' . $build->get_name . '.lst.names'); - run_("chroot " . $live->get_system_root . + run_("chroot " . $build->get_system_root . qq( sh -c "rpm -qa --qf '[%{NAME} %{FILESIZES} %{FILESTATES}\n]' | awk '{if(\\\$3==0) {s[\\\$1]+=\\\$2}} END{for (p in s){print s[p],p}}' | sort -n" > ) . - $lists_dir . '/' . $live->get_name . '.lst.full'); + $lists_dir . '/' . $build->get_name . '.lst.full'); - run_("chroot " . $live->get_system_root . + run_("chroot " . $build->get_system_root . qq( sh -c "urpmi_rpm-find-leaves | xargs rpm -q --qf '[%{NAME} %{FILESIZES} %{FILESTATES}\n]' | awk '{if(\\\$3==0) {s[\\\$1]+=\\\$2}} END{for (p in s){print s[p],p}}' | sort -n" > ) . - $lists_dir . '/' . $live->get_name . '.lst.leaves'); + $lists_dir . '/' . $build->get_name . '.lst.leaves'); require lang; - my @live_langs = $live->get_langs; + my @live_langs = $build->get_langs; my @langs = grep { member($_, @live_langs) || member(lang::locale_to_main_locale($_), @live_langs) } lang::list_langs(); - my $langs_file = $lists_dir . '/' . $live->get_name . '.langs'; + my $langs_file = $lists_dir . '/' . $build->get_name . '.langs'; output_p($langs_file, map { lang::l2name($_) . " (" . $_ . ")\n" } sort(@langs)); } diff --git a/lib/MGA/DrakISO/Config.pm b/lib/MGA/DrakISO/Config.pm index cda9695..a16e0cc 100644 --- a/lib/MGA/DrakISO/Config.pm +++ b/lib/MGA/DrakISO/Config.pm @@ -17,58 +17,58 @@ our $default_config_path = 'config/live.cfg'; our $default_settings_path = 'config/settings.cfg'; sub read_config { - my ($live, $config_root, $config_path, $settings_path) = @_; + my ($build, $config_root, $config_path, $settings_path) = @_; if ($config_path && -e getcwd() . '/' . $config_path) { $config_root = getcwd(); } print "using $config_root as directory root\n"; - add2hash($live->{settings} ||= {}, { getVarsFromSh($config_root . '/' . $settings_path) }) if $settings_path; + add2hash($build->{settings} ||= {}, { getVarsFromSh($config_root . '/' . $settings_path) }) if $settings_path; if ($config_path) { #- don't use do(), since it can't see lexicals in the enclosing scope my $cfg = eval(cat_($config_root . '/' . $config_path)) or die "unable to load $config_path: $@\n"; - put_in_hash($live, $cfg); + put_in_hash($build, $cfg); print "loaded $config_path as config file\n"; } - $live->{settings}{config_root} = $config_root; + $build->{settings}{config_root} = $config_root; } sub check_config { - my ($live) = @_; - unless (keys(%$live)) { + my ($build) = @_; + unless (keys(%$build)) { warn "no live definition\n"; Pod::Usage::pod2usage(); } #- check for minimum requirements - ref $live->{media} && $live->{media}{storage} or die "no media storage definition\n"; - ref $live->{system} or die "no system definition\n"; + ref $build->{media} && $build->{media}{storage} or die "no media storage definition\n"; + ref $build->{system} or die "no system definition\n"; } sub complete_config { - my ($live) = @_; + my ($build) = @_; - $live->{settings}{builddir} ||= '/var/lib/draklive/build'; - $live->{settings}{chroot} ||= '/var/lib/draklive/chroot'; + $build->{settings}{builddir} ||= '/var/lib/draklive/build'; + $build->{settings}{chroot} ||= '/var/lib/draklive/chroot'; - $live->{settings}{arch} ||= chomp_(`rpm --eval '%{_target_cpu}'`); - $live->{media}{title} ||= "live"; + $build->{settings}{arch} ||= chomp_(`rpm --eval '%{_target_cpu}'`); + $build->{media}{title} ||= "live"; $_ = MGA::DrakISO::Media::new($_) foreach ( - $live->{media}, - ($live->{replicator} ? $live->{replicator}{media} : ()), - ($live->{oem_rescue} ? $live->{oem_rescue}{media} : ()), + $build->{media}, + ($build->{replicator} ? $build->{replicator}{media} : ()), + ($build->{oem_rescue} ? $build->{oem_rescue}{media} : ()), ); - mkdir_p($live->get_builddir); - mkdir_p($live->get_system_root); - $live->{mnt} ||= $live->get_builddir . "/mnt"; + mkdir_p($build->get_builddir); + mkdir_p($build->get_system_root); + $build->{mnt} ||= $build->get_builddir . "/mnt"; } sub dump_config { - my ($live) = @_; + my ($build) = @_; use Data::Dumper; - print Data::Dumper->Dump([ $live ], [ "live" ]); + print Data::Dumper->Dump([ $build ], [ "live" ]); } 1; diff --git a/lib/MGA/DrakISO/ISOBuild.pm b/lib/MGA/DrakISO/ISOBuild.pm index d3305fe..16fa36e 100644 --- a/lib/MGA/DrakISO/ISOBuild.pm +++ b/lib/MGA/DrakISO/ISOBuild.pm @@ -37,25 +37,25 @@ sub new { } sub get_name { - my ($live) = @_; - my $fields = $live->{name_fields} || $live->default_name_fields; - join('-', grep { $_ } @{$live->{settings}}{@$fields}); + my ($build) = @_; + my $fields = $build->{name_fields} || $build->default_name_fields; + join('-', grep { $_ } @{$build->{settings}}{@$fields}); } sub get_set_suffix { - my ($live) = @_; - $live->{settings}{set} ? "-$live->{settings}{set}" : ""; + my ($build) = @_; + $build->{settings}{set} ? "-$build->{settings}{set}" : ""; } sub get_builddir { - my ($live, $o_subdir) = @_; - $live->{settings}{builddir} . '/' . $live->get_name . $live->get_set_suffix . if_($o_subdir, '/' . $o_subdir); + my ($build, $o_subdir) = @_; + $build->{settings}{builddir} . '/' . $build->get_name . $build->get_set_suffix . if_($o_subdir, '/' . $o_subdir); } sub get_absolute_path { - my ($live, $path) = @_; + my ($build, $path) = @_; if (defined $path && substr($path, 0, 1) ne '/') { - $live->{settings}{config_root} . '/' . $path; + $build->{settings}{config_root} . '/' . $path; } else { $path; } diff --git a/lib/MGA/DrakISO/LiveBuild.pm b/lib/MGA/DrakISO/LiveBuild.pm index dbfda48..67561d2 100644 --- a/lib/MGA/DrakISO/LiveBuild.pm +++ b/lib/MGA/DrakISO/LiveBuild.pm @@ -40,42 +40,42 @@ sub new { } sub default_name_fields { - my ($live) = @_; + my ($build) = @_; [ qw(name version product desktop), - if_($live->{settings}{region} ne 'all', $live->{settings}{region}), + if_($build->{settings}{region} ne 'all', $build->{settings}{region}), qw(arch media) ]; } sub get_langs { - my ($live) = @_; + my ($build) = @_; uniq( - (ref $live->{regions} ? @{$live->{regions}{$live->{settings}{region}}} : ()), - @{$live->{system}{langs_always}} + (ref $build->{regions} ? @{$build->{regions}{$build->{settings}{region}}} : ()), + @{$build->{system}{langs_always}} ); } sub get_system_root { - my ($live) = @_; - $live->{settings}{chroot} . '/' . $live->get_name . $live->get_set_suffix; + my ($build) = @_; + $build->{settings}{chroot} . '/' . $build->get_name . $build->get_set_suffix; } sub find_kernel { - my ($live) = @_; + my ($build) = @_; require bootloader; - local $::prefix = $live->get_system_root; + local $::prefix = $build->get_system_root; my @kernels = bootloader::get_kernels_and_labels(); my $kernel; - if ($live->{system}{kernel}) { - $kernel = find { $_->{version} eq $live->{system}{kernel} } @kernels; - $kernel or die "kernel $live->{system}{kernel} can not be found\n"; + if ($build->{system}{kernel}) { + $kernel = find { $_->{version} eq $build->{system}{kernel} } @kernels; + $kernel or die "kernel $build->{system}{kernel} can not be found\n"; } $kernel ||= first(@kernels) or die "no kernel can be found\n"; } sub get_initrd_name { - my ($live) = @_; - 'initrd-' . $live->find_kernel->{version} . '.img'; + my ($build) = @_; + 'initrd-' . $build->find_kernel->{version} . '.img'; } 1; diff --git a/lib/MGA/DrakISO/Loopback.pm b/lib/MGA/DrakISO/Loopback.pm index f3ba5ae..288d78f 100644 --- a/lib/MGA/DrakISO/Loopback.pm +++ b/lib/MGA/DrakISO/Loopback.pm @@ -22,17 +22,17 @@ our %loop_types; modules => sub { "loop", best_squashfs4_compression($_[0]) ? "squashfs" : "squashfs_lzma" }, extension => '-lzma.sqfs', build => sub { - my ($live, $dir) = @_; - my $dest = $live->get_builddir('loopbacks') . $dir->{path} . $loop_types{squashfs}{extension}; + my ($build, $dir) = @_; + my $dest = $build->get_builddir('loopbacks') . $dir->{path} . $loop_types{squashfs}{extension}; mkdir_p(dirname($dest)); - my $root = $dir->{root} || $live->get_system_root; + my $root = $dir->{root} || $build->get_system_root; my $src = $root . $dir->{build_from}; my $total = directory_usage($src); print "have to process " . int($total/1000000) . " MB\n"; my $exclude_file = tmpnam(); output_p($exclude_file, map { $root . "$_\n" } grep { -e $root . $_ } @{$dir->{exclude} || []}); - my $sort = $live->{settings}{config_root} . '/' . $dir->{sort}; - my $squashfs4_comp = best_squashfs4_compression($live); + my $sort = $build->{settings}{config_root} . '/' . $dir->{sort}; + my $squashfs4_comp = best_squashfs4_compression($build); run_($squashfs4_comp ? 'mksquashfs' : 'mksquashfs3', $src, $dest, $squashfs4_comp ? ('-comp', $squashfs4_comp) : '-lzma', '-noappend', '-b', '1048576', @@ -91,8 +91,8 @@ our %loop_types; modules => [], extension => '.loop', build => sub { - my ($live, $dir) = @_; - my $dest = $live->get_builddir('loopbacks') . $dir->{path} . $loop_types{loopfs}{extension}; + my ($build, $dir) = @_; + my $dest = $build->get_builddir('loopbacks') . $dir->{path} . $loop_types{loopfs}{extension}; mkdir_p(dirname($dest)); MGA::DrakISO::Utils::device_allocate_file($dest, $dir->{pre_allocate}); MGA::DrakISO::Utils::device_mkfs($dest, $dir->{fs}) if !defined $dir->{min_size}; @@ -144,9 +144,9 @@ our %loop_types; ); sub has_squashfs4_with { - my ($live, $comp) = @_; + my ($build, $comp) = @_; my $ucomp = uc($comp); - cat_($live->get_system_root . "/boot/config-" . $live->find_kernel->{version}) =~ /^CONFIG_SQUASHFS_$ucomp=y$/m; + cat_($build->get_system_root . "/boot/config-" . $build->find_kernel->{version}) =~ /^CONFIG_SQUASHFS_$ucomp=y$/m; } sub mksquashfs4_compressors() { @@ -154,8 +154,8 @@ sub mksquashfs4_compressors() { } sub best_squashfs4_compression { - my ($live) = @_; - find { has_squashfs4_with($live, $_) } intersection([ mksquashfs4_compressors() ], [ qw(xz lzma) ]); + my ($build) = @_; + find { has_squashfs4_with($build, $_) } intersection([ mksquashfs4_compressors() ], [ qw(xz lzma) ]); } 1; diff --git a/lib/MGA/DrakISO/Utils.pm b/lib/MGA/DrakISO/Utils.pm index b20cb32..40495e6 100644 --- a/lib/MGA/DrakISO/Utils.pm +++ b/lib/MGA/DrakISO/Utils.pm @@ -63,15 +63,15 @@ sub device_mkfs { } sub mount_system_fs { - my ($live) = @_; - run_('mount', '-t', 'devtmpfs', '/dev', $live->get_system_root . '/dev'); - run_('mount', '-t', 'proc', '/proc', $live->get_system_root . '/proc'); - run_('mount', '-t', 'sysfs', '/sys', $live->get_system_root . '/sys'); + my ($build) = @_; + run_('mount', '-t', 'devtmpfs', '/dev', $build->get_system_root . '/dev'); + run_('mount', '-t', 'proc', '/proc', $build->get_system_root . '/proc'); + run_('mount', '-t', 'sysfs', '/sys', $build->get_system_root . '/sys'); } sub umount_external_fs { - my ($live) = @_; - my $system_root = Cwd::abs_path($live->get_system_root); + my ($build) = @_; + my $system_root = Cwd::abs_path($build->get_system_root); my @mounts = grep { $_ =~ $system_root } split("\n", cat_('/proc/mounts')); foreach (reverse(@mounts)) { my @field = split(' ' , $_); |