From d731f9c574138a9cb31c586a8f1e7d7181a44456 Mon Sep 17 00:00:00 2001 From: Michael Vogt Date: Mon, 8 Jan 2007 11:19:32 +0100 Subject: * apt-pkg/init.cc: - added Dir::State::Mirrors * doc/examples/configure-index: - added Acquire::mirror::RefreshInterval * methods/mirror.{cc,h}: - download the mirror file into Dir::State::Mirrors - added RefreshInterval option to not ask for the mirror file too often --- debian/apt.dirs | 1 + 1 file changed, 1 insertion(+) (limited to 'debian') diff --git a/debian/apt.dirs b/debian/apt.dirs index e1cb738fa..b81878baa 100644 --- a/debian/apt.dirs +++ b/debian/apt.dirs @@ -5,5 +5,6 @@ etc/apt etc/apt/sources.list.d var/cache/apt/archives/partial var/lib/apt/lists/partial +var/lib/apt/mirrors/partial var/lib/apt/periodic usr/share/bug/apt -- cgit v1.2.3-70-g09d2 From 362d29343e5d25248bcd84300aa1b18effe891e7 Mon Sep 17 00:00:00 2001 From: Michael Vogt Date: Wed, 24 Jan 2007 14:42:17 +0100 Subject: make the mirror failures actually produce a error message --- cmdline/makefile | 6 ++++++ cmdline/report-mirror-failure | 21 -------------------- configure.in | 2 +- debian/changelog | 2 +- methods/mirror.cc | 46 ++++++++++++++++++++++++++++++++----------- po/apt-all.pot | 6 +++--- 6 files changed, 46 insertions(+), 37 deletions(-) delete mode 100755 cmdline/report-mirror-failure (limited to 'debian') diff --git a/cmdline/makefile b/cmdline/makefile index 882a0e1b5..f07c7da3b 100644 --- a/cmdline/makefile +++ b/cmdline/makefile @@ -52,3 +52,9 @@ SOURCE=apt-key TO=$(BIN) TARGET=program include $(COPY_H) + +# The apt-key program +SOURCE=apt-report-mirror-failure +TO=$(LIB) +TARGET=program +include $(COPY_H) diff --git a/cmdline/report-mirror-failure b/cmdline/report-mirror-failure deleted file mode 100755 index 8301ed079..000000000 --- a/cmdline/report-mirror-failure +++ /dev/null @@ -1,21 +0,0 @@ -#!/usr/bin/python - -import sys -import urllib -import apt_pkg - -apt_pkg.init() -url = apt_pkg.Config.Find("Acquire::Mirror::ReportFailures", - "http://people.ubuntu.com:9000/mirror-failure") - #"http://localhost:9000/mirror-failure") -if not url: - sys.exit(0) - -data = {} -data['url'] = sys.argv[1] -data['error'] = sys.argv[2] -f = urllib.urlopen(url, urllib.urlencode(data)) -f.read() -f.close() - - diff --git a/configure.in b/configure.in index 81f327c37..df452ba34 100644 --- a/configure.in +++ b/configure.in @@ -18,7 +18,7 @@ AC_CONFIG_AUX_DIR(buildlib) AC_CONFIG_HEADER(include/config.h:buildlib/config.h.in include/apti18n.h:buildlib/apti18n.h.in) dnl -- SET THIS TO THE RELEASE VERSION -- -AC_DEFINE_UNQUOTED(VERSION,"0.6.46.3") +AC_DEFINE_UNQUOTED(VERSION,"0.6.46.4") PACKAGE="apt" AC_DEFINE_UNQUOTED(PACKAGE,"$PACKAGE") AC_SUBST(PACKAGE) diff --git a/debian/changelog b/debian/changelog index 24e10dcd5..6c9ada3a5 100644 --- a/debian/changelog +++ b/debian/changelog @@ -2,7 +2,7 @@ apt (0.6.46.4) unstable; urgency=low * add apt-secure.8 to "See also" section - -- + -- Michael Vogt Wed, 24 Jan 2007 14:34:15 +0100 apt (0.6.46.3) unstable; urgency=low diff --git a/methods/mirror.cc b/methods/mirror.cc index 6621d47e2..8f9b8ed34 100644 --- a/methods/mirror.cc +++ b/methods/mirror.cc @@ -30,13 +30,18 @@ using namespace std; #include "apti18n.h" /*}}}*/ -/* +/* Done: + * - works with http only + * - always picks the first mirror from the list + * - call out to problem reporting script + * - supports "deb mirror://host/path/to/mirror-list/// dist component" + * * TODO: - * - what about gpgv failures? better standard format for errors - to send back to LP - #OR# - * - implement it at the pkgAcquire::Item::Failed() level but then - we need to send back what uri exactly was failing + * what about gpgv failures? this should call-out to the problem reporting + script, but we need to know what mirror was used + * better standard format for errors to send back + * - implement failure reporting at the pkgAcquire::Item::Failed() level + but then we need to send back what uri exactly was failing [mvo: the problem with this approach is ::Failed() is not really called for all failures :/ e.g. md5sum mismatch in a archive is not] @@ -46,6 +51,7 @@ using namespace std; * - magicmarker is (a bit) evil, maybe just use a similar approach as in clean and read the sources.list and use the GetURI() method to find the prefix? + * support more than http * - testing :) */ @@ -243,16 +249,34 @@ void MirrorMethod::URIDone(FetchResult &Res,FetchResult *Alt) void MirrorMethod::ReportMirrorFailure(string FailCode) { // report that Queue->Uri failed +#if 0 std::cerr << "\nReportMirrorFailure: " << Queue->Uri << " FailCode: " << FailCode << std::endl; -#if 0 // FIXME: do not use system, make sure to properly encode - // URI/FailCode, do not hardcode the submit url - system("curl -d url=" + Queue->Uri + - " -d FailureCode=" + FailCode + - " http://localhost:8000/ &"); #endif + const char *Args[40]; + unsigned int i = 0; + string report = _config->Find("Methods::Mirror::ProblemReporting", + "/usr/lib/apt/report-mirror-failure"); + Args[i++] = report.c_str(); + Args[i++] = Queue->Uri.c_str(); + Args[i++] = FailCode.c_str(); + pid_t pid = ExecFork(); + if(pid < 0) + { + _error->Error("ReportMirrorFailure Fork failed"); + return; + } + else if(pid == 0) + { + execvp(report.c_str(), (char**)Args); + } + if(!ExecWait(pid, "report-mirror-failure")) + { + _error->Warning("Couldn't report problem to '%s'", + _config->Find("Acquire::Mirror::ReportFailures").c_str()); + } } int main() diff --git a/po/apt-all.pot b/po/apt-all.pot index aee5c09c8..dd140bd63 100644 --- a/po/apt-all.pot +++ b/po/apt-all.pot @@ -7,7 +7,7 @@ msgid "" msgstr "" "Project-Id-Version: PACKAGE VERSION\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2006-11-24 16:37+0100\n" +"POT-Creation-Date: 2007-01-24 12:51+0100\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" @@ -1330,7 +1330,7 @@ msgstr "" #: apt-inst/extract.cc:467 apt-pkg/contrib/configuration.cc:750 #: apt-pkg/contrib/cdromutl.cc:153 apt-pkg/sourcelist.cc:324 -#: apt-pkg/acquire.cc:421 apt-pkg/clean.cc:38 methods/mirror.cc:92 +#: apt-pkg/acquire.cc:421 apt-pkg/clean.cc:38 methods/mirror.cc:96 #, c-format msgid "Unable to read %s" msgstr "" @@ -1956,7 +1956,7 @@ msgid "Unable to stat the mount point %s" msgstr "" #: apt-pkg/contrib/cdromutl.cc:149 apt-pkg/acquire.cc:427 apt-pkg/clean.cc:44 -#: methods/mirror.cc:98 +#: methods/mirror.cc:102 #, c-format msgid "Unable to change to %s" msgstr "" -- cgit v1.2.3-70-g09d2 From 3f599bb721c4ac58d8ff18991c9704b5f30eaa2b Mon Sep 17 00:00:00 2001 From: Michael Vogt Date: Tue, 6 Feb 2007 10:49:25 +0100 Subject: * apt-pkg/acquire-item.cc: - default to "/usr/lib/apt/apt-report-mirror-failure" * cmdline/apt-report-mirror-failure: - no default comit url for now * debian/rules: - move apt-report-mirror-failure into /usr/lib/apt * doc/examples/configure-index: - more documentation * methods/mirror.cc: - updated TODO --- apt-pkg/acquire-item.cc | 2 +- cmdline/apt-report-mirror-failure | 4 ++-- cmdline/makefile | 2 +- debian/rules | 4 ++++ doc/examples/configure-index | 4 ++++ methods/mirror.cc | 1 + 6 files changed, 13 insertions(+), 4 deletions(-) (limited to 'debian') diff --git a/apt-pkg/acquire-item.cc b/apt-pkg/acquire-item.cc index 14610d6e9..38530152f 100644 --- a/apt-pkg/acquire-item.cc +++ b/apt-pkg/acquire-item.cc @@ -154,7 +154,7 @@ void pkgAcquire::Item::ReportMirrorFailure(string FailCode) const char *Args[40]; unsigned int i = 0; string report = _config->Find("Methods::Mirror::ProblemReporting", - "/usr/bin/apt-report-mirror-failure"); + "/usr/lib/apt/apt-report-mirror-failure"); if(!FileExists(report)) return; Args[i++] = report.c_str(); diff --git a/cmdline/apt-report-mirror-failure b/cmdline/apt-report-mirror-failure index fb43f0e74..1567e78e3 100755 --- a/cmdline/apt-report-mirror-failure +++ b/cmdline/apt-report-mirror-failure @@ -5,8 +5,8 @@ import urllib import apt_pkg apt_pkg.init() -url = apt_pkg.Config.Find("Acquire::Mirror::ReportFailures", - "http://people.ubuntu.com:9000/mirror-failure") +url = apt_pkg.Config.Find("Acquire::Mirror::ReportFailures", None) + #"http://people.ubuntu.com:9000/mirror-failure") #"http://localhost:9000/mirror-failure") if not url: sys.exit(0) diff --git a/cmdline/makefile b/cmdline/makefile index f07c7da3b..8d284c2f3 100644 --- a/cmdline/makefile +++ b/cmdline/makefile @@ -55,6 +55,6 @@ include $(COPY_H) # The apt-key program SOURCE=apt-report-mirror-failure -TO=$(LIB) +TO=$(BIN) TARGET=program include $(COPY_H) diff --git a/debian/rules b/debian/rules index 02ee734bb..9e87b1723 100755 --- a/debian/rules +++ b/debian/rules @@ -214,6 +214,10 @@ apt: build debian/shlibs.local # head -n 500 ChangeLog > debian/ChangeLog + # move the mirror failure script in place + mv debian/$@/usr/bin/apt-report-mirror-failure \ + debian/$@/usr/lib/apt/apt-report-mirror-failure \ + dh_installexamples -p$@ $(BLD)/docs/examples/* dh_installman -p$@ dh_installcron -p$@ diff --git a/doc/examples/configure-index b/doc/examples/configure-index index 81bb6b3b0..81fa4c52f 100644 --- a/doc/examples/configure-index +++ b/doc/examples/configure-index @@ -166,6 +166,10 @@ Acquire RefreshInterval "360"; // refresh interval in minutes MaxAge "90"; // max age for a mirror file in days before // it gets deleted + // mirror failure reporting script + ProblemReporting "/usr/lib/apt/apt-report-mirror-failure"; + // mirror failure reporting url + ReportFailures "http://example.com/mirror-failure"; }; }; diff --git a/methods/mirror.cc b/methods/mirror.cc index c5c0c7461..9a86a10c2 100644 --- a/methods/mirror.cc +++ b/methods/mirror.cc @@ -42,6 +42,7 @@ using namespace std; * - deal with runing as non-root because we can't write to the lists dir then -> use the cached mirror file * - better method to download than having a pkgAcquire interface here + * and better error handling there! * - support more than http * - testing :) */ -- cgit v1.2.3-70-g09d2