diff options
author | Martin Whitaker <mageia@martin-whitaker.me.uk> | 2018-01-04 00:13:19 +0000 |
---|---|---|
committer | Martin Whitaker <mageia@martin-whitaker.me.uk> | 2018-01-04 00:13:19 +0000 |
commit | abcda65bfa9bbf5c9448cf39af8b70214e937d87 (patch) | |
tree | 728bfa6e80c758f9322cea8fc83df1201dabc41b /lib | |
parent | ac8cba54067943f54825f9b81be21a06a0902fcf (diff) | |
download | drakiso-abcda65bfa9bbf5c9448cf39af8b70214e937d87.tar drakiso-abcda65bfa9bbf5c9448cf39af8b70214e937d87.tar.gz drakiso-abcda65bfa9bbf5c9448cf39af8b70214e937d87.tar.bz2 drakiso-abcda65bfa9bbf5c9448cf39af8b70214e937d87.tar.xz drakiso-abcda65bfa9bbf5c9448cf39af8b70214e937d87.zip |
drakclassic: support packages existing in two media classes.
This enables use of the tainted media, which provide alternative
versions of some packages that exist in the core media. This
ensures both versions are present on the ISO, so the user can
choose whether or not to enable the tainted media.
Diffstat (limited to 'lib')
-rw-r--r-- | lib/MGA/DrakISO/BuildMedia.pm | 57 |
1 files changed, 35 insertions, 22 deletions
diff --git a/lib/MGA/DrakISO/BuildMedia.pm b/lib/MGA/DrakISO/BuildMedia.pm index 9bf157f..497012a 100644 --- a/lib/MGA/DrakISO/BuildMedia.pm +++ b/lib/MGA/DrakISO/BuildMedia.pm @@ -45,8 +45,11 @@ my $urpm; # The hash key is the package name and the hash value is a hash containing the # following fields: # -# object the URPM::Package object for the newest version/release -# of that package +# base_pkg a reference to the URPM::Package object for the newest +# version/release of that package in the base media +# +# best_pkg a reference to the URPM::Package object for the newest +# version/release of that package in all media # # class undefined if the package is not selected # set to 1 if the package was explicity selected @@ -88,7 +91,9 @@ sub prepare_media { update_dependencies($build); build_installer_media($build); - check_installer_media($build); + + check_installer_media($build, ${$build->{repo}{classes}}[0]); + check_installer_media($build, '*'); my $arch = $build->{settings}{arch}; my $version = $build->{settings}{version}; @@ -172,11 +177,19 @@ sub get_available_packages { urpm::media::configure($urpm); + my $base_class = ${$build->{repo}{classes}}[0]; + $urpm->traverse(sub { my ($pkg) = @_; - my $name = $pkg->name(); - if (!defined $package{$name} || $pkg->compare_pkg($package{$name}{object}) > 0) { - $package{$name}{object} = $pkg; + my $name = $pkg->name; + my @medium = grep { $pkg->id >= $_->{start} && $pkg->id <= $_->{end} } @{$urpm->{media}} + or die "ERROR: failed to identify the medium containing the $name package\n"; + if (!defined $package{$name} || $pkg->compare_pkg($package{$name}{best_pkg}) > 0) { + $package{$name}{best_pkg} = $pkg; + } + return if $medium[0]->{name} !~ /^$base_class/; + if (!defined $package{$name}{base_pkg} || $pkg->compare_pkg($package{$name}{base_pkg}) > 0) { + $package{$name}{base_pkg} = $pkg; } }); } @@ -371,7 +384,7 @@ sub update_dependencies { my @search_list = grep { $package{$_}{class} == 1 } keys %package; while (@search_list) { foreach my $name (@search_list) { - my $pkg = $package{$name}{object}; + my $pkg = $package{$name}{best_pkg}; my $parent_name = $pkg->name(); my @requires = $pkg->requires_nosense(); $urpm->traverse_tag('whatprovides', \@requires, sub { @@ -433,16 +446,16 @@ sub build_installer_media { # single medium for each class, so we ignore the source media type. my @packages = grep { defined $package{$_}{class} } keys %package; foreach my $name (@packages) { - my $pkg = $package{$name}{object}; - my $id = $pkg->id(); - my @medium = grep { $id >= $_->{start} && $id <= $_->{end} } @{$urpm->{media}} - or die "ERROR: failed to identify the medium containing the $name package\n"; - my $src_path = $medium[0]->{url} . '/' . $pkg->filename(); - my @path_parts = split('/', $src_path); - my $class = $path_parts[-3]; - my $name = $path_parts[-1]; - my $dst_path = $media_dir . $class . '/' . $name; - copy_or_link($src_path, $dst_path); + foreach my $pkg (uniq($package{$name}{best_pkg}, $package{$name}{base_pkg})) { + defined $pkg or next; + my @medium = grep { $pkg->id >= $_->{start} && $pkg->id <= $_->{end} } @{$urpm->{media}}; + my $src_path = $medium[0]->{url} . '/' . $pkg->filename(); + my @path_parts = split('/', $src_path); + my $class = $path_parts[-3]; + my $name = $path_parts[-1]; + my $dst_path = $media_dir . $class . '/' . $name; + copy_or_link($src_path, $dst_path); + } } print " generating media info\n" if $::verbose > 1; @@ -500,14 +513,14 @@ sub create_media_cfg { } sub check_installer_media { - my ($build) = @_; + my ($build, $class) = @_; - print "Checking installer media\n" if $::verbose; + print "Checking installer media [$class]\n" if $::verbose; my $arch = $build->{settings}{arch}; - my $media_dir = $build->get_builddir('files/' . $arch . '/media/'); - my $log_file = $build->get_builddir('tmp') . '/rpmcheck.log'; - system("zcat -q $media_dir/*/media_info/hdlist.cz | rpmcheck -explain -failures > $log_file") == 0 + my $media_dir = $build->get_builddir('files/' . $arch . '/media'); + my $log_file = $build->get_builddir('tmp') . '/rpmcheck.log'; + system("zcat -q $media_dir/$class/media_info/hdlist.cz | rpmcheck -explain -failures > $log_file") == 0 or die "ERROR: failed to run rpmcheck\n"; if (system("grep -q FAILED $log_file") == 0) { |