Re: APT sources idea
* "James A. Treacy"
| The problem with this is the usual problem in figuring out where a site
| is actually located. Additionally, geographic location often has little
| relation to how good a connection that a person has to a site.
Hmm, is that a problem?
from mirror/Mirrors.masterlist:
Site: http.us.debian.org
Alias: ftp1.us.debian.org
Type: Push-Primary
Archive-http: /debian/
Archive-ftp: /debian/
Archive-rsync: debian/
Country: US United States
Comment: Rotating DNS mirror cluster
Should be pretty easy to generate apt sources lines from this,
actually, something like:
<html>
<title>Autogenerate apt lines
</title>
<body>
<?
$MASTERLIST="/home/tfheen/workdir/debian/dwn/webwml/english/mirror/Mirrors.masterlist";
$mirrors = array();
$fd = fopen($MASTERLIST,"r");
$site = "";
while (!feof($fd)) {
$buffer = trim(fgets($fd, 4096));
if (strstr($buffer,"Site: ") != false) {
$tmp = split(":",$buffer);
$site = trim($tmp[1]);
$mirrors[$site] = array();
$mirrors[$site]["Site"] = $site;
} else {
$tmp = split(":",$buffer);
$key = trim($tmp[0]);
$value = trim($tmp[1]);
$mirrors[$site][$key] = $value;
}
}
$countries = array();
while (list($k,$v) = each($mirrors)) {
if (!isset($countries[$v["Country"]])) {
$countries[$v["Country"]] = 1;
}
}
ksort($countries);
if (isset($HTTP_POST_VARS["country"])) {
reset($mirrors);
while (list($k,$v) = each($mirrors)) {
if ($v["Country"] == $HTTP_POST_VARS["country"]) {
print "<pre>";
if (isset($v["Archive-http"])) {
print "deb http://$k".$v["Archive-http"]." ".$HTTP_POST_VARS["dist"]. " main contrib non-free\n";
} elseif (isset($v["Archive-ftp"])) {
print "deb ftp://$k".$v["Archive-ftp"]." ".$HTTP_POST_VARS["dist"]. " main contrib non-free\n";
}
if (isset($v["NonUS-http"])) {
print "deb http://$k".$v["NonUS-http"]." non-US/".$HTTP_POST_VARS["dist"]. " main contrib non-free\n";
} elseif (isset($v["NonUS-ftp"])) {
print "deb ftp://$k".$v["NonUS-ftp"]." non-US/".$HTTP_POST_VARS["dist"]. " main contrib non-free\n";
}
// print "$k";
print "</pre>";
}
}
}
?>
<form method="post">
<input type="radio" name="dist" value="stable">Stable
<input type="radio" name="dist" value="testing">Testing
<input type="radio" name="dist" value="unstable">Unstable
<select name="country">
<?
while (list($k,$v) = each($countries)) {
print "<option value=\"$k\">$k</option>\n";
}
?>
</select>
<input type="submit">
</form>
</body>
</html>
is a start. (PHP)
--
Tollef Fog Heen
Axiom #1: You Can't Win
Reply to: