webtools/portdb/cacher/pdbcacher.php
2015-09-14 12:12:05 +02:00

236 lines
13 KiB
PHP
Executable File

#!/usr/bin/php
<?php
require('DB.php');
# Collect port info from 3rd-party repositories into a sqlite database
# Written by Simone Rota <sip@crux.nu>
#
# Configuration #############################################################
#
# Collections: name|Maintainer <email>|type|url
# Supported types: httpup, rsync
$version = "3.1";
$collections = array (
"core|core-ports@crux.nu|rsync|crux.nu::ports/crux-".$version."/core/",
"opt|crux@crux.nu|rsync|crux.nu::ports/crux-".$version."/opt/",
"xorg|xorg-ports@crux.nu|rsync|crux.nu::ports/crux-".$version."/xorg/",
"compat-32|compat-32-ports@crux.nu|rsync|crux.nu::ports/crux-".$version."/compat-32/",
"contrib|crux@crux.nu|rsync|crux.nu::ports/crux-".$version."/contrib/",
#"kde|alan+crux@mizrahi.com.ve|rsync|crux.nu::ports/crux-2.5/kde/",
"kde4|alan+crux@mizrahi.com.ve|rsync|crux.nu::ports/crux-3.0/kde4/",
"xfce|sepen@crux.nu|rsync|crux.nu::ports/crux-".$version."/xfce/",
"enlightenment|pitillo@ono.com|rsync|crux.nu::ports/crux-".$version."/enlightenment/",
"aba|abaumann@yahoo.com|httpup|http://www.andreasbaumann.cc/crux/ports/", #Andreas Baumann
"ako|alexko256@gmail.com|httpup|http://ports.ako.serveftp.org/", #Alex Kostrewa
"alan|alan+crux@mizrahi.com.ve|httpup|http://www.mizrahi.com.ve/crux/pkgs/",
"alexta|oleksii.tkachuk@gmail.com|httpup|http://alexta.googlecode.com/git/", #Oleksii Tkachuk
"andrew|hello@andrewrose.co.uk|httpup|http://crux.andrewrose.co.uk/pkgs/", #Andrew Rose
"asie|kontakt@asie.pl|httpup|http://crux.asie.pl/", #Adrian Siekierka
"aubic|ales@hushmail.com|httpup|http://crux.org.pl/ports/aubic/",
"augustao|augustao@augustao.org|httpup|http://augustao.org/ports/", #Augusto Pereira
#"bashy|ronny.kornexl@t-online.de|httpup|http://ronny-kornexl.homepage.t-online.de/crux/ports/", #Ronny Kornexl
"bitpuffin|contact@bitpuffin.com|httpup|http://cruxports.bitpuffin.com/bitpuffin/", #Isak Andersson
"bdfy|jean@mosk.ru|httpup|http://bdfy.googlecode.com/svn/trunk/", #Ivan Rodionov
"captlloyd|captlloyd@gmail.com|httpup|http://lloyd.is.an.evil-genius.net/crux/ports/", #Justin W. Lloyd
"chw|chw@tks6.net|httpup|http://iacs.epfl.ch/~winkelma/crux_ports/", # Christoph Winkelmann
"crshd|crshd@mail.com|httpup|http://crshd.users.anapnea.net/linux/crux/ports/", #Christian Brassat
"cruxab|abaranov.anton@gmail.com|httpup|http://cruxab.comlu.com/crux/ports/", #Anton Baranov
"cruxpl|sirmacik@crux.org.pl|httpup|http://sirmacik.net/static/download/cruxpl-ports/", # CRUX Poland (Marcin Karpezo)
"darthlukan|darthlukan@gmail.com|httpup|http://ports.brianctomlinson.com/", #Brian Tomlinson
"deepthought|erich@eckner.net|httpup|http://crux.eckner.net/", # Erich Eckner
"df|wyatt@prairieturtle.ca|httpup|http://home.cc.umanitoba.ca/~fonsecah/crux/ports/", # Daryl Fonseca-Holt (nthwyatt)
"dokpm0|Kevin@RawFedDogs.net|httpup|http://crux.RawFedDogs.net/", #Kevin Monceaux
"doom|dxm@openmailbox.org|httpup|https://raw.github.com/Doomicide/crux-ports/master/", #Maximilian Dietrich (doomicide)
"ecarux|kontakt@ecarux.de|httpup|http://ecarux.de/ports/", #Hannes Mayer
"emulators|nogagplz@gmail.com|httpup|http://crux.ster.zone/ports/emulators/", #Neville Phillips (responsible: Danny Rawlins)
"emulators-i686|crux@romster.me|httpup|http://crux.ster.zone/ports/emulators-i686/", #Danny Rawlins
"falcony|falcony@users.sourceforge.net|httpup|http://falcony.googlecode.com/svn/trunk/falcony/", #Maxim Falcony
"fho|holler_f@informatik.haw-hamburg.de|httpup|http://users.informatik.haw-hamburg.de/~holler_f/crux_ports/", # Fabian Holler
"fillo|fillo@fillo.me|httpup|http://fillo.pw/cruxports/", # Dimitry (fillo)
"flaveur|grim@asu.ntu-kpi.kiev.ua|httpup|http://flaveur.googlecode.com/svn/trunk/ports/", #Oleksiy Khilkevich
"f1y|dwanasciegroszy@o2.pl|httpup|http://pierwszeliceum.bedzin.pl:8080/~f1y/httpup/", #Bartosz Sobel
"haikob|haiko.brandes@stud.uni-goettingen.de|httpup|http://www.stud.uni-goettingen.de/~s462320/crux/",
"haskell|moritz+crux@wzff.de|rsync|rsync.wzff.de::crux-haskell/", #Moritz Wilhelmy's haskell collection
"hnc|bile@landofbile.com|httpup|http://www.landofbile.com/crux_ports/", #Antonio SJ Musumeci
"jaeger|jaeger@morpheus.net|rsync|morpheus.net::cruxports/", #Matt Housh
"jdolan|jasonthomasdolan@yahoo.com|httpup|http://jdolan.dyndns.org/jaydolan/ports/",
"joacim|joacim@joac.im|httpup|http://raw.github.com/joacimot/CRUX-Ports/master/", #Joacim Olsen Tangen
"joe9|joe9mail@gmail.com|httpup|http://crux.ster.zone/ports/joe9/", #Joe M
"jturner|james@calminferno.net|httpup|http://calminferno.net/crux/", #James Turner
"jue|jue@jue.li|httpup|http://jue.li/crux/ports/",
"juef|juef@openmailbox.org|httpup|http://chiselapp.com/user/juef/repository/crux-ports/doc/tip/", #Svyatoslav Mishyn
"jw|jw@smts.ch|httpup|http://jw.smts.ch/files/crux/ports/",
"karpunix|sirmacik@gmail.com|httpup|http://download.sirmacik.lin4all.org/crux/ports/", # Marcin Karpezo
"kori|kori@openmailbox.org|httpup|https://raw.github.com/kori/crux-ports/master/", #Kori Ayakashi
"kp4|vs@kp4.ru|httpup|http://crux.kp4.ru/", # Vitaly Sinilin
"kris|email@zero-io.net|httpup|https://raw.githubusercontent.com/krleh/ports/master/", # Kris Lehmann
"larryn|wawrzek@gmail.com|httpup|http://wawrzek.name/Crux/Ports/",
"lennart|devel@lennart.sauerbeck.org|rsync|code-monkey.de::lennarts-crux-ports/", #Lennart Sauerbeck
"leo-unglaub|leo@leo-unglaub.net|rsync|leo-unglaub.net::crux-ports-leo-unglaub/", # Leo Unglaub
"linoports|benemue@googlemail.com|rsync|karif.server-speed.net::linoports/", #Benedikt Muller
#"l00nix|l00nixcdoc@gmail.com|httpup|http://l00nix.com/repo/crux/", #Cody
"lxde|rotwang@crux.org.pl|httpup|http://crux.org.pl/ports/lxde/", #Bartlomeij Palmowski
"malster|clover@mail.nnov.ru|httpup|http://malster.nnov.ru/ports/",
"mason|msonderegger@aon.at|httpup|http://www.tip9ug.jp/who/dude/webdir/lunix/CRUX/", #Markus Sonderegger
"mechaniputer|beadleha@clarkson.edu|httpup|http://people.clarkson.edu/~beadleha/crux/ports/", #Herbert A. Beadle
"mhedenskog|mattias@hedenskog.se|httpup|http://magog.se/crux/",
"mike_attic|mike@openbunker.org|httpup|http://www.openbunker.org/crux/ports/mike_attic/", #Mikhail Kolesnik
"mike|mike@openbunker.org|httpup|http://openbunker.org/crux/ports/mike/", #Mikhail Kolesnik
"mikejsavage|mike@mikejsavage.co.uk|httpup|http://mikejsavage.co.uk/crux/", #Mike Savage
#"mono|nymacro@gmail.com|httpup|http://members.optusnet.com.au/dfmarks/crux/mono/",
#"mruiz|manuel.tienza@gmail.com|httpup|http://www.tienza.es/crux/ports/", #Manuel Tienza
#"namenlos|richard.poettler@gmail.com|httpup|http://www.sti2.at/~richardp/ports/", #Richard Poettler
"nexscrp|jkr@nex.scrapping.cc|httpup|http://nex.scrapping.cc/crux/ports/", #Jonas Kramer
"nwe|niklas@allow.se|rsync|www.allow.se::ports/", #Niklas Wennerstrand
"nilp|mytchel@openmailbox.org|httpup|http://raw.github.com/mytch444/crux-ports/master/", #Mytchel Hammond
"ninuzzo|ant@venus.deis.unical.it|httpup|http://monitor.deis.unical.it/ant/crux/",
"nipul|lucas@die.net.au|httpup|http://nipul.die.net.au/ports/", #Lucas Hazel
"nogagplz|nogagplz@gmail.com|httpup|http://crux.ster.zone/ports/nogagplz/", #Neville Phillips (responsible: Danny Rawlinks)
"nym|nymacro@gmail.com|httpup|http://members.optushome.com.au/dfmarks/crux/ports/",
#"omfgroflbboq|omfgroflbboq@spam4.me|httpup|https://github.com/omfgroflbbq/crux-ports/",
"patroclo7|patroclo7@gmail.com|httpup|http://www.patroclo7.org/crux/ports/patroclo7/", #Giorgio Lando
"pitillo|pitillo@ono.com|rsync|vjml.es::ports/pitillo/", #Victor Martinez
"pitman|mad.skipjack@mail.ru|httpup|http://raw.github.com/KonstantinLepa/crux-ports/master/", #Konstantin Lepa
"predatorfreak|predatorfreak@dcaf-security.org|httpup|http://www.dcaf-security.org/ports/", #Brett Andrew Goulder
"prologic|prologic@shortcircuit.net.au|httpup|http://crux.shortcircuit.net.au/", #James Mills
"qba|teoqba@gmail.com|httpup|http://escher.unige.ch/~qba/crux/ports/", #Kuba Kaminski
#"rehabdoll|fredrik@obra.se|rsync|obra.se::ports/", #Fredrik Rinnest
"rexich|bjorn@krstarica.com|httpup|http://crux.ster.zone/ports/rexich/", #Filip Rex Dimovski
"rho|rho@thinkingspot.ch|httpup|http://www.thinkingspot.ch/crux/ports/",
"rines|richard@nespithal.com|httpup|http://crux.richardnespithal.com/", #Richard Nespithal
"rk|crux@roeschu.ch|httpup|http://www.roeschu.ch/ports/crux/",
#"rmull|rmmullen@gmail.com|httpup|http://lug.bu.edu/mirror/crux/ports/", #Ryan Mullen
"roliveira|crux@roliveira.eu|httpup|http://roliveira.eu/crux/ports/", #Ricardo Oliveira
"romster|crux@romster.me|httpup|http://crux.ster.zone/ports/romster/", #Danny Rawlins
"rotwang|rotwang@crux.org.pl|httpup|http://crux.org.pl/ports/rotwang/", #Bartlomiej Palmowski
"rugek|rugek@btcl.de|httpup|http://rugek.dirtyhack.net/crux-ports/rugek/",
"sepen|sepen@crux.nu|rsync|init.it.cx::ports/current/sepen/", #Jose V Beneyto
"sgtmcd|sgtmcd@sgtmcd.com|httpup|http://crux.sgtmcd.com/ports/",
"shin|shin@sterneck.asia|httpup|http://ports.sterneck.asia/shin/", #Shin Sterneck
"singular|arbor@mail.ru|httpup|http://singular.ru/ports/",
"slapdash|dave-slapdash@weller-fahy.com|httpup|http://slapdash.caterva.org/", #David J. Weller-Fahy
"stdevel|webmaster@stankowic-development.net|httpup|http://crux.stankowic-development.net/", #Christian Stankowic
"strw|strawi@googlemail.com|httpup|http://www.gnoedi.org/~straw/crux/ports/",
"swhitton|spw@sdf.org|httpup|http://spw.sdf.org/crux/", #Sean Whitton
"syl|syl@clyl.net|rsync|rsync.clyl.net::crux/", # Pierre Chaussee
"tadzik|tadzikes@gmail.com|httpup|http://mhroczny.abuser.eu/~tadzik/ports/", #Tadeus Sosnierz (irc handle: tadzik)
"teatime|teatime@kyber.io|httpup|http://kyber.io/crux/ports/teatime/", #teatime@irc.kyber.io
"thenschel|thenschel@henschelsoft.de|httpup|http://www.henschelsoft.de/cruxports/",
"ticklestix|npardoe@ticklestix.co.uk|httpup|http://www.ticklestix.co.uk/crux/", #Nathan Pardoe
"tillb|tillbiedermann@yahoo.de|httpup|http://still2come.net/crux/ports/tillb/", #Till Biedermann
"tilman|tilman@code-monkey.de|rsync|code-monkey.de::tilmans-crux-ports/",
"timcow|timcowchip@gmail.com|httpup|https://bitbucket.org/timcowchip/crux-ports/raw/master/", #Chris Farrell
"tsubasa|nickp102@gmail.com|httpup|http://tsubasa.googlecode.com/svn/trunk/tsubasa/", #Sasha Chernyavsky
"uhlu|crux@uhlu.com|httpup|http://ports.uhlu.com/repository/",
"u7knv9h|u7knv9h@openmailbox.org|httpup|https://raw.githubusercontent.com/u7knv9h/CRUX-ports/master/", #F.Kiroles
"vico|vico@bicisport.de|httpup|http://vico.kleinplanet.de/files/repo/",
#"vni|younghead@ukr.net|httpup|http://vni.org.ua/crux/ports/vni/", #Vasylchyshyn Nikolay
"wzff|moritz+crux@wzff.de|rsync|rsync.wzff.de::crux-wzff/", #Moritz Wilhelmy
"xen|syl@clyl.net|rsync|rsync.clyl.net::crux-xen/", # Pierre Chaussee
#"yhafri|ycrux@club-internet.fr|httpup|http://perso.club-internet.fr/yhafri/crux/",
"z3bra|willy@mailoo.org|httpup|http://crux.z3bra.org/ports/" #Willy Goiffon
);
$dsn = 'sqlite:////home/crux/public_html/local/portdb.db';
# End of configuration ######################################################
$db =& DB::connect($dsn);
if (DB::isError($db)) die("Cannot connect to database");
$db->setFetchMode(DB_FETCHMODE_ASSOC);
# Clean existing entries
$sql = "delete from ports";
$res = $db->simpleQuery($sql);
if (DB::isError($res)) die("Query error (delete)");
$sql = "delete from collections";
$res = $db->simpleQuery($sql);
if (DB::isError($res)) die("Query error (delete)");
$sql = "vacuum";
$res = $db->simpleQuery($sql);
if (DB::isError($res)) die("Query error (delete)");
foreach ($collections as $coll) {
$ports = getCollection($coll);
if ($ports !== FALSE) {
storeCollection($coll, $ports);
} else {
$fields = explode('|', $coll);
echo "Errors while retrieving collection ". $fields[0]."\n";
}
}
function getCollection($coll) {
$fields = explode('|', $coll);
switch ($fields[2]) {
case "httpup":
return getHttpupCollection($coll);
break;
case "rsync":
return getRsyncCollection($coll);
break;
default:
return FALSE;
}
}
function getRsyncCollection($coll) {
$ports = array();
$out = array();
$fields = explode('|', $coll);
$res = -1;
exec("/usr/bin/rsync --list-only $fields[3]", $out, $res);
if ($res !== 0)
return FALSE;
foreach ($out as $line) {
if ($line[0] == "d") {
$sp = explode(' ', $line);
$portname = $sp[count($sp)-1];
if ($portname != ".")
$ports[] = $portname;
}
}
if (count($ports)>0)
return $ports;
return FALSE;
}
function getHttpupCollection($coll){
$ports = array();
$fields = explode('|', $coll);
$lines = file($fields[3]."REPO");
if ($lines === FALSE)
return FALSE;
foreach ($lines as $line) {
if (substr($line, 0, 2) == "d:") {
$ports[] = trim(substr($line,2));
}
}
if (count($ports)>0)
return $ports;
return FALSE;
}
function storeCollection($coll, $ports) {
global $db;
$fields = explode('|', $coll);
foreach ($ports as $port) {
$vals = array($port, $fields[0]);
$sth = $db->prepare("insert into ports values (NULL, ?, ?)");
$res = $db->execute($sth, $vals);
if (DB::isError($res)) die("Query error (port)");
}
$vals = explode('|', $coll);
$sth = $db->prepare("insert into collections values (NULL, ?, ?, ?, ?)");
$res = $db->execute($sth, $vals);
if (DB::isError($res)) die("Query error (collection)");
}
?>