summaryrefslogtreecommitdiffstats
path: root/perl-install/install/media.pm
diff options
context:
space:
mode:
Diffstat (limited to 'perl-install/install/media.pm')
-rw-r--r--perl-install/install/media.pm84
1 files changed, 36 insertions, 48 deletions
diff --git a/perl-install/install/media.pm b/perl-install/install/media.pm
index da8becd7f..149deffc3 100644
--- a/perl-install/install/media.pm
+++ b/perl-install/install/media.pm
@@ -1,4 +1,4 @@
-package install::media; # $Id$
+package install::media;
use strict;
@@ -6,6 +6,9 @@ our @ISA = qw(Exporter);
our @EXPORT_OK = qw(getFile_ getAndSaveFile_ getAndSaveFile_media_info packageMedium);
use common;
+use Data::Dumper;
+# Make sure report.bug are more easily comparable:
+$Data::Dumper::Sortkeys = 1;
use fs::type;
use urpm::download;
use urpm::media;
@@ -42,11 +45,6 @@ use urpm::media;
our $postinstall_rpms = '';
my %mounted_media;
-sub _free_medium_id {
- my ($media) = @_;
- int(@$media);
-}
-
sub allMediums {
my ($packages) = @_;
@@ -63,6 +61,7 @@ sub packageMedium {
my ($packages, $p) = @_;
URPM::pkg2media($packages->{media}, $p) || {};
}
+
sub packagesOfMedium {
my ($packages, $medium) = @_;
@@ -80,16 +79,6 @@ sub path {
($phys_m->{real_mntpoint} || fs::get::mntpoint_prefixed($phys_m)) . $phys_m->{rel_path} . '/' . $f;
}
-sub rel_rpm_file {
- my ($medium, $f) = @_;
- if (my ($arch) = $f =~ m|\.([^\.]*)\.rpm$|) {
- $f = "$medium->{rpmsdir}/$f";
- $f =~ s/%{ARCH}/$arch/g;
- $f =~ s,^/+,,g;
- }
- $f;
-}
-
sub umount_phys_medium {
my ($phys_m) = @_;
@@ -104,6 +93,7 @@ sub umount_phys_medium {
}
$ok;
}
+
sub _mount_phys_medium {
my ($phys_m, $o_rel_file, $b_force_change) = @_;
@@ -170,7 +160,7 @@ sub stage2_phys_medium {
my $user = $ENV{LOGIN} && ($ENV{LOGIN} . ($ENV{PASSWORD} && ":$ENV{PASSWORD}") . '@');
$ENV{URLPREFIX} = "ftp://$user$ENV{HOST}/$ENV{PREFIX}";
}
- if ($method eq 'http' || $method eq 'ftp') {
+ if (member($method, qw(http ftp))) {
{ method => $method, url => $ENV{URLPREFIX} };
} elsif ($method =~ /(.*)-iso$/) {
my $dir_method = $1;
@@ -284,6 +274,7 @@ sub _iso_phys_media {
mntpoint => $mntpoint, rel_path => $rel_path,
};
}
+
sub _get_phys_media_iso {
my ($all_hds, $main_phys_m, $names) = @_;
@@ -296,6 +287,7 @@ sub _get_phys_media_iso {
$m;
} @ISOs;
}
+
sub _look_for_ISO_images {
my ($main_iso) = @_;
@@ -332,6 +324,7 @@ sub _open_file_and_size {
my $fh = common::open_file($f) or return;
$size, $fh;
}
+
sub getFile_ {
my ($phys_m, $f) = @_;
log::l("getFile $f on " . phys_medium_to_string($phys_m) . "");
@@ -339,13 +332,14 @@ sub getFile_ {
my ($_size, $fh) = get_file_and_size($phys_m, $f) or return;
$fh;
}
+
sub get_file_and_size {
my ($phys_m, $f) = @_;
- if ($f =~ m|^http://|) {
+ if ($f =~ m|^https?://|) {
require install::http;
install::http::get_file_and_size($f);
- } elsif (member($phys_m->{method}, qw(ftp http))) {
+ } elsif (member($phys_m->{method}, qw(ftp http https))) {
require install::http;
install::http::get_file_and_size_($f, $phys_m->{url});
} elsif ($f =~ m!^/!) {
@@ -367,6 +361,7 @@ sub getAndSaveFile_ {
my $fh = getFile_($phys_m, $file) or return;
_getAndSaveFile_raw($fh, $local);
}
+
sub _getAndSaveFile_progress {
my ($in_wait, $msg, $phys_m, $file, $local) = @_;
my ($size, $fh) = get_file_and_size($phys_m, $file) or return;
@@ -376,6 +371,7 @@ sub _getAndSaveFile_progress {
_getAndSaveFile_raw($fh, $local);
}
}
+
sub _getAndSaveFile_raw {
my ($fh, $local) = @_;
@@ -386,6 +382,7 @@ sub _getAndSaveFile_raw {
while (<$fh>) { syswrite($F, $_) or unlink($local), die("getAndSaveFile($local): $!") }
1;
}
+
sub _getAndSaveFile_progress_raw {
my ($in_wait, $msg, $size, $fh, $local) = @_;
@@ -393,6 +390,7 @@ sub _getAndSaveFile_progress_raw {
open(my $out, ">$local") or log::l("getAndSaveFile(opening $local): $!"), return;
_print_with_progress($in_wait, $msg, $size, $fh, $out) or unlink($local), die("getAndSaveFile($local): $!");
}
+
sub _print_with_progress {
my ($in_wait, $msg, $size, $in, $out) = @_;
@@ -417,19 +415,12 @@ sub _print_with_progress {
1;
}
-
sub urpmidir() {
my $v = "$::prefix/var/lib/urpmi";
-l $v && !-e $v and unlink $v and mkdir $v, 0755; #- dangling symlink
-w $v ? $v : '/tmp';
}
-sub hdlist_on_disk {
- my ($m) = @_;
-
- urpmidir() . "/hdlist.$m->{fakemedium}.cz";
-}
-
sub _allow_copy_rpms_on_disk {
my ($medium, $hdlists) = @_;
@@ -475,34 +466,33 @@ sub _parse_media_cfg {
}
sub select_only_some_media {
- my ($packages, $selected_names) = @_;
+ my ($media_list, $selected_names) = @_;
my @names = split(',', $selected_names);
- foreach my $m (@{$packages->{media}}) {
+ foreach my $m (@$media_list) {
my $bool = !member($m->{name}, @names);
# workaround urpmi transforming "ignore => ''" or "ignore => 0" into "ignore => 1":
undef $bool if !$bool;
- log::l "disabling '$m->{name}' medium: " . to_bool($bool);
+ log::l("disabling '$m->{name}' medium: " . to_bool($bool));
urpm::media::_tempignore($m, $bool);
# make sure we update un-ignored media (eg: */Testing and the like):
$m->{modified} = 1 if !$bool;
}
}
-sub configure_media {
+sub update_media {
my ($packages) = @_;
urpm::media::update_media($packages, distrib => 1, callback => \&urpm::download::sync_logger) or
log::l('updating media failed');
- urpm::media::configure($packages);
}
sub get_media {
my ($o, $media, $packages) = @_;
- use Data::Dumper;
my ($suppl_CDs, $copy_rpms_on_disk, $phys_m);
foreach (@$media) {
if ($_->{type} eq 'media_cfg') {
$phys_m = url2mounted_phys_medium($o, $_->{url}, 'media_info');
+ local $phys_m->{is_suppl} = $_->{url} ne "drakx://media"; # so that _get_media_url() works
($suppl_CDs, $copy_rpms_on_disk) = get_media_cfg($o, $phys_m, $packages, $_->{selected_names}, $_->{force_rpmsrate});
} elsif ($_->{type} eq 'media') {
$phys_m = url2mounted_phys_medium($o, $_->{url});
@@ -534,8 +524,8 @@ sub adjust_paths_in_urpmi_cfg {
$medium->{url} =~ s!^.*?/media/!$phys_m->{url}/!;
} elsif (member($phys_m->{method}, qw(disk nfs))) {
# use the real mount point:
- if ($medium->{url} =~ m!/tmp/image!) {
- $medium->{url} =~ s!/tmp/image!$phys_m->{mntpoint}!;
+ if ($medium->{url} =~ m!/tmp/image(/media)?!) {
+ $medium->{url} =~ s!/tmp/image(/media)?!$phys_m->{mntpoint}$phys_m->{rel_path}!;
} else {
# just remove $::prefix and we already have the real mount point:
$medium->{url} =~ s!^$::prefix!!;
@@ -631,7 +621,7 @@ sub _get_media_url {
my ($o, $phys_medium) = @_;
my $uri;
if ($phys_medium->{is_suppl}) {
- if (member($phys_medium->{method}, qw(ftp http))) {
+ if (member($phys_medium->{method}, qw(ftp http https))) {
$uri = $phys_medium->{url};
$uri =~ s!/media$!!;
} elsif (member($phys_medium->{method}, qw(cdrom nfs))) {
@@ -640,8 +630,8 @@ sub _get_media_url {
$uri .= "/$arch" if -d "$uri/$arch";
}
} else {
- $uri = $o->{stage2_phys_medium}{url} =~ m!^(http|ftp)://! && $o->{stage2_phys_medium}{url} ||
- $phys_medium->{method} =~ m!^(ftp|http)://! && $phys_medium->{method} || '/tmp/image';
+ $uri = $o->{stage2_phys_medium}{url} =~ m!^(https?|ftp)://! && $o->{stage2_phys_medium}{url} ||
+ $phys_medium->{method} =~ m!^(ftp|https?)://! && $phys_medium->{method} || '/tmp/image';
}
$uri;
}
@@ -658,7 +648,7 @@ sub get_media_cfg {
die "media.cfg not found";
}
- my $suppl_CDs = exists $o->{supplmedia} ? $o->{supplmedia} : $distribconf->{suppl} || 0;
+ my $suppl_CDs = defined $o->{supplmedia} ? $o->{supplmedia} : $distribconf->{suppl} || 0;
my $deselectionAllowed = $distribconf->{askmedia} || $o->{askmedia} || 0;
log::l(Data::Dumper->Dump([ $phys_medium ], [ 'phys_medium' ]));
@@ -668,18 +658,16 @@ sub get_media_cfg {
urpm::media::add_distrib_media($packages, undef, $uri, ask_media => undef); #allmedia => 1
- if (defined $selected_names) {
- select_only_some_media($packages, $selected_names);
- }
+ my @new_media = difference2($packages->{media}, \@media);
+ _associate_phys_media($o->{all_hds}, $phys_medium, \@new_media);
+
+ select_only_some_media(\@new_media, $selected_names) if defined $selected_names;
if ($deselectionAllowed && !@{$packages->{media}}) {
my $allow = _allow_copy_rpms_on_disk($phys_medium, $packages->{media});
$o->ask_deselect_media__copy_on_disk($packages->{media}, $allow && \$o->{copy_rpms_on_disk}) if $allow || @{$packages->{media}} > 1;
}
- my @new_media = difference2($packages->{media}, \@media);
- _associate_phys_media($o->{all_hds}, $phys_medium, \@new_media);
-
log::l("get_media_cfg read " . int(@{$packages->{depslist}}) . " headers");
_get_compsUsers_pl($phys_medium, $force_rpmsrate);
@@ -707,13 +695,13 @@ sub get_standalone_medium {
}
sub _get_medium {
- my ($in_wait, $phys_m, $packages, $m) = @_;
+ my ($_in_wait, $phys_m, $packages, $m) = @_;
!$m->{ignore} or log::l("ignoring packages in $m->{rel_hdlist}"), return;
my $url = _get_media_url({}, $phys_m);
log::l("trying '$url'\n");
- urpm::media::add_medium($packages, $m->{name} || 'Supplementary medium', $url) or $packages->{fatal}(10, N("unable to add medium"));
+ urpm::media::add_medium($packages, $m->{name} || 'Supplementary medium', $url, 0) or $packages->{fatal}(10, N("unable to add medium"));
}
@@ -788,7 +776,7 @@ sub clean_postinstall_rpms() {
sub copy_rpms_on_disk {
my ($o) = @_;
- my $dest_dir = '/var/ftp/pub/Mandrivalinux/media';
+ my $dest_dir = '/var/ftp/pub/Mageialinux/media';
#- don't be afraid, cleanup old RPMs if upgrade
eval { rm_rf("$::prefix$dest_dir") if $o->{isUpgrade} };
mkdir_p("$::prefix$dest_dir");
@@ -838,7 +826,7 @@ sub copy_rpms_on_disk {
sub _get_medium_dir {
my ($phys_m) = @_;
- if ($phys_m->{method} eq 'ftp' || $phys_m->{method} eq 'http' || $phys_m->{method} eq 'cdrom') {
+ if (member($phys_m->{method}, qw(ftp http https cdrom))) {
$phys_m->{url};
} else {
"$phys_m->{mntpoint}$phys_m->{rel_path}";