/[pkg-grass]/trunk/scripts/dgis-status.pl
ViewVC logotype

Contents of /trunk/scripts/dgis-status.pl

Parent Directory Parent Directory | Revision Log Revision Log


Revision 190 - (show annotations) (download)
Wed Sep 14 09:55:45 2005 UTC (7 years, 8 months ago) by frankie
File MIME type: text/plain
File size: 4413 byte(s)

Changed URL for script on cvs
1 #!/usr/bin/perl
2 #
3 # dgis-status.pl - DebianGis packages status script
4 #
5 # $Id$
6 #
7 # Copyright 2005 (C) Francesco P. Lovergine <frankie@debian.org>
8 #
9 # This program is free software; you can redistribute it and/or modify
10 # it under the terms of the GNU General Public License as published by
11 # the Free Software Foundation; either version 2 of the License, or
12 # (at your option) any later version.
13 #
14 # This program is distributed in the hope that it will be useful,
15 # but WITHOUT ANY WARRANTY; without even the implied warranty of
16 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 # GNU General Public License for more details.
18 #
19 # You should have received a copy of the GNU General Public License
20 # along with this program; if not, write to the Free Software
21 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
22 #
23 # On Debian GNU/Linux GPL is available under /usr/share/common-licenses
24 #
25
26 use strict 'vars';
27
28 use Getopt::Std;
29 use FileHandle;
30
31 getopts ('odhvf:'); # -o option: only do difference (no wget)
32 our($opt_o, $opt_h, $opt_v, $opt_b, $opt_c, $opt_d, $opt_f);
33
34 push @INC, $ENV{'HOME'}."/pkg-grass/scripts";
35
36 require "dgis-packages.inc";
37
38 my %wget = ( 'quiet' => 'wget --passive-ftp --quiet -O ','verbose' => 'wget --passive-ftp -O ' );
39 my %gunzip = ( 'quiet' => 'gunzip --force --quiet ', 'verbose' => 'gunzip --force' );
40 my %paths = (
41 'dgis-stable' => "http://pkg-grass.alioth.debian.org/debian-gis/dists/stable/main/source/",
42 'dgis-unstable' => "http://pkg-grass.alioth.debian.org/debian-gis/dists/unstable/main/source/",
43 'stable' => "http://merkel.debian.org/debian/dists/stable/main/source/",
44 'unstable' => "http://merkel.debian.org/debian/dists/unstable/main/source/",
45 );
46
47 my $sources = "Sources";
48 my $sourcesgz = "$sources.gz";
49 my $verbose = 0;
50
51 my $debug = $opt_d;
52 my $verbose = $opt_v ? 'verbose' : 'quiet';
53
54 if ($opt_h) {
55 print STDERR <<EOT;
56 usage: $0 [-odvh]
57 options:
58 -h this help...
59 -o ONLY calculate differences on local files (don't wget Sources.gz)
60 -d debug
61 -v verbose
62 EOT
63 exit;
64 }
65
66 unless ($opt_o) { # Skip wget if -o option "only difference"
67 for my $s ( keys %paths ) {
68 system ("$wget{$verbose} $s.$sourcesgz $paths{$s}/$sourcesgz");
69 system ("$gunzip{$verbose} $s.$sourcesgz") if -f "$s.$sourcesgz";
70 }
71 }
72
73 my %files = undef;
74 my %dgishash = undef;
75 my %tot_pkgs = undef;
76
77 for my $s ( keys %paths ) {
78 $files{$s} = new FileHandle "<$s.$sources";
79 die "Cannot open $s: $!\n" if ! defined $files{$s};
80 IO::Handle->input_record_separator("\n\n");
81 binmode $files{$s},":unix" if $] > 5.007; # To avoid UTF-8 interpretation as in perl 5.8...
82 }
83
84
85 for my $p (@main::dgislist) { $dgishash{$p} = {}; }
86
87 for my $s ( keys %paths ) {
88 $tot_pkgs{$s} = 0;
89 my $F = $files{$s};
90 while ( <$F> ) {
91 if (/Package:\s(\S+).*\nVersion:\s(\S+)/s) {
92 my $package = $1;
93 my $version = $2;
94 if ( defined $dgishash{$package} ) {
95 $dgishash{$package}->{$s}="$version";
96 }
97 }
98 $tot_pkgs{$s}++;
99 }
100 }
101
102 print <<EOF;
103 <!doctype html public "-//w3c//dtd html 4.01//en" "http://www.w3.org/tr/html4/strict.dtd">
104 <html>
105 <style type="text/css">
106 <!--
107 a: img { border-style: none }
108 -->
109 </style>
110 <head>
111 <title>DebianGis Status</title>
112 <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
113 </head>
114 <body>
115 <table border="1" bgcolor="#ffffcc">
116 <caption bgcolo="#ffffaa"><h3>DebianGis Source Packages</h3></caption>
117 <tr>
118 <TH />Package
119 <TH />Stable
120 <TH />Unstable
121 <TH />DebianGis stable
122 <TH />DebianGis unstable
123 </tr>
124 EOF
125
126
127 for my $p ( sort keys %dgishash ) {
128 next unless $p;
129 for my $s ( keys %paths ) {
130 $dgishash{$p}->{$s} = "none" unless $dgishash{$p}->{$s};
131 }
132 print <<EOF;
133 <tr>
134 <td>$p</td>
135 <td>$dgishash{$p}->{stable}</td>
136 <td>$dgishash{$p}->{unstable}</td>
137 <td>$dgishash{$p}->{'dgis-stable'}</td>
138 <td>$dgishash{$p}->{'dgis-unstable'}</td>
139 </tr>
140 EOF
141 }
142
143 my $now = gmtime;
144
145 print <<EOF;
146 </table>
147 <p />Status at: $now
148 <br />Total of Stable/Unstable/DebianGisStable/DebianGisUnstable packages: $tot_pkgs{stable}/$tot_pkgs{unstable}/$tot_pkgs{'dgis-stable'}/$tot_pkgs{'dgis-unstable'}
149 <p />Generated by <a href="http://cvs.alioth.debian.org/cgi-bin/cvsweb.cgi/scripts/dgis-status.pl?cvsroot=pkg-grass&sortby=rev">this GPL licensed perl script</a>
150 written by: <a href="mailto:frankie\@debian.org">Francesco P. Lovergine</a> for DebianGis use.
151 </body>
152 </htmL>
153
154 EOF

Properties

Name Value
svn:eol-style native
svn:executable *
svn:keywords Author Date Id Revision

  ViewVC Help
Powered by ViewVC 1.1.5