[SCM] pkg-kde repository scripts branch, master, updated. 40371f7be569f9a44d95fd99faa38a36f9235a1d

Modestas Vainius modax at alioth.debian.org
Fri Mar 5 20:28:38 UTC 2010


The following commit has been merged in the master branch:
commit 40371f7be569f9a44d95fd99faa38a36f9235a1d
Author: Modestas Vainius <modestas at vainius.eu>
Date:   Fri Mar 5 22:27:44 2010 +0200

    reprepro-html-index: group binary-only packages in the output as well.
---
 reprepro-html-index |   58 ++++++++++++++++++++++++++++++++++++++++++++++----
 1 files changed, 53 insertions(+), 5 deletions(-)

diff --git a/reprepro-html-index b/reprepro-html-index
index 47b3d62..8f5b756 100755
--- a/reprepro-html-index
+++ b/reprepro-html-index
@@ -202,6 +202,22 @@ sub get_binary_packages {
 	return grep { not $_->is_source() } values %{$self->{allpkgs}};
 }
 
+sub get_binpkgs_archver_summary {
+	my $self=shift;
+	my %byname;
+	foreach my $pkg ($self->get_binary_packages()) {
+		push @{$byname{$pkg->get_name()}}, $pkg;
+	}
+	foreach my $name (keys %byname) {
+		my %archver;
+		foreach my $pkg (@{$byname{$name}}) {
+			$archver{$pkg->get_repoarch()}{$pkg->get_version()} = $pkg;
+		}
+		$byname{$name} = \%archver;
+	}
+	return \%byname;
+}
+
 sub read_all_packages {
 	my $self=shift;
 	my $reprepro = new KdeTrunk::Reprepro(
@@ -334,12 +350,44 @@ sub print_html_summary {
 	}
 
 	# Binary-only packages
-	foreach my $pkg (sort { $a->get_name() cmp $b->get_name() }
-                         $self->get_binary_packages()) {
+	my $all_archver = $self->get_binpkgs_archver_summary();
+	foreach my $name (sort { $a cmp $b }
+	                       keys %$all_archver) {
+		my $archver = $all_archver->{$name};
+		my $onlyverpkg;
+		pkg_archver: foreach my $arch (keys %$archver) {
+			for my $ver (keys %{$archver->{$arch}}) {
+				if (! defined $onlyverpkg) {
+					$onlyverpkg = $archver->{$arch}{$ver};
+				} elsif ($onlyverpkg->get_version() ne $ver) {
+					$onlyverpkg = undef;
+					last pkg_archver;
+				}
+			}
+		}
 		print '<tr>', "\n";
-		print '<td>', '<a href="', $pkg->get_path(), '">', $pkg->get_name(), '</a></td>', "\n";
-		print '<td>', $pkg->get_version(), '</td>', "\n";
-		print '<td>', $pkg->get_repoarch(), '(', $pkg->get_arch(), ')', '</td>', "\n";
+		if (defined $onlyverpkg) {
+			my $path = $onlyverpkg->get_path();
+			# Strip the filename, leave path
+			$path =~ s,[^/]+$,,;
+			print '<td>', '<a href="', $path, '">', $name, '</a></td>', "\n";
+			print '<td>', $onlyverpkg->get_version(), '</td>', "\n";
+			print '<td>', join(", ", map {
+					sprintf("%s/%s",  $_, (values %{$archver->{$_}})[0]->get_arch()) }
+					keys %$archver), '</td>', "\n";
+			print '</tr>', "\n";
+		} else {
+			print '<td>', $name, '</td>', "\n";
+			print '<td>&nbsp;</td>', "\n";
+			print '<td>', "\n";
+			for my $arch (sort(keys %$archver)) {
+				my $vers = $archver->{$arch};
+				print $arch, ": ", join(", ",
+					map { sprintf('<a href="%s">%s</a>', $vers->{$_}->get_path(), $_) }
+						keys %$vers), ";";
+			}
+			print '</td>', "\n";
+		}
 		print '</tr>', "\n";
 	}
 	print '</tbody>', "\n";

-- 
pkg-kde repository scripts



More information about the pkg-kde-commits mailing list