From 181d587044121448e4d9925cc18ffb404b7b4a9c Mon Sep 17 00:00:00 2001 From: Michael Vogt Date: Mon, 6 Jan 2014 08:35:51 +0100 Subject: document deb822 style sources.list --- doc/sources.list.5.xml | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/doc/sources.list.5.xml b/doc/sources.list.5.xml index 87fb4d71e..ef5219ec2 100644 --- a/doc/sources.list.5.xml +++ b/doc/sources.list.5.xml @@ -76,12 +76,27 @@ code in the same form as the deb type. A deb-src line is required to fetch source indexes. - The format for a sources.list entry using the deb and deb-src types is: deb [ options ] uri distribution [component1] [component2] [...] + Alternatively a rfc822 style format is also supported: + + Type: deb + URI: http://example.com + Dist: stable + Section: component1 component2 + [option1]: [option1-value] + + Type: deb-src + URI: http://example.com + Dist: stable + Section: component1 component2 + [option1]: [option1-value] + + + The URI for the deb type must specify the base of the Debian distribution, from which APT will find the information it needs. distribution can specify an exact path, in which case the -- cgit v1.2.3 From db6594dfc508378b6d658aff2761da5406404238 Mon Sep 17 00:00:00 2001 From: Michael Vogt Date: Thu, 16 Jan 2014 08:03:24 +0100 Subject: remove "," in components again --- apt-pkg/sourcelist.cc | 6 +----- test/integration/test-apt-sources-deb822 | 11 ----------- 2 files changed, 1 insertion(+), 16 deletions(-) diff --git a/apt-pkg/sourcelist.cc b/apt-pkg/sourcelist.cc index 5e4a58e95..42ada7e18 100644 --- a/apt-pkg/sourcelist.cc +++ b/apt-pkg/sourcelist.cc @@ -363,11 +363,7 @@ int pkgSourceList::ParseFileDeb822(string File) // now create one item per section string const Section = Tags.FindS("Section"); - std::vector list; - if (Section.find(",")) - list = StringSplit(Section, ","); - else - list = StringSplit(Section, " "); + std::vector list = StringSplit(Section, " "); for (std::vector::const_iterator I = list.begin(); I != list.end(); I++) Parse->CreateItem(SrcList, URI, Dist, (*I), Options); diff --git a/test/integration/test-apt-sources-deb822 b/test/integration/test-apt-sources-deb822 index bacad1ed4..b110c1462 100755 --- a/test/integration/test-apt-sources-deb822 +++ b/test/integration/test-apt-sources-deb822 @@ -33,17 +33,6 @@ testequalwithmsg "Simple deb822 sources.list works" "'http://ftp.debian.org/debi '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 - -# two sections (we support both "," and " " as seperator) -echo "$BASE" | sed s/main/"main,contrib"/ > $SOURCES - -testequalwithmsg "Two sections deb822 sources.list work" "'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 - - # Two entries echo "$BASE" > $SOURCES echo "" >> $SOURCES -- cgit v1.2.3 From 7037aab52fc935298b033a4c7ba7ccb5b697622e Mon Sep 17 00:00:00 2001 From: Michael Vogt Date: Thu, 16 Jan 2014 16:25:33 +0100 Subject: * refactor to have a new virtual ParseStanza Have a similar ParseStanza() to the current ParseLine(). Rename the Architectures options in deb822 to make it more user friendly --- apt-pkg/sourcelist.cc | 65 +++++++++++++++++++------------- apt-pkg/sourcelist.h | 5 +++ test/integration/test-apt-sources-deb822 | 2 +- 3 files changed, 45 insertions(+), 27 deletions(-) diff --git a/apt-pkg/sourcelist.cc b/apt-pkg/sourcelist.cc index 42ada7e18..fe0eace07 100644 --- a/apt-pkg/sourcelist.cc +++ b/apt-pkg/sourcelist.cc @@ -71,6 +71,44 @@ bool pkgSourceList::Type::FixupURI(string &URI) const return true; } /*}}}*/ +bool pkgSourceList::Type::ParseStanza(vector &List, + pkgTagSection &Tags, + int i, + FileFd &Fd) +{ + map Options; + + string URI = Tags.FindS("URL"); + if (!FixupURI(URI)) + { + _error->Error(_("Malformed stanza %u in source list %s (URI parse)"),i,Fd.Name().c_str()); + return false; + } + + string Dist = Tags.FindS("Dist"); + Dist = SubstVar(Dist,"$(ARCH)",_config->Find("APT::Architecture")); + + // Define external/internal options + const char* option_deb822[] = { + "Architectures", "Architectures-Add", "Architectures-Delete", "Trusted", + }; + const char* option_internal[] = { + "arch", "arch+", "arch-", "trusted", + }; + 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]); + + // now create one item per section + string const Section = Tags.FindS("Section"); + std::vector list = StringSplit(Section, " "); + for (std::vector::const_iterator I = list.begin(); + I != list.end(); I++) + return CreateItem(List, URI, Dist, (*I), Options); + + return true; +} + // Type::ParseLine - Parse a single line /*{{{*/ // --------------------------------------------------------------------- /* This is a generic one that is the 'usual' format for sources.list @@ -313,7 +351,6 @@ bool pkgSourceList::ParseFileOldStyle(string File) int pkgSourceList::ParseFileDeb822(string File) { pkgTagSection Tags; - map Options; unsigned int i=0; // see if we can read the file @@ -338,35 +375,11 @@ int pkgSourceList::ParseFileDeb822(string File) if (Parse == 0) { _error->Error(_("Type '%s' is not known on stanza %u in source list %s"),type.c_str(),i,Fd.Name().c_str()); - // true means we do not retry with old-style sources.list return -1; } - string URI = Tags.FindS("URL"); - if (!Parse->FixupURI(URI)) - { - _error->Error(_("Malformed stanza %u in source list %s (URI parse)"),i,Fd.Name().c_str()); - // means we do not retry with old-style sources.list + if (!Parse->ParseStanza(SrcList, Tags, i, Fd)) return -1; - } - - string Dist = Tags.FindS("Dist"); - Dist = SubstVar(Dist,"$(ARCH)",_config->Find("APT::Architecture")); - - // check if there are any options we support - const char* option_str[] = { - "arch", "arch+", "arch-", "trusted", - }; - for (unsigned int j=0; j < sizeof(option_str)/sizeof(char*); j++) - if (Tags.Exists(option_str[j])) - Options[option_str[j]] = Tags.FindS(option_str[j]); - - // now create one item per section - string const Section = Tags.FindS("Section"); - std::vector list = StringSplit(Section, " "); - for (std::vector::const_iterator I = list.begin(); - I != list.end(); I++) - Parse->CreateItem(SrcList, URI, Dist, (*I), Options); i++; } diff --git a/apt-pkg/sourcelist.h b/apt-pkg/sourcelist.h index d83c76d6a..0ccb4aa00 100644 --- a/apt-pkg/sourcelist.h +++ b/apt-pkg/sourcelist.h @@ -31,6 +31,7 @@ #include #include #include +#include #ifndef APT_8_CLEANER_HEADERS #include @@ -60,6 +61,10 @@ class pkgSourceList const char *Label; bool FixupURI(std::string &URI) const; + virtual bool ParseStanza(std::vector &List, + pkgTagSection &Tags, + int stanza_n, + FileFd &Fd); virtual bool ParseLine(std::vector &List, const char *Buffer, unsigned long const &CurLine,std::string const &File) const; diff --git a/test/integration/test-apt-sources-deb822 b/test/integration/test-apt-sources-deb822 index b110c1462..fcb6010c3 100755 --- a/test/integration/test-apt-sources-deb822 +++ b/test/integration/test-apt-sources-deb822 @@ -48,7 +48,7 @@ testequalwithmsg "Multiple entries in deb822 sources.list work" "'http://ftp.deb # ARCH option echo "$BASE" > $SOURCES -echo "Arch: amd64,armel" >> $SOURCES +echo "Architectures: amd64,armel" >> $SOURCES testequalwithmsg "Arch: option in deb822 sources.list works" "'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 : -- cgit v1.2.3 From 796a0eff1acebe858632c344e77bfc3189b2244f Mon Sep 17 00:00:00 2001 From: Michael Vogt Date: Thu, 16 Jan 2014 17:00:56 +0100 Subject: rename "distribution" in sources.list to "suite" --- apt-pkg/sourcelist.cc | 2 +- doc/sources.list.5.xml | 38 +++++++++++++++++--------------- test/integration/test-apt-sources-deb822 | 4 ++-- 3 files changed, 23 insertions(+), 21 deletions(-) diff --git a/apt-pkg/sourcelist.cc b/apt-pkg/sourcelist.cc index fe0eace07..ddebd206d 100644 --- a/apt-pkg/sourcelist.cc +++ b/apt-pkg/sourcelist.cc @@ -85,7 +85,7 @@ bool pkgSourceList::Type::ParseStanza(vector &List, return false; } - string Dist = Tags.FindS("Dist"); + string Dist = Tags.FindS("Suite"); Dist = SubstVar(Dist,"$(ARCH)",_config->Find("APT::Architecture")); // Define external/internal options diff --git a/doc/sources.list.5.xml b/doc/sources.list.5.xml index ef5219ec2..7a82bd4ce 100644 --- a/doc/sources.list.5.xml +++ b/doc/sources.list.5.xml @@ -79,19 +79,19 @@ The format for a sources.list entry using the deb and deb-src types is: - deb [ options ] uri distribution [component1] [component2] [...] + deb [ options ] uri suite [component1] [component2] [...] Alternatively a rfc822 style format is also supported: Type: deb URI: http://example.com - Dist: stable + Suite: stable Section: component1 component2 [option1]: [option1-value] Type: deb-src URI: http://example.com - Dist: stable + Suite: stable Section: component1 component2 [option1]: [option1-value] @@ -99,14 +99,14 @@ The URI for the deb type must specify the base of the Debian distribution, from which APT will find the information it needs. - distribution can specify an exact path, in which case the - components must be omitted and distribution must end with + suite can specify an exact path, in which case the + components must be omitted and suite must end with a slash (/). This is useful for the case when only a particular sub-section of the archive denoted by the URI is of interest. - If distribution does not specify an exact path, at least + If suite does not specify an exact path, at least one component must be present. - distribution may also contain a variable, + suite may also contain a variable, $(ARCH) which expands to the Debian architecture (such as amd64 or armel) used on the system. This permits architecture-independent @@ -114,17 +114,19 @@ of interest when specifying an exact path, APT will automatically generate a URI with the current architecture otherwise. - Since only one distribution can be specified per line it may be necessary - to have multiple lines for the same URI, if a subset of all available - distributions or components at that location is desired. - APT will sort the URI list after it has generated a complete set - internally, and will collapse multiple references to the same Internet - host, for instance, into a single connection, so that it does not - inefficiently establish an FTP connection, close it, do something else, - and then re-establish a connection to that same host. This feature is - useful for accessing busy FTP sites with limits on the number of - simultaneous anonymous users. APT also parallelizes connections to - different hosts to more effectively deal with sites with low bandwidth. + In the traditional style sources.list format since only one + distribution can be specified per line it may be necessary to have + multiple lines for the same URI, if a subset of all available + distributions or components at that location is desired. APT will + sort the URI list after it has generated a complete set internally, + and will collapse multiple references to the same Internet host, + for instance, into a single connection, so that it does not + inefficiently establish an FTP connection, close it, do something + else, and then re-establish a connection to that same host. This + feature is useful for accessing busy FTP sites with limits on the + number of simultaneous anonymous users. APT also parallelizes + connections to different hosts to more effectively deal with sites + with low bandwidth. options is always optional and needs to be surrounded by square brackets. It can consist of multiple settings in the form diff --git a/test/integration/test-apt-sources-deb822 b/test/integration/test-apt-sources-deb822 index fcb6010c3..00ca102be 100755 --- a/test/integration/test-apt-sources-deb822 +++ b/test/integration/test-apt-sources-deb822 @@ -21,7 +21,7 @@ BASE="# some comment Type: deb URL: http://ftp.debian.org/debian -Dist: stable +Suite: stable Section: main Comment: Some random string that can be very long" @@ -62,7 +62,7 @@ testequalwithmsg "Invalid sources.list file gives proper error" "E: Malformed li E: The list of sources could not be read." aptget update --print-uris echo "Type: deb -Dist: stable +Suite: stable " > $SOURCES testequalwithmsg "Invalid deb822 sources.list file gives proper error" "E: Malformed stanza 0 in source list $TMPWORKINGDIRECTORY/rootdir/etc/apt/sources.list (URI parse) -- cgit v1.2.3 From a51fa92c521a6790446108a54ad1d9b6a16515ff Mon Sep 17 00:00:00 2001 From: Michael Vogt Date: Thu, 16 Jan 2014 17:03:07 +0100 Subject: rename URL to Uri in deb822-sources --- apt-pkg/sourcelist.cc | 2 +- doc/sources.list.5.xml | 4 ++-- test/integration/test-apt-sources-deb822 | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/apt-pkg/sourcelist.cc b/apt-pkg/sourcelist.cc index ddebd206d..0cea8dc7f 100644 --- a/apt-pkg/sourcelist.cc +++ b/apt-pkg/sourcelist.cc @@ -78,7 +78,7 @@ bool pkgSourceList::Type::ParseStanza(vector &List, { map Options; - string URI = Tags.FindS("URL"); + string URI = Tags.FindS("Uri"); if (!FixupURI(URI)) { _error->Error(_("Malformed stanza %u in source list %s (URI parse)"),i,Fd.Name().c_str()); diff --git a/doc/sources.list.5.xml b/doc/sources.list.5.xml index 7a82bd4ce..e770023d5 100644 --- a/doc/sources.list.5.xml +++ b/doc/sources.list.5.xml @@ -84,13 +84,13 @@ Alternatively a rfc822 style format is also supported: Type: deb - URI: http://example.com + Uri: http://example.com Suite: stable Section: component1 component2 [option1]: [option1-value] Type: deb-src - URI: http://example.com + Uri: http://example.com Suite: stable Section: component1 component2 [option1]: [option1-value] diff --git a/test/integration/test-apt-sources-deb822 b/test/integration/test-apt-sources-deb822 index 00ca102be..edf52487c 100755 --- a/test/integration/test-apt-sources-deb822 +++ b/test/integration/test-apt-sources-deb822 @@ -20,7 +20,7 @@ BASE="# some comment #Type: meep Type: deb -URL: http://ftp.debian.org/debian +Uri: http://ftp.debian.org/debian Suite: stable Section: main Comment: Some random string -- cgit v1.2.3 From d73743ddae1228bcd409700d8d0ffbe26e2e6cd1 Mon Sep 17 00:00:00 2001 From: Michael Vogt Date: Thu, 16 Jan 2014 17:13:18 +0100 Subject: support multiple "Suite:" entries --- apt-pkg/sourcelist.cc | 27 ++++++++++++++++++--------- test/integration/test-apt-sources-deb822 | 8 ++++++++ 2 files changed, 26 insertions(+), 9 deletions(-) diff --git a/apt-pkg/sourcelist.cc b/apt-pkg/sourcelist.cc index 0cea8dc7f..09d8287a0 100644 --- a/apt-pkg/sourcelist.cc +++ b/apt-pkg/sourcelist.cc @@ -85,9 +85,6 @@ bool pkgSourceList::Type::ParseStanza(vector &List, return false; } - string Dist = Tags.FindS("Suite"); - Dist = SubstVar(Dist,"$(ARCH)",_config->Find("APT::Architecture")); - // Define external/internal options const char* option_deb822[] = { "Architectures", "Architectures-Add", "Architectures-Delete", "Trusted", @@ -99,13 +96,25 @@ bool pkgSourceList::Type::ParseStanza(vector &List, if (Tags.Exists(option_deb822[j])) Options[option_internal[j]] = Tags.FindS(option_deb822[j]); - // now create one item per section + // now create one item per suite/section + string Suite = Tags.FindS("Suite"); + Suite = SubstVar(Suite,"$(ARCH)",_config->Find("APT::Architecture")); string const Section = Tags.FindS("Section"); - std::vector list = StringSplit(Section, " "); - for (std::vector::const_iterator I = list.begin(); - I != list.end(); I++) - return CreateItem(List, URI, Dist, (*I), Options); - + + std::vector list_dist = StringSplit(Suite, " "); + std::vector list_section = StringSplit(Section, " "); + for (std::vector::const_iterator I = list_dist.begin(); + I != list_dist.end(); I++) + { + for (std::vector::const_iterator J = list_section.begin(); + J != list_section.end(); J++) + { + if (CreateItem(List, URI, (*I), (*J), Options) == false) + { + return false; + } + } + } return true; } diff --git a/test/integration/test-apt-sources-deb822 b/test/integration/test-apt-sources-deb822 index edf52487c..67d119565 100755 --- a/test/integration/test-apt-sources-deb822 +++ b/test/integration/test-apt-sources-deb822 @@ -45,6 +45,14 @@ testequalwithmsg "Multiple entries in deb822 sources.list work" "'http://ftp.deb 'http://ftp.debian.org/debian/dists/unstable/main/i18n/Translation-en.bz2' ftp.debian.org_debian_dists_unstable_main_i18n_Translation-en 0 : 'http://ftp.debian.org/debian/dists/unstable/InRelease' ftp.debian.org_debian_dists_unstable_InRelease 0 " aptget update --print-uris +# two suite entries +echo "$BASE" | sed -e "s/stable/stable unstable/" > $SOURCES +testequalwithmsg "Two Suite entries deb822 sources.list work" "'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 +'http://ftp.debian.org/debian/dists/unstable/main/binary-i386/Packages.bz2' ftp.debian.org_debian_dists_unstable_main_binary-i386_Packages 0 : +'http://ftp.debian.org/debian/dists/unstable/main/i18n/Translation-en.bz2' ftp.debian.org_debian_dists_unstable_main_i18n_Translation-en 0 : +'http://ftp.debian.org/debian/dists/unstable/InRelease' ftp.debian.org_debian_dists_unstable_InRelease 0 " aptget update --print-uris # ARCH option echo "$BASE" > $SOURCES -- cgit v1.2.3 From 78766f46d043c1c1eeb9869db7e1c5b4093d5274 Mon Sep 17 00:00:00 2001 From: Michael Vogt Date: Thu, 16 Jan 2014 18:14:14 +0100 Subject: update libapt test --- test/libapt/sourcelist_test.cc | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/test/libapt/sourcelist_test.cc b/test/libapt/sourcelist_test.cc index 6e83d08e0..1d30bd85b 100644 --- a/test/libapt/sourcelist_test.cc +++ b/test/libapt/sourcelist_test.cc @@ -23,15 +23,15 @@ int main(int argc, char *argv[]) { const char contents[] = "" "Type: deb\n" - "URL: http://ftp.debian.org/debian\n" - "Dist: stable\n" + "Uri: http://ftp.debian.org/debian\n" + "Suite: stable\n" "Section: main\n" "Comment: Some random string\n" " that can be very long\n" "\n" "Type: deb\n" - "URL: http://ftp.debian.org/debian\n" - "Dist: unstable\n" + "Uri: http://ftp.debian.org/debian\n" + "Suite: unstable\n" "Section: main non-free\n" ; -- cgit v1.2.3