source: scripts/watch.php @ 2364

Revision 2363, 3.7 KB checked in by alanbach-guest, 6 years ago (diff)

Modified for a better handling of Parsix specific packages

Line 
1<?php
2// PHP script to create Parsix watch file table rows.
3// Coyright 2007 Alan Baghumian / GNU/GPL
4// Based on Debian DEHS http://svn.debian.org/wsvn/dehs
5//
6// Updated: 2007-10-30 10:11 +330 GMT
7
8$vars=$_GET["vars"];
9uscan($vars);
10
11// Display warnings?
12$show_warnings=false;
13
14function uscan($vars){
15        $svn_url="http://svn.debian.org/svn/pkg-parsix/pkg";
16        $arrvars=explode("*", $vars);
17        $path = $arrvars[0];
18
19        $arrarchs=explode("-", $arrvars[1]);
20
21        $spkg = $arrvars[2];
22        $parsix_ver = $arrvars[3];
23
24        $parsix_rev = $arrvars[4];
25        $component = $arrvars[5];
26        $parsix_spec = $arrvars[6];
27
28        if(!empty($parsix_rev)){
29              $parsix_rev = "-".$parsix_rev;
30        }
31
32        if(!empty($arrarchs[0])){
33              $archs .= "<font color=red>".$arrarchs[0]."</font>&nbsp;&nbsp;";
34        }
35
36        if(!empty($arrarchs[1])){
37              $archs .= "<font color=green>".$arrarchs[1]."</font>&nbsp;&nbsp;";
38        }
39
40        if(!empty($arrarchs[2])){
41              $archs .= "<font color=blue>".$arrarchs[2]."</font>";
42        }
43
44        # work around the plus bug
45        $path=str_replace("KKK", "+", $path); 
46
47        $uscan_res=shell_exec("/usr/bin/uscan --report --dehs --check-dirname-level 0 ".$path);
48
49        # work around the plus bug
50        $uscan_res=str_replace("+", "KKK", $uscan_res); 
51
52        $p = xml_parser_create();
53        xml_parse_into_struct($p, $uscan_res, $vals, $index);
54        xml_parser_free($p);
55
56        $pkg=$vals[$index['PACKAGE'][0]][value];
57   
58        if(!empty($pkg)){
59                $pkg=str_replace("KKK", "+", $pkg); 
60        }else{
61                $pkg = $spkg;
62        }
63
64        $upstream=$vals[$index['UPSTREAM-VERSION'][0]][value];
65        $up_url=$vals[$index['UPSTREAM-URL'][0]][value];
66        $up_url=str_replace("KKK", "+", $up_url); 
67        $parsix=$vals[$index['DEBIAN-UVERSION'][0]][value];
68        $status=$vals[$index['STATUS'][0]][value];
69        $warnings=$vals[$index['WARNINGS'][0]][value];
70        if ($upstream=='') $upstream=null;
71        if ($up_url=='')  $up_url=null;
72        if ($parsix=='') $parsix=null;
73        if ($status=='') $status=null;
74        if ($warnings=='') $warnings=null;
75
76        if($upstream == $parsix){
77                $color="green";
78        }else{
79                $color="red";
80        }
81
82        switch($status)
83        {
84                case "up to date":
85                        $bk_color="#00ff00";
86                        break;
87                case "Newer version available":
88                        $bk_color="#ffff00";
89                        break;
90                case "Debian version newer than remote site":
91                        $bk_color="#ffcc99";
92                        break;
93                default:
94                        $status = "Watch file does not find";
95                        $bk_color="#1bffe8";
96                        break;                 
97        }       
98
99        if($pkg !='' || $pkg !=null){
100                if($upstream != null){
101                        echo "<tr bgcolor=white><td><b>".$pkg."</b></td><td><a href=".$up_url.">".$upstream."</a></td><td><font color=".$color.">".$parsix."</font></td><td align=center>".$archs."</td><td bgcolor=".$bk_color.">".$status."</td>";
102                }else{
103                        if(strstr($spkg, 'parsix') != null){
104                             $upstream = "<a href=".$svn_url."/".$component."/".$spkg."/trunk/>".$parsix_ver."</a>";
105                             $status = "up to date";
106                             $bk_color="#00ff00";
107                        }else{
108                             if($parsix_spec > 0){
109                                 $upstream = "<a href=".$svn_url."/".$component."/".$spkg."/trunk/>".$parsix_ver."</a>";
110                                 $status = "up to date";
111                                 $bk_color="#00ff00";
112                             }else{
113                                 $upstream = "N/A";
114                             }
115                        }
116
117                        if($show_warnings){
118                                echo "<tr bgcolor=white><td><b>".$pkg."</b></td><td colspan=5 bgcolor=#ff9966>".$warnings."</td><td>";
119                        }else{
120                                echo "<tr bgcolor=white><td><b>".$spkg."</b></td><td>".$upstream."</td><td><font color=".$color.">".$parsix_ver."</font></td><td align=center>".$archs."</td><td bgcolor=".$bk_color.">".$status."</td>";
121                        }
122                }
123        }
124}       
125?>
Note: See TracBrowser for help on using the repository browser.