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

[DebianGIS] UbuntuGIS Thermometer script



Francesco,
I've extended your dgis-status.pl script to return the Ubuntu status too. (Nice script, thanks for writing it).
The extended script and output are attached.

I'm interested to hear your thoughts on what we should do with future versions of the script and status page.

I think it would be good if we only have the one script and status page for both projects so that improvements added to one script will apply to the other too.


--
Cameron Shorter
Geospatial Systems Architect
Tel: +61 (0)2 8570 5050
Mob: +61 (0)419 142 254

Think Globally, Fix Locally
Geospatial Solutions enhanced with Open Standards and Open Source
http://www.lisasoft.com


<<< text/html; charset=ISO-8859-1; name="ubuntugis-status.html": Unrecognized >>>
#!/usr/bin/perl
#
#       dgis-status.pl - UbuntuGIS/DebianGis packages status script
#
#       $Id: dgis-status.pl 1145 2007-10-01 11:45:09Z frankie $
#
#       Copyright 2005-2007 (C) Francesco P. Lovergine <frankie@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
#
#       Authors:
#         Francesco P. Lovergine (original author of dgis-status.pl)
#         Cameron Shorter (extended to Ubuntu)
#

use strict 'vars';

use Getopt::Std;
use FileHandle;
use SVN::Client;

use AptPkg::Config '$_config';
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 );

#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/";
 ],
 '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/";
 ],
);
my @versions = (
 "stable", "testing", "unstable", "bpo", "jaunty", "intrepid",
 "hardy",  "gutsy",   "dapper"
);
my $ubuntuVer = "jaunty";
my $sources   = "Sources";
my $sourcesgz = "$sources.gz";
my $verbose   = 0;

my $debug = $opt_d;
my $verbose = $opt_v ? 'verbose' : 'quiet';

if ($opt_h) {
 print STDERR <<EOT;
usage:   $0 [-odvh]
options:
-h this help...
-o ONLY calculate differences on local files (don't wget Sources.gz)
-d debug
-v verbose
EOT
 exit;
}

sub GetSvnUrl {
 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";
}

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";);

my %files    = undef;
my %dgishash = undef;
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...
}

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}++;
 }
}

print <<EOF;
<!doctype html public "-//w3c//dtd html 4.01//en" "http://www.w3.org/tr/html4/strict.dtd";>
<html>
 <style type="text/css">
<!--
table.pkg {
        border-collapse: collapse;
}
.pkg th, .pkg td {
        text-align: left;
        border: 1px solid black;
        padding: 0.2em;
}
.pkg thead {
        background-color: silver;
        color: #000000;
}
table.pkg tr.title {
        color: #ffffff;
        background-color: #df0451;
}

/* orange */
table.pkg tr.ubuntuOutOfDate {
        color: #000000;
        background-color: #f09005;
}

/* white */
table.pkg tr.unpackaged {
        color: #000000;
        background-color: #ffffff;
}

/* yellow */
table.pkg tr.debianOutOfDate {
        color: #000000;
        background-color: #f0f005;
}

/* 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;
}
-->
</style>
   <head>
      <title>DebianGIS/UbuntuGIS Package Thermometer</title>
   <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
   </head>
<body>
<p><a href="https://wiki.ubuntu.com/UbuntuGIS";>UbuntuGIS home page</a>.</p>
<table border=0 cellspacing=10 cellpadding=5>
<tr><td valign=top>

<table class='pkg'>
<caption><h3>DebianGIS/UbuntuGIS Package Thermometer</h3></caption>
<tr class='title'>
<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} = "&nbsp;" 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 "&nbsp;"
  || $dgishash{$p}->{unstable} ne "&nbsp;" )
 {
  $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'";

 # UpToDate
 if ($dgishash{$p}->{$ubuntuVer} ne "&nbsp;"
  && $dgishash{$p}->{$ubuntuVer} ge $dgishash{$p}->{unstable} )
 {
  $tr_class = "class='upToDate'";
 }

 # debianOutOfDate
 #if (
 #  $dgishash{$p}->{unstable} ne "&nbsp;"
 #   && $dgishash{$p}->{unstable} ne $dgishash{$p}->{stable}
 #) {
 #        $tr_class = "class='debianOutOfDate'";
 #}

 # ubuntuOutOfDate
 if (
  $dgishash{$p}->{unstable} ne "&nbsp;"
  && ($dgishash{$p}->{$ubuntuVer} lt $dgishash{$p}->{unstable}
   || $dgishash{$p}->{ubuntuVer} eq "&nbsp;" )
   )
 {
  $tr_class = "class='ubuntuOutOfDate'";
 }

 # obsolete
 if ($dgishash{$p}->{unstable} eq "&nbsp;"
  && $dgishash{$p}->{stable} ne "&nbsp;" )
 {
  $tr_class = "class='obsolete'";
 }

 # unpackaged
 if ($dgishash{$p}->{stable} eq "&nbsp;"
  && $dgishash{$p}->{unstable}   eq "&nbsp;"
  && $dgishash{$p}->{testing}    eq "&nbsp;"
  && $dgishash{$p}->{$ubuntuVer} eq "&nbsp;" )
 {
  $tr_class = "class='unpackaged'";
 }

#        # UpToDate
#       if (
#          $dgishash{$p}->{stable} ne "&nbsp;"
#          && $vs->compare($dgishash{$p}->{stable},$dgishash{$p}->{unstable}) > 0
#          && $vs->compare($dgishash{$p}->{stable},$dgishash{$p}->{testing}) > 0
#          && $vs->compare($dgishash{$p}->{stable},$dgishash{$p}->{$ubuntuVer}) > 0
#        ) {
#               $tr_class = "class='upToDate'";
#       }
#
#        # debianOutOfDate
#       if (
#          $dgishash{$p}->{unstable} ne "&nbsp;"
#          && $vs->compare($dgishash{$p}->{unstable},$dgishash{$p}->{stable}) > 1
#        ) {
#               $tr_class = "class='debianOutOfDate'";
#       }
#
#        # ubuntuOutOfDate
#       if (
#          $dgishash{$p}->{unstable} ne "&nbsp;"
#          && $vs->compare($dgishash{$p}->{unstable},$dgishash{$p}->{$ubuntuVer}) > 1
#        ) {
#               $tr_class = "class='ubuntuOutOfDate'";
#       }
#
#        # obsolete
#       if (
#          $dgishash{$p}->{unstable} eq "&nbsp;"
#          && $dgishash{$p}->{stable} ne "&nbsp;"
#        ) {
#               $tr_class = "class='obsolete'";
#       }
#
#        # unpackaged
#       if (
#          $dgishash{$p}->{stable} eq "&nbsp;"
#          && $dgishash{$p}->{unstable} eq "&nbsp;"
#          && $dgishash{$p}->{test} eq "&nbsp;"
#          && $dgishash{$p}->{$ubuntuVer} eq "&nbsp;"
#        ) {
#               $tr_class = "class='unpackaged'";
#       }

#       if ( $dgishash{$p}->{unstable} ne "&nbsp;" && $dgishash{$p}->{stable} eq "&nbsp;" ) {
#               $tr_class = "class='upToDate'";
#       }
#       if ( $dgishash{$p}->{unstable} eq "&nbsp;" && $dgishash{$p}->{stable} eq "&nbsp;" ) {
#               $tr_class = "class='debianOutOfDate'";
#       }
#       if ( $dgishash{$p}->{unstable} ne "&nbsp;" && $dgishash{$p}->{stable} ne "&nbsp;" &&
#            $vs->compare($dgishash{$p}->{unstable},$dgishash{$p}->{stable}) > 0 ) {
#               $tr_class = "class='ubuntuOutOfDate'";
#       }
#       if ( $dgishash{$p}->{unstable} ne "&nbsp;" && $dgishash{$p}->{testing} ne "&nbsp;" &&
#            $vs->compare($dgishash{$p}->{unstable},$dgishash{$p}->{testing}) > 0 ) {
#               $tr_class = "class='obsolete'";
#       }
#       if ( $dgishash{$p}->{unstable} ne "&nbsp;" && $dgishash{$p}->{testing} eq "&nbsp;" ) {
#               $tr_class = "class='obsolete'";
#       }
 print <<EOF;
<tr $tr_class>
<td >$p_url</td> 
EOF
 for my $v (@versions) {
  print("<td >$dgishash{$p}->{$v}</td>");
 }
 print("</tr>");
}

my $now = gmtime;

print <<EOF;
</table>
</td>

<td valign=top>
</table>
<table border=0>
<caption><h3>Color legend</h3></caption>

<tr>
<td>
<table class='pkg'>
<tr class='upToDate'>
<td>&nbsp;</td>
</tr>
</table>
</td>
<td>
<small>Ubuntu version >= Debian</small>
</td>
</tr>

<tr>
<td>
<table class='pkg'>
<tr class='ubuntuOutOfDate'>
<td>&nbsp;</td>
</tr>
</table>
</td>
<td>
<small>Ubuntu behind Debian unstable</small>
</td>
</tr>

<tr>
<td>
<table class='pkg'>
<tr class='unpackaged'>
<td>&nbsp;</td>
</tr>
</table>
</td>
<td>
<small>Not packaged</small>
</td>
</tr>

<tr>
<td>
<table class='pkg'>
<tr class='obsolete'>
<td>&nbsp;</td>
</tr>
</table>
</td>
<td>
<small>Obsolete</small>
</td>
</tr>

</td>
</tr>
</table>
        <p>Status at: $now</p>
        <p>See also the <a href="http://pkg-grass.alioth.debian.org/debiangis-status.html"DebianGis packages thermometer</a>.</p>
        <p><small>Generated by a derivative of <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> </p>
        <p>written by: <a href="mailto:frankie\@debian.org";>Francesco P. Lovergine</a> for DebianGis use.</small></p>
</body>
</htmL>

EOF

Reply to: