From a537ce19f955f39ee62281bb12bc71a4c67bc635 Mon Sep 17 00:00:00 2001 From: Michael Vogt Date: Mon, 2 Dec 2013 08:01:00 +0100 Subject: first version with test --- test/integration/test-apt-sources-deb822 | 45 ++++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) create mode 100755 test/integration/test-apt-sources-deb822 (limited to 'test') diff --git a/test/integration/test-apt-sources-deb822 b/test/integration/test-apt-sources-deb822 new file mode 100755 index 000000000..cdf30c02a --- /dev/null +++ b/test/integration/test-apt-sources-deb822 @@ -0,0 +1,45 @@ +#!/bin/sh +set -e + +TESTDIR=$(readlink -f $(dirname $0)) +. $TESTDIR/framework + +setupenvironment +configarchitecture "i386" + +BASE="Type: deb +URL: http://ftp.debian.org/debian +Dist: stable +Section: main +Comment: Some random string + that can be very long" + +# simple case +echo "$BASE" > rootdir/etc/apt/sources.list + +testequal "'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 + + +# Two entries +echo "$BASE" > rootdir/etc/apt/sources.list +echo "" >> rootdir/etc/apt/sources.list +echo "$BASE" | sed s/stable/unstable/ >> rootdir/etc/apt/sources.list + +testequal "'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" > rootdir/etc/apt/sources.list +echo "Arch: amd64,armel" >> rootdir/etc/apt/sources.list + +testequal "'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 : +'http://ftp.debian.org/debian/dists/stable/InRelease' ftp.debian.org_debian_dists_stable_InRelease 0 " aptget update --print-uris -- cgit v1.2.3-70-g09d2 From caeb19b796f7045f489dbce0bf681925d49136a9 Mon Sep 17 00:00:00 2001 From: Michael Vogt Date: Mon, 2 Dec 2013 08:21:49 +0100 Subject: add unittest for new sourceslist parser as well --- test/libapt/makefile | 6 +++++ test/libapt/sourcelist_test.cc | 52 ++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 58 insertions(+) create mode 100644 test/libapt/sourcelist_test.cc (limited to 'test') diff --git a/test/libapt/makefile b/test/libapt/makefile index 73403b24c..a8e053d6e 100644 --- a/test/libapt/makefile +++ b/test/libapt/makefile @@ -111,3 +111,9 @@ SLIBS = -lapt-pkg SOURCE = tagfile_test.cc include $(PROGRAM_H) +# test sourcelist +PROGRAM = SourceList${BASENAME} +SLIBS = -lapt-pkg +SOURCE = sourcelist_test.cc +include $(PROGRAM_H) + diff --git a/test/libapt/sourcelist_test.cc b/test/libapt/sourcelist_test.cc new file mode 100644 index 000000000..6e83d08e0 --- /dev/null +++ b/test/libapt/sourcelist_test.cc @@ -0,0 +1,52 @@ +#include +#include + +#include "assert.h" +#include +#include +#include + +char *tempfile = NULL; +int tempfile_fd = -1; + +void remove_tmpfile(void) +{ + if (tempfile_fd > 0) + close(tempfile_fd); + if (tempfile != NULL) { + unlink(tempfile); + free(tempfile); + } +} + +int main(int argc, char *argv[]) +{ + const char contents[] = "" + "Type: deb\n" + "URL: http://ftp.debian.org/debian\n" + "Dist: 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" + "Section: main non-free\n" + ; + + FileFd fd; + tempfile = strdup("apt-test.XXXXXXXX"); + tempfile_fd = mkstemp(tempfile); + + /* (Re-)Open (as FileFd), write and seek to start of the temp file */ + equals(fd.OpenDescriptor(tempfile_fd, FileFd::ReadWrite), true); + equals(fd.Write(contents, strlen(contents)), true); + equals(fd.Seek(0), true); + + pkgSourceList sources(tempfile); + equals(sources.size(), 2); + + /* clean up handled by atexit handler, so just return here */ + return 0; +} -- cgit v1.2.3-70-g09d2 From 300b15e3456aff88b3016a8bac90a0ba8911db8f Mon Sep 17 00:00:00 2001 From: Michael Vogt Date: Mon, 2 Dec 2013 08:36:10 +0100 Subject: fix section adding --- apt-pkg/sourcelist.cc | 11 ++++++++++- test/integration/test-apt-sources-deb822 | 10 ++++++++++ 2 files changed, 20 insertions(+), 1 deletion(-) (limited to 'test') diff --git a/apt-pkg/sourcelist.cc b/apt-pkg/sourcelist.cc index 1261ebb52..4883e2fab 100644 --- a/apt-pkg/sourcelist.cc +++ b/apt-pkg/sourcelist.cc @@ -273,7 +273,16 @@ bool pkgSourceList::ReadAppend(string File) 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]); - Parse->CreateItem(SrcList, URI, Dist, Section, Options); + + // now create one item per section + std::vector list; + if (Section.find(",")) + list = StringSplit(Section, ","); + else + list = StringSplit(Section, " "); + for (int i=0; i < list.size(); i++) + Parse->CreateItem(SrcList, URI, Dist, list[i], Options); + i++; } // we are done diff --git a/test/integration/test-apt-sources-deb822 b/test/integration/test-apt-sources-deb822 index cdf30c02a..6e9700bb0 100755 --- a/test/integration/test-apt-sources-deb822 +++ b/test/integration/test-apt-sources-deb822 @@ -22,6 +22,16 @@ testequal "'http://ftp.debian.org/debian/dists/stable/main/binary-i386/Packages. '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"/ > rootdir/etc/apt/sources.list + +testequal "'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" > rootdir/etc/apt/sources.list echo "" >> rootdir/etc/apt/sources.list -- cgit v1.2.3-70-g09d2 From 47d2bc78adb49f3182f9a3d7a4baea363e772d64 Mon Sep 17 00:00:00 2001 From: David Kalnischkies Date: Fri, 6 Dec 2013 12:17:48 +0100 Subject: implement POC client-side merging of pdiffs via apt-file MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The idea of pdiffs is to avoid downloading the hole file by patching the existing index. This works very well, but becomes slow if a lot of patches needs to be applied to reconstruct an up-to-date index and in recent years more and more dinstall (or similar) runs are executed creating more and more pdiffs in the same amount of time, so pdiffs became less useful. The solution is simple: Reduce the amount of patches (which are very small) which need to be applied on top of the index we have available (which is usually pretty big). This can be done in two ways: Either merge the patches on the server-side so that the client has to download only one patch or the patches are all downloaded and merged on the client-side. The first needs a client who is doing one step at a time who can also skip patches if it needs (APT supports this for a long time now). The later is implemented by this commit, but depends on the server NOT merging the patches and the patches being in a strict order in which no patch is skipped. This is traditionally the case for dak, but other repository creators support merging – e.g. reprepro (which helpfully adds a flag indicating that the patches are merged). To support both or even mixes a client needs more information which isn't available for now. This POC uses the external diffindex-rred included in apt-file to do the heavy lifting of merging & applying all patches in one pass, hence to test this feature apt-file needs to be installed. --- apt-pkg/acquire-item.cc | 151 +++++++++++++++++++++++++++++++++++++- apt-pkg/acquire-item.h | 100 ++++++++++++++++++++++++- methods/rred.cc | 128 ++++++++++++++++++++++++-------- test/integration/test-pdiff-usage | 147 ++++++++++++++++++++++++++++++++----- 4 files changed, 470 insertions(+), 56 deletions(-) (limited to 'test') diff --git a/apt-pkg/acquire-item.cc b/apt-pkg/acquire-item.cc index 009531c2e..b5b9577ef 100644 --- a/apt-pkg/acquire-item.cc +++ b/apt-pkg/acquire-item.cc @@ -498,14 +498,42 @@ bool pkgAcqDiffIndex::ParseDiffIndex(string IndexDiffFile) /*{{{*/ } // we have something, queue the next diff - if(found) + if(found) { // queue the diffs string::size_type const last_space = Description.rfind(" "); if(last_space != string::npos) Description.erase(last_space, Description.size()-last_space); - new pkgAcqIndexDiffs(Owner, RealURI, Description, Desc.ShortDesc, - ExpectedHash, ServerSha1, available_patches); + + /* decide if we should download patches one by one or in one go: + The first is good if the server merges patches, but many don't so client + based merging can be attempt in which case the second is better. + "bad things" will happen if patches are merged on the server, + but client side merging is attempt as well */ + bool pdiff_merge = _config->FindB("Acquire::PDiffs::Merge", true); + if (pdiff_merge == true) + { + // this perl script is provided by apt-file + pdiff_merge = FileExists(_config->FindFile("Dir::Bin::rred", "/usr/bin/diffindex-rred")); + if (pdiff_merge == true) + { + // reprepro adds this flag if it has merged patches on the server + std::string const precedence = Tags.FindS("X-Patch-Precedence"); + pdiff_merge = (precedence != "merged"); + } + } + + if (pdiff_merge == false) + new pkgAcqIndexDiffs(Owner, RealURI, Description, Desc.ShortDesc, + ExpectedHash, ServerSha1, available_patches); + else + { + std::vector *diffs = new std::vector(available_patches.size()); + for(size_t i = 0; i < available_patches.size(); ++i) + (*diffs)[i] = new pkgAcqIndexMergeDiffs(Owner, RealURI, Description, Desc.ShortDesc, ExpectedHash, + available_patches[i], diffs); + } + Complete = false; Status = StatDone; Dequeue(); @@ -754,6 +782,123 @@ void pkgAcqIndexDiffs::Done(string Message,unsigned long long Size,string Md5Has } } /*}}}*/ +// AcqIndexMergeDiffs::AcqIndexMergeDiffs - Constructor /*{{{*/ +pkgAcqIndexMergeDiffs::pkgAcqIndexMergeDiffs(pkgAcquire *Owner, + string const &URI, string const &URIDesc, + string const &ShortDesc, HashString const &ExpectedHash, + DiffInfo const &patch, + std::vector const * const allPatches) + : Item(Owner), RealURI(URI), ExpectedHash(ExpectedHash), + patch(patch),allPatches(allPatches), State(StateFetchDiff) +{ + + DestFile = _config->FindDir("Dir::State::lists") + "partial/"; + DestFile += URItoFileName(URI); + + Debug = _config->FindB("Debug::pkgAcquire::Diffs",false); + + Description = URIDesc; + Desc.Owner = this; + Desc.ShortDesc = ShortDesc; + + Desc.URI = string(RealURI) + ".diff/" + patch.file + ".gz"; + Desc.Description = Description + " " + patch.file + string(".pdiff"); + DestFile = _config->FindDir("Dir::State::lists") + "partial/"; + DestFile += URItoFileName(RealURI + ".diff/" + patch.file); + + if(Debug) + std::clog << "pkgAcqIndexMergeDiffs: " << Desc.URI << std::endl; + + QueueURI(Desc); +} + /*}}}*/ +void pkgAcqIndexMergeDiffs::Failed(string Message,pkgAcquire::MethodConfig *Cnf)/*{{{*/ +{ + if(Debug) + std::clog << "pkgAcqIndexMergeDiffs failed: " << Desc.URI << " with " << Message << std::endl; + Complete = false; + Status = StatDone; + Dequeue(); + + // check if we are the first to fail, otherwise we are done here + State = StateDoneDiff; + for (std::vector::const_iterator I = allPatches->begin(); + I != allPatches->end(); ++I) + if ((*I)->State == StateErrorDiff) + return; + + // first failure means we should fallback + State = StateErrorDiff; + std::clog << "Falling back to normal index file aquire" << std::endl; + new pkgAcqIndex(Owner, RealURI, Description,Desc.ShortDesc, + ExpectedHash); +} + /*}}}*/ +void pkgAcqIndexMergeDiffs::Done(string Message,unsigned long long Size,string Md5Hash, /*{{{*/ + pkgAcquire::MethodConfig *Cnf) +{ + if(Debug) + std::clog << "pkgAcqIndexMergeDiffs::Done(): " << Desc.URI << std::endl; + + Item::Done(Message,Size,Md5Hash,Cnf); + + string const FinalFile = _config->FindDir("Dir::State::lists") + URItoFileName(RealURI); + + if (State == StateFetchDiff) + { + // rred expects the patch as $FinalFile.ed.$patchname.gz + Rename(DestFile, FinalFile + ".ed." + patch.file + ".gz"); + + // check if this is the last completed diff + State = StateDoneDiff; + for (std::vector::const_iterator I = allPatches->begin(); + I != allPatches->end(); ++I) + if ((*I)->State != StateDoneDiff) + { + if(Debug) + std::clog << "Not the last done diff in the batch: " << Desc.URI << std::endl; + return; + } + + // this is the last completed diff, so we are ready to apply now + State = StateApplyDiff; + + if(Debug) + std::clog << "Sending to rred method: " << FinalFile << std::endl; + + Local = true; + Desc.URI = "rred:" + FinalFile; + QueueURI(Desc); + Mode = "rred"; + return; + } + // success in download/apply all diffs, clean up + else if (State == StateApplyDiff) + { + // see if we really got the expected file + if(!ExpectedHash.empty() && !ExpectedHash.VerifyFile(DestFile)) + { + RenameOnError(HashSumMismatch); + return; + } + + // move the result into place + if(Debug) + std::clog << "Moving patched file in place: " << std::endl + << DestFile << " -> " << FinalFile << std::endl; + Rename(DestFile, FinalFile); + chmod(FinalFile.c_str(), 0644); + + // otherwise lists cleanup will eat the file + DestFile = FinalFile; + + // all set and done + Complete = true; + if(Debug) + std::clog << "allDone: " << DestFile << "\n" << std::endl; + } +} + /*}}}*/ // AcqIndex::AcqIndex - Constructor /*{{{*/ // --------------------------------------------------------------------- /* The package file is added to the queue and a second class is diff --git a/apt-pkg/acquire-item.h b/apt-pkg/acquire-item.h index 6b4f73708..5a1c7979c 100644 --- a/apt-pkg/acquire-item.h +++ b/apt-pkg/acquire-item.h @@ -429,7 +429,105 @@ class pkgAcqDiffIndex : public pkgAcquire::Item std::string ShortDesc, HashString ExpectedHash); }; /*}}}*/ -/** \brief An item that is responsible for fetching all the patches {{{ +/** \brief An item that is responsible for fetching client-merge patches {{{ + * that need to be applied to a given package index file. + * + * Instead of downloading and applying each patch one by one like its + * sister #pkgAcqIndexDiffs this class will download all patches at once + * and call rred with all the patches downloaded once. Rred will then + * merge and apply them in one go, which should be a lot faster – but is + * incompatible with server-based merges of patches like reprepro can do. + * + * \sa pkgAcqDiffIndex, pkgAcqIndex + */ +class pkgAcqIndexMergeDiffs : public pkgAcquire::Item +{ + protected: + + /** \brief If \b true, debugging output will be written to + * std::clog. + */ + bool Debug; + + /** \brief description of the item that is currently being + * downloaded. + */ + pkgAcquire::ItemDesc Desc; + + /** \brief URI of the package index file that is being + * reconstructed. + */ + std::string RealURI; + + /** \brief HashSum of the package index file that is being + * reconstructed. + */ + HashString ExpectedHash; + + /** \brief description of the file being downloaded. */ + std::string Description; + + /** \brief information about the current patch */ + struct DiffInfo const patch; + + /** \brief list of all download items for the patches */ + std::vector const * const allPatches; + + /** The current status of this patch. */ + enum DiffState + { + /** \brief The diff is currently being fetched. */ + StateFetchDiff, + + /** \brief The diff is currently being applied. */ + StateApplyDiff, + + /** \brief the work with this diff is done */ + StateDoneDiff, + + /** \brief something bad happened and fallback was triggered */ + StateErrorDiff + } State; + + public: + /** \brief Called when the patch file failed to be downloaded. + * + * This method will fall back to downloading the whole index file + * outright; its arguments are ignored. + */ + virtual void Failed(std::string Message,pkgAcquire::MethodConfig *Cnf); + + virtual void Done(std::string Message,unsigned long long Size,std::string Md5Hash, + pkgAcquire::MethodConfig *Cnf); + virtual std::string DescURI() {return RealURI + "Index";}; + + /** \brief Create an index merge-diff item. + * + * \param Owner The pkgAcquire object that owns this item. + * + * \param URI The URI of the package index file being + * reconstructed. + * + * \param URIDesc A long description of this item. + * + * \param ShortDesc A brief description of this item. + * + * \param ExpectedHash The expected md5sum of the completely + * reconstructed package index file; the index file will be tested + * against this value when it is entirely reconstructed. + * + * \param patch contains infos about the patch this item is supposed + * to download which were read from the index + * + * \param allPatches contains all related items so that each item can + * check if it was the last one to complete the download step + */ + pkgAcqIndexMergeDiffs(pkgAcquire *Owner,std::string const &URI,std::string const &URIDesc, + std::string const &ShortDesc, HashString const &ExpectedHash, + DiffInfo const &patch, std::vector const * const allPatches); +}; + /*}}}*/ +/** \brief An item that is responsible for fetching server-merge patches {{{ * that need to be applied to a given package index file. * * After downloading and applying a single patch, this item will diff --git a/methods/rred.cc b/methods/rred.cc index 7c65f8f92..bea8ed263 100644 --- a/methods/rred.cc +++ b/methods/rred.cc @@ -11,6 +11,8 @@ #include #include +#include +#include #include #include #include @@ -465,50 +467,112 @@ bool RredMethod::Fetch(FetchItem *Itm) /*{{{*/ } else URIStart(Res); - if (Debug == true) - std::clog << "Patching " << Path << " with " << Path - << ".ed and putting result into " << Itm->DestFile << std::endl; - // Open the source and destination files (the d'tor of FileFd will do - // the cleanup/closing of the fds) - FileFd From(Path,FileFd::ReadOnly); - FileFd Patch(Path+".ed",FileFd::ReadOnly, FileFd::Gzip); - FileFd To(Itm->DestFile,FileFd::WriteAtomic); - To.EraseOnFailure(); - if (_error->PendingError() == true) - return false; - + std::string lastPatchName; Hashes Hash; - // now do the actual patching - State const result = patchMMap(Patch, From, To, &Hash); - if (result == MMAP_FAILED) { - // retry with patchFile - Patch.Seek(0); - From.Seek(0); - To.Open(Itm->DestFile,FileFd::WriteAtomic); + + // check for a single ed file + if (FileExists(Path+".ed") == true) + { + if (Debug == true) + std::clog << "Patching " << Path << " with " << Path + << ".ed and putting result into " << Itm->DestFile << std::endl; + + // Open the source and destination files + lastPatchName = Path + ".ed"; + FileFd From(Path,FileFd::ReadOnly); + FileFd To(Itm->DestFile,FileFd::WriteAtomic); + To.EraseOnFailure(); + FileFd Patch(lastPatchName, FileFd::ReadOnly, FileFd::Gzip); if (_error->PendingError() == true) - return false; - if (patchFile(Patch, From, To, &Hash) != ED_OK) { - return _error->WarningE("rred", _("Could not patch %s with mmap and with file operation usage - the patch seems to be corrupt."), Path.c_str()); + return false; + + // now do the actual patching + State const result = patchMMap(Patch, From, To, &Hash); + if (result == MMAP_FAILED) { + // retry with patchFile + Patch.Seek(0); + From.Seek(0); + To.Open(Itm->DestFile,FileFd::WriteAtomic); + if (_error->PendingError() == true) + return false; + if (patchFile(Patch, From, To, &Hash) != ED_OK) { + return _error->WarningE("rred", _("Could not patch %s with mmap and with file operation usage - the patch seems to be corrupt."), Path.c_str()); + } else if (Debug == true) { + std::clog << "rred: finished file patching of " << Path << " after mmap failed." << std::endl; + } + } else if (result != ED_OK) { + return _error->Errno("rred", _("Could not patch %s with mmap (but no mmap specific fail) - the patch seems to be corrupt."), Path.c_str()); } else if (Debug == true) { - std::clog << "rred: finished file patching of " << Path << " after mmap failed." << std::endl; + std::clog << "rred: finished mmap patching of " << Path << std::endl; } - } else if (result != ED_OK) { - return _error->Errno("rred", _("Could not patch %s with mmap (but no mmap specific fail) - the patch seems to be corrupt."), Path.c_str()); - } else if (Debug == true) { - std::clog << "rred: finished mmap patching of " << Path << std::endl; + + // write out the result + From.Close(); + Patch.Close(); + To.Close(); } + else + { + if (Debug == true) + std::clog << "Patching " << Path << " with all " << Path << ".ed.*.gz files and " + << "putting result into " << Itm->DestFile << std::endl; + + int From = open(Path.c_str(), O_RDONLY); + unlink(Itm->DestFile.c_str()); + int To = open(Itm->DestFile.c_str(), O_WRONLY | O_CREAT | O_EXCL, 0644); + SetCloseExec(From, false); + SetCloseExec(To, false); + + _error->PushToStack(); + std::vector patches = GetListOfFilesInDir(flNotFile(Path), "gz", true, false); + _error->RevertToStack(); + + std::string externalrred = _config->Find("Dir::Bin::rred", "/usr/bin/diffindex-rred"); + std::vector Args; + Args.reserve(22); + Args.push_back(externalrred.c_str()); + + std::string const baseName = Path + ".ed."; + for (std::vector::const_iterator p = patches.begin(); + p != patches.end(); ++p) + if (p->compare(0, baseName.length(), baseName) == 0) + Args.push_back(p->c_str()); + + Args.push_back(NULL); + + pid_t Patcher = ExecFork(); + if (Patcher == 0) { + dup2(From, STDIN_FILENO); + dup2(To, STDOUT_FILENO); + + execvp(Args[0], (char **) &Args[0]); + std::cerr << "Failed to execute patcher " << Args[0] << "!" << std::endl; + _exit(100); + } + // last is NULL, so the one before is the last patch + lastPatchName = Args[Args.size() - 2]; - // write out the result - From.Close(); - Patch.Close(); - To.Close(); + if (ExecWait(Patcher, "rred") == false) + return _error->Errno("rred", "Patching via external rred failed"); + + close(From); + close(To); + + struct stat Buf; + if (stat(Itm->DestFile.c_str(), &Buf) != 0) + return _error->Errno("stat",_("Failed to stat")); + + To = open(Path.c_str(), O_RDONLY); + Hash.AddFD(To, Buf.st_size); + close(To); + } /* Transfer the modification times from the patch file to be able to see in which state the file should be and use the access time from the "old" file */ struct stat BufBase, BufPatch; if (stat(Path.c_str(),&BufBase) != 0 || - stat(std::string(Path+".ed").c_str(),&BufPatch) != 0) + stat(lastPatchName.c_str(), &BufPatch) != 0) return _error->Errno("stat",_("Failed to stat")); struct utimbuf TimeBuf; diff --git a/test/integration/test-pdiff-usage b/test/integration/test-pdiff-usage index ac0563b7f..5a06e0ccb 100755 --- a/test/integration/test-pdiff-usage +++ b/test/integration/test-pdiff-usage @@ -5,39 +5,146 @@ TESTDIR=$(readlink -f $(dirname $0)) . $TESTDIR/framework setupenvironment -configarchitecture "i386" +configarchitecture 'i386' buildaptarchive setupflataptarchive changetowebserver -signreleasefiles -testsuccess aptget update -testnopackage newstuff PKGFILE="${TESTDIR}/$(echo "$(basename $0)" | sed 's#^test-#Packages-#')" -testequal "$(cat ${PKGFILE}) + +echo '#!/bin/sh +touch merge-was-used +/usr/bin/diffindex-rred "$@"' > extrred +chmod +x extrred +echo 'Dir::Bin::rred "./extrred";' > rootdir/etc/apt/apt.conf.d/99rred + +wasmergeused() { + testsuccess aptget update "$@" + msgtest 'Check if the right pdiff merger was used' + if [ -e ./merge-was-used ]; then + rm -f ./merge-was-used + if echo "$*" | grep -q -- '-o Acquire::PDiffs::Merge=1'; then + msgpass + else + msgfail "Merge shouldn't have been used, but was" + fi + elif echo "$*" | grep -q -- '-o Acquire::PDiffs::Merge=1'; then + msgfail "Merge should have been used, but wasn't" + else + msgpass + fi +} + +testrun() { + # setup the base + find aptarchive -name 'Packages*' -type f -delete + cp ${PKGFILE} aptarchive/Packages + compressfile 'aptarchive/Packages' + generatereleasefiles + signreleasefiles + rm -rf aptarchive/Packages.diff rootdir/var/lib/apt/lists + testsuccess aptget update "$@" + cp -a rootdir/var/lib/apt/lists rootdir/var/lib/apt/lists-bak + testnopackage newstuff + testequal "$(cat ${PKGFILE}) " aptcache show apt oldstuff -cp ${PKGFILE}-new aptarchive/Packages -compressfile 'aptarchive/Packages' -rm -rf aptarchive/Packages.diff -mkdir -p aptarchive/Packages.diff -PATCHFILE="aptarchive/Packages.diff/$(date +%Y-%m-%d-%H%M.%S)" -diff -e ${PKGFILE} ${PKGFILE}-new > ${PATCHFILE} || true -cat $PATCHFILE | gzip > ${PATCHFILE}.gz -PATCHINDEX="aptarchive/Packages.diff/Index" -echo "SHA1-Current: $(sha1sum ${PKGFILE}-new | cut -d' ' -f 1) $(stat -c%s ${PKGFILE}-new) + # apply with one patch + cp ${PKGFILE}-new aptarchive/Packages + compressfile 'aptarchive/Packages' + mkdir -p aptarchive/Packages.diff + PATCHFILE="aptarchive/Packages.diff/$(date +%Y-%m-%d-%H%M.%S)" + diff -e ${PKGFILE} ${PKGFILE}-new > ${PATCHFILE} || true + cat $PATCHFILE | gzip > ${PATCHFILE}.gz + PATCHINDEX='aptarchive/Packages.diff/Index' + echo "SHA1-Current: $(sha1sum ${PKGFILE}-new | cut -d' ' -f 1) $(stat -c%s ${PKGFILE}-new) SHA1-History: 9f4148e06d7faa37062994ff10d0c842d7017513 33053002 2010-08-18-2013.28 $(sha1sum $PKGFILE | cut -d' ' -f 1) $(stat -c%s $PKGFILE) $(basename $PATCHFILE) SHA1-Patches: 7651fc0ac57cd83d41c63195a9342e2db5650257 19722 2010-08-18-0814.28 $(sha1sum $PATCHFILE | cut -d' ' -f 1) $(stat -c%s $PATCHFILE) $(basename $PATCHFILE)" > $PATCHINDEX -generatereleasefiles '+1hour' -signreleasefiles -find aptarchive -name 'Packages*' -type f -delete -testsuccess aptget update + generatereleasefiles '+1hour' + signreleasefiles + find aptarchive -name 'Packages*' -type f -delete + wasmergeused "$@" + testnopackage oldstuff + testequal "$(cat ${PKGFILE}-new) +" aptcache show apt newstuff -testnopackage oldstuff -testequal "$(cat ${PKGFILE}-new) + # index is already up-to-date + find rootdir/var/lib/apt/lists -name '*.IndexDiff' -type f -delete + testsuccess aptget update "$@" + testequal "$(cat ${PKGFILE}-new) " aptcache show apt newstuff + + # apply with two patches + cp ${PKGFILE}-new aptarchive/Packages + echo ' +Package: futurestuff +Version: 1.0 +Architecture: i386 +Maintainer: Joe Sixpack +Installed-Size: 202 +Filename: pool/futurestuff_1.0_i386.deb +Size: 202200 +MD5sum: 311aeeaaae5ba33aff1ceaf3e1f76671 +SHA1: 3c695e028f7a1ae324deeaae5ba332desa81088c +SHA256: b46fd154615edaae5ba33c56a5cc0e7deaef23e2da3e4f129727fd660f28f050 +Description: some cool and shiny future stuff + This package will appear in the next next mirror update +Description-md5: d5f89fbbc2ce34c455dfee9b67d82b6b' >> aptarchive/Packages + + compressfile 'aptarchive/Packages' + PATCHFILE2="aptarchive/Packages.diff/$(date -d 'now + 1hour' '+%Y-%m-%d-%H%M.%S')" + diff -e ${PKGFILE}-new aptarchive/Packages > ${PATCHFILE2} || true + cat $PATCHFILE2 | gzip > ${PATCHFILE2}.gz + echo "SHA1-Current: $(sha1sum aptarchive/Packages | cut -d' ' -f 1) $(stat -c%s aptarchive/Packages) +SHA1-History: + 9f4148e06d7faa37062994ff10d0c842d7017513 33053002 2010-08-18-2013.28 + $(sha1sum ${PKGFILE} | cut -d' ' -f 1) $(stat -c%s ${PKGFILE}) $(basename ${PATCHFILE}) + $(sha1sum ${PKGFILE}-new | cut -d' ' -f 1) $(stat -c%s ${PKGFILE}-new) $(basename ${PATCHFILE2}) +SHA1-Patches: + 7651fc0ac57cd83d41c63195a9342e2db5650257 19722 2010-08-18-0814.28 + $(sha1sum $PATCHFILE | cut -d' ' -f 1) $(stat -c%s $PATCHFILE) $(basename $PATCHFILE) + $(sha1sum ${PATCHFILE2} | cut -d' ' -f 1) $(stat -c%s ${PATCHFILE2}) $(basename ${PATCHFILE2})" > $PATCHINDEX + generatereleasefiles '+2hour' + signreleasefiles + cp -a aptarchive/Packages Packages-future + find aptarchive -name 'Packages*' -type f -delete + rm -rf rootdir/var/lib/apt/lists + cp -a rootdir/var/lib/apt/lists-bak rootdir/var/lib/apt/lists + wasmergeused "$@" + testnopackage oldstuff + testequal "$(cat Packages-future) +" aptcache show apt newstuff futurestuff + + # patch applying fails, but successful fallback + rm -rf rootdir/var/lib/apt/lists + cp -a rootdir/var/lib/apt/lists-bak rootdir/var/lib/apt/lists + cp ${PKGFILE}-new aptarchive/Packages + compressfile 'aptarchive/Packages' + mkdir -p aptarchive/Packages.diff + PATCHFILE="aptarchive/Packages.diff/$(date +%Y-%m-%d-%H%M.%S)" + diff -e ${PKGFILE} ${PKGFILE}-new > ${PATCHFILE} || true + PATCHINDEX='aptarchive/Packages.diff/Index' + echo "SHA1-Current: $(sha1sum ${PKGFILE}-new | cut -d' ' -f 1) $(stat -c%s ${PKGFILE}-new) +SHA1-History: + 9f4148e06d7faa37062994ff10d0c842d7017513 33053002 2010-08-18-2013.28 + $(sha1sum $PKGFILE | cut -d' ' -f 1) $(stat -c%s $PKGFILE) $(basename $PATCHFILE) +SHA1-Patches: + 7651fc0ac57cd83d41c63195a9342e2db5650257 19722 2010-08-18-0814.28 + $(sha1sum $PATCHFILE | cut -d' ' -f 1) $(stat -c%s $PATCHFILE) $(basename $PATCHFILE)" > $PATCHINDEX + echo 'I am Mallory and I change files' >> $PATCHFILE + cat $PATCHFILE | gzip > ${PATCHFILE}.gz + generatereleasefiles '+1hour' + signreleasefiles + testsuccess aptget update "$@" + testnopackage oldstuff + testequal "$(cat ${PKGFILE}-new) +" aptcache show apt newstuff +} + +testrun -o Debug::pkgAcquire::Diffs=1 -o Debug::pkgAcquire::rred=1 -o Acquire::PDiffs::Merge=0 +testrun -o Debug::pkgAcquire::Diffs=1 -o Debug::pkgAcquire::rred=1 -o Acquire::PDiffs::Merge=1 -- cgit v1.2.3-70-g09d2 From d2d68aaf5bc2211e9c488f2603ccb4e5fd591a6d Mon Sep 17 00:00:00 2001 From: Michael Vogt Date: Sat, 4 Jan 2014 15:39:04 +0100 Subject: improve tests --- apt-pkg/sourcelist.cc | 3 ++- test/integration/framework | 13 +++++++++++-- test/integration/test-apt-sources-deb822 | 21 ++++++++++++++++----- 3 files changed, 29 insertions(+), 8 deletions(-) (limited to 'test') diff --git a/apt-pkg/sourcelist.cc b/apt-pkg/sourcelist.cc index 99cdbe030..35e13b6f5 100644 --- a/apt-pkg/sourcelist.cc +++ b/apt-pkg/sourcelist.cc @@ -342,7 +342,8 @@ bool pkgSourceList::ParseFileDeb822(string File) // check if there are any options we support const char* option_str[] = { - "arch", "arch+", "arch-", "trusted" }; + "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]); diff --git a/test/integration/framework b/test/integration/framework index a28363768..6ada1e9cc 100644 --- a/test/integration/framework +++ b/test/integration/framework @@ -948,13 +948,22 @@ testempty() { test -z "$($* 2>&1)" && msgpass || msgfail } -testequal() { +testequalwithmsg() { + local MSG="$1" + shift local COMPAREFILE=$(mktemp) addtrap "rm $COMPAREFILE;" echo "$1" > $COMPAREFILE shift - msgtest "Test for equality of" "$*" + msgtest "$MSG" $* 2>&1 | checkdiff $COMPAREFILE - && msgpass || msgfail +} + +testequal() { + local EXPECTED="$1" + shift + local MSG="Test for equality of $*" + testequalwithmsg "$MSG" "$EXPECTED" $* } testequalor2() { diff --git a/test/integration/test-apt-sources-deb822 b/test/integration/test-apt-sources-deb822 index 6e9700bb0..24fb1bdb0 100755 --- a/test/integration/test-apt-sources-deb822 +++ b/test/integration/test-apt-sources-deb822 @@ -7,7 +7,17 @@ TESTDIR=$(readlink -f $(dirname $0)) setupenvironment configarchitecture "i386" -BASE="Type: deb +echo "deb http://ftp.debian.org/debian stable main" > rootdir/etc/apt/sources.list +testequalwithmsg "Old style sources.list works" "'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 + + +BASE="# some comment +# that contains a : as well +#Type: meep + +Type: deb URL: http://ftp.debian.org/debian Dist: stable Section: main @@ -17,7 +27,7 @@ Comment: Some random string # simple case echo "$BASE" > rootdir/etc/apt/sources.list -testequal "'http://ftp.debian.org/debian/dists/stable/main/binary-i386/Packages.bz2' ftp.debian.org_debian_dists_stable_main_binary-i386_Packages 0 : +testequalwithmsg "Simple deb822 sources.list works" "'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 @@ -25,7 +35,7 @@ testequal "'http://ftp.debian.org/debian/dists/stable/main/binary-i386/Packages. # two sections (we support both "," and " " as seperator) echo "$BASE" | sed s/main/"main,contrib"/ > rootdir/etc/apt/sources.list -testequal "'http://ftp.debian.org/debian/dists/stable/main/binary-i386/Packages.bz2' ftp.debian.org_debian_dists_stable_main_binary-i386_Packages 0 : +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 : @@ -37,7 +47,7 @@ echo "$BASE" > rootdir/etc/apt/sources.list echo "" >> rootdir/etc/apt/sources.list echo "$BASE" | sed s/stable/unstable/ >> rootdir/etc/apt/sources.list -testequal "'http://ftp.debian.org/debian/dists/stable/main/binary-i386/Packages.bz2' ftp.debian.org_debian_dists_stable_main_binary-i386_Packages 0 : +testequalwithmsg "Multiple entries in 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 : @@ -49,7 +59,8 @@ testequal "'http://ftp.debian.org/debian/dists/stable/main/binary-i386/Packages. echo "$BASE" > rootdir/etc/apt/sources.list echo "Arch: amd64,armel" >> rootdir/etc/apt/sources.list -testequal "'http://ftp.debian.org/debian/dists/stable/main/binary-amd64/Packages.bz2' ftp.debian.org_debian_dists_stable_main_binary-amd64_Packages 0 : +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 : '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 + -- cgit v1.2.3-70-g09d2 From 4194c9aee2766845618ef0431fd4803b0467aab7 Mon Sep 17 00:00:00 2001 From: Michael Vogt Date: Sat, 4 Jan 2014 16:23:32 +0100 Subject: improve error message --- apt-pkg/sourcelist.cc | 34 +++++++++++++++++++++----------- apt-pkg/sourcelist.h | 2 +- test/integration/test-apt-sources-deb822 | 30 ++++++++++++++++++++-------- 3 files changed, 45 insertions(+), 21 deletions(-) (limited to 'test') diff --git a/apt-pkg/sourcelist.cc b/apt-pkg/sourcelist.cc index 35e13b6f5..5e4a58e95 100644 --- a/apt-pkg/sourcelist.cc +++ b/apt-pkg/sourcelist.cc @@ -240,8 +240,14 @@ bool pkgSourceList::Read(string File) bool pkgSourceList::ReadAppend(string File) { if (_config->FindB("APT::Sources::Use-Deb822", true) == true) - if (ParseFileDeb822(File)) + { + int lines_parsed =ParseFileDeb822(File); + if (lines_parsed < 0) + return false; + else if (lines_parsed > 0) return true; + // no lines parsed ... fall through and use old style parser + } return ParseFileOldStyle(File); } @@ -303,10 +309,9 @@ bool pkgSourceList::ParseFileOldStyle(string File) /*}}}*/ // SourceList::ParseFileDeb822 - Parse deb822 style sources.list /*{{{*/ // --------------------------------------------------------------------- -/* */ -bool pkgSourceList::ParseFileDeb822(string File) +/* Returns: the number of stanzas parsed*/ +int pkgSourceList::ParseFileDeb822(string File) { - pkgTagSection Tags; map Options; unsigned int i=0; @@ -318,7 +323,7 @@ bool pkgSourceList::ParseFileDeb822(string File) if (_error->PendingError() == true) { _error->RevertToStack(); - return false; + return 0; } _error->MergeWithStack(); @@ -331,11 +336,19 @@ bool pkgSourceList::ParseFileDeb822(string File) string const type = Tags.FindS("Type"); Type *Parse = Type::GetType(type.c_str()); if (Parse == 0) - return _error->Error(_("Type '%s' is not known on stanza %u in source list %s"),type.c_str(),i,Fd.Name().c_str()); + { + _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)) - return _error->Error(_("Malformed stanza %u in source list %s (URI parse)"),i,Fd.Name().c_str()); + { + _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 + return -1; + } string Dist = Tags.FindS("Dist"); Dist = SubstVar(Dist,"$(ARCH)",_config->Find("APT::Architecture")); @@ -362,11 +375,8 @@ bool pkgSourceList::ParseFileDeb822(string File) i++; } - // we are done - if(i>0) - return true; - - return false; + // we are done, return the number of stanzas read + return i; } /*}}}*/ // SourceList::FindIndex - Get the index associated with a file /*{{{*/ diff --git a/apt-pkg/sourcelist.h b/apt-pkg/sourcelist.h index 5e0d585bb..d83c76d6a 100644 --- a/apt-pkg/sourcelist.h +++ b/apt-pkg/sourcelist.h @@ -76,7 +76,7 @@ class pkgSourceList std::vector SrcList; - bool ParseFileDeb822(std::string File); + int ParseFileDeb822(std::string File); bool ParseFileOldStyle(std::string File); public: diff --git a/test/integration/test-apt-sources-deb822 b/test/integration/test-apt-sources-deb822 index 24fb1bdb0..bacad1ed4 100755 --- a/test/integration/test-apt-sources-deb822 +++ b/test/integration/test-apt-sources-deb822 @@ -7,7 +7,9 @@ TESTDIR=$(readlink -f $(dirname $0)) setupenvironment configarchitecture "i386" -echo "deb http://ftp.debian.org/debian stable main" > rootdir/etc/apt/sources.list +SOURCES="rootdir/etc/apt/sources.list" + +echo "deb http://ftp.debian.org/debian stable main" > $SOURCES testequalwithmsg "Old style sources.list works" "'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 @@ -25,7 +27,7 @@ Comment: Some random string that can be very long" # simple case -echo "$BASE" > rootdir/etc/apt/sources.list +echo "$BASE" > $SOURCES testequalwithmsg "Simple deb822 sources.list works" "'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 : @@ -33,7 +35,7 @@ testequalwithmsg "Simple deb822 sources.list works" "'http://ftp.debian.org/debi # two sections (we support both "," and " " as seperator) -echo "$BASE" | sed s/main/"main,contrib"/ > rootdir/etc/apt/sources.list +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 : @@ -43,9 +45,9 @@ testequalwithmsg "Two sections deb822 sources.list work" "'http://ftp.debian.org # Two entries -echo "$BASE" > rootdir/etc/apt/sources.list -echo "" >> rootdir/etc/apt/sources.list -echo "$BASE" | sed s/stable/unstable/ >> rootdir/etc/apt/sources.list +echo "$BASE" > $SOURCES +echo "" >> $SOURCES +echo "$BASE" | sed s/stable/unstable/ >> $SOURCES testequalwithmsg "Multiple entries in 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 : @@ -56,11 +58,23 @@ testequalwithmsg "Multiple entries in deb822 sources.list work" "'http://ftp.deb # ARCH option -echo "$BASE" > rootdir/etc/apt/sources.list -echo "Arch: amd64,armel" >> rootdir/etc/apt/sources.list +echo "$BASE" > $SOURCES +echo "Arch: 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 : '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 +# invalid sources.list file +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 +Dist: 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) +E: The list of sources could not be read." aptget update --print-uris -- cgit v1.2.3-70-g09d2 From 9aaa45283b14c3c81641f3f3e38157a267b1e8f7 Mon Sep 17 00:00:00 2001 From: David Kalnischkies Date: Wed, 15 Jan 2014 16:14:23 +0100 Subject: actually register the tempfile removal atexit Git-Dch: Ignore --- test/libapt/sourcelist_test.cc | 1 + 1 file changed, 1 insertion(+) (limited to 'test') diff --git a/test/libapt/sourcelist_test.cc b/test/libapt/sourcelist_test.cc index 6e83d08e0..adadae6a7 100644 --- a/test/libapt/sourcelist_test.cc +++ b/test/libapt/sourcelist_test.cc @@ -36,6 +36,7 @@ int main(int argc, char *argv[]) ; FileFd fd; + atexit(remove_tmpfile); tempfile = strdup("apt-test.XXXXXXXX"); tempfile_fd = mkstemp(tempfile); -- cgit v1.2.3-70-g09d2 From 50bd6fd3794dd1f61185302129dc6cd218d20b98 Mon Sep 17 00:00:00 2001 From: David Kalnischkies Date: Wed, 15 Jan 2014 17:23:05 +0100 Subject: integrate Anthonys rred with POC for client-side merge Providing the benefits of both without the downsides :) (ABI breaks or external dependencies) For this Anthonys rred is equipped with: - magic-filename-pickup of patches rather than explicit messages - use of FileFd instead of FILE* to get on-the-fly uncompress of the gzip compressed pdiff patches The acquire code in turn stops checking for apt-file's helper as our own rred is now clever enough for our needs. --- apt-pkg/acquire-item.cc | 11 ++--- methods/rred.cc | 94 +++++++++++---------------------------- test/integration/test-pdiff-usage | 23 +++++++--- 3 files changed, 45 insertions(+), 83 deletions(-) (limited to 'test') diff --git a/apt-pkg/acquire-item.cc b/apt-pkg/acquire-item.cc index 7f6443555..1185908f3 100644 --- a/apt-pkg/acquire-item.cc +++ b/apt-pkg/acquire-item.cc @@ -513,14 +513,9 @@ bool pkgAcqDiffIndex::ParseDiffIndex(string IndexDiffFile) /*{{{*/ bool pdiff_merge = _config->FindB("Acquire::PDiffs::Merge", true); if (pdiff_merge == true) { - // this perl script is provided by apt-file - pdiff_merge = FileExists(_config->FindFile("Dir::Bin::rred", "/usr/bin/diffindex-rred")); - if (pdiff_merge == true) - { - // reprepro adds this flag if it has merged patches on the server - std::string const precedence = Tags.FindS("X-Patch-Precedence"); - pdiff_merge = (precedence != "merged"); - } + // reprepro adds this flag if it has merged patches on the server + std::string const precedence = Tags.FindS("X-Patch-Precedence"); + pdiff_merge = (precedence != "merged"); } if (pdiff_merge == false) diff --git a/methods/rred.cc b/methods/rred.cc index ed3fcc82e..313166160 100644 --- a/methods/rred.cc +++ b/methods/rred.cc @@ -407,13 +407,13 @@ class Patch { public: - void read_diff(FILE *f) + void read_diff(FileFd &f) { char buffer[BLOCK_SIZE]; bool cmdwanted = true; Change ch(0); - while(fgets(buffer, sizeof(buffer), f)) + while(f.ReadLine(buffer, sizeof(buffer))) { if (cmdwanted) { char *m, *c; @@ -534,66 +534,11 @@ class Patch { } }; -bool LookupPatches(const std::string &Message, std::vector &lines) -{ - const char *Tag = "Patches"; - const size_t Length = strlen(Tag); - - std::string::const_iterator I, J; - - std::clog << "Looking for \"Patches:\" section in message:\n\n" << Message << "\n\n"; - std::clog.flush(); - - for (I = Message.begin(); I + Length < Message.end(); ++I) - { - if (I[Length] == ':' && stringcasecmp(I, I+Length, Tag) == 0) - { - // found the tag, now read the patches - for(;;) { - for (; I < Message.end() && *I != '\n'; ++I); - if (I < Message.end()) I++; - if (I == Message.end() || *I != ' ') - break; - while (I < Message.end() && isspace(*I)) I++; - for (J = I; J < Message.end() && *J != '\n'; ++J) - ; - do - J--; - while (I < J && isspace(*J)); - if (I < J) - lines.push_back(std::string(I,++J)); - else - break; - I = J; - } - std::clog << "Found " << lines.size() << " patches!\n"; - std::clog.flush(); - return true; - } - } - std::clog << "Found no patches! :(\n"; - std::clog.flush(); - return false; -} - - class RredMethod : public pkgAcqMethod { private: bool Debug; - std::vector patchpaths; protected: - virtual bool HandleMessage(int Number, std::string Message) { - if (Number == 600) - { - patchpaths.clear(); - LookupPatches(Message, patchpaths); - std::clog << "Ended up with " << patchpaths.size() << " patches!\n"; - std::clog.flush(); - } - return pkgAcqMethod::HandleMessage(Number, Message); - } - virtual bool Fetch(FetchItem *Itm) { Debug = _config->FindB("Debug::pkgAcquire::RRed", false); URI Get = Itm->Uri; @@ -601,17 +546,29 @@ class RredMethod : public pkgAcqMethod { FetchResult Res; Res.Filename = Itm->DestFile; - if (Itm->Uri.empty()) { + if (Itm->Uri.empty()) + { Path = Itm->DestFile; Itm->DestFile.append(".result"); } else URIStart(Res); + std::vector patchpaths; Patch patch; - if (patchpaths.empty()) - { + if (FileExists(Path + ".ed") == true) patchpaths.push_back(Path + ".ed"); + else + { + _error->PushToStack(); + std::vector patches = GetListOfFilesInDir(flNotFile(Path), "gz", true, false); + _error->RevertToStack(); + + std::string const baseName = Path + ".ed."; + for (std::vector::const_iterator p = patches.begin(); + p != patches.end(); ++p) + if (p->compare(0, baseName.length(), baseName) == 0) + patchpaths.push_back(*p); } std::string patch_name; @@ -624,13 +581,15 @@ class RredMethod : public pkgAcqMethod { std::clog << "Patching " << Path << " with " << patch_name << std::endl; - FILE *p = fopen(patch_name.c_str(), "r"); - if (p == NULL) { - std::clog << "Could not open patch file " << patch_name << std::endl; + FileFd p; + // all patches are compressed, even if the name doesn't reflect it + if (p.Open(patch_name, FileFd::ReadOnly, FileFd::Gzip) == false) { + std::cerr << "Could not open patch file " << patch_name << std::endl; + _error->DumpErrors(std::cerr); abort(); } patch.read_diff(p); - fclose(p); + p.Close(); } if (Debug == true) @@ -697,10 +656,9 @@ int main(int argc, char **argv) } for (; i < argc; i++) { - FILE *p; - p = fopen(argv[i], "r"); - if (!p) { - perror(argv[i]); + FileFd p; + if (p.Open(argv[i], FileFd::ReadOnly) == false) { + _error->DumpErrors(std::cerr); exit(1); } patch.read_diff(p); diff --git a/test/integration/test-pdiff-usage b/test/integration/test-pdiff-usage index 5a06e0ccb..ad31511b9 100755 --- a/test/integration/test-pdiff-usage +++ b/test/integration/test-pdiff-usage @@ -20,10 +20,19 @@ chmod +x extrred echo 'Dir::Bin::rred "./extrred";' > rootdir/etc/apt/apt.conf.d/99rred wasmergeused() { - testsuccess aptget update "$@" + msgtest 'Test for successful execution of' "$*" + local OUTPUT=$(mktemp) + addtrap "rm $OUTPUT;" + if aptget update "$@" >${OUTPUT} 2>&1; then + msgpass + else + echo + cat $OUTPUT + msgfail + fi + msgtest 'Check if the right pdiff merger was used' - if [ -e ./merge-was-used ]; then - rm -f ./merge-was-used + if grep -q '^pkgAcqIndexMergeDiffs::Done(): rred' $OUTPUT; then if echo "$*" | grep -q -- '-o Acquire::PDiffs::Merge=1'; then msgpass else @@ -50,7 +59,7 @@ testrun() { testequal "$(cat ${PKGFILE}) " aptcache show apt oldstuff - # apply with one patch + msgmsg 'Testcase: apply with one patch' cp ${PKGFILE}-new aptarchive/Packages compressfile 'aptarchive/Packages' mkdir -p aptarchive/Packages.diff @@ -73,13 +82,13 @@ SHA1-Patches: testequal "$(cat ${PKGFILE}-new) " aptcache show apt newstuff - # index is already up-to-date + msgmsg 'Testcase: index is already up-to-date' find rootdir/var/lib/apt/lists -name '*.IndexDiff' -type f -delete testsuccess aptget update "$@" testequal "$(cat ${PKGFILE}-new) " aptcache show apt newstuff - # apply with two patches + msgmsg 'Testcase: apply with two patches' cp ${PKGFILE}-new aptarchive/Packages echo ' Package: futurestuff @@ -120,7 +129,7 @@ SHA1-Patches: testequal "$(cat Packages-future) " aptcache show apt newstuff futurestuff - # patch applying fails, but successful fallback + msgmsg 'Testcase: patch applying fails, but successful fallback' rm -rf rootdir/var/lib/apt/lists cp -a rootdir/var/lib/apt/lists-bak rootdir/var/lib/apt/lists cp ${PKGFILE}-new aptarchive/Packages -- cgit v1.2.3-70-g09d2 From f74a6fa120759d0a1bd4a5aff0dc2c50911b5407 Mon Sep 17 00:00:00 2001 From: David Kalnischkies Date: Wed, 15 Jan 2014 18:44:47 +0100 Subject: rework some testcases to not spit out text Rework also uncovers two FIXMEs Git-Dch: Ignore --- test/integration/framework | 22 ++++---- test/integration/test-apt-progress-fd-conffile | 17 +++++-- test/integration/test-apt-sources-deb822 | 70 ++++++++++++++------------ test/integration/test-bug-728500-tempdir | 19 +++++-- 4 files changed, 77 insertions(+), 51 deletions(-) (limited to 'test') diff --git a/test/integration/framework b/test/integration/framework index 6ada1e9cc..2fe059280 100644 --- a/test/integration/framework +++ b/test/integration/framework @@ -948,22 +948,22 @@ testempty() { test -z "$($* 2>&1)" && msgpass || msgfail } -testequalwithmsg() { - local MSG="$1" - shift +testequal() { + local MSG='Test of equality of' + if [ "$1" = '--nomsg' ]; then + MSG='' + shift + fi + local COMPAREFILE=$(mktemp) addtrap "rm $COMPAREFILE;" echo "$1" > $COMPAREFILE shift - msgtest "$MSG" - $* 2>&1 | checkdiff $COMPAREFILE - && msgpass || msgfail -} -testequal() { - local EXPECTED="$1" - shift - local MSG="Test for equality of $*" - testequalwithmsg "$MSG" "$EXPECTED" $* + if [ -n "$MSG" ]; then + msgtest "$MSG" "$*" + fi + $* 2>&1 | checkdiff $COMPAREFILE - && msgpass || msgfail } testequalor2() { diff --git a/test/integration/test-apt-progress-fd-conffile b/test/integration/test-apt-progress-fd-conffile index 0b42b1b2f..085d5e871 100755 --- a/test/integration/test-apt-progress-fd-conffile +++ b/test/integration/test-apt-progress-fd-conffile @@ -32,12 +32,19 @@ testsuccess aptget install compiz-core=1.0 # fake conffile change echo "meep" >> rootdir/etc/compiz.conf/compiz.conf -# install +# FIXME: Is there really no way to see if dpkg actually prompts? +msgtest 'Test for successful execution of' 'apt-get install compiz-core=2.0' +OUTPUT=$(mktemp) +addtrap "rm $OUTPUT;" exec 3> apt-progress.log -echo n | aptget install compiz-core=2.0 -o APT::Status-Fd=3 -o Dpkg::Use-Pty=false +if aptget install compiz-core=2.0 -o APT::Status-Fd=3 -o Dpkg::Use-Pty=false -o dpkg::options::='--force-confold' >${OUTPUT} 2>&1; then + msgpass +else + echo + cat $OUTPUT + msgfail +fi # and ensure there is a conffile message in the file -msgtest "Conffile prompt in apt-progress.log" +msgtest 'Test status fd for an included' 'pmconffile msg' grep -q "pmconffile:/etc/compiz.conf/compiz.conf" apt-progress.log && msgpass || (cat apt-progress.log && msgfail) - -cat apt-progress.log \ No newline at end of file diff --git a/test/integration/test-apt-sources-deb822 b/test/integration/test-apt-sources-deb822 index bacad1ed4..8c022767f 100755 --- a/test/integration/test-apt-sources-deb822 +++ b/test/integration/test-apt-sources-deb822 @@ -5,17 +5,10 @@ TESTDIR=$(readlink -f $(dirname $0)) . $TESTDIR/framework setupenvironment -configarchitecture "i386" +configarchitecture 'i386' -SOURCES="rootdir/etc/apt/sources.list" - -echo "deb http://ftp.debian.org/debian stable main" > $SOURCES -testequalwithmsg "Old style sources.list works" "'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 - - -BASE="# some comment +SOURCES='rootdir/etc/apt/sources.list' +BASE='# some comment # that contains a : as well #Type: meep @@ -24,57 +17,72 @@ URL: http://ftp.debian.org/debian Dist: stable Section: main Comment: Some random string - that can be very long" + that can be very long' -# simple case -echo "$BASE" > $SOURCES -testequalwithmsg "Simple deb822 sources.list works" "'http://ftp.debian.org/debian/dists/stable/main/binary-i386/Packages.bz2' ftp.debian.org_debian_dists_stable_main_binary-i386_Packages 0 : +msgtest 'Test old-style sources.list' +echo "deb http://ftp.debian.org/debian stable main" > $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/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 +'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 +msgtest 'Test simple deb822 sources.list' +echo "$BASE" > $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/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 -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 : + +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 +'http://ftp.debian.org/debian/dists/stable/InRelease' ftp.debian.org_debian_dists_stable_InRelease 0 " aptget update --print-uris + +# FIXME: Advertised, but not supported at the moment +#msgtest 'Test deb822 with two sections' 'seperated by space' +#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 -# Two entries + +msgtest 'Test deb822 with' 'two entries' echo "$BASE" > $SOURCES echo "" >> $SOURCES echo "$BASE" | sed s/stable/unstable/ >> $SOURCES - -testequalwithmsg "Multiple entries in 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 : +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/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 +'http://ftp.debian.org/debian/dists/unstable/InRelease' ftp.debian.org_debian_dists_unstable_InRelease 0 " aptget update --print-uris -# ARCH option +msgtest 'Test deb822' 'architecture option' echo "$BASE" > $SOURCES echo "Arch: 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 : +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 : 'http://ftp.debian.org/debian/dists/stable/InRelease' ftp.debian.org_debian_dists_stable_InRelease 0 " aptget update --print-uris -# invalid sources.list file -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) +msgtest 'Test old-style sources.list file which has' 'malformed dist' +echo "deb http://ftp.debian.org" > $SOURCES +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 Dist: 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) +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 diff --git a/test/integration/test-bug-728500-tempdir b/test/integration/test-bug-728500-tempdir index 0606538a1..0451fc1ed 100755 --- a/test/integration/test-bug-728500-tempdir +++ b/test/integration/test-bug-728500-tempdir @@ -7,12 +7,23 @@ TESTDIR=$(readlink -f $(dirname $0)) setupenvironment configarchitecture 'i386' -buildsimplenativepackage 'coolstuff' 'all' '1.0' 'unstable' +insertpackage 'unstable' 'coolstuff' 'all' '1.0' setupaptarchive changetowebserver -msgtest 'Test with incorect TMPDIR' +msgtest 'Test apt-get update with incorrect' 'TMPDIR' + +OUTPUT=$(mktemp) +addtrap "rm $OUTPUT;" export TMPDIR=/does-not-exists -aptget update && msgpass || msgfail -unset TMPDIR \ No newline at end of file +if aptget update >${OUTPUT} 2>&1; then + msgpass +else + echo + cat $OUTPUT + msgfail +fi +unset TMPDIR + +testequal 'coolstuff' aptcache pkgnames -- cgit v1.2.3-70-g09d2 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(-) (limited to 'test') 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-70-g09d2 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(-) (limited to 'test') 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-70-g09d2 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(-) (limited to 'test') 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-70-g09d2 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(-) (limited to 'test') 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-70-g09d2 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(-) (limited to 'test') 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-70-g09d2 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(-) (limited to 'test') 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-70-g09d2 From 866e9fadf892368fcb50e6a192bcdd350cfe8e5c Mon Sep 17 00:00:00 2001 From: Michael Vogt Date: Fri, 17 Jan 2014 20:41:55 +0100 Subject: implement suggestion by donkult (thanks!) --- apt-pkg/sourcelist.cc | 4 ++-- doc/sources.list.5.xml | 4 ++-- test/integration/test-apt-sources-deb822 | 2 +- test/libapt/sourcelist_test.cc | 4 ++-- 4 files changed, 7 insertions(+), 7 deletions(-) (limited to 'test') diff --git a/apt-pkg/sourcelist.cc b/apt-pkg/sourcelist.cc index 09d8287a0..51b766095 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("Uri"); + string URI = Tags.FindS("URI"); if (!FixupURI(URI)) { _error->Error(_("Malformed stanza %u in source list %s (URI parse)"),i,Fd.Name().c_str()); @@ -87,7 +87,7 @@ bool pkgSourceList::Type::ParseStanza(vector &List, // Define external/internal options const char* option_deb822[] = { - "Architectures", "Architectures-Add", "Architectures-Delete", "Trusted", + "Architectures", "Architectures-Add", "Architectures-Remove", "Trusted", }; const char* option_internal[] = { "arch", "arch+", "arch-", "trusted", diff --git a/doc/sources.list.5.xml b/doc/sources.list.5.xml index e770023d5..7a82bd4ce 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 67d119565..a055c8d5e 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 -Uri: http://ftp.debian.org/debian +URI: http://ftp.debian.org/debian Suite: stable Section: main Comment: Some random string diff --git a/test/libapt/sourcelist_test.cc b/test/libapt/sourcelist_test.cc index 1d30bd85b..6a625770f 100644 --- a/test/libapt/sourcelist_test.cc +++ b/test/libapt/sourcelist_test.cc @@ -23,14 +23,14 @@ int main(int argc, char *argv[]) { const char contents[] = "" "Type: deb\n" - "Uri: http://ftp.debian.org/debian\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" - "Uri: http://ftp.debian.org/debian\n" + "URI: http://ftp.debian.org/debian\n" "Suite: unstable\n" "Section: main non-free\n" ; -- cgit v1.2.3-70-g09d2 From 6c069a2247781754bcc8574687cb98b493c6ab8a Mon Sep 17 00:00:00 2001 From: Michael Vogt Date: Sat, 18 Jan 2014 20:51:03 +0100 Subject: rename "Suite/Section" to plural --- apt-pkg/sourcelist.cc | 4 ++-- doc/sources.list.5.xml | 10 +++++----- test/integration/test-apt-sources-deb822 | 6 +++--- test/libapt/sourcelist_test.cc | 4 ++-- 4 files changed, 12 insertions(+), 12 deletions(-) (limited to 'test') diff --git a/apt-pkg/sourcelist.cc b/apt-pkg/sourcelist.cc index 51b766095..4e580ba04 100644 --- a/apt-pkg/sourcelist.cc +++ b/apt-pkg/sourcelist.cc @@ -97,9 +97,9 @@ bool pkgSourceList::Type::ParseStanza(vector &List, Options[option_internal[j]] = Tags.FindS(option_deb822[j]); // now create one item per suite/section - string Suite = Tags.FindS("Suite"); + string Suite = Tags.FindS("Suites"); Suite = SubstVar(Suite,"$(ARCH)",_config->Find("APT::Architecture")); - string const Section = Tags.FindS("Section"); + string const Section = Tags.FindS("Sections"); std::vector list_dist = StringSplit(Suite, " "); std::vector list_section = StringSplit(Section, " "); diff --git a/doc/sources.list.5.xml b/doc/sources.list.5.xml index 7a82bd4ce..87f4d5fc5 100644 --- a/doc/sources.list.5.xml +++ b/doc/sources.list.5.xml @@ -20,7 +20,7 @@ &apt-email; &apt-product; - 2012-06-09T00:00:00Z + 2014-01-18T00:00:00Z @@ -85,14 +85,14 @@ Type: deb URI: http://example.com - Suite: stable - Section: component1 component2 + Suites: stable + Sections: component1 component2 [option1]: [option1-value] Type: deb-src URI: http://example.com - Suite: stable - Section: component1 component2 + Suites: stable + Sections: component1 component2 [option1]: [option1-value] diff --git a/test/integration/test-apt-sources-deb822 b/test/integration/test-apt-sources-deb822 index a055c8d5e..c73b942d4 100755 --- a/test/integration/test-apt-sources-deb822 +++ b/test/integration/test-apt-sources-deb822 @@ -21,8 +21,8 @@ BASE="# some comment Type: deb URI: http://ftp.debian.org/debian -Suite: stable -Section: main +Suites: stable +Sections: main Comment: Some random string that can be very long" @@ -70,7 +70,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 -Suite: stable +Suites: 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) diff --git a/test/libapt/sourcelist_test.cc b/test/libapt/sourcelist_test.cc index 6a625770f..ae5d11f66 100644 --- a/test/libapt/sourcelist_test.cc +++ b/test/libapt/sourcelist_test.cc @@ -24,8 +24,8 @@ int main(int argc, char *argv[]) const char contents[] = "" "Type: deb\n" "URI: http://ftp.debian.org/debian\n" - "Suite: stable\n" - "Section: main\n" + "Suites: stable\n" + "Sections: main\n" "Comment: Some random string\n" " that can be very long\n" "\n" -- cgit v1.2.3-70-g09d2