diff options
Diffstat (limited to 'perl-install/harddrake/sound.pm')
0 files changed, 0 insertions, 0 deletions
![]() |
index : drakx | |
Mageia Installer and base platform for many utilities | Thierry Vignaud [tv] |
summaryrefslogtreecommitdiffstats |
package install_any; # $Id$
use strict;
use vars qw(@ISA %EXPORT_TAGS @EXPORT_OK $boot_medium $current_medium $asked_medium @advertising_images);
@ISA = qw(Exporter);
%EXPORT_TAGS = (
all => [ qw(getNextStep spawnShell addToBeDone) ],
);
@EXPORT_OK = map { @$_ } values %EXPORT_TAGS;
#-######################################################################################
#- misc imports
#-######################################################################################
use MDK::Common::System;
use common;
use run_program;
use fs::type;
use fs::format;
use partition_table;
use devices;
use fsedit;
use modules;
use detect_devices;
use lang;
use any;
use log;
#- boot medium (the first medium to take into account).
$boot_medium = 1;
$current_medium = $boot_medium;
$asked_medium = $boot_medium;
our $global_ftp_prefix;
sub drakx_version() {
$::move ? sprintf "DrakX-move v%s", cat_('/usr/bin/stage2/move.pm') =~ /move\.pm,v (\S+ \S+ \S+)/
: sprintf "DrakX v%s built %s", $::testing ? ('TEST', scalar gmtime()) : (split('/', cat__(getFile("install/stage2/VERSION"))))[2,3];
}
#-######################################################################################
#- Media change variables&functions
#-######################################################################################
my $postinstall_rpms = '';
my $cdrom;
my %iso_images;
sub mountCdrom {
my ($mountpoint, $o_cdrom) = @_;
$o_cdrom = $cdrom if !defined $o_cdrom;
eval { fs::mount($o_cdrom, $mountpoint, "iso9660", 'readonly') };
}
sub useMedium($) {
#- before ejecting the first CD, there are some files to copy!
#- does nothing if the function has already been called.
$_[0] > 1 and method_allows_medium_change($::o->{method}) and setup_postinstall_rpms($::prefix, $::o->{packages});
$asked_medium eq $_[0] or log::l("selecting new medium '$_[0]'");
$asked_medium = $_[0];
}
sub changeMedium($$) {
my ($method, $medium_name) = @_;
log::l("change to medium $medium_name for method $method (refused by default)");
0;
}
sub relGetFile($) {
local $_ = $_[0];
if (my ($arch) = m|\.([^\.]*)\.rpm$|) {
$_ = "$::o->{packages}{mediums}{$asked_medium}{rpmsdir}/$_";
s/%{ARCH}/$arch/g;
s,^/+,,g;
}
$_;
}
sub askChangeMedium($$) {
my ($method, $medium_name) = @_;
my $allow;
do {
local $::o->{method} = $method = 'cdrom' if $medium_name =~ /^\d+s$/; #- Suppl CD
eval { $allow = changeMedium($method, $medium_name) };
} while $@; #- really it is not allowed to die in changeMedium!!! or install will core with rpmlib!!!
log::l($allow ? "accepting medium $medium_name" : "refusing medium $medium_name");
$allow;
}
sub method_is_from_ISO_images($) {
my ($method) = @_;
$method eq "disk-iso" || $method eq "nfs-iso";
}
sub method_allows_medium_change($) {
my ($method) = @_;
$method eq "cdrom" || method_is_from_ISO_images($method);
}
sub look_for_ISO_images() {
$iso_images{media} = [];
($iso_images{loopdev}, $iso_images{mountpoint}) = cat_("/proc/mounts") =~ m|(/dev/loop\d+)\s+(/tmp/image) iso9660| or return;
my $get_iso_ids = sub {
my ($F) = @_;
my ($vol_id, $app_id) = c::get_iso_volume_ids(fileno $F);
#- the ISO volume names must end in -Disc\d+
my ($cd_set) = $vol_id =~ /^(.*)-Disc\d+$/;
$cd_set && { cd_set => $cd_set, app_id => $app_id };
};
sysopen(my $F, $iso_images{loopdev}, 0) or return;
put_in_hash(\%iso_images, $get_iso_ids->($F));
my $iso_dir = $ENV{ISOPATH};
#- strip old root and remove iso file from path if present
$iso_dir =~ s!^/sysroot!!; $iso_dir =~ s![^/]*\.iso$!!;
foreach my $iso_file (glob("$iso_dir/*.iso")) {
my $iso_dev = devices::set_loop($iso_file) or return;
if (sysopen($F, $iso_dev, 0)) {
my $iso_ids = $get_iso_ids->($F);
push @{$iso_images{media}}, { file => $iso_file, %$iso_ids } if $iso_ids;
close($F); #- needed to delete loop device
}
devices::del_loop($iso_dev);
}
1;
}
sub find_ISO_image_labelled($) {
%iso_images or look_for_ISO_images() or return;
my ($iso_label) = @_;
find { $_->{app_id} eq $iso_label && $_->{cd_set} eq $iso_images{cd_set} } @{$iso_images{media}};
}
sub changeIso($) {
my ($iso_label) = @_;
my $iso_info = find_ISO_image_labelled($iso_label) or return;
eval { fs::umount($iso_images{mountpoint}) };
$@ and warnAboutFilesStillOpen();
devices::del_loop($iso_images{loopdev});
$iso_images{loopdev} = devices::set_loop($iso_info->{file});
eval {
fs::mount($iso_images{loopdev}, $iso_images{mountpoint}, "iso9660", 'readonly');
log::l("using ISO image '$iso_label'");
1;
};
}
sub errorOpeningFile($) {
my ($file) = @_;
$file eq 'XXX' and return; #- special case to force closing file after rpmlib transaction.
$current_medium eq $asked_medium and log::l("errorOpeningFile $file"), return; #- nothing to do in such case.
$::o->{packages}{mediums}{$asked_medium}{selected} or return; #- not selected means no need to worry about.
my $current_method = $::o->{packages}{mediums}{$asked_medium}{method} || $::o->{method};
my $max = 32; #- always refuse after $max tries.
if ($current_method eq "cdrom") {
cat_("/proc/mounts") =~ m,(/dev/\S+)\s+(/mnt/cdrom|/tmp/image),
and ($cdrom, my $mountpoint) = ($1, $2);
return unless $cdrom;
ejectCdrom($cdrom, $mountpoint);
while ($max > 0 && askChangeMedium($current_method, $asked_medium)) {
$current_medium = $asked_medium;
mountCdrom("/tmp/image");
my $getFile = getFile($file);
$getFile && @advertising_images and copy_advertising($::o);
$getFile and return $getFile;
$current_medium = 'unknown'; #- do not know what CD is inserted now.
ejectCdrom($cdrom, $mountpoint);
--$max;
}
} else {
while ($max > 0 && askChangeMedium($current_method, $asked_medium)) {
$current_medium = $asked_medium;
my $getFile = getFile($file); $getFile and return $getFile;
$current_medium = 'unknown'; #- do not know what CD image has been copied.
--$max;
}
}
#- Do not unselect supplementary CDs.
return if $asked_medium =~ /^\d+s$/;
#- keep in mind the asked medium has been refused on this way.
#- this means it is no more selected.
$::o->{packages}{mediums}{$asked_medium}{selected} = undef;
#- on cancel, we can expect the current medium to be undefined too,
#- this enables remounting if selecting a package back.
$current_medium = 'unknown';
return;
}
sub getFile {
my ($f, $o_method, $o_altroot) = @_;
my $current_method = ($asked_medium ? $::o->{packages}{mediums}{$asked_medium}{method} : '') || $::o->{method};
log::l("getFile $f:$o_method ($asked_medium:$current_method)");
my $rel = relGetFile($f);
do {
if ($f =~ m|^http://|) {
require http;
http::getFile($f);
} elsif ($o_method =~ /crypto|update/i) {
require crypto;
crypto::getFile($f);
} elsif ($current_method eq "ftp") {
require ftp;
ftp::getFile($rel, @{ $::o->{packages}{mediums}{$asked_medium}{ftp_prefix} || $global_ftp_prefix || [] });
} elsif ($current_method eq "http") {
require http;
http::getFile(($ENV{URLPREFIX} || $o_altroot) . "/$rel");
} else {
#- try to open the file, but examine if it is present in the repository,