summaryrefslogtreecommitdiff
path: root/apt-pkg
diff options
context:
space:
mode:
authorMichael Vogt <michael.vogt@ubuntu.com>2011-07-28 09:19:45 +0200
committerMichael Vogt <michael.vogt@ubuntu.com>2011-07-28 09:19:45 +0200
commit0b7d641cf12761c3dcc5edb4031adfc9709963e4 (patch)
tree5d12281c5f482e6f85636f57ef86a2dc92e8713c /apt-pkg
parent7d79339f811aeebacb3f841bac6075fdfbadd03f (diff)
parented6ba81db1b2832089ea443cf0030ab3f15fda97 (diff)
* merged latest fixes from debian-sid
* apt-pkg/contrib/sha1.cc: - fix illegally casts of on-stack buffer to a type requiring more alignment than it has resulting in segfaults on sparc (Closes: #634696) * apt-pkg/contrib/cdromutl.cc: - fix escape problem when looking for the mounted devices * apt-pkg/contrib/strutl.{h,cc}, test/libapt/strutil_test.cc: - add new DeEscapeString() similar to DeQuoteString but unescape character escapes like \0XX and \xXX (plus added test) * refresh po/* * cmdline/apt-get.cc: - fix missing download progress in apt-get download - do not require unused partial dirs in 'source' (Closes: #633510) - buildconflicts effect all architectures - implement MultiarchCross for build-dep and source (Closes: #632221) * cmdline/apt-key: - use a tmpfile instead of /etc/apt/secring.gpg (Closes: #632596) * debian/apt.postinst: - remove /etc/apt/secring.gpg if it is an empty file * doc/apt-cache.8.xml: - apply madison typofix from John Feuerstein, thanks! (Closes: #633455) * apt-pkg/policy.cc: - emit an error on unknown APT::Default-Release value (Closes: #407511) * apt-pkg/aptconfiguration.cc: - ensure that native architecture is if not specified otherwise the first architecture in the Architectures vector * apt-pkg/deb/deblistparser.cc: - Strip only :any and :native if MultiArch should be stripped as it is save to ignore them in non-MultiArch contexts but if the dependency is a specific architecture (and not the native) do not strip
Diffstat (limited to 'apt-pkg')
-rw-r--r--apt-pkg/acquire.h2
-rw-r--r--apt-pkg/aptconfiguration.cc2
-rw-r--r--apt-pkg/contrib/cdromutl.cc4
-rw-r--r--apt-pkg/contrib/configuration.cc2
-rw-r--r--apt-pkg/contrib/configuration.h2
-rw-r--r--apt-pkg/contrib/sha1.cc5
-rw-r--r--apt-pkg/contrib/strutl.cc61
-rw-r--r--apt-pkg/contrib/strutl.h4
-rw-r--r--apt-pkg/deb/deblistparser.cc9
-rw-r--r--apt-pkg/policy.cc18
10 files changed, 97 insertions, 12 deletions
diff --git a/apt-pkg/acquire.h b/apt-pkg/acquire.h
index c9eaa67d1..ae555df22 100644
--- a/apt-pkg/acquire.h
+++ b/apt-pkg/acquire.h
@@ -349,6 +349,8 @@ class pkgAcquire
*/
bool Setup(pkgAcquireStatus *Progress = NULL, string const &Lock = "");
+ void SetLog(pkgAcquireStatus *Progress) { Log = Progress; }
+
/** \brief Construct a new pkgAcquire. */
pkgAcquire(pkgAcquireStatus *Log) __deprecated;
pkgAcquire();
diff --git a/apt-pkg/aptconfiguration.cc b/apt-pkg/aptconfiguration.cc
index e8c8e73d0..9ccbeecf1 100644
--- a/apt-pkg/aptconfiguration.cc
+++ b/apt-pkg/aptconfiguration.cc
@@ -352,7 +352,7 @@ std::vector<std::string> const Configuration::getArchitectures(bool const &Cache
if (archs.empty() == true ||
std::find(archs.begin(), archs.end(), arch) == archs.end())
- archs.push_back(arch);
+ archs.insert(archs.begin(), arch);
// erase duplicates and empty strings
for (std::vector<string>::reverse_iterator a = archs.rbegin();
diff --git a/apt-pkg/contrib/cdromutl.cc b/apt-pkg/contrib/cdromutl.cc
index 821e6d688..e25caf1a5 100644
--- a/apt-pkg/contrib/cdromutl.cc
+++ b/apt-pkg/contrib/cdromutl.cc
@@ -258,7 +258,9 @@ string FindMountPointForDevice(const char *devnode)
if(TokSplitString(' ', buf, out, 10))
{
fclose(f);
- return string(out[1]);
+ // unescape the \0XXX chars in the path
+ string mount_point = out[1];
+ return DeEscapeString(mount_point);
}
}
}
diff --git a/apt-pkg/contrib/configuration.cc b/apt-pkg/contrib/configuration.cc
index 0664e3704..942ea9fbc 100644
--- a/apt-pkg/contrib/configuration.cc
+++ b/apt-pkg/contrib/configuration.cc
@@ -345,7 +345,7 @@ void Configuration::Set(const char *Name,const string &Value)
// Configuration::Set - Set an integer value /*{{{*/
// ---------------------------------------------------------------------
/* */
-void Configuration::Set(const char *Name,int const Value)
+void Configuration::Set(const char *Name,int const &Value)
{
Item *Itm = Lookup(Name,true);
if (Itm == 0)
diff --git a/apt-pkg/contrib/configuration.h b/apt-pkg/contrib/configuration.h
index 3568ce815..2844ec097 100644
--- a/apt-pkg/contrib/configuration.h
+++ b/apt-pkg/contrib/configuration.h
@@ -84,7 +84,7 @@ class Configuration
void CndSet(const char *Name,const string &Value);
void CndSet(const char *Name,const int Value);
void Set(const char *Name,const string &Value);
- void Set(const char *Name,const int Value);
+ void Set(const char *Name,const int &Value);
inline bool Exists(const string &Name) const {return Exists(Name.c_str());};
bool Exists(const char *Name) const;
diff --git a/apt-pkg/contrib/sha1.cc b/apt-pkg/contrib/sha1.cc
index 4b0552102..5b9db202d 100644
--- a/apt-pkg/contrib/sha1.cc
+++ b/apt-pkg/contrib/sha1.cc
@@ -74,10 +74,9 @@ static void SHA1Transform(uint32_t state[5],uint8_t const buffer[64])
uint32_t l[16];
}
CHAR64LONG16;
- CHAR64LONG16 *block;
+ CHAR64LONG16 workspace, *block;
- uint8_t workspace[64];
- block = (CHAR64LONG16 *)workspace;
+ block = &workspace;
memcpy(block,buffer,sizeof(workspace));
/* Copy context->state[] to working vars */
diff --git a/apt-pkg/contrib/strutl.cc b/apt-pkg/contrib/strutl.cc
index 072dda3ac..ab2da2d9a 100644
--- a/apt-pkg/contrib/strutl.cc
+++ b/apt-pkg/contrib/strutl.cc
@@ -1240,7 +1240,68 @@ bool CheckDomainList(const string &Host,const string &List)
return false;
}
/*}}}*/
+// DeEscapeString - unescape (\0XX and \xXX) from a string /*{{{*/
+// ---------------------------------------------------------------------
+/* */
+string DeEscapeString(const string &input)
+{
+ char tmp[3];
+ string::const_iterator it, escape_start;
+ string output, octal, hex;
+ for (it = input.begin(); it != input.end(); it++)
+ {
+ // just copy non-escape chars
+ if (*it != '\\')
+ {
+ output += *it;
+ continue;
+ }
+ // deal with double escape
+ if (*it == '\\' &&
+ (it + 1 < input.end()) && it[1] == '\\')
+ {
+ // copy
+ output += *it;
+ // advance iterator one step further
+ it += 1;
+ continue;
+ }
+
+ // ensure we have a char to read
+ if (it + 1 == input.end())
+ continue;
+
+ // read it
+ it++;
+ switch (*it)
+ {
+ case '0':
+ if (it + 2 <= input.end()) {
+ tmp[0] = it[1];
+ tmp[1] = it[2];
+ tmp[2] = 0;
+ output += (char)strtol(tmp, 0, 8);
+ it += 2;
+ }
+ break;
+ case 'x':
+ if (it + 2 <= input.end()) {
+ tmp[0] = it[1];
+ tmp[1] = it[2];
+ tmp[2] = 0;
+ output += (char)strtol(tmp, 0, 16);
+ it += 2;
+ }
+ break;
+ default:
+ // FIXME: raise exception here?
+ break;
+ }
+ }
+ return output;
+}
+ /*}}}*/
// URI::CopyFrom - Copy from an object /*{{{*/
// ---------------------------------------------------------------------
/* This parses the URI into all of its components */
diff --git a/apt-pkg/contrib/strutl.h b/apt-pkg/contrib/strutl.h
index 89cbf0370..fba85cf94 100644
--- a/apt-pkg/contrib/strutl.h
+++ b/apt-pkg/contrib/strutl.h
@@ -39,6 +39,10 @@ bool ParseCWord(const char *&String,string &Res);
string QuoteString(const string &Str,const char *Bad);
string DeQuoteString(const string &Str);
string DeQuoteString(string::const_iterator const &begin, string::const_iterator const &end);
+
+// unescape (\0XX and \xXX) from a string
+string DeEscapeString(const string &input);
+
string SizeToStr(double Bytes);
string TimeToStr(unsigned long Sec);
string Base64Encode(const string &Str);
diff --git a/apt-pkg/deb/deblistparser.cc b/apt-pkg/deb/deblistparser.cc
index b708296d3..d23207f4a 100644
--- a/apt-pkg/deb/deblistparser.cc
+++ b/apt-pkg/deb/deblistparser.cc
@@ -456,7 +456,7 @@ const char *debListParser::ConvertRelation(const char *I,unsigned int &Op)
*
* The complete architecture, consisting of <kernel>-<cpu>.
*/
-static string CompleteArch(std::string& arch) {
+static string CompleteArch(std::string const &arch) {
if (arch == "armel") return "linux-arm";
if (arch == "armhf") return "linux-arm";
if (arch == "lpia") return "linux-i386";
@@ -495,9 +495,13 @@ const char *debListParser::ParseDepends(const char *Start,const char *Stop,
Package.assign(Start,I - Start);
// We don't want to confuse library users which can't handle MultiArch
+ string const arch = _config->Find("APT::Architecture");
if (StripMultiArch == true) {
size_t const found = Package.rfind(':');
- if (found != string::npos)
+ if (found != string::npos &&
+ (strcmp(Package.c_str() + found, ":any") == 0 ||
+ strcmp(Package.c_str() + found, ":native") == 0 ||
+ strcmp(Package.c_str() + found + 1, arch.c_str()) == 0))
Package = Package.substr(0,found);
}
@@ -538,7 +542,6 @@ const char *debListParser::ParseDepends(const char *Start,const char *Stop,
if (ParseArchFlags == true)
{
- string arch = _config->Find("APT::Architecture");
string completeArch = CompleteArch(arch);
// Parse an architecture
diff --git a/apt-pkg/policy.cc b/apt-pkg/policy.cc
index be96d4c84..2c22fe0da 100644
--- a/apt-pkg/policy.cc
+++ b/apt-pkg/policy.cc
@@ -56,8 +56,22 @@ pkgPolicy::pkgPolicy(pkgCache *Owner) : Pins(0), PFPriority(0), Cache(Owner)
// The config file has a master override.
string DefRel = _config->Find("APT::Default-Release");
if (DefRel.empty() == false)
- CreatePin(pkgVersionMatch::Release,"",DefRel,990);
-
+ {
+ bool found = false;
+ // FIXME: make ExpressionMatches static to use it here easily
+ pkgVersionMatch vm("", pkgVersionMatch::None);
+ for (pkgCache::PkgFileIterator F = Cache->FileBegin(); F != Cache->FileEnd(); ++F)
+ {
+ if ((F->Archive != 0 && vm.ExpressionMatches(DefRel, F.Archive()) == true) ||
+ (F->Codename != 0 && vm.ExpressionMatches(DefRel, F.Codename()) == true) ||
+ (F->Version != 0 && vm.ExpressionMatches(DefRel, F.Version()) == true))
+ found = true;
+ }
+ if (found == false)
+ _error->Error(_("The value '%s' is invalid for APT::Default-Release as such a release is not available in the sources"), DefRel.c_str());
+ else
+ CreatePin(pkgVersionMatch::Release,"",DefRel,990);
+ }
InitDefaults();
}
/*}}}*/