[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Bug#1028210: check-dfsg-status: add support for non-free-firmware/ and local/



Package: check-dfsg-status
Version: 1.32
Severity: normal
X-Debbugs-Cc: debian-devel-games@lists.debian.org


Hi,

I was playing around adding detection for "local/" in this tool.
I did like how it was done for contrib/: a lot of copy-pasting.
(see this ugly patch in attachment).


Now I realize all this code should be copy-pasted once again
for "non-free-firmware/" which feels wrong.

By the way the current regexp works by luck but does not
seems to work by design; so I get false positives
for packages actually in (main)/locales.


I would factorize this duplicated/triplicated code,
but I just don't know Perl engouh.


The "local/" trick could later be mandated for other tools that
generate or handle locally built .deb not meant to me distributed,
like "non-free" but even worse/restrictive;
which now get mixed up with the official packages.

Greetings,

------------------------


Sample output:

========================================

             Locally built packages installed on brix

! debconf-i18n                        full internationalization support for debconf
  doom-wad                            IWAD for "Doom" game
  doom2-masterlevels-wad              game PWAD for Master Levels for DOOM II
  doom2-nerve-wad                     game PWAD for Doom 2: No Rest for the Living
  doom2-wad                           game IWAD for Doom 2: Hell on Earth
! gnupg-l10n                          GNU privacy guard - localization files
  griffon-legend-data                 game data for The Griffon Legend
  grimfandango-demo-en-data           game data for Grim Fandango (demo)
  hhgg-data                           game data for The Hitchhiker's Guide to the Galaxy
  jazz-jackrabbit-hh95-data           game data for Jazz Jackrabbit Holiday Hare '95

.... .... ....

  Locally built packages with status other than installed on brix


grimfandango-fr-data                ( ins)

  12 non-free packages, 0.4% of 3396 installed packages.
!  -> missing one count for non-free-firmware
  16 contrib packages, 0.5% of 3396 installed packages.
  77 local packages, 2.3% of 3396 installed packages.


-- System Information:
Debian Release: bookworm/sid
  APT prefers testing
  APT policy: (501, 'testing'), (450, 'unstable')
Architecture: amd64 (x86_64)
Foreign Architectures: i386

Kernel: Linux 6.0.0-6-amd64 (SMP w/2 CPU threads; PREEMPT)
Locale: LANG=fr_BE.UTF-8, LC_CTYPE=fr_BE.UTF-8 (charmap=UTF-8), LANGUAGE=fr_BE:fr
Shell: /bin/sh linked to /usr/bin/dash
Init: systemd (via /run/systemd/system)

-- no debconf information
--- /usr/bin/check-dfsg-status	2021-04-09 23:09:03.000000000 +0200
+++ check-dfsg-status	2022-12-30 16:29:30.215084872 +0100
@@ -108,6 +108,10 @@
 my %contrib = ();
 my $is_other_contrib = 0;	###  preset none found, yet
 my %other_contrib = ();
+my $is_local = 0;		###  preset none found, yet
+my %local = ();
+my $is_other_local = 0;		###  preset none found, yet
+my %other_local = ();
 my %pkg_status = ();
 my $pkgcnt = 0;
 my $clumpcnt = 0;
@@ -167,7 +171,7 @@
 		($label, $section) = split(/:\s+/,$_,2);
 		print "\tsection=[$section]\n" if $debug >= 1;
 		$has_section = 1;	###  we have necessary section
-		if ($section =~ /contrib|non-free|restricted|multiverse|partner/) {
+		if ($section =~ /contrib|non-free|restricted|multiverse|partner|local/) {
 		    ###  read thru rest of array to find descr instead of waiting for it
 		    my $found_descr =0;
 		    while (! $found_descr) {
@@ -191,6 +195,14 @@
 			    $is_other_contrib = 1;
 			    $other_contrib{$pkg} = $shortdescr;
 			}
+		    } elsif ($section =~ /local/) {
+			if (lc $status eq 'installed') {
+			    $is_local = 1;
+			    $local{$pkg} = $shortdescr;
+			} else {
+			    $is_other_local = 1;
+			    $other_local{$pkg} = $shortdescr;
+			}
 		    } else {
 			if (lc $status eq 'installed') {
 			    $is_nonfree = 1;
@@ -276,6 +288,8 @@
     }
 }
 
+##################################################################
+
 my $cbcnt = 0;
 
 my $contribcnt = (keys %contrib);
@@ -321,6 +335,53 @@
     }
 }
 
+##################################################################
+
+my $loccnt = 0;
+
+my $localcnt = (keys %local);
+
+if($is_contrib) {
+    print "\n";
+    if($sparse) {
+	foreach $pkgname (sort keys (%local)) {
+	    $localcnt++;
+	    print "$pkgname\n";
+	}
+    } else {
+	$~ = "local_head";
+	write ;
+	$~ = "locp";
+	foreach $pkgname (sort keys(%local) ) {
+	    $localcnt++;
+	    write ;
+	    print "  Reason: $reason{$pkgname}\n"
+		if (exists $reason{$pkgname} and $explain);
+	}
+    }
+}
+
+my $ploccnt = 0;
+my $other_localcnt = (keys %other_local);
+if($is_local) {
+    if($sparse) {
+	foreach $pkgname (sort keys(%other_local)) {
+	    $ploccnt++;
+	    print "$pkgname\n";
+	}
+    } else {
+	$~ = "local_partialhead";
+	write;
+	$~ = "ploc";
+	foreach $pkgname (sort keys(%other_local)) {
+	    $ploccnt++;
+	    write;
+	    print "  Reason: $reason{$pkgname}\n"
+		if (exists $reason{$pkgname} and $explain);
+	}
+    }
+}
+
 if (!$quiet and !$sparse) {
     printf "\n";
     if ($nfcnt != 0 or $pnfcnt != 0) {
@@ -337,6 +398,13 @@
 	printf "  %d contrib packages, %2.1f%% of %d installed packages.\n", 
 	$total_contrib, $percentage, $total_installed;
     }
+    if ($loccnt != 0 or $ploccnt != 0) {
+	my $total_local = $localcnt + $other_localcnt;
+	my $total_installed = $pkgcnt;
+	my $percentage = $total_local * 100 / $total_installed;
+	printf "  %d local packages, %2.1f%% of %d installed packages.\n", 
+	$total_local, $percentage, $total_installed;
+    }
 }
 if (!$quiet and $nfcnt == 0 and $pnfcnt == 0 and $cbcnt == 0 and $pcbcnt == 0) {
     print "No non-free or contrib packages installed on $sysname!  You have completed the first step to enlightenment.\n"
@@ -366,6 +434,18 @@
 "Contrib packages with status other than installed on $sysname"
 
 .
+format local_head =
+@||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
+"Locally built packages installed on $sysname"
+
+.
+format local_partialhead =
+
+@||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
+"Locally built packages with status other than installed on $sysname"
+
+
+.
 
 format nfp =
 @<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< @<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
@@ -386,3 +466,13 @@
 @<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< @<@<<@< @<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
 $pkgname, '(', $pkg_status{$pkgname},')', $other_contrib{$pkgname}
 .
+
+format locp =
+@<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< @<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
+$pkgname, $local{$pkgname}
+.
+
+format ploc =
+@<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< @<@<<@< @<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
+$pkgname, '(', $pkg_status{$pkgname},')', $other_local{$pkgname}
+.

Reply to: