Просмотр исходного кода

add support for multiple URIs in deb822 style sources.list

Michael Vogt лет назад: 12
Родитель
Сommit
75c10df153
4 измененных файлов с 32 добавлено и 16 удалено
  1. 18 11
      apt-pkg/sourcelist.cc
  2. 2 2
      doc/sources.list.5.xml
  3. 10 1
      test/integration/test-apt-sources-deb822
  4. 2 2
      test/libapt/sourcelist_test.cc

+ 18 - 11
apt-pkg/sourcelist.cc

@@ -78,13 +78,6 @@ bool pkgSourceList::Type::ParseStanza(vector<metaIndex *> &List,
 {
 {
    map<string, string> Options;
    map<string, string> Options;
 
 
-   string URI = Tags.FindS("URI");
-   if (!FixupURI(URI))
-   {
-      _error->Error(_("Malformed stanza %u in source list %s (URI parse)"),i,Fd.Name().c_str());
-      return false;
-   }
-
    string Enabled = Tags.FindS("Enabled");
    string Enabled = Tags.FindS("Enabled");
    if (Enabled.size() > 0 && StringToBool(Enabled) == false)
    if (Enabled.size() > 0 && StringToBool(Enabled) == false)
       return true;
       return true;
@@ -104,20 +97,34 @@ bool pkgSourceList::Type::ParseStanza(vector<metaIndex *> &List,
    string Suite = Tags.FindS("Suites");
    string Suite = Tags.FindS("Suites");
    Suite = SubstVar(Suite,"$(ARCH)",_config->Find("APT::Architecture"));
    Suite = SubstVar(Suite,"$(ARCH)",_config->Find("APT::Architecture"));
    string const Section = Tags.FindS("Sections");
    string const Section = Tags.FindS("Sections");
+   string URIS = Tags.FindS("URIs");
 
 
+   std::vector<std::string> list_uris = StringSplit(URIS, " ");
    std::vector<std::string> list_dist = StringSplit(Suite, " ");
    std::vector<std::string> list_dist = StringSplit(Suite, " ");
    std::vector<std::string> list_section = StringSplit(Section, " ");
    std::vector<std::string> list_section = StringSplit(Section, " ");
-   for (std::vector<std::string>::const_iterator I = list_dist.begin();
-        I != list_dist.end(); I++)
+   
+   for (std::vector<std::string>::const_iterator U = list_uris.begin();
+        U != list_uris.end(); U++)
    {
    {
-      for (std::vector<std::string>::const_iterator J = list_section.begin();
-           J != list_section.end(); J++)
+      std::string URI = (*U);
+      if (!FixupURI(URI))
+      {
+         _error->Error(_("Malformed stanza %u in source list %s (URI parse)"),i,Fd.Name().c_str());
+         return false;
+      }
+
+      for (std::vector<std::string>::const_iterator I = list_dist.begin();
+           I != list_dist.end(); I++)
+      {
+         for (std::vector<std::string>::const_iterator J = list_section.begin();
+              J != list_section.end(); J++)
          {
          {
             if (CreateItem(List, URI, (*I), (*J), Options) == false)
             if (CreateItem(List, URI, (*I), (*J), Options) == false)
             {
             {
                return false;
                return false;
             }
             }
          }
          }
+      }
    }
    }
    return true;
    return true;
 }
 }

+ 2 - 2
doc/sources.list.5.xml

@@ -84,7 +84,7 @@
    <para>Alternatively a rfc822 style format is also supported:
    <para>Alternatively a rfc822 style format is also supported:
    <literallayout>
    <literallayout>
      Type: deb
      Type: deb
-     URI: http://example.com
+     URIs: http://example.com
      Suites: stable testing
      Suites: stable testing
      Sections: component1 component2
      Sections: component1 component2
      Description: short
      Description: short
@@ -92,7 +92,7 @@
      [option1]: [option1-value]
      [option1]: [option1-value]
 
 
      Type: deb-src
      Type: deb-src
-     URI: http://example.com
+     URIs: http://example.com
      Suites: stable
      Suites: stable
      Sections: component1 component2
      Sections: component1 component2
      Enabled: no
      Enabled: no

+ 10 - 1
test/integration/test-apt-sources-deb822

@@ -20,7 +20,7 @@ BASE="# some comment
 #Type: meep
 #Type: meep
 
 
 Type: deb
 Type: deb
-URI: http://ftp.debian.org/debian
+URIs: http://ftp.debian.org/debian
 Suites: stable
 Suites: stable
 Sections: main
 Sections: main
 Description: summay
 Description: summay
@@ -79,3 +79,12 @@ E: The list of sources could not be read."  aptget update --print-uris
 echo "$BASE"  > $SOURCES
 echo "$BASE"  > $SOURCES
 echo "Enabled: no" >> $SOURCES
 echo "Enabled: no" >> $SOURCES
 testempty aptget update --print-uris
 testempty aptget update --print-uris
+
+# multiple URIs
+echo "$BASE"  | sed -e 's#http://ftp.debian.org/debian#http://ftp.debian.org/debian http://ftp.de.debian.org/debian#' > $SOURCES
+testequalwithmsg "Multiple URIs work" "'http://ftp.de.debian.org/debian/dists/stable/main/binary-i386/Packages.bz2' ftp.de.debian.org_debian_dists_stable_main_binary-i386_Packages 0 :
+'http://ftp.de.debian.org/debian/dists/stable/main/i18n/Translation-en.bz2' ftp.de.debian.org_debian_dists_stable_main_i18n_Translation-en 0 :
+'http://ftp.de.debian.org/debian/dists/stable/InRelease' ftp.de.debian.org_debian_dists_stable_InRelease 0 
+'http://ftp.debian.org/debian/dists/stable/main/binary-i386/Packages.bz2' ftp.debian.org_debian_dists_stable_main_binary-i386_Packages 0 :
+'http://ftp.debian.org/debian/dists/stable/main/i18n/Translation-en.bz2' ftp.debian.org_debian_dists_stable_main_i18n_Translation-en 0 :
+'http://ftp.debian.org/debian/dists/stable/InRelease' ftp.debian.org_debian_dists_stable_InRelease 0 "  aptget update --print-uris 

+ 2 - 2
test/libapt/sourcelist_test.cc

@@ -23,14 +23,14 @@ int main(int argc, char *argv[])
 {
 {
    const char contents[] = ""
    const char contents[] = ""
       "Type: deb\n"
       "Type: deb\n"
-      "URI: http://ftp.debian.org/debian\n"
+      "URIs: http://ftp.debian.org/debian\n"
       "Suites: stable\n"
       "Suites: stable\n"
       "Sections: main\n"
       "Sections: main\n"
       "Description: short\n"
       "Description: short\n"
       " long description that can be very long\n"
       " long description that can be very long\n"
       "\n"
       "\n"
       "Type: deb\n"
       "Type: deb\n"
-      "URI: http://ftp.debian.org/debian\n"
+      "URIs: http://ftp.debian.org/debian\n"
       "Suite: unstable\n"
       "Suite: unstable\n"
       "Section: main non-free\n"
       "Section: main non-free\n"
       ;
       ;