summaryrefslogtreecommitdiffstats
path: root/lib/MGA
diff options
context:
space:
mode:
authorMartin Whitaker <mageia@martin-whitaker.me.uk>2022-09-24 12:20:17 +0100
committerMartin Whitaker <mageia@martin-whitaker.me.uk>2022-09-24 12:31:35 +0100
commit1ab4a92f0d6713cd316e46ad9a6b5c7d83ab0417 (patch)
tree2c1fa1d8339369de5f511718efa5567bc6f0c5cc /lib/MGA
parentd1784e90a0be98720cdcba429f774143674eeae9 (diff)
downloaddrakiso-1ab4a92f0d6713cd316e46ad9a6b5c7d83ab0417.tar
drakiso-1ab4a92f0d6713cd316e46ad9a6b5c7d83ab0417.tar.gz
drakiso-1ab4a92f0d6713cd316e46ad9a6b5c7d83ab0417.tar.bz2
drakiso-1ab4a92f0d6713cd316e46ad9a6b5c7d83ab0417.tar.xz
drakiso-1ab4a92f0d6713cd316e46ad9a6b5c7d83ab0417.zip
Simplify BuildMedia::create_index().
Code improvement - no functional change.
Diffstat (limited to 'lib/MGA')
-rw-r--r--lib/MGA/DrakISO/BuildMedia.pm22
1 files changed, 10 insertions, 12 deletions
diff --git a/lib/MGA/DrakISO/BuildMedia.pm b/lib/MGA/DrakISO/BuildMedia.pm
index b7a377d..ffff043 100644
--- a/lib/MGA/DrakISO/BuildMedia.pm
+++ b/lib/MGA/DrakISO/BuildMedia.pm
@@ -622,26 +622,24 @@ sub create_index {
my $media_dir = $build->get_build_dir('files/' . $arch . '/media/');
my @hdlists = glob("$media_dir/*/media_info/hdlist.cz");
- my @tab;
+ my %pkgs;
my $urpm = URPM->new;
foreach (@hdlists) {
$urpm->parse_hdlist($_);
- $urpm->traverse(sub {
- my $pkg = shift;
- my $pkgname = $pkg->name;
- my $version = $pkg->version;
- my $arch = $pkg->arch;
- push @tab, "$pkgname-$version ($arch)";
- });
}
-
- my %hashtab = map { $_ => 1 } @tab;
- my @orderedpkgs = sort keys %hashtab;
+ $urpm->traverse(sub {
+ my ($pkg) = @_;
+ my $pkgname = $pkg->name;
+ my $version = $pkg->version;
+ my $arch = $pkg->arch;
+ $pkgs{"$pkgname-$version ($arch)"} = 1;
+ });
+ my @ordered_pkgs = sort keys %pkgs;
my $label = $build->{media}{label};
open(my $f, '>', $file);
- foreach (@orderedpkgs) {
+ foreach (@ordered_pkgs) {
print $f "$label $_\n";
}
close($f);