From 0d7a243df522cad460bc1f94f32c6b7f766cabb1 Mon Sep 17 00:00:00 2001 From: "Eugene V. Lyubimkin" Date: Sat, 25 Oct 2008 01:33:40 +0300 Subject: Added fallback to uncompressed files while acquiring index files (Sources and Packages) --- apt-pkg/acquire-item.cc | 25 +++++++++++++++++++------ 1 file changed, 19 insertions(+), 6 deletions(-) (limited to 'apt-pkg') diff --git a/apt-pkg/acquire-item.cc b/apt-pkg/acquire-item.cc index 7cae6c8b7..b014092df 100644 --- a/apt-pkg/acquire-item.cc +++ b/apt-pkg/acquire-item.cc @@ -570,7 +570,7 @@ pkgAcqIndex::pkgAcqIndex(pkgAcquire *Owner, } else { CompressionExtension = comprExt; } - Desc.URI = URI + CompressionExtension; + Desc.URI = URI + (CompressionExtension == "plain" ? "" : CompressionExtension); Desc.Description = URIDesc; Desc.Owner = this; @@ -597,19 +597,30 @@ string pkgAcqIndex::Custom600Headers() void pkgAcqIndex::Failed(string Message,pkgAcquire::MethodConfig *Cnf) { + bool descChanged = false; // no .bz2 found, retry with .gz if(Desc.URI.substr(Desc.URI.size()-3) == "bz2") { - Desc.URI = Desc.URI.substr(0,Desc.URI.size()-3) + "gz"; + Desc.URI = Desc.URI.substr(0,Desc.URI.size()-3) + "gz"; - // retry with a gzip one - new pkgAcqIndex(Owner, RealURI, Desc.Description,Desc.ShortDesc, + new pkgAcqIndex(Owner, RealURI, Desc.Description,Desc.ShortDesc, ExpectedHash, string(".gz")); + descChanged = true; + } + // no .gz found, retry with uncompressed + else if(Desc.URI.substr(Desc.URI.size()-2) == "gz") { + Desc.URI = Desc.URI.substr(0,Desc.URI.size()-2); + + new pkgAcqIndex(Owner, RealURI, Desc.Description,Desc.ShortDesc, + ExpectedHash, string("plain")); + descChanged = true; + } + if (descChanged) { Status = StatDone; Complete = false; Dequeue(); return; - } - + } + // on decompression failure, remove bad versions in partial/ if(Decompression && Erase) { string s = _config->FindDir("Dir::State::lists") + "partial/"; @@ -706,6 +717,8 @@ void pkgAcqIndex::Done(string Message,unsigned long Size,string Hash, decompProg = "bzip2"; else if(compExt == ".gz") decompProg = "gzip"; + else if(compExt == "ges" || compExt == "ces") // packaGES or sourCES + decompProg = "copy"; else { _error->Error("Unsupported extension: %s", compExt.c_str()); return; -- cgit v1.2.3-70-g09d2 From 4805f1cfd795c41db2a3c7fed56c15bb8c350c49 Mon Sep 17 00:00:00 2001 From: "Eugene V. Lyubimkin" Date: Sat, 25 Oct 2008 17:03:16 +0300 Subject: Strip user/password from URL in error message. --- apt-pkg/algorithms.cc | 18 +++++++++++++++++- debian/changelog | 3 +++ 2 files changed, 20 insertions(+), 1 deletion(-) (limited to 'apt-pkg') diff --git a/apt-pkg/algorithms.cc b/apt-pkg/algorithms.cc index 2e2a976bb..bd59a4749 100644 --- a/apt-pkg/algorithms.cc +++ b/apt-pkg/algorithms.cc @@ -23,6 +23,7 @@ #include #include +#include #include #include #include @@ -1342,7 +1343,22 @@ bool ListUpdate(pkgAcquireStatus &Stat, (*I)->Finished(); - _error->Warning(_("Failed to fetch %s %s\n"),(*I)->DescURI().c_str(), + // stripping username/password from URI if present + string descUri = (*I)->DescURI(); + regex_t userPassRegex; + regcomp(&userPassRegex, "\\://(\\w+)\\:(\\w+)@", REG_EXTENDED); + regmatch_t userPassMatch; + regexec(&userPassRegex, descUri.c_str(), 1, &userPassMatch, 0); + if (userPassMatch.rm_so != -1) // regexp matched + { + // really stripping + size_t stripStart = userPassMatch.rm_so + 3; + size_t stripEnd = userPassMatch.rm_eo; + descUri = descUri.substr(0, stripStart) + + descUri.substr(stripEnd, string::npos); + } + + _error->Warning(_("Failed to fetch %s %s\n"), descUri.c_str(), (*I)->ErrorText.c_str()); if ((*I)->Status == pkgAcquire::Item::StatTransientNetworkError) diff --git a/debian/changelog b/debian/changelog index 5c2c5f292..40e1cc23d 100644 --- a/debian/changelog +++ b/debian/changelog @@ -4,6 +4,9 @@ apt (0.7.17) unstable; urgency=low * apt-pkg/acquire-item.cc: - Added fallback to uncompressed 'Packages' if neither 'bz2' nor 'gz' available. (Closes: #409284) + * apt-pkg/algorithm.cc: + - Strip username and password from source URL in error message. + (Closes: #425150) -- Eugene V. Lyubimkin Fri, 24 Oct 2008 23:45:17 +0300 -- cgit v1.2.3-70-g09d2 From 27d5a2046999b86605968e7cbf0778dd95e63371 Mon Sep 17 00:00:00 2001 From: "Eugene V. Lyubimkin" Date: Sat, 25 Oct 2008 22:15:20 +0300 Subject: Fixed error output when fallback'ed to uncompressed Packages/Sources. --- apt-pkg/acquire-item.cc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'apt-pkg') diff --git a/apt-pkg/acquire-item.cc b/apt-pkg/acquire-item.cc index b014092df..503ad7dae 100644 --- a/apt-pkg/acquire-item.cc +++ b/apt-pkg/acquire-item.cc @@ -568,9 +568,9 @@ pkgAcqIndex::pkgAcqIndex(pkgAcquire *Owner, else CompressionExtension = ".gz"; } else { - CompressionExtension = comprExt; + CompressionExtension = (comprExt == "plain" ? "" : comprExt); } - Desc.URI = URI + (CompressionExtension == "plain" ? "" : CompressionExtension); + Desc.URI = URI + CompressionExtension; Desc.Description = URIDesc; Desc.Owner = this; -- cgit v1.2.3-70-g09d2 From 2d6f9accbcf38923911854a918d971c0905b262c Mon Sep 17 00:00:00 2001 From: "Eugene V. Lyubimkin" Date: Sat, 25 Oct 2008 22:49:22 +0300 Subject: Corrected determining if regexp matched. --- apt-pkg/algorithms.cc | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'apt-pkg') diff --git a/apt-pkg/algorithms.cc b/apt-pkg/algorithms.cc index bd59a4749..6f30a52da 100644 --- a/apt-pkg/algorithms.cc +++ b/apt-pkg/algorithms.cc @@ -1348,8 +1348,8 @@ bool ListUpdate(pkgAcquireStatus &Stat, regex_t userPassRegex; regcomp(&userPassRegex, "\\://(\\w+)\\:(\\w+)@", REG_EXTENDED); regmatch_t userPassMatch; - regexec(&userPassRegex, descUri.c_str(), 1, &userPassMatch, 0); - if (userPassMatch.rm_so != -1) // regexp matched + int regMatchResult = regexec(&userPassRegex, descUri.c_str(), 1, &userPassMatch, 0); + if (regMatchResult == 0 && userPassMatch.rm_so != -1) // regexp matched { // really stripping size_t stripStart = userPassMatch.rm_so + 3; @@ -1357,6 +1357,7 @@ bool ListUpdate(pkgAcquireStatus &Stat, descUri = descUri.substr(0, stripStart) + descUri.substr(stripEnd, string::npos); } + regfree(&userPassRegex); _error->Warning(_("Failed to fetch %s %s\n"), descUri.c_str(), (*I)->ErrorText.c_str()); -- cgit v1.2.3-70-g09d2 From c94e518c5ee831c21063ce38e6446113db087456 Mon Sep 17 00:00:00 2001 From: "Eugene V. Lyubimkin" Date: Sun, 26 Oct 2008 13:39:10 +0200 Subject: Switched from regexp to using existing URI class to strip user/password. --- apt-pkg/algorithms.cc | 19 ++++--------------- 1 file changed, 4 insertions(+), 15 deletions(-) (limited to 'apt-pkg') diff --git a/apt-pkg/algorithms.cc b/apt-pkg/algorithms.cc index 6f30a52da..70212e5c9 100644 --- a/apt-pkg/algorithms.cc +++ b/apt-pkg/algorithms.cc @@ -1343,21 +1343,10 @@ bool ListUpdate(pkgAcquireStatus &Stat, (*I)->Finished(); - // stripping username/password from URI if present - string descUri = (*I)->DescURI(); - regex_t userPassRegex; - regcomp(&userPassRegex, "\\://(\\w+)\\:(\\w+)@", REG_EXTENDED); - regmatch_t userPassMatch; - int regMatchResult = regexec(&userPassRegex, descUri.c_str(), 1, &userPassMatch, 0); - if (regMatchResult == 0 && userPassMatch.rm_so != -1) // regexp matched - { - // really stripping - size_t stripStart = userPassMatch.rm_so + 3; - size_t stripEnd = userPassMatch.rm_eo; - descUri = descUri.substr(0, stripStart) + - descUri.substr(stripEnd, string::npos); - } - regfree(&userPassRegex); + ::URI uri((*I)->DescURI()); + uri.User.clear(); + uri.Password.clear(); + string descUri = string(uri); _error->Warning(_("Failed to fetch %s %s\n"), descUri.c_str(), (*I)->ErrorText.c_str()); -- cgit v1.2.3-70-g09d2 From 4b94b383390fb93c58fb14460679fadbb3c8ee93 Mon Sep 17 00:00:00 2001 From: "Eugene V. Lyubimkin" Date: Sun, 26 Oct 2008 13:41:09 +0200 Subject: Forgot to remove regex.h include in previous commit. Now done --- apt-pkg/algorithms.cc | 1 - 1 file changed, 1 deletion(-) (limited to 'apt-pkg') diff --git a/apt-pkg/algorithms.cc b/apt-pkg/algorithms.cc index 70212e5c9..1d04ae64d 100644 --- a/apt-pkg/algorithms.cc +++ b/apt-pkg/algorithms.cc @@ -23,7 +23,6 @@ #include #include -#include #include #include #include -- cgit v1.2.3-70-g09d2