Quellcode durchsuchen

make the mirror failures actually produce a error message

Michael Vogt vor 19 Jahren
Ursprung
Commit
362d29343e
6 geänderte Dateien mit 46 neuen und 37 gelöschten Zeilen
  1. 6 0
      cmdline/makefile
  2. 0 21
      cmdline/report-mirror-failure
  3. 1 1
      configure.in
  4. 1 1
      debian/changelog
  5. 35 11
      methods/mirror.cc
  6. 3 3
      po/apt-all.pot

+ 6 - 0
cmdline/makefile

@@ -52,3 +52,9 @@ SOURCE=apt-key
 TO=$(BIN)
 TO=$(BIN)
 TARGET=program
 TARGET=program
 include $(COPY_H)
 include $(COPY_H)
+
+# The apt-key program
+SOURCE=apt-report-mirror-failure
+TO=$(LIB)
+TARGET=program
+include $(COPY_H)

+ 0 - 21
cmdline/report-mirror-failure

@@ -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()
-
-

+ 1 - 1
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)
 AC_CONFIG_HEADER(include/config.h:buildlib/config.h.in include/apti18n.h:buildlib/apti18n.h.in)
 
 
 dnl -- SET THIS TO THE RELEASE VERSION --
 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"
 PACKAGE="apt"
 AC_DEFINE_UNQUOTED(PACKAGE,"$PACKAGE")
 AC_DEFINE_UNQUOTED(PACKAGE,"$PACKAGE")
 AC_SUBST(PACKAGE)
 AC_SUBST(PACKAGE)

+ 1 - 1
debian/changelog

@@ -2,7 +2,7 @@ apt (0.6.46.4) unstable; urgency=low
 
 
   * add apt-secure.8 to "See also" section
   * add apt-secure.8 to "See also" section
 
 
- --
+ -- Michael Vogt <michael.vogt@ubuntu.com>  Wed, 24 Jan 2007 14:34:15 +0100
 
 
 apt (0.6.46.3) unstable; urgency=low
 apt (0.6.46.3) unstable; urgency=low
 
 

+ 35 - 11
methods/mirror.cc

@@ -30,13 +30,18 @@ using namespace std;
 #include "apti18n.h"
 #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: 
  * 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
      [mvo: the problem with this approach is ::Failed() is not really
            called for all failures :/ e.g. md5sum mismatch in a archive
            called for all failures :/ e.g. md5sum mismatch in a archive
            is not]
            is not]
@@ -46,6 +51,7 @@ using namespace std;
  * - magicmarker is (a bit) evil, maybe just use a similar approach as in
  * - 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
      clean and read the sources.list and use the GetURI() method to find
      the prefix?
      the prefix?
+ * support more than http
  * - testing :)
  * - testing :)
  */
  */
 
 
@@ -243,16 +249,34 @@ void MirrorMethod::URIDone(FetchResult &Res,FetchResult *Alt)
 void MirrorMethod::ReportMirrorFailure(string FailCode)
 void MirrorMethod::ReportMirrorFailure(string FailCode)
 {
 {
    // report that Queue->Uri failed
    // report that Queue->Uri failed
+#if 0
    std::cerr << "\nReportMirrorFailure: " 
    std::cerr << "\nReportMirrorFailure: " 
 	     << Queue->Uri
 	     << Queue->Uri
 	     << " FailCode: " 
 	     << " FailCode: " 
 	     << FailCode << std::endl;
 	     << 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
 #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()
 int main()

+ 3 - 3
po/apt-all.pot

@@ -7,7 +7,7 @@ msgid ""
 msgstr ""
 msgstr ""
 "Project-Id-Version: PACKAGE VERSION\n"
 "Project-Id-Version: PACKAGE VERSION\n"
 "Report-Msgid-Bugs-To: \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"
 "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
 "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
 "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
 "Language-Team: LANGUAGE <LL@li.org>\n"
 "Language-Team: LANGUAGE <LL@li.org>\n"
@@ -1330,7 +1330,7 @@ msgstr ""
 
 
 #: apt-inst/extract.cc:467 apt-pkg/contrib/configuration.cc:750
 #: apt-inst/extract.cc:467 apt-pkg/contrib/configuration.cc:750
 #: apt-pkg/contrib/cdromutl.cc:153 apt-pkg/sourcelist.cc:324
 #: 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
 #, c-format
 msgid "Unable to read %s"
 msgid "Unable to read %s"
 msgstr ""
 msgstr ""
@@ -1956,7 +1956,7 @@ msgid "Unable to stat the mount point %s"
 msgstr ""
 msgstr ""
 
 
 #: apt-pkg/contrib/cdromutl.cc:149 apt-pkg/acquire.cc:427 apt-pkg/clean.cc:44
 #: 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
 #, c-format
 msgid "Unable to change to %s"
 msgid "Unable to change to %s"
 msgstr ""
 msgstr ""