package install_any; # $Id$
use diagnostics;
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 partition_table qw(:types);
use partition_table::raw;
use devices;
use fsedit;
use modules;
use detect_devices;
use lang;
use any;
use log;
use fs;
#- boot medium (the first medium to take into account).
$boot_medium = 1;
$current_medium = $boot_medium;
$asked_medium = $boot_medium;
#-######################################################################################
#- Media change variables&functions
#-######################################################################################
my $postinstall_rpms = '';
my $cdrom;
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 $::o->{method} eq 'cdrom' 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) = @_;
log::l("change to medium $medium 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;
}
$_;
}
sub askChangeMedium($$) {
my ($method, $medium) = @_;
my $allow;
do {
eval { $allow = changeMedium($method, $medium) };
} while $@; #- really it is not allowed to die in changeMedium!!! or install will cores with rpmlib!!!
log::l($allow ? "accepting medium $medium" : "refusing medium $medium");
$allow;
}
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 for worying about.
my $max = 32; #- always refuse after $max tries.
if ($::o->{method} eq "cdrom") {
cat_("/proc/mounts") =~ m,(/(?:dev|tmp)/\S+)\s+(?:/mnt/cdrom|/tmp/image), and $cdrom = $1;
return unless $cdrom;
ejectCdrom($cdrom);
while ($max > 0 && askChangeMedium($::o->{method}, $asked_medium)) {
$current_medium = $asked_medium;
eval { fs::mount($cdrom, "/tmp/image", "iso9660", 'readonly') };
my $getFile = getFile($file);
$getFile && @advertising_images and copy_advertising($::o);
$getFile and return $getFile;
$current_medium = 'unknown'; #- don't know what CD is inserted now.
ejectCdrom($cdrom);
--$max;
}
} else {
while ($max > 0 && askChangeMedium($::o->{method}, $asked_medium)) {
$current_medium = $asked_medium;
my $getFile = getFile($file); $getFile and return $getFile;
$current_medium = 'unknown'; #- don't know what CD image has been copied.
--$max;
}
}
#- 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 enable remounting if selecting a package back.
$current_medium = 'unknown';
return;
}
sub getFile {
my ($f, $o_method) = @_;
log::l("getFile $f:$o_method");
my $rel = relGetFile($f);
do {
|