]> git.saurik.com Git - apt.git/commitdiff
Merge remote-tracking branch 'mvo/debian/sid' into debian/sid
authorMichael Vogt <mvo@debian.org>
Sat, 25 Jan 2014 20:55:11 +0000 (21:55 +0100)
committerMichael Vogt <mvo@debian.org>
Sat, 25 Jan 2014 20:55:11 +0000 (21:55 +0100)
1  2 
apt-pkg/sourcelist.cc
test/integration/test-apt-sources-deb822

diff --combined apt-pkg/sourcelist.cc
index ac326d157e76e08a8841630fdf478698b1215bd9,8462027c50d4abd289b1ebe4588590e64e2694a5..1f5179885627ab780a1e2b8a25ae9da619689133
@@@ -20,6 -20,7 +20,7 @@@
  #include <apt-pkg/tagfile.h>
  
  #include <fstream>
+ #include <algorithm>
  
  #include <apti18n.h>
                                                                        /*}}}*/
@@@ -78,9 -79,12 +79,9 @@@ bool pkgSourceList::Type::ParseStanza(v
  {
     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");
 +   if (Enabled.size() > 0 && StringToBool(Enabled) == false)
 +      return true;
     
     // Define external/internal options
     const char* option_deb822[] = { 
     };
     for (unsigned int j=0; j < sizeof(option_deb822)/sizeof(char*); j++)
        if (Tags.Exists(option_deb822[j]))
-          Options[option_internal[j]] = Tags.FindS(option_deb822[j]);
+       {
+          // for deb822 the " " is the delimiter, but the backend expects ","
+          std::string option = Tags.FindS(option_deb822[j]);
+          std::replace(option.begin(), option.end(), ' ', ',');
+          Options[option_internal[j]] = option;
+       }
     
     // now create one item per suite/section
     string Suite = Tags.FindS("Suites");
     Suite = SubstVar(Suite,"$(ARCH)",_config->Find("APT::Architecture"));
     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_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)
              {
                 return false;
              }
           }
 +      }
     }
     return true;
  }
@@@ -297,7 -292,7 +303,7 @@@ bool pkgSourceList::Read(string File
  /* */
  bool pkgSourceList::ReadAppend(string File)
  {
 -   if (_config->FindB("APT::Sources::Use-Deb822", true) == true)
 +   if (_config->FindB("APT::Sources::Use-Deb822", false) == true)
     {
        int lines_parsed =ParseFileDeb822(File);
        if (lines_parsed < 0)
@@@ -387,26 -382,21 +393,26 @@@ int pkgSourceList::ParseFileDeb822(stri
     // 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 743543cd5cfea8f0db8542ab58b506f659c0e815,7237960182891df0471ac62ba80681200f5f0449..742adb5e2c51a05c6fb52deb8bd942b8aa0fd97e
@@@ -10,14 -10,15 +10,14 @@@ configarchitecture 'i386
  SOURCES='rootdir/etc/apt/sources.list'
  BASE='# some comment
  # that contains a : as well
 -#Type: meep
 +#Types: meep
  
 -Type: deb
 -URI: http://ftp.debian.org/debian
 +Types: deb
 +URIs: http://ftp.debian.org/debian
  Suites: stable
  Sections: main
 -Comment: Some random string
 - that can be very long'
 -
 +Description: summay
 + and the long part'
  
  msgtest 'Test old-style sources.list'
  echo "deb http://ftp.debian.org/debian stable main" > $SOURCES
@@@ -32,6 -33,15 +32,6 @@@ testequal --nomsg "'http://ftp.debian.o
  'http://ftp.debian.org/debian/dists/stable/InRelease' ftp.debian.org_debian_dists_stable_InRelease 0 "  aptget update --print-uris
  
  
 -msgtest 'Test deb822 with two sections' 'seperated by comma'
 -echo "$BASE" | sed 's/main/main contrib/' > $SOURCES
 -testequal --nomsg "'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/contrib/binary-i386/Packages.bz2' ftp.debian.org_debian_dists_stable_contrib_binary-i386_Packages 0 :
 -'http://ftp.debian.org/debian/dists/stable/contrib/i18n/Translation-en.bz2' ftp.debian.org_debian_dists_stable_contrib_i18n_Translation-en 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
 -
 -
  msgtest 'Test deb822 with' 'two entries'
  # Two entries
  echo "$BASE" > $SOURCES
@@@ -56,7 -66,7 +56,7 @@@ testequal --nomsg "'http://ftp.debian.o
  
  msgtest 'Test deb822' 'architecture option'
  echo "$BASE" > $SOURCES
- echo "Architectures: amd64,armel" >> $SOURCES
+ echo "Architectures: amd64 armel" >> $SOURCES
  testequal --nomsg "'http://ftp.debian.org/debian/dists/stable/main/binary-amd64/Packages.bz2' ftp.debian.org_debian_dists_stable_main_binary-amd64_Packages 0 :
  'http://ftp.debian.org/debian/dists/stable/main/binary-armel/Packages.bz2' ftp.debian.org_debian_dists_stable_main_binary-armel_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 :
@@@ -68,32 -78,10 +68,32 @@@ echo "deb http://ftp.debian.org" > $SOU
  testequal --nomsg "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
  
 -
  msgtest 'Test deb822 sources.list file which has' 'malformed URI'
 -echo "Type: deb
 +echo "Types: deb
  Suites: stable
  " > $SOURCES
  testequal --nomsg  "E: Malformed stanza 0 in source list $TMPWORKINGDIRECTORY/rootdir/etc/apt/sources.list (URI parse)
  E: The list of sources could not be read."  aptget update --print-uris
 +
 +# with Enabled: false
 +echo "$BASE"  > $SOURCES
 +echo "Enabled: no" >> $SOURCES
 +testempty aptget update --print-uris
 +
 +# multiple URIs
 +msgtest 'Test deb822 sources.list file which has' 'Multiple URIs work'
 +echo "$BASE"  | sed -e 's#http://ftp.debian.org/debian#http://ftp.debian.org/debian http://ftp.de.debian.org/debian#' > $SOURCES
 +testequal --nomsg  "'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 
 +
 +# multiple Type in one field
 +msgtest 'Test deb822 sources.list file which has' 'Multiple Types work'
 +echo "$BASE"  | sed -e 's#Types: deb#Types: deb deb-src#' > $SOURCES
 +testequal --nomsg "'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