]> git.saurik.com Git - apt.git/commitdiff
add support for multipl types in one line
authorMichael Vogt <mvo@debian.org>
Mon, 20 Jan 2014 07:17:43 +0000 (08:17 +0100)
committerMichael Vogt <mvo@debian.org>
Mon, 20 Jan 2014 07:17:43 +0000 (08:17 +0100)
apt-pkg/sourcelist.cc
doc/sources.list.5.xml
test/integration/test-apt-sources-deb822
test/libapt/sourcelist_test.cc

index 3390051491e5463d018f249009b97a7cb52b4407..bbc514f5bbfea60be776b9e9502bde6f9de6089e 100644 (file)
@@ -387,21 +387,26 @@ int pkgSourceList::ParseFileDeb822(string File)
    // read step by step
    while (Sources.Step(Tags) == true)
    {
-      if(!Tags.Exists("Type")) 
+      if(!Tags.Exists("Types")) 
          continue;
 
-      string const type = Tags.FindS("Type");
-      Type *Parse = Type::GetType(type.c_str());
-      if (Parse == 0)
+      string const types = Tags.FindS("Types");
+      std::vector<std::string> list_types = StringSplit(types, " ");
+      for (std::vector<std::string>::const_iterator I = list_types.begin();
+        I != list_types.end(); I++)
       {
-         _error->Error(_("Type '%s' is not known on stanza %u in source list %s"),type.c_str(),i,Fd.Name().c_str());
-         return -1;
-      }
+         Type *Parse = Type::GetType((*I).c_str());
+         if (Parse == 0)
+         {
+            _error->Error(_("Type '%s' is not known on stanza %u in source list %s"), (*I).c_str(),i,Fd.Name().c_str());
+            return -1;
+         }
          
-      if (!Parse->ParseStanza(SrcList, Tags, i, Fd))
-         return -1;
+         if (!Parse->ParseStanza(SrcList, Tags, i, Fd))
+            return -1;
 
-      i++;
+         i++;
+      }
    }
 
    // we are done, return the number of stanzas read
index 5a421293ee096b19ea558f954e81f0c6e2b8746e..4d0c4d5022f46602aae703ccc59ab37ed2f59acf 100644 (file)
@@ -83,7 +83,7 @@
 
    <para>Alternatively a rfc822 style format is also supported:
    <literallayout>
-     Type: deb
+     Types: deb deb-src
      URIs: http://example.com
      Suites: stable testing
      Sections: component1 component2
@@ -91,9 +91,9 @@
       long long long
      [option1]: [option1-value]
 
-     Type: deb-src
-     URIs: http://example.com
-     Suites: stable
+     Types: deb
+     URIs: http://another.example.com
+     Suites: experimental
      Sections: component1 component2
      Enabled: no
      Description: short
index 5c91dd6f5504113dd9147d5790284fc61fc3c629..e74fc4cb90ca5b21f144a029e5f19c1d990d862f 100755 (executable)
@@ -17,9 +17,9 @@ testequalwithmsg "Old style sources.list works" "'http://ftp.debian.org/debian/d
 
 BASE="# some comment
 # that contains a : as well
-#Type: meep
+#Types: meep
 
-Type: deb
+Types: deb
 URIs: http://ftp.debian.org/debian
 Suites: stable
 Sections: main
@@ -68,7 +68,7 @@ echo "deb http://ftp.debian.org" > $SOURCES
 testequalwithmsg "Invalid sources.list file gives proper error" "E: Malformed line 1 in source list $TMPWORKINGDIRECTORY/rootdir/etc/apt/sources.list (dist)
 E: The list of sources could not be read."  aptget update --print-uris
 
-echo "Type: deb
+echo "Types: deb
 Suites: stable
 " > $SOURCES
 
@@ -88,3 +88,10 @@ testequalwithmsg "Multiple URIs work" "'http://ftp.de.debian.org/debian/dists/st
 '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 
+
+# multiple Type in one field
+echo "$BASE"  | sed -e 's#Types: deb#Types: deb deb-src#' > $SOURCES
+testequalwithmsg "Multiple Types work" "'http://ftp.debian.org/debian/dists/stable/main/source/Sources.bz2' ftp.debian.org_debian_dists_stable_main_source_Sources 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 
index 3597b3d583228ac2be1569eba653df177ba81b46..6ab30ba6727d9ad5520bfe954940a97c7b5a0de0 100644 (file)
@@ -22,17 +22,17 @@ void remove_tmpfile(void)
 int main(int argc, char *argv[])
 {
    const char contents[] = ""
-      "Type: deb\n"
+      "Types: deb\n"
       "URIs: http://ftp.debian.org/debian\n"
       "Suites: stable\n"
       "Sections: main\n"
       "Description: short\n"
       " long description that can be very long\n"
       "\n"
-      "Type: deb\n"
+      "Types: deb\n"
       "URIs: http://ftp.debian.org/debian\n"
-      "Suite: unstable\n"
-      "Section: main non-free\n"
+      "Suites: unstable\n"
+      "Sections: main non-free\n"
       ;
 
    FileFd fd;