[debian-edu-commits] [Git][debian-edu/upstream/sitesummary][master] Introduced packageversion-summary listing versions seen for a given package.
Petter Reinholdtsen (@pere)
gitlab at salsa.debian.org
Wed Oct 4 08:30:34 BST 2023
Petter Reinholdtsen pushed to branch master at Debian Edu / upstream / sitesummary
Commits:
a62d92a7 by Petter Reinholdtsen at 2023-10-04T09:30:20+02:00
Introduced packageversion-summary listing versions seen for a given package.
- - - - -
2 changed files:
- Makefile
- + packageversion-summary
Changes:
=====================================
Makefile
=====================================
@@ -26,6 +26,7 @@ COLLECTORS = \
SUMMARYSCRIPTS = \
agesinceseen-summary \
debian-version-summary \
+ packageversion-summary \
site-summary \
hardware-model-summary \
hostclass-summary \
=====================================
packageversion-summary
=====================================
@@ -0,0 +1,83 @@
+#!/usr/bin/perl
+
+use strict;
+use warnings;
+
+use SiteSummary;
+use Getopt::Long;
+
+my %pkgvers;
+my $listhosts;
+
+sub usage {
+ my $retval = shift;
+ print <<EOF;
+Usage: $0 <packagename> [-l]
+ -l list hosts using the given kernel versions
+EOF
+ exit $retval;
+}
+
+GetOptions("l", \$listhosts) || usage(1);
+my $pkg = $ARGV[0];
+
+unless ($pkg) {
+ print <<EOF;
+Error: missing name of package to look for.
+EOF
+ usage(1);
+}
+
+for_all_hosts(\&handle_host);
+
+print_summary();
+
+sub get_pkg_ver {
+ my $pkg = shift;
+ my $hostid = shift;
+ my $path = get_filepath_current($hostid, "/debian/dpkg-l");
+ my $pver = undef;
+ if (open (FILE, $path)) {
+ while(<FILE>) {
+ chomp;
+ next unless (/^ii\s.+$/);
+ my @f = (split(/\s+/, $_));
+ if ( ($f[1] =~ m/^(.+):.+$/ && $pkg eq $1)
+ || ($pkg eq $f[1]) ) {
+ $pver = $f[2];
+ }
+ }
+ close(FILE);
+ return $pver;
+ } else {
+ return undef;
+ }
+}
+
+sub handle_host {
+ my $hostid = shift;
+ #print "$hostid\n";
+ for my $pver (get_pkg_ver($pkg, $hostid)) {
+ $pver = "<missing>" unless defined $pver;
+ if (exists $pkgvers{$pver}) {
+ push @{$pkgvers{$pver}}, $hostid ;
+ } else {
+ $pkgvers{$pver} = [$hostid];
+ }
+ }
+}
+
+sub print_summary {
+ printf(" %-20s %5s\n", "$pkg version", "count");
+ for my $pver (sort keys %pkgvers) {
+ printf(" %-20s %5d\n", $pver, scalar @{$pkgvers{$pver}});
+ if ($listhosts) {
+ for my $hostid (sort @{$pkgvers{$pver}}) {
+ my $hostname = get_hostname($hostid);
+ my $site = get_site($hostid) || "";
+ my $sitegroup = get_sitegroup($hostid) || "";
+ printf " %s %s/%s %s\n", $hostname, $site, $sitegroup, $hostid;
+ }
+ }
+ }
+}
View it on GitLab: https://salsa.debian.org/debian-edu/upstream/sitesummary/-/commit/a62d92a71b72e04336b8e904bee7c0fcc56aee4e
--
View it on GitLab: https://salsa.debian.org/debian-edu/upstream/sitesummary/-/commit/a62d92a71b72e04336b8e904bee7c0fcc56aee4e
You're receiving this email because of your account on salsa.debian.org.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://alioth-lists.debian.net/pipermail/debian-edu-commits/attachments/20231004/f4962985/attachment-0001.htm>
More information about the debian-edu-commits
mailing list