aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rwxr-xr-xiurt239
-rw-r--r--lib/Iurt/Chroot.pm27
-rw-r--r--lib/Iurt/Urpmi.pm12
3 files changed, 49 insertions, 29 deletions
diff --git a/iurt2 b/iurt2
index 2f5691b..991ce43 100755
--- a/iurt2
+++ b/iurt2
@@ -275,12 +275,39 @@ $run{todo} = [];
($run{with_flags}) = $run{with_flags} . " --without " . @_[0];
1;
}, "Adding specified extra --without parameter to rpm" ],
- [ "", "additional-media", 1, "<path>",
- "Includes an additional media",
- sub {
- $run{additional_media} ||= [];
- push @{$run{additional_media}}, @_[0];
- }, "Adding an additional media" ],
+ # [ short option, long option, # of args, syntax description,
+ # action description, action, execution message ]
+ #############################
+ [ "", "additional-media",
+ [
+ [ "", "additional-media", 1, "",
+ "Use additional medias (media prefix is like http:///server.mandriva.com/dis/)",
+ sub {
+ my ($tmp, @arg) = @_;
+ $tmp->[0] ||= {};
+ push @$tmp, @arg;
+ 1;
+ }, "Setting additional medias options"
+ ],
+ [ "m", "media", -1, "<media1> <media2> ... <median>",
+ "Media to add instead of --distrib",
+ sub {
+ my ($tmp, @media) = @_;
+ $tmp->[0]{media} = \@media;
+ 1
+ }, "Limiting rebuild to the kernel in the given media regexp"
+ ],
+ ],
+ "[options] <media prefix>",
+ "Also uses these medias (media prefix is like http:///server.mandriva.com/dis/)",
+ sub {
+ my ($opt, $media) = @_;
+ $opt->{repository} = $media;
+ $run{additional_media} = $opt;
+ 1
+ }, "Activating additional medias"
+ ],
+ ###############################
[ "", "icecream", 1, "<procs>",
"Enables icecream usage by <procs> procs",
sub {
diff --git a/lib/Iurt/Chroot.pm b/lib/Iurt/Chroot.pm
index 9b465de..42974bc 100644
--- a/lib/Iurt/Chroot.pm
+++ b/lib/Iurt/Chroot.pm
@@ -49,7 +49,7 @@ sub clean_chroot {
system("$sudo umount $chroot/var/cache/icecream &> /dev/null");
}
if (-d "$chroot/urpmi_medias/") {
- system ("$sudo umount $chroot/urpmi_medias/*");
+ system ("$sudo umount $chroot/urpmi_medias");
}
sudo($run, $config, '--rm', '-r', $chroot);
}
@@ -75,21 +75,16 @@ sub clean_chroot {
system("$sudo mount -o bind /var/cache/icecream $chroot/var/cache/icecream &>/dev/null") and return;
}
- my $count = 0;
- foreach my $m (@{$run->{additional_media}}) {
- if (($m =~ m/^(http:|ftp:)/)) {
- next;
+ if ($run->{additional_media} && $run->{additional_media}{repository}) {
+ my $rep = $run->{additional_media}{repository};
+ if (!($rep =~ m/^(http:|ftp:)/)) {
+ my $mount_point = "$chroot/urpmi_medias";
+ my $bind;
+ my $url = $rep;
+ $url =~ s!^file://!!;
+ system("$sudo mkdir -p $mount_point");
+ system("$sudo mount -o bind $url $mount_point") and return;
}
- my $mount_point = "$chroot/urpmi_medias/$count";
- my $bind;
- my ($url) = $m;
- $url =~ s!^(http://|ftp://|file://)!!;
- if (($m =~ m/^(file:)/)) {
- $bind = "-o bind";
- }
- system("$sudo mkdir -p $mount_point");
- system("$sudo mount $bind $url $mount_point") and return;
- $count++;
}
1;
}
@@ -500,7 +495,7 @@ sub build_chroot {
system("$sudo umount $tmp_chroot/var/cache/icecream &> /dev/null");
}
if (-d "$tmp_chroot/urpmi_medias/") {
- system ("$sudo umount $tmp_chroot/urpmi_medias/*");
+ system ("$sudo umount $tmp_chroot/urpmi_medias");
}
return !system($sudo, 'tar', 'czf', $chroot_tar, '-C', $tmp_chroot, '.');
}
diff --git a/lib/Iurt/Urpmi.pm b/lib/Iurt/Urpmi.pm
index c004def..091630d 100644
--- a/lib/Iurt/Urpmi.pm
+++ b/lib/Iurt/Urpmi.pm
@@ -110,17 +110,15 @@ sub urpmi_command {
}
}
- my $count = 0;
- foreach my $m (@{$run->{additional_media}}) {
- my $name = $m;
+ foreach my $m (@{$run->{additional_media}{media}}) {
+ my $name = "$run->{additional_media}{repository}_$m";
$name =~ s![/:]!_!g;
my $url;
- if (($m =~ m!^(http:|ftp:)!)) {
- $url = $m;
+ if (($run->{additional_media}{repository} =~ m!^(http:|ftp:)!)) {
+ $url = $run->{additional_media}{repository};
}
else {
- $url = "/urpmi_medias/$count";
- $count++;
+ $url = "/urpmi_medias/media/$m";
}
if (!add_media($self, $chroot_tmp, $name, "$name $url")) {
plog("ERROR: Unable to add media $m");