+###### Get list of packages that can be manually maintained
+print "getting restricted package versions\n" if $debug;
+my %restrpkgs;
+my $restplines = `$restrictedpackages`
+ or die "Could not get the list of restricted packages " .
+ "from $restrictedpackages: $! ";
+print "Got package list: \n$restplines\n" if $debug>2;
+my $pname;
+my $pver;
+for my $pline ( split("\n",$restplines) ) {
+ chomp($pline);
+ $pname = $1 if $pline =~ /^Package:\s+(\S*)\s*$/;
+ $pver = $1 if $pline =~ /^Version:\s+(\S*)\s*$/;
+ print "$pline: p=$pname v=$pver\n" if $debug>2;
+ if ( $pname && $pver ) {
+ print "\nPackage $pname version $pver \n" if $debug>2;
+ if ( ! $restrpkgs{$pname} ) {
+ $restrpkgs{$pname} = $pver;
+ print "found $pname, first version $pver\n" if $debug>1;
+ } else {
+ my $bver = $restrpkgs{$pname};
+ `dpkg --compare-versions "$bver" lt "$pver" `;
+ if ( ! $? ) {
+ print "found $pname, better version $pver (better than $bver)\n"
+ if $debug>1;
+ $restrpkgs{$pname} = $pver;
+ } else {
+ print "found $pname, but version $pver is no better than $bver\n"
+ if $debug>2;
+ }
+ }
+ $pname = ""; # clear for the next one.
+ $pver = "";
+ }
+}
+
+if ( $debug >1 ) {
+ print "got " . scalar(keys(%restrpkgs)) . " restricted packages\n";
+ for $pname ( sort (keys(%restrpkgs)) ) {
+ print " $pname " . $restrpkgs{$pname} . "\n";
+ }
+}
+