Bug#815202: packages: machines and sponsors information is outdated
Stéphane Blondon <[email protected]>
| Newsgroups | gmane.linux.debian.devel.www |
|---|---|
| Message-ID | <57044C96.2000708__7364.57517273283$1459899746$gmane$org@gmail.com> |
Le 05/04/2016 07:06, Paul Wise a écrit : > On Tue, Apr 5, 2016 at 9:05 AM, Stéphane Blondon wrote: > >> There are no commit since two years, so I'm not sure it's still alive. > > Nevertheless, it is the way forward. > >> I tried to extract the useful code from the script. It depends on the >> libnet-ldapapi-perl package and the configuration of the machine which >> is running the LDAP. > > The Debian LDAP can be accessed from any machine, anonymous access > will only return the public data (including hostname stuff). So you > shouldn't need to run on db.d.o nor read the config file at all. Thank you for these infos, I ignored them. :-) I attached 2 scripts (one in Perl, one in Python) allowing to get the names of the machines providing packages.debian.org service. I think some checks about LDAP errors could be added but it's a start. I guess the perl script could be included in order to fix the current bug report. -- Stéphane
packagemachines.pl
(application/x-perl, 757 B)
#!/usr/bin/perl
#
# package libnet-ldap-perl must be installed
use strict;
use Net::LDAP;
my $ldap_server = "db.debian.org";
my $ldap_base = "dc=debian,dc=org";
my @package_machine_names = ();
sub get_packages_machines(){
my $ldap = Net::LDAP->new($ldap_server);
$ldap->bind();
my $mesg = $ldap->search(base => $ldap_base, filter => 'host=*');
$ldap->unbind();
foreach my $machine ($mesg->entries) {
my $host = $machine->get_value ("host");
my $purpose = $machine->get_value ("purpose");
if( index($purpose, "packages.debian.org") >= 0 ){
push(@package_machine_names, $host)
}
}
}
get_packages_machines();
foreach my $name (@package_machine_names){ print $name."\n";}
packagemachines.py
(text/x-python, 798 B)
#! /usr/bin/python
#
# package python-ldap must be installed
import ldap
def get_packages_machines():
machines = _request_machines_on_ldap()
packages_machines = []
for machine in machines:
details = machine[1]
try:
if "packages.debian.org" in details["purpose"][0]:
packages_machines.append(details["host"][0])
except KeyError:
pass
return packages_machines
def _request_machines_on_ldap():
l = ldap.initialize("ldap://db.debian.org")
l.simple_bind_s("", "")
ldap_result_id = l.search("dc=debian,dc=org", ldap.SCOPE_SUBTREE, "host=*")
result_type, result_data = l.result(ldap_result_id, 1)
l.unbind_s()
return result_data
if __name__ == "__main__":
print(get_packages_machines())
signature.asc
(application/pgp-signature, 819 B)
-----BEGIN PGP SIGNATURE----- Version: GnuPG v2 iQIbBAEBCAAGBQJXBEygAAoJEKK5G8bNTr3cq78P+L0qxo70B5KuHKCNAH6J+EyD WVqrt4/Wlhonl94I4dTipaDFcyqNldQstZo18kRhTd+64QBEXlvyfdshok+Q1bvj Du5Q8z7oLhbqoSviFG73kCd+Q2ztUe6ylZa1VKlKh+hztv53gHW1B4YulgJx0EsM 1bEwSKR+TIsuvPwRF3ZNQR/QtRCc+t0ka1rgK9iSHNh2TM/bkVfD5x6hWU3zHoOC eIlOdcOUEsRXVKqLZF8edWcSLITw9KgvtjS/6snGG+zFBxFw91q93sly3Vxc7YVA Xfj2GNjf1CGFtCn/Nh+lkmzj8KMnhZqfBYOzWhMoFA+cJYc0yhYlg9exFNTKF7oQ S/FZ5AMeQaErYaLiy5279SOOFznPaK1z6fJ39rbpLXy52kOUAJCk6xH13F/Ogkqi NDNt8YFBYYsHYdvqI7ut59FPrfHvvTZoutbRKRY4fTyeliVlSfGk+BWgBmzVnnc4 KqVhPVT3Fyy9oA8WdCs7Jl5bzH0m4P9w2mWRKPnbgNO8dcbjHpHsQRnrr6wESxw5 ulhglMaSgUbScgPIqWu9m6FVK4FzgY1l2AZAP5ycXBiQGn7V8xyPRS7rTAjtTgNE KsoIxDr0KwRxtC4MlgSndWn7VExcZgTApCpy4JhMTWo16vW8YP8LfS8d1+smA8YF TyxfTmA3gDFBt3iw7Ek= =jmEn -----END PGP SIGNATURE-----