diff options
Diffstat (limited to 'perl-install/install/any.pm')
| -rw-r--r-- | perl-install/install/any.pm | 270 |
1 files changed, 234 insertions, 36 deletions
diff --git a/perl-install/install/any.pm b/perl-install/install/any.pm index 0ce8d5533..f016dad5b 100644 --- a/perl-install/install/any.pm +++ b/perl-install/install/any.pm @@ -1,4 +1,4 @@ -package install::any; # $Id: any.pm 259898 2009-09-03 14:05:46Z tv $ +package install::any; use strict; @@ -8,6 +8,7 @@ our @EXPORT_OK = qw(addToBeDone); #-###################################################################################### #- misc imports #-###################################################################################### +use feature 'state'; use common; use run_program; use fs::type; @@ -22,8 +23,24 @@ use lang; use any; use log; +=head1 SYNOPSYS + +Misc installer specific functions + +=head1 Functions + +=over + +=cut + our @advertising_images; +=item drakx_version($o) + +Returns DrakX version as stored in C<install/stage2/VERSION> file + +=cut + sub drakx_version { my ($o) = @_; @@ -38,11 +55,23 @@ sub dont_run_directly_stage2() { readlink("/usr/bin/runinstall2") eq "runinstall2.sh"; } +=item is_network_install($o) + +Is it a network install? + +=cut + sub is_network_install { my ($o) = @_; member($o->{method}, qw(ftp http nfs)); } +=item spawnShell() + +Starts a shell on tty2 + +=cut + sub spawnShell() { return if $::local_install || $::testing; @@ -83,6 +112,12 @@ cant_spawn: c::_exit(1); } +=item getAvailableSpace($o) + +Returns available space + +=cut + sub getAvailableSpace { my ($o) = @_; fs::any::getAvailableSpace($o->{fstab}); @@ -102,6 +137,12 @@ sub preConfigureTimezone { add2hash_($o->{timezone}, { UTC => $utc, ntp => $ntp }); } +=item ask_suppl_media_method($o) + +Enables to add supplementary media + +=cut + sub ask_suppl_media_method { my ($o) = @_; our $suppl_already_asked; @@ -114,7 +155,7 @@ sub ask_suppl_media_method { Do you have a supplementary installation medium to configure?", - "\n\n\n" . join(",\n\n", map { "- $_->{name}" } install::media::allMediums($o->{packages})))); + "\n\n\n" . join(",\n\n", map { "- $_->{name}" . ($_->{ignore} ? " (disabled)" : '') } install::media::allMediums($o->{packages})))); my %l = my @l = ( '' => N("None"), @@ -124,8 +165,9 @@ Do you have a supplementary installation medium to configure?", 'nfs' => N("Network (NFS)"), ); - $o->ask_from( - '', $msg, + $o->ask_from_({ messages => $msg, + interactive_help_id => 'add_supplemental_media', + }, [ { val => \my $suppl, list => [ map { $_->[0] } group_by2(@l) ], @@ -138,8 +180,13 @@ Do you have a supplementary installation medium to configure?", $suppl; } -#- if the supplementary media is networked, but not the main one, network -#- support must be installed and network started. +=item prep_net_suppl_media($o) + +If the supplementary media is networked, but not the main one, network +support must be installed and network started. + +=cut + sub prep_net_suppl_media { my ($o) = @_; @@ -147,11 +194,16 @@ sub prep_net_suppl_media { return if our $net_suppl_media_configured && network::tools::has_network_connection(); $net_suppl_media_configured = 1; - # needed so that one can install basesystem before adding suppl network media: - install::media::configure_media($o->{packages}); - #- install basesystem now - $o->do_pkgs->ensure_is_installed('basesystem', undef, 1); + # needed so that one can install basesystem-minimal before adding suppl network media: + install::media::update_media($o->{packages}); + require urpm::media; + urpm::media::configure($o->{packages}); + #- install basesystem-minimal now + $o->do_pkgs->ensure_is_installed('basesystem-minimal', undef, 1); + + # in case of no network install: + $o->{net} ||= {}; require network::netconnect; network::netconnect::real_main($o->{net}, $o, $o->{modules_conf}); require install::interactive; @@ -159,6 +211,12 @@ sub prep_net_suppl_media { sleep(3); } +=item ask_url($in, $o_url) + +Asks URL of the mirror + +=cut + sub ask_url { my ($in, $o_url) = @_; @@ -174,6 +232,13 @@ sub ask_url { } } } ]) && $url; } + +=item ask_mirror($o, $type, $o_url) + +Retrieves list of mirrors and offers to pick one + +=cut + sub ask_mirror { my ($o, $type, $o_url) = @_; @@ -218,7 +283,7 @@ sub ask_mirror { sub ask_suppl_media_url { my ($o, $method, $o_url) = @_; - if ($method eq 'ftp' || $method eq 'http') { + if (member($method, qw(ftp http))) { install::any::ask_mirror($o, 'distrib', $o_url); } elsif ($method eq 'cdrom') { 'cdrom://'; @@ -243,6 +308,14 @@ sub ask_suppl_media_url { "nfs://$host$dir"; } else { internal_error("bad method $method") } } + + +=item selectSupplMedia($o) + +Offers to add a supplementary media. If yes, ask which mirror to use, ... + +=cut + sub selectSupplMedia { my ($o) = @_; my $url; @@ -297,6 +370,15 @@ sub selectSupplMedia { goto ask_url; } +=item load_rate_files($o) + +Loads the package rates file (C<rpmsrate>) as well as the C<compssUsers.pl> +file which contains the package groups GUI. + +Both files came from the C<meta-task> package. + +=cut + sub load_rate_files { my ($o) = @_; #- must be done after getProvides @@ -316,10 +398,34 @@ sub _tainted_medium() { N("Tainted Release") } sub _nonfree_medium() { N("Nonfree Release") } # FIXME: move me in ../any.pm or in harddrake::*, might be needed by rpmdrake/harddrake: -sub is_firmware_needed { +sub is_firmware_needed_ { my ($o) = @_; + require list_firmwares; + my @l = map { $_->{driver} } detect_devices::probeall(); + my @need = intersection(\@l, \@list_firmwares::modules_with_nonfree_firmware); + log::l("the following driver(s) need nonfree firmware(s): " . join(', ', @need)) if @need; + require pkgs; - pkgs::detect_graphical_drivers($o->do_pkgs); + my @xpkgs = pkgs::detect_graphical_drivers($o->do_pkgs); + log::l("the following nonfree firmware(s) are needed for X.org: " . join(', ', @xpkgs)) if @xpkgs; + + my $need_microcode = detect_devices::hasCPUMicrocode(); + log::l("nonfree firmware is needed for the CPU (microcode)") if $need_microcode; + + @need || @xpkgs || $need_microcode; +} + +=item is_firmware_needed($o) + +Is a firmware needed by some HW? + +=cut + +sub is_firmware_needed { + my ($o) = @_; + state $res; + $res = is_firmware_needed_($o) if !defined $res; + $res; } sub msg_if_firmware_needed { @@ -332,6 +438,26 @@ sub msg_if_firmware_needed { ); } +=item enable_nonfree_media($medium) + +Enable a disabled Nonfree medium. + +=cut + +sub enable_nonfree_media { + my ($medium) = @_; + return if $medium->{name} !~ /Nonfree/ || !$medium->{ignore}; + log::l("preselecting $medium->{name}"); + $medium->{temp_enabled} = 1; +} + +=item media_screen($o) + +Lists available media with their status (enabled/disabled). +Suggests to enable Nonfree media if needed. + +=cut + sub media_screen { my ($o) = @_; @@ -340,33 +466,47 @@ sub media_screen { # - nice info # - ignore already failed media (such as 32bit media on NFS) # - detect if non-free/tainted were selected previously / are now needed - # rpm -qa |grep tainted/non-free + check for kmod with firmwares + # rpm -qa |grep tainted/non-free # - use red color in that case (gtk+ version? interactive::gtk version?) # - present media as trees (eg 3 main branches (core/nonfree/tainted and sub medium below (release/updates/...) + # - enable to add media from the media screen + # - introduce 'mandatory' keyword for guessing media that can *not* be disabled my %descriptions = ( 'Core Release' => N("\"%s\" contains the various pieces of the systems and its applications", _core_medium()), 'Nonfree Release' => N("\"%s\" contains non free software.\n", _nonfree_medium()) . - N("It also contains firmwares needed for certain devices to operate (eg: some ATI/AMD graphic cards, some network cards, some RAID cards, ..."), + N("It also contains firmwares needed for certain devices to operate (eg: some ATI/AMD graphic cards, some network cards, some RAID cards, ...)"), 'Tainted Release' => N("\"%s\" contains software that can not be distributed in every country due to software patents.", _tainted_medium()) . N("It also contains software from \"%s\" rebuild with additional capabilities.", _core_medium()), ); + my $nonfree_is_needed = is_firmware_needed($o); + $o->ask_from_({ messages => join("\n", - N("Media Choice"), N("Here you can enable more media if you want."), msg_if_firmware_needed($o) ), + interactive_help_id => 'media_selection', focus_first => sub { 1 } }, [ map { my $medium = $_; $medium->{temp_enabled} = !$medium->{ignore}; + my $name = $medium->{name}; + my ($distribconf, $medium_path) = @{$_->{mediacfg}}; + my @media_types = split(':', $distribconf->getvalue($medium_path, 'media_type')); + my $parent = $distribconf->getvalue($distribconf->getvalue($medium_path, 'updates_for'), 'name'); + my $non_regular_medium = intersection(\@media_types, [ qw(backports debug source testing) ]); + enable_nonfree_media($medium) if $nonfree_is_needed && !$non_regular_medium; + $non_regular_medium ? () : +{ - val => \$medium->{temp_enabled}, type => 'bool', text => $medium->{name}, + val => \$medium->{temp_enabled}, type => 'bool', text => $name, + help => $medium->{update} ? N("This medium provides package updates for medium \"%s\"", $parent) : $descriptions{$name}, # 'Core Release' cannot be unselected: - disabled => sub { $medium->{name} eq 'Core Release' }, - format => sub { $descriptions{$_[0]} || translate(%descriptions) }, + disabled => sub { + state $parent_media = $parent && urpm::media::name2medium($urpm, $parent); + $name =~ /^(?:Core|Main) Release$/ || $parent_media ? !$parent_media->{temp_enabled} : 0; + }, }; - } grep { $_->{name} =~ /Release$|Updates$/ } @{$urpm->{media}}, + } @{$urpm->{media}}, ]); @@ -390,6 +530,28 @@ sub media_screen { ); } +=item setPackages($o) + +=over 4 + +=item * Initialize urpmi + +=item * Retrieves media.cfg + +=item * Offers to add supplementary media (according to the install method) + +=item * Offers to enable some disabled media + +=item * Ensure we have a kernel and basesystem + +=item * Flags package rates + +=item * Select default packages according to the computer + +=back + +=cut + sub setPackages { my ($o) = @_; @@ -397,7 +559,7 @@ sub setPackages { require install::pkgs; { #- clean shared regions very early - # (configure_media will open rpmdb for listing existing pubkeys, + # (update_media will open rpmdb for listing existing pubkeys, # which may fail when rpm version mistmatches between drakx & chrooted env) install::pkgs::clean_rpmdb_shared_regions(); $urpm = $o->{packages} = install::pkgs::empty_packages($o->{keep_unrequested_dependencies}); @@ -417,7 +579,10 @@ sub setPackages { } install::pkgs::start_pushing_error(); - media_screen($o); + media_screen($o) if !$::auto_install; + my @choosen_media = map { $_->{name} } grep { !$_->{ignore} } @{$urpm->{media}}; + log::l("choosen media: ", join(', ', @choosen_media)); + die "no choosen media" if !@choosen_media; # actually read synthesis now we have all the ones we want: require urpm::media; @@ -471,6 +636,12 @@ sub setPackages { } } +=item remove_package_for_upgrade($o) + +Removes packages that must be uninstalled prior to upgrade + +=cut + sub remove_package_for_upgrade { my ($o) = @_; my $extension = $o->{upgrade_by_removing_pkgs_matching}; @@ -493,6 +664,12 @@ sub remove_package_for_upgrade { log::l("Removing packages took: ", formatTimeRaw(time() - $time)); } +=item count_files($dir) + +Returns the number of files in $dir + +=cut + sub count_files { my ($dir) = @_; -d $dir or return 0; @@ -619,6 +796,12 @@ sub rpmsrate_always_flags { $rpmsrate_flags_chosen; } +=item default_packages($o) + +Selects default packages to install according to configuration (FS, HW, ...) + +=cut + sub default_packages { my ($o) = @_; my @l; @@ -638,7 +821,7 @@ sub default_packages { add_n_log("have crypted DM", "cryptsetup") if !is_empty_array_ref($o->{all_hds}{dmcrypts}); add_n_log("some disks are fake RAID", qw(mdadm dmraid)) if any { fs::type::is_dmraid($_) } @{$o->{all_hds}{hds}}; add_n_log("CPU needs microcode", "microcode_ctl") if detect_devices::hasCPUMicrocode(); - add_n_log("CPU needs cpufreq", 'cpupower') if detect_devices::hasCPUFreq(); + add_n_log("CPU needs cpupower", 'cpupower') if detect_devices::hasCPUFreq(); add_n_log("APM support needed", 'apmd') if -e "/proc/apm"; add_n_log("needed by hardware", detect_devices::probe_name('Pkg')); my @ltmp = map { $_->{BOOTPROTO} eq 'dhcp' ? $_->{DHCP_CLIENT} || 'dhcp-client' : () } values %{$o->{net}{ifcfg}}; @@ -646,9 +829,10 @@ sub default_packages { # will get auto selected at summary stage for bootloader: add_n_log("needed later at summary stage", qw(acpi acpid mageia-gfxboot-theme)); # will get auto selected at summary stage for firewall: - add_n_log("needed for firewall/security", qw(shorewall mandi-ifw)); + add_n_log("needed for firewall/security", qw(shorewall shorewall-ipv6 mandi-ifw)); # only needed for CDs/DVDs installations: add_n_log("method='cdrom'", 'perl-Hal-Cdroms') if $o->{method} eq 'cdrom'; + add_n_log("needed for VMware hypervisor", 'open-vm-tools') if detect_devices::is_vmware(); my $dmi_BIOS = detect_devices::dmidecode_category('BIOS'); my $dmi_Base_Board = detect_devices::dmidecode_category('Base Board'); @@ -759,7 +943,7 @@ sub g_auto_install { require install::pkgs; $o->{default_packages} = install::pkgs::selected_leaves($::o->{packages}); - my @fields = qw(mntpoint fs_type size); + my @fields = qw(fs_type hd level mntpoint options parts size VG_name); $o->{partitions} = [ map { my %l; @l{@fields} = @$_{@fields}; \%l; } grep { @@ -809,9 +993,6 @@ sub getAndSaveAutoInstallFloppies { eval { modules::load('loop') }; - if (arch() =~ /ia64/) { - #- nothing yet - } else { my $mountdir = "$::prefix/root/aif-mount"; -d $mountdir or mkdir $mountdir, 0755; my $param = 'kickstart=floppy ' . generate_automatic_stage1_params($o); @@ -854,7 +1035,6 @@ sub getAndSaveAutoInstallFloppies { } rmdir $mountdir; $img; - } } @@ -884,7 +1064,7 @@ sub loadO { my $o; foreach (removable_media__early_in_install()) { my $dev = devices::make($_->{device}); - foreach my $fs (arch() =~ /sparc/ ? 'romfs' : ('ext2', 'vfat')) { + foreach my $fs (qw(ext2 vfat)) { eval { fs::mount::mount($dev, '/mnt', $fs, 'readonly'); 1 } or next; if (my $abs_f = find { -e $_ } "/mnt/$f", "/mnt/$f.pl") { $o = loadO_($O, $abs_f); @@ -1340,7 +1520,10 @@ sub take_screenshot { } my $nb = 1; $nb++ while -e "$dir/$nb.png"; - system('fb2png', '/dev/fb0', "$dir/$nb.png", '0'); + run_program::run('fb2png', '/dev/fb0', "$dir/$nb.png", '0'); + + # help doesn't remember warning has been shown (one shot processes): + $warned ||= -e "$dir/2.png"; if (!$warned && !$nowarn) { $warned = 1; @@ -1393,14 +1576,25 @@ sub set_security { sub write_fstab { my ($o) = @_; - fs::write_fstab($o->{all_hds}, $::prefix) - if !$::local_install && (!$o->{isUpgrade} || $o->{isUpgrade} =~ /redhat|conectiva/ || $o->{migrate_device_names}); + return if $::local_install || $o->{isUpgrade} && $o->{isUpgrade} !~ /redhat|conectiva/ && !$o->{migrate_device_names}; + fs::write_fstab($o->{all_hds}, $::prefix); } -sub adjust_files_mtime_to_timezone() { - #- to ensure linuxconf does not cry against those files being in the future - #- to ensure fc-cache works correctly on fonts installed after reboot +=item adjust_files_mtime_to_timezone() { + +Fixes mtime of a couple important files according to timezone in order to: + +=over 4 + +=item * to ensure linuxconf does not cry against those files being in the future + +=item * to ensure fc-cache works correctly on fonts installed after reboot +=back + +=cut + +sub adjust_files_mtime_to_timezone() { my $timezone_shift = run_program::rooted_get_stdout($::prefix, 'date', '+%z'); my ($h, $m) = $timezone_shift =~ /\+(..)(..)/ or return; my $now = time() - ($h * 60 + $m * 60) * 60; @@ -1496,4 +1690,8 @@ sub configure_pcmcia { run_program::run("/lib/udev/pcmcia-socket-startup"); } +=back + +=cut + 1; |
