summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Kalnischkies <david@kalnischkies.de>2015-04-07 16:58:44 +0200
committerDavid Kalnischkies <david@kalnischkies.de>2015-04-07 18:30:15 +0200
commit66c3875df391b1120b43831efcbe88a78569fbfe (patch)
tree0cfc5d1e07eac9ae43124c9c0ad7b906c1326bd6
parenta2679f55b5b14092db88fab3799f06e6b68e439e (diff)
avoid depends on std::string implementation for pkgAcquire::Item::Mode
In /experimental this is resolved by deprecating Mode and moving to a new std::string, but that breaks ABI of course, so that was out of question. We can't change to a malloc/free style c-string either as Mode is public and hence a library user could be setting this as well. std::string implementors actually helped us out here with copy-on-write which means that while the variable "obviously" runs out of scope here, in reality you get the correct result as the string we work with here comes from the configuration in which it is still valid. Such a dependency on magic is bad of course, but its still interesting that only python3 seems to have an issue with it… With some silly explicit if-else assigning we can sidestep this issue while retaining the same output for 99.99% of all users (= noone actually configures additional compression algorithms which are also provided by repositories…), but even for these 0.01% its just a small change in the display as Mode can not be used for anything else. Example: apt/aptitude uses it in its 'update' implementations in the one-line progress at the bottom for specific items. Closes: 781858
-rw-r--r--apt-pkg/acquire-item.cc14
1 files changed, 12 insertions, 2 deletions
diff --git a/apt-pkg/acquire-item.cc b/apt-pkg/acquire-item.cc
index 253cbdaf7..0bcafdc5c 100644
--- a/apt-pkg/acquire-item.cc
+++ b/apt-pkg/acquire-item.cc
@@ -1194,8 +1194,18 @@ void pkgAcqIndex::Done(string Message,unsigned long long Size,string Hash,
Desc.URI = decompProg + ":" + FileName;
QueueURI(Desc);
- // FIXME: this points to a c++ string that goes out of scope
- Mode = decompProg.c_str();
+ if (decompProg == "copy")
+ Mode = "copy";
+ else if (decompProg == "xz")
+ Mode = "xz";
+ else if (decompProg == "lzma")
+ Mode = "lzma";
+ else if (decompProg == "bzip2")
+ Mode = "bzip2";
+ else if (decompProg == "gzip")
+ Mode = "gzip";
+ else
+ Mode = "decomp";
}
/*}}}*/
// AcqIndexTrans::pkgAcqIndexTrans - Constructor /*{{{*/