1 #!/usr/bin/php
2 <?php
3 require('DB.php');
4 # Collect port info from 3rd-party repositories into a sqlite database
5 # Written by Simone Rota <sip@crux.nu>
6 #
7 # Configuration #############################################################
8 #
9 # Collections: name|Maintainer <email>|type|url
10 # Supported types: httpup, rsync
11
12 $collections = array (
13 "core|crux@crux.nu|rsync|crux.nu::ports/crux-2.2/core/",
14 "opt|crux@crux.nu|rsync|crux.nu::ports/crux-2.2/opt/",
15 "opt|tilman@code-monkey.de|rsync|crux.nu::ports/crux-2.2/xorg/",
16 "contrib|crux@crux.nu|rsync|crux.nu::crux-contrib/",
17 "acrux|acrux_it@libero.it|httpup|http://acrux.homelinux.org/crux/repos/",
18 "alan|alan-cpkg@mizrahi.com.ve|httpup|http://www.mizrahi.com.ve/crux/pkgs/",
19 "alpa|genki@codeguru.li|httpup|http://www.mobillinux.de/crux/",
20 "anttinyk|aon@iki.fi|httpup|http://aon.iki.fi/crux-ports/",
21 "arg|arg@suckless.org|httpup|http://suckless.org/crux/arg/",
22 "bashy|ronny.kornexl@arcor.de|httpup|http://ronnykornexl.de/",
23 "brointhemix|q3storage@go2.pl|httpup|http://www.nowydwor.mm.pl/~brointhemix/crux-repo/",
24 "buddy|percent20@gmail.com|httpup|http://www.buddylindsey.com/crux/ports/",
25 "ca|ca256@gmx.net|httpup|http://egge.portland.co.uk/crux/ca/",
26 "chw|chw@tks6.net|httpup|http://chw.tks6.net/crux_ports/",
27 "crux.spb.ru|tzong@crux.spb.ru|httpup|http://crux.spb.ru/ports/",
28 "dahl|dahl@c64.org|httpup|http://dahl.varnamo.nu/httpup/",
29 "danieldk|danieldk@pobox.com|httpup|http://danieldk.org/ports/",
30 "dektria|dektria@users.sourceforge.net|httpup|http://dektria.org.ua/CRUX/ports/",
31 "ea|crux@eckigesauge.de|httpup|http://www.eckigesauge.de/crux/ports/",
32 "falcon|raider@behid.net|httpup|http://crux.thunder.homeunix.org/ports/",
33 "gnome|jaeger@morpheus.net|httpup|http://jaeger.morpheus.net/linux/crux/repos/gnome/",
34 "haikob|haiko.brandes@stud.uni-goettingen.de|httpup|http://www.stud.uni-goettingen.de/~s462320/crux/",
35 "han|han@mijncomputer.nl|httpup|http://www.xs4all.nl/~hanb/software/crux/han/",
36 "heidi|forum@heidi.linuxpl.com|httpup|http://heidi.linuxpl.com/ports/heidi/",
37 "hnc|bile@landofbile.com|httpup|http://www.landofbile.com/crux_ports/",
38 "j2|jjasghar@gmail.com|httpup|http://tito.homelinux.org/repo/",
39 "jaeger|jaeger@morpheus.net|httpup|http://jaeger.morpheus.net/linux/crux/repo/",
40 "jdolan|jasonthomasdolan@yahoo.com|httpup|http://jdolan.dyndns.org/jaydolan/ports/",
41 "jue|jue@jue.li|httpup|http://jue.li/crux/ports/",
42 "jw|jw@smts.ch|httpup|http://jw.smts.ch/files/crux/ports/",
43 "larryn|wawrzek@gmail.com|httpup|http://wawrzek.name/Crux/Ports/",
44 "lithium|lithium@poolofrandomness.com|httpup|http://www.poolofrandomness.com/crux/",
45 "malster|clover@mail.nnov.ru|httpup|http://malster.nnov.ru/ports/",
46 "mark|mark@borkware.net|httpup|http://borkware.net/crux/ports/",
47 "mhedenskog|mattias@hedenskog.se|httpup|http://magog.se/crux/",
48 "mike|mike@openbunker.org|httpup|http://openbunker.org/crux/ports/mike/",
49 "mono|nymacro@gmail.com|httpup|http://members.optusnet.com.au/dfmarks/crux/mono/",
50 "niklas|niklas@ulug.org|httpup|http://www.drummel.net/crux/",
51 "ninuzzo|ant@venus.deis.unical.it|httpup|http://monitor.deis.unical.it/ant/crux/",
52 "nthuynh|nthuynh@fastmail.fm|httpup|http://nthuynh.yazzy.org/crux/httpup/",
53 "nym|nymacro@gmail.com|httpup|http://members.optushome.com.au/dfmarks/crux/ports/",
54 "obbl|mo@obbl-net.de|httpup|http://obbl.homeunix.org/~crux/ports/",
55 "ogg|ogg@linux.se|httpup|http://ogg.kicks-ass.net/crux/ports/",
56 "per-olov|teozal@chem.uni.torun.pl|httpup|http://sapho.chem.uni.torun.pl/~teozal/crux/ports/per-olov/",
57 "predatorfreak|predatorfreak@dcaf-security.org|httpup|http://www.dcaf-security.org/ports/",
58 "prologic|prologic@shortcircuit.net.au|httpup|http://crux.shortcircuit.net.au/ports/",
59 "rehabdoll|fredrik@obra.se|httpup|http://fredrik.obra.se/crux/ports/",
60 "rho|rho@thinkingspot.ch|httpup|http://www.thinkingspot.ch/crux/ports/",
61 "rk|crux@roeschu.ch|httpup|http://www.roeschu.ch/ports/crux/",
62 "romster|romster@shortcircuit.net.au|httpup|http://romster.shortcircuit.net.au/crux/ports/",
63 "rugek|rugek@btcl.de|httpup|http://rugek.dirtyhack.net/crux-ports/rugek/",
64 "scree|jonathanr@bluebottle.com|httpup|http://s89775182.onlinehome.us/scree/ports/",
65 "sepen|sepen_@hotmail.com|httpup|http://mikeux.dyndns.org/crux/",
66 "sgtmcd|sgtmcd@sgtmcd.com|httpup|http://crux.sgtmcd.com/ports/",
67 "singular|arbor@mail.ru|httpup|http://singular.ru/ports/",
68 "ssimon|swsimon@gmail.com|httpup|http://lumina.ig3.net/linux/crux/ports/",
69 "steini|steini@kieselsteini.de|httpup|http://kieselsteini.de/dateien/ports/",
70 "strw|strawi@googlemail.com|httpup|http://www.gnoedi.org/~straw/crux/ports/",
71 "syslinx|phil@syslinx.org|httpup|http://www.syslinx.org/crux/ports/",
72 "thenschel|thenschel@henschelsoft.de|httpup|http://www.henschelsoft.de/cruxports/",
73 "thomas|t.mausbach@netcologne.de|httpup|http://www.mausbach.mynetcologne.de/crux/httpup/thomas/",
74 "tilman|tilman@code-monkey.de|rsync|code-monkey.de::crux-ports/",
75 "uhlu|crux@uhlu.com|httpup|http://ports.uhlu.com/repository/",
76 "uibds|Schick.Johannes@gmail.com|httpup|http://www.stud.uni-karlsruhe.de/~uibds/ports/",
77 "vico|vico@bicisport.de|httpup|http://vico.kleinplanet.de/files/repo/",
78 "viper|viper@hometux.de|httpup|http://hometux.de/crux/ports/",
79 "x11r7|tilman@code-monkey.de|rsync|code-monkey.de::crux-ports-x11r7",
80 "yazicivo|v0lkany@yahoo.com|httpup|http://yazicivo.fateback.com/ports/",
81 "yhafri|ycrux@club-internet.fr|httpup|http://perso.club-internet.fr/yhafri/crux/",
82 "yom|yom@iaelu.net|httpup|http://iaelu.net:6981/ports/yom/",
83 "zh_current|zh@despammed.com|httpup|http://zh.yazzy.org/crux/httpup/current/",
84 "zh_embed|zh@despammed.com|httpup|http://zh.yazzy.org/crux/httpup/embed/",
85 );
86
87 # inactive or unavailable repositories
88 # "cpwi|ulughbegh@bluebottle.com|httpup|http://www.scmerkezi.org/crux/ports/",
89 # "danm|daniel@danm.de|httpup|http://www.danm.de/ports/",
90 # "diederick|diederick76@gmail.com|httpup|http://www.diederickdevries.net/~diederick/repo/",
91 # "jolupa|jolupa@ya.com|httpup|http://www.jolupatech.info/crux/",
92 # "loophole|loophole@morpheus.net|httpup|http://loophole.morpheus.net/linux/ports/",
93 # "monad|arbor@mail.ru|httpup|http://monad.ru/ports/",
94 # "noneus|noneus@noneus.de|httpup|http://noneus.de/crux-ports/",
95 # "pazo|off_pazo@shiba.dk|httpup|http://shiba.dk/pazo/ports/",
96 # "phire|michael.auchter@gmail.com|httpup|http://ports.phire.org/",
97 # "radix|luke.hoersten@gmail.com|httpup|http://www.theradixpoint.com/crux/ports/",
98 # "sten|nick.steeves@shaw.ca|httpup|http://members.shaw.ca/nick.steeves/ports/",
99 # "stsp|stsp@binarchy.net|httpup|http://guerila.com/stsp/crux/ports/",
100 # "ukraine|artur@idt.org.ua|httpup|http://crux.org.ua/repo/ukraine",
101 # "wimpress|crux@flexion.plus.com|httpup|http://www.flexion.plus.com/stable/",
102
103 $dsn = 'sqlite:////home/crux/public_html/local/portdb.db';
104
105 # End of configuration ######################################################
106
107 $db =& DB::connect($dsn);
108 if (DB::isError($db)) die("Cannot connect to database");
109 $db->setFetchMode(DB_FETCHMODE_ASSOC);
110
111 # Clean existing entries
112 $sql = "delete from ports";
113 $res = $db->simpleQuery($sql);
114 if (DB::isError($res)) die("Query error (delete)");
115 $sql = "delete from collections";
116 $res = $db->simpleQuery($sql);
117 if (DB::isError($res)) die("Query error (delete)");
118 $sql = "vacuum";
119 $res = $db->simpleQuery($sql);
120 if (DB::isError($res)) die("Query error (delete)");
121
122
123
124 foreach ($collections as $coll) {
125 $ports = getCollection($coll);
126 if ($ports !== FALSE) {
127 storeCollection($coll, $ports);
128 } else {
129 $fields = explode('|', $coll);
130 echo "Errors while retrieving collection ". $fields[0]."\n";
131 }
132 }
133
134 function getCollection($coll) {
135 $fields = explode('|', $coll);
136 switch ($fields[2]) {
137 case "httpup":
138 return getHttpupCollection($coll);
139 break;
140 case "rsync":
141 return getRsyncCollection($coll);
142 break;
143 default:
144 return FALSE;
145 }
146 }
147
148 function getRsyncCollection($coll) {
149 $ports = array();
150 $out = array();
151 $fields = explode('|', $coll);
152 $res = -1;
153 exec("/usr/bin/rsync --list-only $fields[3]", $out, $res);
154 if ($res !== 0)
155 return FALSE;
156 foreach ($out as $line) {
157 if ($line[0] == "d") {
158 $sp = explode(' ', $line);
159 $portname = $sp[count($sp)-1];
160 if ($portname != ".")
161 $ports[] = $portname;
162 }
163 }
164 if (count($ports)>0)
165 return $ports;
166 return FALSE;
167 }
168
169 function getHttpupCollection($coll){
170 $ports = array();
171 $fields = explode('|', $coll);
172 $lines = file($fields[3]."REPO");
173 if ($lines === FALSE)
174 return FALSE;
175 foreach ($lines as $line) {
176 if (substr($line, 0, 2) == "d:") {
177 $ports[] = trim(substr($line,2));
178 }
179 }
180 if (count($ports)>0)
181 return $ports;
182 return FALSE;
183 }
184
185 function storeCollection($coll, $ports) {
186 global $db;
187 $fields = explode('|', $coll);
188 foreach ($ports as $port) {
189 $vals = array($port, $fields[0]);
190 $sth = $db->prepare("insert into ports values (NULL, ?, ?)");
191 $res = $db->execute($sth, $vals);
192 if (DB::isError($res)) die("Query error (port)");
193 }
194 $vals = explode('|', $coll);
195 $sth = $db->prepare("insert into collections values (NULL, ?, ?, ?, ?)");
196 $res = $db->execute($sth, $vals);
197 if (DB::isError($res)) die("Query error (collection)");
198 }
199
200
201
202 ?>
|