Author: camerons-guest Date: 2009-01-14 10:50:00 +0000 (Wed, 14 Jan 2009) New Revision: 1842
Modified: scripts/dgis-status.pl Log: Now includes a -u option to display table as ubuntu - plus a number of other tweaks Modified: scripts/dgis-status.pl =================================================================== --- scripts/dgis-status.pl 2009-01-14 10:30:54 UTC (rev 1841) +++ scripts/dgis-status.pl 2009-01-14 10:50:00 UTC (rev 1842) @@ -1,27 +1,39 @@ #!/usr/bin/perl # -# dgis-status.pl - DebianGis packages status script +# dgis-status.pl - UbuntuGIS/DebianGis packages status script # -# $Id$ -# -# Copyright 2005-2007 (C) Francesco P. Lovergine <fran...@debian.org> -# -# This program is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 2 of the License, or -# (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -# -# On Debian GNU/Linux GPL is available under /usr/share/common-licenses -# +# $Id$ +# +# Copyright 2005-2007 (C) Francesco P. Lovergine <fran...@debian.org> +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +# +# On Debian GNU/Linux GPL is available under /usr/share/common-licenses +# +# Installation: +# On a Debian based system, +# apt-get install libsvn-perl libcache-apt-perl +# +# Usage: +# For available options type: +# debian-status.pl -h +# +# Authors: +# Francesco P. Lovergine (original author of dgis-status.pl) +# Cameron Shorter (extended to Ubuntu) +# use strict 'vars'; @@ -33,73 +45,146 @@ use AptPkg::System '$_system'; use AptPkg::Version; -getopts ('odhvf:'); # -o option: only do difference (no wget) -our($opt_o, $opt_h, $opt_v, $opt_b, $opt_c, $opt_d, $opt_f); +getopts('odhuvf:'); # -o option: only do difference (no wget) +our ( $opt_o, $opt_h, $opt_u, $opt_v, $opt_b, $opt_c, $opt_d, $opt_f ); -push @INC, $ENV{'HOME'}."/pkg-grass/scripts"; +#push @INC, $ENV{'HOME'}."/pkg-grass/scripts"; +push @INC, $ENV{'HOME'} . "work/ubuntugis/pkg-grass/scripts"; +#my $_stable = "fred"; +#my $_unstable = "fred"; +#my $_ubuntu = "fred"; +#my $_testing = "fred"; my $svn_repo = "svn://svn.debian.org/pkg-grass"; my $web_repo = "http://svn.debian.org/wsvn/pkg-grass"; require "dgis-packages.inc"; -my %wget = ( 'quiet' => 'wget --passive-ftp --quiet -O ','verbose' => 'wget --passive-ftp -O ' ); -my %gunzip = ( 'quiet' => 'gunzip --force --quiet ', 'verbose' => 'gunzip --force' ); -my %paths = ( - 'stable' => ["http://ftp.nl.debian.org/debian/dists/stable/main/source/", - "http://ftp.nl.debian.org/debian/dists/stable/non-free/source/", - "http://ftp.it.debian.org/debian/dists/stable/contrib/source/"], - 'testing' => ["http://ftp.nl.debian.org/debian/dists/testing/main/source/", - "http://ftp.nl.debian.org/debian/dists/testing/non-free/source/", - "http://ftp.it.debian.org/debian/dists/testing/contrib/source/"], - 'unstable' => ["http://ftp.nl.debian.org/debian/dists/unstable/main/source/", - "http://ftp.nl.debian.org/debian/dists/unstable/non-free/source/", - "http://ftp.it.debian.org/debian/dists/unstable/contrib/source/"], - 'bpo' => ["http://www.backports.org/debian/dists/etch-backports/main/source/", - "http://www.backports.org/debian/dists/etch-backports/non-free/source/", - "http://www.backports.org/debian/dists/etch-backports/contrib/source/"], +my %wget = ( + 'quiet' => 'wget --passive-ftp --quiet -O ', + 'verbose' => 'wget --passive-ftp -O ' ); +my %gunzip = + ( 'quiet' => 'gunzip --force --quiet ', 'verbose' => 'gunzip --force' ); +my %paths = ( + 'stable' => [ + "http://ftp.nl.debian.org/debian/dists/stable/main/source/", + "http://ftp.nl.debian.org/debian/dists/stable/non-free/source/", + "http://ftp.it.debian.org/debian/dists/stable/contrib/source/" + ], + 'testing' => [ + "http://ftp.nl.debian.org/debian/dists/testing/main/source/", + "http://ftp.nl.debian.org/debian/dists/testing/non-free/source/", + "http://ftp.it.debian.org/debian/dists/testing/contrib/source/" + ], + 'unstable' => [ + "http://ftp.nl.debian.org/debian/dists/unstable/main/source/", + "http://ftp.nl.debian.org/debian/dists/unstable/non-free/source/", + "http://ftp.it.debian.org/debian/dists/unstable/contrib/source/" + ], + 'bpo' => [ + "http://www.backports.org/debian/dists/etch-backports/main/source/", + "http://www.backports.org/debian/dists/etch-backports/non-free/source/", + "http://www.backports.org/debian/dists/etch-backports/contrib/source/" + ], + 'jaunty' => [ + "http://archive.ubuntu.com/ubuntu/dists/jaunty/main/source/", + "http://archive.ubuntu.com/ubuntu/dists/jaunty/multiverse/source/", + "http://archive.ubuntu.com/ubuntu/dists/jaunty/restricted/source/", + "http://archive.ubuntu.com/ubuntu/dists/jaunty/universe/source/" + ], + 'intrepid' => [ + "http://archive.ubuntu.com/ubuntu/dists/intrepid/main/source/", + "http://archive.ubuntu.com/ubuntu/dists/intrepid/multiverse/source/", + "http://archive.ubuntu.com/ubuntu/dists/intrepid/restricted/source/", + "http://archive.ubuntu.com/ubuntu/dists/intrepid/universe/source/" + ], + 'hardy' => [ + "http://archive.ubuntu.com/ubuntu/dists/hardy/main/source/", + "http://archive.ubuntu.com/ubuntu/dists/hardy/multiverse/source/", + "http://archive.ubuntu.com/ubuntu/dists/hardy/restricted/source/", + "http://archive.ubuntu.com/ubuntu/dists/hardy/universe/source/" + ], + 'gutsy' => [ + "http://archive.ubuntu.com/ubuntu/dists/gutsy/main/source/", + "http://archive.ubuntu.com/ubuntu/dists/gutsy/multiverse/source/", + "http://archive.ubuntu.com/ubuntu/dists/gutsy/restricted/source/", + "http://archive.ubuntu.com/ubuntu/dists/gutsy/universe/source/" + ], + 'dapper' => [ + "http://archive.ubuntu.com/ubuntu/dists/dapper/main/source/", + "http://archive.ubuntu.com/ubuntu/dists/dapper/multiverse/source/", + "http://archive.ubuntu.com/ubuntu/dists/dapper/restricted/source/", + "http://archive.ubuntu.com/ubuntu/dists/dapper/universe/source/" + ], +); +# Output different columns for Ubuntu report +my @versions; +if ($opt_u) { + @versions = ( + "stable", "testing", "unstable", "bpo", + "jaunty", "intrepid", "hardy", "gutsy", + "dapper" + ); +} +else { + @versions = ( "stable", "testing", "unstable", "bpo" ); +} +my $ubuntuVer = "jaunty"; my $sources = "Sources"; my $sourcesgz = "$sources.gz"; my $verbose = 0; -my $debug = $opt_d; -my $verbose = $opt_v ? 'verbose' : 'quiet'; +my $debug = $opt_d; +my $verbose = $opt_v ? 'verbose' : 'quiet'; if ($opt_h) { - print STDERR <<EOT; + print STDERR <<EOT; usage: $0 [-odvh] options: -h this help... -o ONLY calculate differences on local files (don't wget Sources.gz) +-u Include Ubuntu status in output -d debug -v verbose EOT - exit; + exit; } +my $title; +if ($opt_u) { + $title = "UbuntuGIS"; +} +else { + $title = "DebianGIS"; +} + sub GetSvnUrl { - my ($source_package,$file_name) = @_; + my ( $source_package, $file_name ) = @_; - eval { - my $client = SVN::Client->new(auth => [SVN::Client::get_simple_provider()]); - my $dirent = $client->ls("$svn_repo/packages/$source_package/trunk/debian/$file_name",'HEAD',1); - }; - return undef if $@; - return "$web_repo/packages/$source_package/trunk/debian/$file_name?op=file&rev=0&sc=0"; + eval { + my $client = + SVN::Client->new( auth => [ SVN::Client::get_simple_provider() ] ); + my $dirent = $client->ls( + "$svn_repo/packages/$source_package/trunk/debian/$file_name", + 'HEAD', 1 ); + }; + return undef if $@; + return +"$web_repo/packages/$source_package/trunk/debian/$file_name?op=file&rev=0&sc=0"; } - -unless ($opt_o) { # Skip wget if -o option "only difference" - for my $s ( keys %paths ) { - unlink "$s.$sources" if -f "$s.$sources"; - for my $i ( 0 .. $#{$paths{$s}} ) { - system ("$wget{$verbose} $s.$sourcesgz $paths{$s}->[$i]/$sourcesgz"); - system ("$gunzip{$verbose} -c $s.$sourcesgz >> $s.$sources") if -f "$s.$sourcesgz"; - unlink "$s.$sourcesgz" if -f "$s.$sourcesgz"; - } - } +unless ($opt_o) { # Skip wget if -o option "only difference" + for my $s ( keys %paths ) { + unlink "$s.$sources" if -f "$s.$sources"; + for my $i ( 0 .. $#{ $paths{$s} } ) { + system("$wget{$verbose} $s.$sourcesgz $paths{$s}->[$i]/$sourcesgz"); + system("$gunzip{$verbose} -c $s.$sourcesgz >> $s.$sources") + if -f "$s.$sourcesgz"; + unlink "$s.$sourcesgz" if -f "$s.$sourcesgz"; + } + } } #system("$wget{$verbose} bugs.txt http://merkel.debian.org/~hertzog/pts/bugs.txt"); @@ -109,28 +194,28 @@ my %tot_pkgs = undef; for my $s ( keys %paths ) { - $files{$s} = new FileHandle "<$s.$sources"; - die "Cannot open $s: $!\n" if ! defined $files{$s}; - IO::Handle->input_record_separator("\n\n"); - binmode $files{$s},":unix" if $] > 5.007; # To avoid UTF-8 interpretation as in perl 5.8... + $files{$s} = new FileHandle "<$s.$sources"; + die "Cannot open $s: $!\n" if !defined $files{$s}; + IO::Handle->input_record_separator("\n\n"); + binmode $files{$s}, ":unix" + if $] > 5.007; # To avoid UTF-8 interpretation as in perl 5.8... } +for my $p ( keys %main::dgislist ) { $dgishash{$p} = {}; } -for my $p (keys %main::dgislist) { $dgishash{$p} = {}; } - for my $s ( keys %paths ) { - $tot_pkgs{$s} = 0; - my $F = $files{$s}; - while ( <$F> ) { - if (/Package:\s(\S+).*\nVersion:\s(\S+)/s) { - my $package = $1; - my $version = $2; - if ( defined $dgishash{$package} ) { - $dgishash{$package}->{$s}="$version"; - } - } - $tot_pkgs{$s}++; - } + $tot_pkgs{$s} = 0; + my $F = $files{$s}; + while (<$F>) { + if (/Package:\s(\S+).*\nVersion:\s(\S+)/s) { + my $package = $1; + my $version = $2; + if ( defined $dgishash{$package} ) { + $dgishash{$package}->{$s} = "$version"; + } + } + $tot_pkgs{$s}++; + } } print <<EOF; @@ -139,113 +224,217 @@ <style type="text/css"> <!-- table.pkg { - border-collapse: collapse; + border-collapse: collapse; } .pkg th, .pkg td { - text-align: left; - border: 1px solid black; - padding: 0.2em; + text-align: left; + border: 1px solid black; + padding: 0.2em; } .pkg thead { - background-color: silver; - color: #000000; + background-color: silver; + color: #000000; } table.pkg tr.title { - color: #ffffff; - background-color: #df0451; + color: #ffffff; + background-color: #df0451; } -table.pkg tr.orange { - color: #000000; - background-color: #f09005; + +/* orange */ +table.pkg tr.ubuntuOutOfDate { + color: #000000; + background-color: #f09005; } -table.pkg tr.yellow { - color: #000000; - background-color: #f0f005; + +/* white */ +table.pkg tr.unpackaged { + color: #000000; + background-color: #ffffff; } -table.pkg tr.green { - color: #000000; - background-color: #a0f005; + +/* yellow */ +table.pkg tr.debianOutOfDate { + color: #000000; + background-color: #f0f005; } -table.pkg tr.red { - color: #000000; - background-color: #f03000; + +/* green */ +table.pkg tr.upToDate { + color: #000000; + background-color: #a0f005; } + +/* red */ +table.pkg tr.obsolete { + color: #000000; + background-color: #f03000; +} table.pkg tr.othered { - color: #000000; - background-color: #dc5858; + color: #000000; + background-color: #dc5858; } --> </style> <head> - <title>DebianGis Status</title> + <title>$title Package Thermometer</title> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> </head> <body> -<p /><em>Go to <a href="http://wiki.debian.org/DebianGis">DebianGis Wiki</a></em> +<small> +<p><a href="http://wiki.debian.org/DebianGis">DebianGIS home</a> | +<a href="https://wiki.ubuntu.com/UbuntuGIS">UbuntuGIS home</a> | +<a href="http://pkg-grass.alioth.debian.org/debiangis-status.html">DebianGis packages thermometer</a> | +<a href="http://pkg-grass.alioth.debian.org/ubuntugis-status.html">UbuntuGis packages thermometer</a>.</p> +</small> <table border=0 cellspacing=10 cellpadding=5> <tr><td valign=top> <table class='pkg'> -<caption><h3>DebianGis Source Packages</h3></caption> +<caption><h3>$title Package Thermometer</h3></caption> <tr class='title'> -<TH />Package -<TH />Stable -<TH />Testing -<TH />Unstable -<TH />Backports.org -</tr> +<TH>Package</TH> EOF +for my $v (@versions) { + print("<TH>$v</TH>"); +} +print("</tr>"); + $_config->init; $_system = $_config->system; my $vs = $_system->versioning; for my $p ( sort keys %dgishash ) { - next unless $p; - for my $s ( keys %paths ) { - $dgishash{$p}->{$s} = " " unless $dgishash{$p}->{$s}; - } - my $p_url = "<strong>$p</strong>"; - my $tr_class = "class='green'"; - my $pkg_url = $main::dgislist{$p}->{url}; - my $todo_url = &GetSvnUrl($p,'TODO'); - if ( $dgishash{$p}->{stable} ne " " || $dgishash{$p}->{unstable} ne " " ) { - $p_url .= " (<a href='http://packages.qa.debian.org/$p'>PTS</a>,"; - } - else { - $p_url .= " (" if $pkg_url; - my $pkg_wnpp = $main::dgislist{$p}->{wnpp}; - $p_url .= "<a href='http://bugs.debian.org/$pkg_wnpp'>WNPP</a>," if $pkg_wnpp; - } - $p_url .= "<a href='$todo_url'>TODO</a>," if $todo_url; - $p_url .= "<a href='$pkg_url'>UP</a>)" if $pkg_url; - if ( $dgishash{$p}->{unstable} ne " " && $dgishash{$p}->{stable} eq " " ) { - $tr_class = "class='green'"; - } - if ( $dgishash{$p}->{unstable} eq " " && $dgishash{$p}->{stable} eq " " ) { - $tr_class = "class='yellow'"; - } - if ( $dgishash{$p}->{unstable} ne " " && $dgishash{$p}->{stable} ne " " && - $vs->compare($dgishash{$p}->{unstable},$dgishash{$p}->{stable}) > 0 ) { - $tr_class = "class='orange'"; - } - if ( $dgishash{$p}->{unstable} ne " " && $dgishash{$p}->{testing} ne " " && - $vs->compare($dgishash{$p}->{unstable},$dgishash{$p}->{testing}) > 0 ) { - $tr_class = "class='red'"; - } - if ( $dgishash{$p}->{unstable} ne " " && $dgishash{$p}->{testing} eq " " ) { - $tr_class = "class='red'"; - } - print <<EOF; + next unless $p; + for my $s ( keys %paths ) { + $dgishash{$p}->{$s} = " " unless $dgishash{$p}->{$s}; + } + my $p_url = "<strong>$p</strong>"; + my $tr_class = "class='upToDate'"; + my $pkg_url = $main::dgislist{$p}->{url}; + my $todo_url = &GetSvnUrl( $p, 'TODO' ); + if ( $dgishash{$p}->{stable} ne " " + || $dgishash{$p}->{unstable} ne " " ) + { + $p_url .= " (<a href='http://packages.qa.debian.org/$p'>PTS</a>,"; + } + else { + $p_url .= " (" if $pkg_url; + my $pkg_wnpp = $main::dgislist{$p}->{wnpp}; + $p_url .= "<a href='http://bugs.debian.org/$pkg_wnpp'>WNPP</a>," + if $pkg_wnpp; + } + $p_url .= "<a href='$todo_url'>TODO</a>," if $todo_url; + $p_url .= "<a href='$pkg_url'>UP</a>)" if $pkg_url; + + # Set row color based on version status + + #$_stable = $dgishash{$p}->{stable}; + #$_unstable = $dgishash{$p}->{unstable}; + #$_testing = $dgishash{$p}->{testing}; + #$_ubuntu = $dgishash{$p}->{$ubuntuVer}; + + $tr_class = "class='unpackaged'"; + + if ($opt_u) { + + # Color table according to ubuntu rules + + # UpToDate + if ( $dgishash{$p}->{$ubuntuVer} ne " " + && $dgishash{$p}->{$ubuntuVer} ge $dgishash{$p}->{unstable} ) + { + $tr_class = "class='upToDate'"; + } + + # debianOutOfDate + #if ( + # $dgishash{$p}->{unstable} ne " " + # && $dgishash{$p}->{unstable} ne $dgishash{$p}->{stable} + #) { + # $tr_class = "class='debianOutOfDate'"; + #} + + # ubuntuOutOfDate + if ( + $dgishash{$p}->{unstable} ne " " + && ( $dgishash{$p}->{$ubuntuVer} lt $dgishash{$p}->{unstable} + || $dgishash{$p}->{ubuntuVer} eq " " ) + ) + { + $tr_class = "class='ubuntuOutOfDate'"; + } + + # obsolete + if ( $dgishash{$p}->{unstable} eq " " + && $dgishash{$p}->{stable} ne " " ) + { + $tr_class = "class='obsolete'"; + } + + # unpackaged + if ( $dgishash{$p}->{stable} eq " " + && $dgishash{$p}->{unstable} eq " " + && $dgishash{$p}->{testing} eq " " + && $dgishash{$p}->{$ubuntuVer} eq " " ) + { + $tr_class = "class='unpackaged'"; + } + } + else { + + # Color table according to debian rules + + # UpToDate: stable=unstable=test + if ( $dgishash{$p}->{stable} ne " " + && $dgishash{$p}->{stable} eq $dgishash{$p}->{unstable} + && $dgishash{$p}->{stable} eq $dgishash{$p}->{test} ) + { + $tr_class = "class='upToDate'"; + } + + # debianOutOfDate: stable < unstable + if ( $dgishash{$p}->{stable} ne " " + && $dgishash{$p}->{stable} lt $dgishash{$p}->{unstable} ) + { + $tr_class = "class='debianOutOfDate'"; + } + + # # ubuntuOutOfDate + # if ( + # $dgishash{$p}->{unstable} ne " " + # && ( $dgishash{$p}->{$ubuntuVer} lt $dgishash{$p}->{unstable} + # || $dgishash{$p}->{ubuntuVer} eq " " ) + # ) + # { + # $tr_class = "class='ubuntuOutOfDate'"; + # } + + # obsolete + if ( $dgishash{$p}->{unstable} eq " " + && $dgishash{$p}->{stable} ne " " ) + { + $tr_class = "class='obsolete'"; + } + + # unpackaged + if ( $dgishash{$p}->{stable} eq " " + && $dgishash{$p}->{unstable} eq " " + && $dgishash{$p}->{testing} eq " " ) + { + $tr_class = "class='unpackaged'"; + } + } + + print <<EOF; <tr $tr_class> <td >$p_url</td> -<td >$dgishash{$p}->{stable}</td> -<td >$dgishash{$p}->{testing}</td> -<td >$dgishash{$p}->{unstable}</td> -<td >$dgishash{$p}->{bpo}</td> -</tr> EOF + for my $v (@versions) { + print("<td >$dgishash{$p}->{$v}</td>"); + } + print("</tr>"); } my $now = gmtime; @@ -255,71 +444,81 @@ </td> <td valign=top> -<table border=0> +</table> +<table border=1> <caption><h3>Color legend</h3></caption> <tr> <td> <table class='pkg'> -<tr class='green'> +<tr class='upToDate'> <td> </td> </tr> </table> </td> <td> -<small>Same version in unstable/testing/stable</small> +<small>Up to date</small> </td> </tr> <tr> <td> <table class='pkg'> -<tr class='orange'> +<tr class='debianOutOfDate'> <td> </td> </tr> </table> </td> <td> -<small>Obsolete or not in stable</small> +<small>Debian stable behind unstable</small> </td> </tr> <tr> <td> <table class='pkg'> -<tr class='yellow'> +<tr class='ubuntuOutOfDate'> <td> </td> </tr> </table> </td> <td> -<small>Not yet packaged at all</small> +<small>Ubuntu behind Debian unstable</small> </td> </tr> <tr> <td> <table class='pkg'> -<tr class='red'> +<tr class='unpackaged'> <td> </td> </tr> </table> </td> <td> -<small>Obsolete or not in testing</small> +<small>Not packaged</small> </td> </tr> +<tr> +<td> +<table class='pkg'> +<tr class='obsolete'> +<td> </td> +</tr> +</table> </td> +<td> +<small>Obsolete</small> +</td> </tr> + +</td> +</tr> </table> -</table> - <p />Status at: $now - <br />Total of Stable/Testing/Unstable/BPO packages: $tot_pkgs{stable}/$tot_pkgs{testing}/$tot_pkgs{unstable}/$tot_pkgs{bpo} - <p /><small>Generated by <a href="http://svn.debian.org/wsvn/pkg-grass/scripts/dgis-status.pl?op=file&rev=0&sc=0">this GPL licensed perl script</a> - written by: <a href="mailto:frank...@debian.org">Francesco P. Lovergine</a> for DebianGis use.</small> - <p /> - <p /><em>Go to <a href="http://wiki.debian.org/DebianGis">DebianGis Wiki</a></em> + <p>Status at: $now</p> + <p><small>Generated by <a href="http://svn.debian.org/wsvn/pkg-grass/scripts/dgis-status.pl?op=file&rev=0&sc=0">this GPL licensed perl script</a> + written by: <a href="mailto:frank...@debian.org">Francesco P. Lovergine</a> for DebianGis use, and extended by Cameron Shorter for UbuntuGIS.</small></p> </body> </htmL> _______________________________________________ Pkg-grass-devel mailing list Pkg-grass-devel@lists.alioth.debian.org http://lists.alioth.debian.org/mailman/listinfo/pkg-grass-devel