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.pm58
1 files changed, 19 insertions, 39 deletions
diff --git a/perl-install/install/media.pm b/perl-install/install/media.pm
index 95a5728ff..149deffc3 100644
--- a/perl-install/install/media.pm
+++ b/perl-install/install/media.pm
@@ -1,4 +1,4 @@
-package install::media; # $Id: media.pm 269998 2010-06-11 17:28:57Z blino $
+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) = @_;
@@ -81,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) = @_;
@@ -172,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;
@@ -348,10 +336,10 @@ sub getFile_ {
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!^/!) {
@@ -433,12 +421,6 @@ sub urpmidir() {
-w $v ? $v : '/tmp';
}
-sub hdlist_on_disk {
- my ($m) = @_;
-
- urpmidir() . "/hdlist.$m->{fakemedium}.cz";
-}
-
sub _allow_copy_rpms_on_disk {
my ($medium, $hdlists) = @_;
@@ -486,27 +468,25 @@ sub _parse_media_cfg {
sub select_only_some_media {
my ($media_list, $selected_names) = @_;
my @names = split(',', $selected_names);
- foreach my $m (@{$media_list}) {
+ 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) {
@@ -544,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!!;
@@ -641,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))) {
@@ -650,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;
}
@@ -668,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' ]));
@@ -715,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"));
}
@@ -846,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}";