summaryrefslogtreecommitdiff
path: root/apt-pkg/deb
diff options
context:
space:
mode:
authorMichael Vogt <mvo@debian.org>2010-07-30 12:45:00 +0200
committerMichael Vogt <mvo@debian.org>2010-07-30 12:45:00 +0200
commitb5cabd30cc1be1c6c1ca675ceb359bab577c1905 (patch)
tree2872bb0149a8123c9abb0c80462f9bb151d11d91 /apt-pkg/deb
parent3000cb123abe00418ccc2e388b6f93b76fe5514d (diff)
parente3326595301fc7bd1ee025a9dbb09ca51a08f5fa (diff)
* merge of the debian-expermental-ma branch
* debian/control: - add dependency on zlib-dev for libapt-pkg-dev * apt-pkg/cacheset.cc: - [ABI BREAK] add an ErrorType option to CacheSetHelper * cmdline/apt-cache.cc: - use Notice instead of Error in the CacheSetHelper messages for compat reasons. Otherwise tools like sbuild blow up - return success in show if a virtual package was given * debian/control: - remove libcurl3-gnutls-dev alternative as the package is gone - increase needed version of libcurl4-gnutls-dev to >= 7.19.0 as we use CURLOPT_{ISSUERCERT,CRLFILE} (Closes: #589642) * apt-pkg/deb/dpkgpm.cc: - Write architecture information to history file. - Add to history whether a change was automatic or not. * apt-pkg/contrib/fileutl.cc: - Add FileFd::OpenDescriptor() (needed for python-apt's #383617). * cmdline/apt-get.cc: - Support large filesystems by using statvfs64() instead of statvfs() and statfs64() instead of statfs() (Closes: #590513). * apt-pkg/cdrom.cc: - Use link() instead of rename() for creating the CD database backup; otherwise there would be a short time without any database. * apt-pkg/depcache.cc: - handle "circular" conflicts for "all" packages correctly * cmdline/apt-cache.cc: - be able to omit dependency types in (r)depends (Closes: #319006) - show in (r)depends the canidate per default instead of newest - share the (r)depends code instead of codecopy * apt-pkg/cacheset.cc: - move them back to the library as they look stable now - add a 'newest' pseudo target release as in pkg/newest * apt-pkg/pkgcache.cc: - prefer non-virtual packages in FindPreferredPkg (Closes: #590041) * test/integration/*: - add with bug#590041 testcase a small test "framework" * apt-pkg/orderlist.cc: - try to install another or-group member in DepRemove before breaking the or group (Closes: #590438) - configure also the replacement before remove by adding Immediate flag * apt-pkg/contrib/error.{cc,h} - docstring cleanup - add inline DumpError() to avoid subtle API break * apt-pkg/contrib/error.{cc,h}: - remove constness of va_list parameter to fix build on amd64 and co Thanks Eric Valette! (Closes: #588610) * apt-pkg/deb/debmetaindex.cc: - do not query each architecture for flat file archives - fix typo preventing display of architecture in Info() * methods/bzip2.cc: - add a copycat of the old gzip.cc as we need it for bzip2 and lzma * debian/rules: - Make DEB_BUILD_OPTIONS=noopt actually work by passing the right CXXFLAGS. * apt-pkg/contrib/fileutl.{h,cc}: - Add support for reading of gzipped files with the new "ReadOnlyGzip" OpenMode. (Closes: #188407) - Link against zlib (in apt-pkg/makefile) and add zlib build dependency. - [ABI BREAK] This adds a new private member to FileFd, but its initialization is in the public header file. * configure.in: - Check for zlib library and headers. * apt-pkg/acquire-item.cc, apt-pkg/deb/debindexfile.cc, apt-pkg/deb/debrecords.cc, apt-pkg/deb/debsrcrecords.h, cmdline/apt-cache.cc: - Open Packages, Sources, and Translations indexes in "ReadOnlyGzip" mode. * apt-pkg/deb/debindexfile.cc: - If we do not find uncompressed package/source/translation indexes, look for gzip compressed ones. * apt-pkg/acquire-item.cc: - If the Acquire::GzipIndexes option is true and we download a gzipped index file, keep it as it is (and rename to .gz) instead of uncompressing it. * doc/apt.conf.5.xml: - Document the new Acquire::GzipIndexes option. * doc/po/apt-doc.pot, doc/po/de.po: - German translation of new Acquire::GzipIndexes option. * Add test/test-indexes.sh: - Test behaviour of index retrieval and usage, in particular with uncompressed and gzip compressed indexes. * methods/gzip.cc: With FileFd now being able to read gzipped files, there is no need for the gzip method any more to spawn an external gzip process. Rewrite it to use FileFd directly, which makes the code a lot simpler, and also using less memory and overhead. * doc/apt.conf.5.xml: - add and document APT::Cache-{Start,Grow,Limit} options for mmap control * apt-pkg/contrib/fileutl.cc: - do not fail von double close() * cmdline/cacheset.cc: - doesn't include it in the library for now as it is too volatile - get the candidate either from an already built depcache or use the policy which is a bit faster than depcache generation - get packages by task^ with FromTask() - only print errors if all tries to get a package by string failed - factor out code to get a single package FromName() - check in Grouped* first without modifier interpretation * cmdline/apt-get.cc: - use the cachsets in the install commands - make the specify order of packages irrelevant (Closes: #196021) * apt-pkg/orderlist.cc: - untouched packages are never missing * apt-pkg/packagemanager.cc: - packages that are not touched doesn't need to be unpacked * debian/control: - remove intltool's dependency as it is an ubuntu artefact * apt-pkg/depcache.cc: - SetCandidateVer for all pseudo packages - SetReInstall for the "all" package of a pseudo package - use the new MatchAgainstConfig for the DefaultRootSetFunc - always mark the all package if a pseudo package is marked for install * apt-pkg/contrib/error.{cc,h}: - complete rewrite but use the same API - add NOTICE and DEBUG as new types of a message - add a simple stack handling to be able to delay error handling * apt-pkg/aptconfiguration.cc: - show a deprecation notice for APT::Acquire::Translation * apt-pkg/contrib/configuration.{cc,h}: - add a wrapper to match strings against configurable regex patterns * apt-pkg/contrib/fileutl.cc: - show notice about ignored file instead of being always silent - add a Dir::Ignore-Files-Silently list option to control the notice * apt-pkg/policy.h: - add another round of const& madness as the previous round accidentally NOT overrides the virtual GetCandidateVer() method (Closes: #587725) * apt-pkg/pkgcachegen.{cc,h}: - make the used MMap moveable (and therefore dynamic resizeable) by applying (some) mad pointer magic (Closes: #195018) * apt-pkg/deb/dpkgpm.cc: - make the apt/term.log output unbuffered (thanks to Matt Zimmerman) * methods/ftp.h: - Handle different logins on the same server (Closes: #586904). * apt-pkg/deb/deblistparser.cc: - Handle architecture wildcards (Closes: #547724). * apt-pkg/versionmatch.cc: - Support matching pins by regular expressions or glob() like patterns, regular expressions have to be put between to slashes; for example, /.*/. * apt-pkg/contrib/fileutl.cc: - Make FileFd replace files atomically in WriteTemp mode (for cache, etc). * debian/control: - Set Standards-Version to 3.9.0 * apt-pkg/cachefile.h: - make pkgPolicy public again, libapt-pkg-perl (and probably others) get unhappy without that * merge the remaining Ubuntu change: - on gpg verification failure warn and restore the last known good state - on failure display the IP of the server (useful for servers that use round robin DNS) - support Original-Maintainer in RewritePackageOrder - enable cdrom autodetection via libudev by default - show message about Vcs in use when apt-get source is run for packages maintained in a Vcs - better support transitional packages with mark auto-installed. when the transitional package is in "oldlibs" the new package is not marked auto installed (same is true for section metapackages) - provide new "deb mirror://archive.foo/mirrors.list sid main" method expects a list of mirrors (generated on the server e.g. via geoip) and will use that, including cycle on failure - write apport crash file on package failure (disabled by default on debian until apport is available) - support mirror failure reporting (disabled by default on debian) * apt-pkg/deb/dpkgpm.cc: - write Disappeared also to the history.log - forward manual-installed bit on package disappearance * apt-pkg/deb/debsystem.cc: - add better config item for extended_states file * apt-pkg/pkgcache.h: - switch {,Install-}Size to unsigned long long * apt-pkg/depcache.cc: - do the autoremove mark process also for required packages to handle these illegally depending on lower priority packages (Closes: #583517) - try harder to find the other pseudo versions for autoremove multiarch - correct "Dangerous iterator usage" pointed out by cppcheck - deal with long long, not with int to remove 2GB Limit (LP: #250909) - deprecate AddSize with Multiplier as it is unused and switch to boolean instead to handle the sizes more gracefully. - switch i{Download,Usr}Size from double to (un)signed long long * apt-pkg/aptconfiguration.cc: - remove duplicate architectures in getArchitectures() * apt-pkg/indexrecords.{cc,h}: - backport forgotten Valid-Until patch from the obsolete experimental branch to prevent replay attacks better, thanks to Thomas Viehmann for the initial patch! (Closes: #499897) - add a constant Exists check for MetaKeys * apt-pkg/acquire-item.cc: - do not try PDiff if it is not listed in the Meta file - sent Last-Modified header also for Translation files * apt-pkg/cacheiterator.h: - let pkgCache::Iterator inherent std::iterator * ftparchive/writer.h: - add a virtual destructor to FTWScanner class (for cppcheck) * apt-pkg/cacheset.{cc,h}: - add simple wrapper around std::set for cache structures - move regex magic from apt-get to new FromRegEx method - move cmdline parsing from apt-cache to new FromCommandLine method - support special release-modifier 'installed' and 'candidate' * apt-pkg/contrib/cmdline.cc: - fix segfault in SaveInConfig caused by writing over char[] sizes * apt-pkg/pkgcache.cc: - get the best matching arch package from a group with FindPreferredPkg * cmdline/apt-cache.cc: - make the search multiarch compatible by using GrpIterator instead - use pkgCacheFile and the new CacheSets all over the place - add --target-release option (Closes: #115520) - accept pkg/release and pkg=version in show and co. (Closes: #236270) - accept package versions in the unmet command * cmdline/apt-get.cc: - use unsigned long long instead of double to store values it gets * apt-pkg/cachefile.{cc,h}: - split Open() into submethods to be able to build only parts - make the OpProgress optional in the Cache buildprocess - store also the SourceList we use internally for export * doc/apt.conf.5.xml: - document the new Valid-Until related options * apt-pkg/contrib/strutl.cc: - split StrToTime() into HTTP1.1 and FTP date parser methods and use strptime() instead of some self-made scanf mangling - use the portable timegm shown in his manpage instead of a strange looking code copycat from wget * ftparchive/writer.cc: - add ValidTime option to generate a Valid-Until header in Release file * apt-pkg/policy.cc: - get the candidate right for a not-installed pseudo package if his non-pseudo friend is installed * apt-pkg/indexcopy.cc: - move the gpg codecopy to a new method and use it also in methods/gpgv.cc * cmdline/apt-get.cc: - rerun dpkg-source in source if --fix-broken is given (Closes: #576752) - don't suggest held packages as they are installed (Closes: #578135) - handle multiple --{tar,diff,dsc}-only options correctly - show at the end of the install process a list of disappeared packages * cmdline/apt-cache.cc: - use GroupCount for package names in stats and add a package struct line * methods/rred.cc: - use the patchfile modification time instead of the one from the "old" file - thanks to Philipp Weis for noticing! (Closes: #571541) * debian/rules: - remove targets referring to CVS or arch as they are useless - use $(CURDIR) instead of $(pwd) - use dpkg-buildflags if available for CXXFLAGS * README.arch: - remove the file completely as it has no use nowadays * apt-pkg/depcache.cc: - be doublesure that the killer query is empty before starting reinstall * methods/gpgv.cc: - remove the keyrings count limit by using vector magic * contrib/mmap.cc: - clarify "MMap reached size limit" error message, thanks Ivan Masár! * doc/apt.ent - add entities for the current oldstable/stable/testing codenames * doc/sources.list.5.xml: - use stable-codename instead of stable in the examples (Closes: #531492) * doc/apt_preferences.5.xml: - adapt some examples here to use current codenames as well - add "NotAutomatic: yes" handling, thanks Osamu Aoki (Closes: #490347) * debian/libapt-pkg-doc.doc-base.cache: - remove yet another reference to the removed cache.sgml * doc/apt-get.8.xml: - do not say explicit target_release_{name,version,codename}, it should be clear by itself and 'man' can break lines again (Closes: #566166) - remove the gnome-apt reference as it is removed from unstable * apt-pkg/deb/dpkgpm.cc: - add 'disappear' to the known processing states, thanks Jonathan Nieder * apt-pkg/packagemanager.h: - export info about disappeared packages with GetDisappearedPackages() * methods/http.{cc,h}: - code cleanup, use enums instead of magic ints * debian/rules: - spell out some less known options to reduce manpage consultation-rate - Use POSIX command substitution: $(<command sequence>) - Remove EOL whitespace (Closes: #577804) * apt-pkg/acquire-item.cc: - Fix pkgAcqFile::Custom600Headers() to always return something. * apt-pkg/depcache.cc: - rewrite the pseudo package reinstaller to be more intelligent in his package choices * apt-pkg/packagemanager.cc: - don't try to "unpack" pseudo packages twice * apt-pkg/contrib/fileutl.cc: - add a parent-guarded "mkdir -p" as CreateDirectory() * apt-pkg/acquire.{cc,h}: - add a delayed constructor with Setup() for success reporting - check for and create directories in Setup if needed instead of error out unfriendly in the Constructor (Closes: #523920, #525783) - optional handle a lock file in Setup() * apt-pkg/acquire-item.cc: - Acquire::ForceHash to force method for expected hash * cmdline/apt-get.cc: - remove the lock file handling and let Acquire take care of it instead - display MD5Sum in --print-uris if not forced to use another method instead of displaying the strongest available (Closes: #576420) - regex for package names executed on Grp- not PkgIterator - show non-candidates as fallback for virtual packages (Closes: #578385) - set also "all" to this version for pseudo packages in TryToChangeVer * apt-pkg/deb/dpkgpm.cc: - remove Chroot-Directory from files passed to install commands. Thanks to Kel Modderman for report & patch! (Closes: #577226) * ftparchive/writer.cc: - remove 999 chars Files and Checksums rewrite limit (Closes: #577759) * cmdline/apt-cache.cc: - align Installed and Candidate Version in policy so they can be compared easier, thanks Ralf Gesellensetter for the pointer! (Closes: #578657) * doc/apt.ent: - Add a note about APT_CONFIG in the -c description (Closes: #578267) * doc/po/de.po: - correct typos in german apt_preferences manpage, thanks Chris Leick! * apt-pkg/sourcelist.cc: - be less strict and accept [option=value] as well * apt-pkg/contrib/configuration.cc: - error out if #clear directive has no argument * doc/files.sgml: - sync documentation with status quo, regarding files/directories in use, extended_states and uri schemes. * doc/cache.sgml: - drop the file in favor of inplace documentation with doxygen * apt-pkg/pkgcache.h: - enhance the Groups ABI by providing a ID as the other structs does - check also the size of the Group struct then checking for the others * cmdline/apt-get.cc: - replace backticks with single quotes around fix-broken command in the broken packages message. (Closes: #577168) * dselect/install: - modernize if-statements not to use 'x' (Closes: #577117) - replace backticks with POSIX $() (Closes: #577116) * cmdline/apt-get.cc: - fix crash when pkg.VersionList() is empty - install html doxygen in libapt-pkg-doc * debian/control: - build-depend on doxygen * apt-pkg/contrib/weakptr.h: - add a class WeakPointable which allows one to register weak pointers to an object which will be set to NULL when the object is deallocated. * [ABI break] apt-pkg/acquire{-worker,-item,}.h: - subclass pkgAcquire::{Worker,Item,ItemDesc} from WeakPointable. * apt-pkg/pkgcache.cc: - Merge fix from David to correct handling in single-arch environments. * cmdline/apt-cache.cc: - Add a showauto command to apt-cache. * cmdline/apt-get.cc: - Add apt-get markauto and unmarkauto commands. * [BREAK] merge MultiArch-ABI. We don't support MultiArch, but we support the usage of the new ABI so libapt users can start to prepare for MultiArch (Closes: #536029) * Ignore :qualifiers after package name in build dependencies in the library by default, but try to honour them in apt-get as we have some sort of MultiArch support ready (Closes: #558103) * add translation of the manpages to PT (portuguese) Thanks to Américo Monteiro! * Switch to dpkg-source 3.0 (native) format * apt-pkg/depcache.cc: - remove Auto-Installed information from extended_states together with the package itself (Closes: #572364) * cmdline/apt-mark: - don't crash if no arguments are given (Closes: #570962) * debian/control: - remove some years old and obsolete Replaces - add automake/conf build-depends/conflicts as recommend by the autotools-dev README (Closes: #572615) * apt-pkg/contrib/mmap.{h,cc}: - add char[] fallback for filesystems without shared writable mmap() like JFFS2. Thanks to Marius Vollmer for writing and to Loïc Minier for pointing to the patch! (Closes: #314334) * doc/apt_preferences.5.xml: - fix two typos and be more verbose in the novice warning. Thanks to Osamu Aoki for pointing it out! (Closes: #567669) - fix a=sid vs. n=sid typo, thanks Ansgar Burchardt! - origin can be used to match a hostname (Closes: #352667) - remove wrong pin-priority is optional remark (Closes: #574944) * apt-pkg/deb/dpkgpm.cc: - fix error message construction in OpenLog() - if available store the Commandline in the history * cmdline/apt-get.cc: - add a --only-upgrade flag to install command (Closes: #572259) - fix memory leaks in error conditions in DoSource() - try version match in FindSrc first exact than fuzzy (LP: #551178) * apt-pkg/contrib/cmndline.cc: - save Commandline in Commandline::AsString for logging * apt-pkg/deb/debversion.cc: - consider absent of debian revision equivalent to 0 (Closes: #573592) * doc/makefile, doc/*: - generate subdirectories for building the manpages in on the fly depending on the po files we have. * apt-pkg/pkgcachegen.cc: - merge versions correctly even if multiple different versions with the same version number are available. Thanks to Magnus Holmgren for the patch! (Closes: #351056) * ftparchive/writer.cc: - write LongDescriptions if they shouldn't be included in Packages file into i18n/Translation-en by default. * doc/po/de.po: - correct a few typos in the german manpage translation. Thanks to Chris Leick and Georg Koppen! (Closes: #574962) * apt-pkg/contrib/strutl.cc: - convert all toupper calls to tolower_ascii for a little speedup * apt-pkg/contrib/strutl.cc: - always escape '%' (LP: #130289) (Closes: #500560) - unescape '%' sequence only if followed by 2 hex digit - username/password are urlencoded in proxy string (RFC 3986)
Diffstat (limited to 'apt-pkg/deb')
-rw-r--r--apt-pkg/deb/debindexfile.cc73
-rw-r--r--apt-pkg/deb/debindexfile.h10
-rw-r--r--apt-pkg/deb/deblistparser.cc260
-rw-r--r--apt-pkg/deb/deblistparser.h22
-rw-r--r--apt-pkg/deb/debmetaindex.cc304
-rw-r--r--apt-pkg/deb/debmetaindex.h28
-rw-r--r--apt-pkg/deb/debrecords.cc2
-rw-r--r--apt-pkg/deb/debsrcrecords.h2
-rw-r--r--apt-pkg/deb/debsystem.cc12
-rw-r--r--apt-pkg/deb/debversion.cc18
-rw-r--r--apt-pkg/deb/dpkgpm.cc338
-rw-r--r--apt-pkg/deb/dpkgpm.h22
12 files changed, 844 insertions, 247 deletions
diff --git a/apt-pkg/deb/debindexfile.cc b/apt-pkg/deb/debindexfile.cc
index 7379ca997..ba5b3f266 100644
--- a/apt-pkg/deb/debindexfile.cc
+++ b/apt-pkg/deb/debindexfile.cc
@@ -63,9 +63,13 @@ string debSourcesIndex::SourceInfo(pkgSrcRecords::Parser const &Record,
/* */
pkgSrcRecords::Parser *debSourcesIndex::CreateSrcParser() const
{
- string SourcesURI = URItoFileName(IndexURI("Sources"));
- return new debSrcRecordParser(_config->FindDir("Dir::State::lists") +
- SourcesURI,this);
+ string SourcesURI = _config->FindDir("Dir::State::lists") +
+ URItoFileName(IndexURI("Sources"));
+ string SourcesURIgzip = SourcesURI + ".gz";
+ if (!FileExists(SourcesURI) && FileExists(SourcesURIgzip))
+ SourcesURI = SourcesURIgzip;
+
+ return new debSrcRecordParser(SourcesURI,this);
}
/*}}}*/
// SourcesIndex::Describe - Give a descriptive path to the index /*{{{*/
@@ -106,8 +110,14 @@ string debSourcesIndex::Info(const char *Type) const
/* */
inline string debSourcesIndex::IndexFile(const char *Type) const
{
- return URItoFileName(IndexURI(Type));
+ string s = URItoFileName(IndexURI(Type));
+ string sgzip = s + ".gz";
+ if (!FileExists(s) && FileExists(sgzip))
+ return sgzip;
+ else
+ return s;
}
+
string debSourcesIndex::IndexURI(const char *Type) const
{
string Res;
@@ -149,9 +159,12 @@ unsigned long debSourcesIndex::Size() const
// PackagesIndex::debPackagesIndex - Contructor /*{{{*/
// ---------------------------------------------------------------------
/* */
-debPackagesIndex::debPackagesIndex(string URI,string Dist,string Section,bool Trusted) :
- pkgIndexFile(Trusted), URI(URI), Dist(Dist), Section(Section)
+debPackagesIndex::debPackagesIndex(string const &URI, string const &Dist, string const &Section,
+ bool const &Trusted, string const &Arch) :
+ pkgIndexFile(Trusted), URI(URI), Dist(Dist), Section(Section), Architecture(Arch)
{
+ if (Architecture == "native")
+ Architecture = _config->Find("APT::Architecture");
}
/*}}}*/
// PackagesIndex::ArchiveInfo - Short version of the archive url /*{{{*/
@@ -171,6 +184,8 @@ string debPackagesIndex::ArchiveInfo(pkgCache::VerIterator Ver) const
Res += " ";
Res += Ver.ParentPkg().Name();
Res += " ";
+ if (Dist[Dist.size() - 1] != '/')
+ Res.append(Ver.Arch()).append(" ");
Res += Ver.VerStr();
return Res;
}
@@ -204,6 +219,8 @@ string debPackagesIndex::Info(const char *Type) const
else
Info += Dist + '/' + Section;
Info += " ";
+ if (Dist[Dist.size() - 1] != '/')
+ Info += Architecture + " ";
Info += Type;
return Info;
}
@@ -213,7 +230,12 @@ string debPackagesIndex::Info(const char *Type) const
/* */
inline string debPackagesIndex::IndexFile(const char *Type) const
{
- return _config->FindDir("Dir::State::lists") + URItoFileName(IndexURI(Type));
+ string s =_config->FindDir("Dir::State::lists") + URItoFileName(IndexURI(Type));
+ string sgzip = s + ".gz";
+ if (!FileExists(s) && FileExists(sgzip))
+ return sgzip;
+ else
+ return s;
}
string debPackagesIndex::IndexURI(const char *Type) const
{
@@ -227,7 +249,7 @@ string debPackagesIndex::IndexURI(const char *Type) const
}
else
Res = URI + "dists/" + Dist + '/' + Section +
- "/binary-" + _config->Find("APT::Architecture") + '/';
+ "/binary-" + Architecture + '/';
Res += Type;
return Res;
@@ -255,21 +277,23 @@ unsigned long debPackagesIndex::Size() const
// PackagesIndex::Merge - Load the index file into a cache /*{{{*/
// ---------------------------------------------------------------------
/* */
-bool debPackagesIndex::Merge(pkgCacheGenerator &Gen,OpProgress &Prog) const
+bool debPackagesIndex::Merge(pkgCacheGenerator &Gen,OpProgress *Prog) const
{
string PackageFile = IndexFile("Packages");
- FileFd Pkg(PackageFile,FileFd::ReadOnly);
- debListParser Parser(&Pkg);
+ FileFd Pkg(PackageFile,FileFd::ReadOnlyGzip);
+ debListParser Parser(&Pkg, Architecture);
+
if (_error->PendingError() == true)
return _error->Error("Problem opening %s",PackageFile.c_str());
-
- Prog.SubProgress(0,Info("Packages"));
+ if (Prog != NULL)
+ Prog->SubProgress(0,Info("Packages"));
::URI Tmp(URI);
if (Gen.SelectFile(PackageFile,Tmp.Host,*this) == false)
return _error->Error("Problem with SelectFile %s",PackageFile.c_str());
// Store the IMS information
pkgCache::PkgFileIterator File = Gen.GetCurFile();
+ pkgCacheGenerator::Dynamic<pkgCache::PkgFileIterator> DynFile(File);
struct stat St;
if (fstat(Pkg.Fd(),&St) != 0)
return _error->Errno("fstat","Failed to stat");
@@ -340,7 +364,12 @@ debTranslationsIndex::debTranslationsIndex(string URI,string Dist,string Section
/* */
inline string debTranslationsIndex::IndexFile(const char *Type) const
{
- return _config->FindDir("Dir::State::lists") + URItoFileName(IndexURI(Type));
+ string s =_config->FindDir("Dir::State::lists") + URItoFileName(IndexURI(Type));
+ string sgzip = s + ".gz";
+ if (!FileExists(s) && FileExists(sgzip))
+ return sgzip;
+ else
+ return s;
}
string debTranslationsIndex::IndexURI(const char *Type) const
{
@@ -438,18 +467,19 @@ unsigned long debTranslationsIndex::Size() const
// TranslationsIndex::Merge - Load the index file into a cache /*{{{*/
// ---------------------------------------------------------------------
/* */
-bool debTranslationsIndex::Merge(pkgCacheGenerator &Gen,OpProgress &Prog) const
+bool debTranslationsIndex::Merge(pkgCacheGenerator &Gen,OpProgress *Prog) const
{
// Check the translation file, if in use
string TranslationFile = IndexFile(Language);
if (TranslationsAvailable() && FileExists(TranslationFile))
{
- FileFd Trans(TranslationFile,FileFd::ReadOnly);
+ FileFd Trans(TranslationFile,FileFd::ReadOnlyGzip);
debListParser TransParser(&Trans);
if (_error->PendingError() == true)
return false;
- Prog.SubProgress(0, Info(TranslationFile.c_str()));
+ if (Prog != NULL)
+ Prog->SubProgress(0, Info(TranslationFile.c_str()));
if (Gen.SelectFile(TranslationFile,string(),*this) == false)
return _error->Error("Problem with SelectFile %s",TranslationFile.c_str());
@@ -522,16 +552,17 @@ unsigned long debStatusIndex::Size() const
// StatusIndex::Merge - Load the index file into a cache /*{{{*/
// ---------------------------------------------------------------------
/* */
-bool debStatusIndex::Merge(pkgCacheGenerator &Gen,OpProgress &Prog) const
+bool debStatusIndex::Merge(pkgCacheGenerator &Gen,OpProgress *Prog) const
{
- FileFd Pkg(File,FileFd::ReadOnly);
+ FileFd Pkg(File,FileFd::ReadOnlyGzip);
if (_error->PendingError() == true)
return false;
debListParser Parser(&Pkg);
if (_error->PendingError() == true)
return false;
-
- Prog.SubProgress(0,File);
+
+ if (Prog != NULL)
+ Prog->SubProgress(0,File);
if (Gen.SelectFile(File,string(),*this,pkgCache::Flag::NotSource) == false)
return _error->Error("Problem with SelectFile %s",File.c_str());
diff --git a/apt-pkg/deb/debindexfile.h b/apt-pkg/deb/debindexfile.h
index c0e8d7d8e..b5085992d 100644
--- a/apt-pkg/deb/debindexfile.h
+++ b/apt-pkg/deb/debindexfile.h
@@ -35,7 +35,7 @@ class debStatusIndex : public pkgIndexFile
virtual bool Exists() const;
virtual bool HasPackages() const {return true;};
virtual unsigned long Size() const;
- virtual bool Merge(pkgCacheGenerator &Gen,OpProgress &Prog) const;
+ virtual bool Merge(pkgCacheGenerator &Gen,OpProgress *Prog) const;
virtual pkgCache::PkgFileIterator FindInCache(pkgCache &Cache) const;
debStatusIndex(string File);
@@ -46,6 +46,7 @@ class debPackagesIndex : public pkgIndexFile
string URI;
string Dist;
string Section;
+ string Architecture;
string Info(const char *Type) const;
string IndexFile(const char *Type) const;
@@ -66,10 +67,11 @@ class debPackagesIndex : public pkgIndexFile
virtual bool Exists() const;
virtual bool HasPackages() const {return true;};
virtual unsigned long Size() const;
- virtual bool Merge(pkgCacheGenerator &Gen,OpProgress &Prog) const;
+ virtual bool Merge(pkgCacheGenerator &Gen,OpProgress *Prog) const;
virtual pkgCache::PkgFileIterator FindInCache(pkgCache &Cache) const;
- debPackagesIndex(string URI,string Dist,string Section,bool Trusted);
+ debPackagesIndex(string const &URI, string const &Dist, string const &Section,
+ bool const &Trusted, string const &Arch = "native");
};
class debTranslationsIndex : public pkgIndexFile
@@ -97,7 +99,7 @@ class debTranslationsIndex : public pkgIndexFile
virtual bool Exists() const;
virtual bool HasPackages() const;
virtual unsigned long Size() const;
- virtual bool Merge(pkgCacheGenerator &Gen,OpProgress &Prog) const;
+ virtual bool Merge(pkgCacheGenerator &Gen,OpProgress *Prog) const;
virtual pkgCache::PkgFileIterator FindInCache(pkgCache &Cache) const;
debTranslationsIndex(string URI,string Dist,string Section, char const * const Language);
diff --git a/apt-pkg/deb/deblistparser.cc b/apt-pkg/deb/deblistparser.cc
index 66108d822..5fb737970 100644
--- a/apt-pkg/deb/deblistparser.cc
+++ b/apt-pkg/deb/deblistparser.cc
@@ -19,6 +19,7 @@
#include <apt-pkg/md5.h>
#include <apt-pkg/macros.h>
+#include <fnmatch.h>
#include <ctype.h>
/*}}}*/
@@ -31,10 +32,15 @@ static debListParser::WordList PrioList[] = {{"important",pkgCache::State::Impor
// ListParser::debListParser - Constructor /*{{{*/
// ---------------------------------------------------------------------
-/* */
-debListParser::debListParser(FileFd *File) : Tags(File)
-{
- Arch = _config->Find("APT::architecture");
+/* Provide an architecture and only this one and "all" will be accepted
+ in Step(), if no Architecture is given we will accept every arch
+ we would accept in general with checkArchitecture() */
+debListParser::debListParser(FileFd *File, string const &Arch) : Tags(File),
+ Arch(Arch) {
+ if (Arch == "native")
+ this->Arch = _config->Find("APT::Architecture");
+ Architectures = APT::Configuration::getArchitectures();
+ MultiArchEnabled = Architectures.size() > 1;
}
/*}}}*/
// ListParser::UniqFindTagWrite - Find the tag and write a unq string /*{{{*/
@@ -52,14 +58,41 @@ unsigned long debListParser::UniqFindTagWrite(const char *Tag)
// ListParser::Package - Return the package name /*{{{*/
// ---------------------------------------------------------------------
/* This is to return the name of the package this section describes */
-string debListParser::Package()
-{
- string Result = Section.FindS("Package");
- if (Result.empty() == true)
+string debListParser::Package() {
+ string const Result = Section.FindS("Package");
+ if(unlikely(Result.empty() == true))
_error->Error("Encountered a section with no Package: header");
return Result;
}
/*}}}*/
+// ListParser::Architecture - Return the package arch /*{{{*/
+// ---------------------------------------------------------------------
+/* This will return the Architecture of the package this section describes
+ Note that architecture "all" packages will get the architecture of the
+ Packages file parsed here. */
+string debListParser::Architecture() {
+ string const Result = Section.FindS("Architecture");
+ if (Result.empty() == true || Result == "all")
+ {
+ if (Arch.empty() == true)
+ /* FIXME: this is a problem for installed arch all
+ packages as we don't know from which arch this
+ package was installed - and therefore which
+ dependency this package resolves. */
+ return _config->Find("APT::Architecture");
+ else
+ return Arch;
+ }
+ return Result;
+}
+ /*}}}*/
+// ListParser::ArchitectureAll /*{{{*/
+// ---------------------------------------------------------------------
+/* */
+bool debListParser::ArchitectureAll() {
+ return Section.FindS("Architecture") == "all";
+}
+ /*}}}*/
// ListParser::Version - Return the version string /*{{{*/
// ---------------------------------------------------------------------
/* This is to return the string describing the version in debian form,
@@ -73,17 +106,39 @@ string debListParser::Version()
// ListParser::NewVersion - Fill in the version structure /*{{{*/
// ---------------------------------------------------------------------
/* */
-bool debListParser::NewVersion(pkgCache::VerIterator Ver)
+bool debListParser::NewVersion(pkgCache::VerIterator &Ver)
{
// Parse the section
Ver->Section = UniqFindTagWrite("Section");
- Ver->Arch = UniqFindTagWrite("Architecture");
-
+
+ // Parse multi-arch
+ if (Section.FindS("Architecture") == "all")
+ /* Arch all packages can't have a Multi-Arch field,
+ but we need a special treatment for them nonetheless */
+ Ver->MultiArch = pkgCache::Version::All;
+ else
+ {
+ string const MultiArch = Section.FindS("Multi-Arch");
+ if (MultiArch.empty() == true)
+ Ver->MultiArch = pkgCache::Version::None;
+ else if (MultiArch == "same")
+ Ver->MultiArch = pkgCache::Version::Same;
+ else if (MultiArch == "foreign")
+ Ver->MultiArch = pkgCache::Version::Foreign;
+ else if (MultiArch == "allowed")
+ Ver->MultiArch = pkgCache::Version::Allowed;
+ else
+ {
+ _error->Warning("Unknown Multi-Arch type »%s« for package »%s«",
+ MultiArch.c_str(), Section.FindS("Package").c_str());
+ Ver->MultiArch = pkgCache::Version::None;
+ }
+ }
+
// Archive Size
- Ver->Size = (unsigned)Section.FindI("Size");
-
+ Ver->Size = Section.FindULL("Size");
// Unpacked Size (in K)
- Ver->InstalledSize = (unsigned)Section.FindI("Installed-Size");
+ Ver->InstalledSize = Section.FindULL("Installed-Size");
Ver->InstalledSize *= 1024;
// Priority
@@ -95,6 +150,24 @@ bool debListParser::NewVersion(pkgCache::VerIterator Ver)
Ver->Priority = pkgCache::State::Extra;
}
+ if (Ver->MultiArch == pkgCache::Version::All)
+ {
+ /* We maintain a "pseudo" arch=all package for architecture all versions
+ on which these versions can depend on. This pseudo package is many used
+ for downloading/installing: The other pseudo-packages will degenerate
+ to a NOP in the download/install step - this package will ensure that
+ it is downloaded only one time and installed only one time -- even if
+ the architecture bound versions coming in and out on regular basis. */
+ if (strcmp(Ver.Arch(true),"all") == 0)
+ return true;
+ else if (MultiArchEnabled == true)
+ {
+ // our pseudo packages have no size to not confuse the fetcher
+ Ver->Size = 0;
+ Ver->InstalledSize = 0;
+ }
+ }
+
if (ParseDepends(Ver,"Depends",pkgCache::Dep::Depends) == false)
return false;
if (ParseDepends(Ver,"Pre-Depends",pkgCache::Dep::PreDepends) == false)
@@ -178,13 +251,21 @@ MD5SumValue debListParser::Description_md5()
// ---------------------------------------------------------------------
/* This is called to update the package with any new information
that might be found in the section */
-bool debListParser::UsePackage(pkgCache::PkgIterator Pkg,
- pkgCache::VerIterator Ver)
+bool debListParser::UsePackage(pkgCache::PkgIterator &Pkg,
+ pkgCache::VerIterator &Ver)
{
if (Pkg->Section == 0)
Pkg->Section = UniqFindTagWrite("Section");
- if (Section.FindFlag("Essential",Pkg->Flags,pkgCache::Flag::Essential) == false)
- return false;
+
+ // Packages which are not from the "native" arch doesn't get the essential flag
+ // in the default "native" mode - it is also possible to mark "all" or "none".
+ // The "installed" mode is handled by ParseStatus(), See #544481 and friends.
+ string const static myArch = _config->Find("APT::Architecture");
+ string const static essential = _config->Find("pkgCacheGen::Essential", "native");
+ if ((essential == "native" && Pkg->Arch != 0 && myArch == Pkg.Arch()) ||
+ essential == "all")
+ if (Section.FindFlag("Essential",Pkg->Flags,pkgCache::Flag::Essential) == false)
+ return false;
if (Section.FindFlag("Important",Pkg->Flags,pkgCache::Flag::Important) == false)
return false;
@@ -251,14 +332,20 @@ unsigned short debListParser::VersionHash()
Some of the above are obsolete (I think?) flag = hold-* and
status = post-inst-failed, removal-failed at least.
*/
-bool debListParser::ParseStatus(pkgCache::PkgIterator Pkg,
- pkgCache::VerIterator Ver)
+bool debListParser::ParseStatus(pkgCache::PkgIterator &Pkg,
+ pkgCache::VerIterator &Ver)
{
const char *Start;
const char *Stop;
if (Section.Find("Status",Start,Stop) == false)
return true;
-
+
+ // UsePackage() is responsible for setting the flag in the default case
+ bool const static essential = _config->Find("pkgCacheGen::Essential", "") == "installed";
+ if (essential == true &&
+ Section.FindFlag("Essential",Pkg->Flags,pkgCache::Flag::Essential) == false)
+ return false;
+
// Isolate the first word
const char *I = Start;
for(; I < Stop && *I != ' '; I++);
@@ -387,6 +474,20 @@ const char *debListParser::ConvertRelation(const char *I,unsigned int &Op)
return I;
}
+/*
+ * CompleteArch:
+ *
+ * The complete architecture, consisting of <kernel>-<cpu>.
+ */
+static string CompleteArch(std::string& arch) {
+ if (arch == "armel") return "linux-arm";
+ if (arch == "lpia") return "linux-i386";
+ if (arch == "powerpcspe") return "linux-powerpc";
+ if (arch == "uclibc-linux-armel") return "linux-arm";
+ if (arch == "uclinux-armel") return "uclinux-arm";
+
+ return (arch.find("-") != string::npos) ? arch : "linux-" + arch;
+}
/*}}}*/
// ListParser::ParseDepends - Parse a dependency element /*{{{*/
// ---------------------------------------------------------------------
@@ -460,6 +561,7 @@ 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
if (I != Stop && *I == '[')
@@ -487,8 +589,13 @@ const char *debListParser::ParseDepends(const char *Start,const char *Stop,
I++;
}
- if (stringcmp(arch,I,End) == 0)
+ if (stringcmp(arch,I,End) == 0) {
Found = true;
+ } else {
+ std::string wildcard = SubstVar(string(I, End), "any", "*");
+ if (fnmatch(wildcard.c_str(), completeArch.c_str(), 0) == 0)
+ Found = true;
+ }
if (*End++ == ']') {
I = End;
@@ -527,15 +634,16 @@ const char *debListParser::ParseDepends(const char *Start,const char *Stop,
// ---------------------------------------------------------------------
/* This is the higher level depends parser. It takes a tag and generates
a complete depends tree for the given version. */
-bool debListParser::ParseDepends(pkgCache::VerIterator Ver,
+bool debListParser::ParseDepends(pkgCache::VerIterator &Ver,
const char *Tag,unsigned int Type)
{
const char *Start;
const char *Stop;
if (Section.Find(Tag,Start,Stop) == false)
return true;
-
+
string Package;
+ string const pkgArch = Ver.Arch(true);
string Version;
unsigned int Op;
@@ -544,8 +652,18 @@ bool debListParser::ParseDepends(pkgCache::VerIterator Ver,
Start = ParseDepends(Start,Stop,Package,Version,Op);
if (Start == 0)
return _error->Error("Problem parsing dependency %s",Tag);
-
- if (NewDepends(Ver,Package,Version,Op,Type) == false)
+
+ if (MultiArchEnabled == true &&
+ (Type == pkgCache::Dep::Conflicts ||
+ Type == pkgCache::Dep::DpkgBreaks ||
+ Type == pkgCache::Dep::Replaces))
+ {
+ for (std::vector<std::string>::const_iterator a = Architectures.begin();
+ a != Architectures.end(); ++a)
+ if (NewDepends(Ver,Package,*a,Version,Op,Type) == false)
+ return false;
+ }
+ else if (NewDepends(Ver,Package,pkgArch,Version,Op,Type) == false)
return false;
if (Start == Stop)
break;
@@ -556,33 +674,55 @@ bool debListParser::ParseDepends(pkgCache::VerIterator Ver,
// ListParser::ParseProvides - Parse the provides list /*{{{*/
// ---------------------------------------------------------------------
/* */
-bool debListParser::ParseProvides(pkgCache::VerIterator Ver)
+bool debListParser::ParseProvides(pkgCache::VerIterator &Ver)
{
const char *Start;
const char *Stop;
- if (Section.Find("Provides",Start,Stop) == false)
- return true;
-
- string Package;
- string Version;
- unsigned int Op;
-
- while (1)
+ if (Section.Find("Provides",Start,Stop) == true)
{
- Start = ParseDepends(Start,Stop,Package,Version,Op);
- if (Start == 0)
- return _error->Error("Problem parsing Provides line");
- if (Op != pkgCache::Dep::NoOp) {
- _error->Warning("Ignoring Provides line with DepCompareOp for package %s", Package.c_str());
- } else {
- if (NewProvides(Ver,Package,Version) == false)
- return false;
+ string Package;
+ string Version;
+ string const Arch = Ver.Arch(true);
+ unsigned int Op;
+
+ while (1)
+ {
+ Start = ParseDepends(Start,Stop,Package,Version,Op);
+ if (Start == 0)
+ return _error->Error("Problem parsing Provides line");
+ if (Op != pkgCache::Dep::NoOp) {
+ _error->Warning("Ignoring Provides line with DepCompareOp for package %s", Package.c_str());
+ } else {
+ if (NewProvides(Ver, Package, Arch, Version) == false)
+ return false;
+ }
+
+ if (Start == Stop)
+ break;
}
+ }
- if (Start == Stop)
- break;
+ if (Ver->MultiArch == pkgCache::Version::Allowed)
+ {
+ string const Package = string(Ver.ParentPkg().Name()).append(":").append("any");
+ NewProvides(Ver, Package, "any", Ver.VerStr());
}
-
+
+ if (Ver->MultiArch != pkgCache::Version::Foreign)
+ return true;
+
+ if (MultiArchEnabled == false)
+ return true;
+
+ string const Package = Ver.ParentPkg().Name();
+ string const Version = Ver.VerStr();
+ for (std::vector<string>::const_iterator a = Architectures.begin();
+ a != Architectures.end(); ++a)
+ {
+ if (NewProvides(Ver, Package, *a, Version) == false)
+ return false;
+ }
+
return true;
}
/*}}}*/
@@ -613,16 +753,23 @@ bool debListParser::Step()
/* See if this is the correct Architecture, if it isn't then we
drop the whole section. A missing arch tag only happens (in theory)
inside the Status file, so that is a positive return */
- const char *Start;
- const char *Stop;
- if (Section.Find("Architecture",Start,Stop) == false)
+ string const Architecture = Section.FindS("Architecture");
+ if (Architecture.empty() == true)
return true;
- if (stringcmp(Arch,Start,Stop) == 0)
- return true;
+ if (Arch.empty() == true || Arch == "any" || MultiArchEnabled == false)
+ {
+ if (APT::Configuration::checkArchitecture(Architecture) == true)
+ return true;
+ }
+ else
+ {
+ if (Architecture == Arch)
+ return true;
- if (stringcmp(Start,Stop,"all") == 0)
- return true;
+ if (Architecture == "all")
+ return true;
+ }
iOffset = Tags.Offset();
}
@@ -632,7 +779,7 @@ bool debListParser::Step()
// ListParser::LoadReleaseInfo - Load the release information /*{{{*/
// ---------------------------------------------------------------------
/* */
-bool debListParser::LoadReleaseInfo(pkgCache::PkgFileIterator FileI,
+bool debListParser::LoadReleaseInfo(pkgCache::PkgFileIterator &FileI,
FileFd &File, string component)
{
pkgTagFile Tags(&File, File.Size() + 256); // XXX
@@ -640,8 +787,9 @@ bool debListParser::LoadReleaseInfo(pkgCache::PkgFileIterator FileI,
if (Tags.Step(Section) == false)
return false;
- //mvo: I don't think we need to fill that in (it's unused since apt-0.6)
- //FileI->Architecture = WriteUniqString(Arch);
+ // FIXME: Do we need it now for multi-arch?
+ // mvo: I don't think we need to fill that in (it's unused since apt-0.6)
+// FileI->Architecture = WriteUniqString(Arch);
// apt-secure does no longer download individual (per-section) Release
// file. to provide Component pinning we use the section name now
diff --git a/apt-pkg/deb/deblistparser.h b/apt-pkg/deb/deblistparser.h
index 1c709229f..4bc1bd93c 100644
--- a/apt-pkg/deb/deblistparser.h
+++ b/apt-pkg/deb/deblistparser.h
@@ -32,12 +32,14 @@ class debListParser : public pkgCacheGenerator::ListParser
pkgTagSection Section;
unsigned long iOffset;
string Arch;
-
+ std::vector<std::string> Architectures;
+ bool MultiArchEnabled;
+
unsigned long UniqFindTagWrite(const char *Tag);
- bool ParseStatus(pkgCache::PkgIterator Pkg,pkgCache::VerIterator Ver);
- bool ParseDepends(pkgCache::VerIterator Ver,const char *Tag,
+ bool ParseStatus(pkgCache::PkgIterator &Pkg,pkgCache::VerIterator &Ver);
+ bool ParseDepends(pkgCache::VerIterator &Ver,const char *Tag,
unsigned int Type);
- bool ParseProvides(pkgCache::VerIterator Ver);
+ bool ParseProvides(pkgCache::VerIterator &Ver);
static bool GrabWord(string Word,WordList *List,unsigned char &Out);
public:
@@ -46,20 +48,22 @@ class debListParser : public pkgCacheGenerator::ListParser
// These all operate against the current section
virtual string Package();
+ virtual string Architecture();
+ virtual bool ArchitectureAll();
virtual string Version();
- virtual bool NewVersion(pkgCache::VerIterator Ver);
+ virtual bool NewVersion(pkgCache::VerIterator &Ver);
virtual string Description();
virtual string DescriptionLanguage();
virtual MD5SumValue Description_md5();
virtual unsigned short VersionHash();
- virtual bool UsePackage(pkgCache::PkgIterator Pkg,
- pkgCache::VerIterator Ver);
+ virtual bool UsePackage(pkgCache::PkgIterator &Pkg,
+ pkgCache::VerIterator &Ver);
virtual unsigned long Offset() {return iOffset;};
virtual unsigned long Size() {return Section.size();};
virtual bool Step();
- bool LoadReleaseInfo(pkgCache::PkgFileIterator FileI,FileFd &File,
+ bool LoadReleaseInfo(pkgCache::PkgFileIterator &FileI,FileFd &File,
string section);
static const char *ParseDepends(const char *Start,const char *Stop,
@@ -68,7 +72,7 @@ class debListParser : public pkgCacheGenerator::ListParser
bool const &StripMultiArch = false);
static const char *ConvertRelation(const char *I,unsigned int &Op);
- debListParser(FileFd *File);
+ debListParser(FileFd *File, string const &Arch = "");
};
#endif
diff --git a/apt-pkg/deb/debmetaindex.cc b/apt-pkg/deb/debmetaindex.cc
index 520e94a80..717d0bcde 100644
--- a/apt-pkg/deb/debmetaindex.cc
+++ b/apt-pkg/deb/debmetaindex.cc
@@ -8,9 +8,11 @@
#include <apt-pkg/aptconfiguration.h>
#include <apt-pkg/error.h>
+#include <set>
+
using namespace std;
-string debReleaseIndex::Info(const char *Type, const string Section) const
+string debReleaseIndex::Info(const char *Type, string const &Section, string const &Arch) const
{
string Info = ::URI::SiteOnly(URI) + ' ';
if (Dist[Dist.size() - 1] == '/')
@@ -19,7 +21,11 @@ string debReleaseIndex::Info(const char *Type, const string Section) const
Info += Dist;
}
else
- Info += Dist + '/' + Section;
+ {
+ Info += Dist + '/' + Section;
+ if (Arch.empty() != true)
+ Info += " " + Arch;
+ }
Info += " ";
Info += Type;
return Info;
@@ -61,16 +67,21 @@ string debReleaseIndex::MetaIndexURI(const char *Type) const
return Res;
}
-string debReleaseIndex::IndexURISuffix(const char *Type, const string Section) const
+string debReleaseIndex::IndexURISuffix(const char *Type, string const &Section, string const &Arch) const
{
string Res ="";
if (Dist[Dist.size() - 1] != '/')
- Res += Section + "/binary-" + _config->Find("APT::Architecture") + '/';
+ {
+ if (Arch == "native")
+ Res += Section + "/binary-" + _config->Find("APT::Architecture") + '/';
+ else
+ Res += Section + "/binary-" + Arch + '/';
+ }
return Res + Type;
}
-string debReleaseIndex::IndexURI(const char *Type, const string Section) const
+string debReleaseIndex::IndexURI(const char *Type, string const &Section, string const &Arch) const
{
if (Dist[Dist.size() - 1] == '/')
{
@@ -82,10 +93,10 @@ string debReleaseIndex::IndexURI(const char *Type, const string Section) const
return Res + Type;
}
else
- return URI + "dists/" + Dist + '/' + IndexURISuffix(Type, Section);
+ return URI + "dists/" + Dist + '/' + IndexURISuffix(Type, Section, Arch);
}
-string debReleaseIndex::SourceIndexURISuffix(const char *Type, const string Section) const
+string debReleaseIndex::SourceIndexURISuffix(const char *Type, const string &Section) const
{
string Res ="";
if (Dist[Dist.size() - 1] != '/')
@@ -93,7 +104,7 @@ string debReleaseIndex::SourceIndexURISuffix(const char *Type, const string Sect
return Res + Type;
}
-string debReleaseIndex::SourceIndexURI(const char *Type, const string Section) const
+string debReleaseIndex::SourceIndexURI(const char *Type, const string &Section) const
{
string Res;
if (Dist[Dist.size() - 1] == '/')
@@ -108,44 +119,61 @@ string debReleaseIndex::SourceIndexURI(const char *Type, const string Section) c
return URI + "dists/" + Dist + "/" + SourceIndexURISuffix(Type, Section);
}
-debReleaseIndex::debReleaseIndex(string URI,string Dist)
-{
- this->URI = URI;
- this->Dist = Dist;
- this->Indexes = NULL;
- this->Type = "deb";
+debReleaseIndex::debReleaseIndex(string const &URI, string const &Dist) {
+ this->URI = URI;
+ this->Dist = Dist;
+ this->Indexes = NULL;
+ this->Type = "deb";
}
-debReleaseIndex::~debReleaseIndex()
-{
- for (vector<const debSectionEntry *>::const_iterator I = SectionEntries.begin();
- I != SectionEntries.end(); I++)
- delete *I;
+debReleaseIndex::~debReleaseIndex() {
+ for (map<string, vector<debSectionEntry const*> >::const_iterator A = ArchEntries.begin();
+ A != ArchEntries.end(); ++A)
+ for (vector<const debSectionEntry *>::const_iterator S = A->second.begin();
+ S != A->second.end(); ++S)
+ delete *S;
}
-vector <struct IndexTarget *>* debReleaseIndex::ComputeIndexTargets() const
-{
- vector <struct IndexTarget *>* IndexTargets = new vector <IndexTarget *>;
- for (vector <const debSectionEntry *>::const_iterator I = SectionEntries.begin();
- I != SectionEntries.end();
- I++)
- {
- IndexTarget * Target = new IndexTarget();
- Target->ShortDesc = (*I)->IsSrc ? "Sources" : "Packages";
- Target->MetaKey
- = (*I)->IsSrc ? SourceIndexURISuffix(Target->ShortDesc.c_str(), (*I)->Section)
- : IndexURISuffix(Target->ShortDesc.c_str(), (*I)->Section);
- Target->URI
- = (*I)->IsSrc ? SourceIndexURI(Target->ShortDesc.c_str(), (*I)->Section)
- : IndexURI(Target->ShortDesc.c_str(), (*I)->Section);
-
- Target->Description = Info (Target->ShortDesc.c_str(), (*I)->Section);
- IndexTargets->push_back (Target);
- }
- return IndexTargets;
+vector <struct IndexTarget *>* debReleaseIndex::ComputeIndexTargets() const {
+ vector <struct IndexTarget *>* IndexTargets = new vector <IndexTarget *>;
+
+ map<string, vector<debSectionEntry const*> >::const_iterator const src = ArchEntries.find("source");
+ if (src != ArchEntries.end()) {
+ vector<debSectionEntry const*> const SectionEntries = src->second;
+ for (vector<debSectionEntry const*>::const_iterator I = SectionEntries.begin();
+ I != SectionEntries.end(); ++I) {
+ IndexTarget * Target = new IndexTarget();
+ Target->ShortDesc = "Sources";
+ Target->MetaKey = SourceIndexURISuffix(Target->ShortDesc.c_str(), (*I)->Section);
+ Target->URI = SourceIndexURI(Target->ShortDesc.c_str(), (*I)->Section);
+ Target->Description = Info (Target->ShortDesc.c_str(), (*I)->Section);
+ IndexTargets->push_back (Target);
+ }
+ }
+
+ // Only source release
+ if (IndexTargets->empty() == false && ArchEntries.size() == 1)
+ return IndexTargets;
+
+ for (map<string, vector<debSectionEntry const*> >::const_iterator a = ArchEntries.begin();
+ a != ArchEntries.end(); ++a) {
+ if (a->first == "source")
+ continue;
+ for (vector <const debSectionEntry *>::const_iterator I = a->second.begin();
+ I != a->second.end(); ++I) {
+ IndexTarget * Target = new IndexTarget();
+ Target->ShortDesc = "Packages";
+ Target->MetaKey = IndexURISuffix(Target->ShortDesc.c_str(), (*I)->Section, a->first);
+ Target->URI = IndexURI(Target->ShortDesc.c_str(), (*I)->Section, a->first);
+ Target->Description = Info (Target->ShortDesc.c_str(), (*I)->Section, a->first);
+ IndexTargets->push_back (Target);
+ }
+ }
+
+ return IndexTargets;
}
/*}}}*/
-bool debReleaseIndex::GetIndexes(pkgAcquire *Owner, bool GetAll) const
+bool debReleaseIndex::GetIndexes(pkgAcquire *Owner, bool const &GetAll) const
{
// special case for --print-uris
if (GetAll) {
@@ -170,24 +198,28 @@ bool debReleaseIndex::GetIndexes(pkgAcquire *Owner, bool GetAll) const
ComputeIndexTargets(),
new indexRecords (Dist));
- // Queue the translations
- std::vector<std::string> const lang = APT::Configuration::getLanguages(true);
- for (vector<const debSectionEntry *>::const_iterator I = SectionEntries.begin();
- I != SectionEntries.end(); I++) {
-
- if((*I)->IsSrc)
- continue;
-
- for (vector<string>::const_iterator l = lang.begin();
- l != lang.end(); l++)
- {
- if (*l == "none") continue;
- debTranslationsIndex i = debTranslationsIndex(URI,Dist,(*I)->Section,(*l).c_str());
- i.GetIndexes(Owner);
- }
- }
-
- return true;
+ // Queue the translations
+ std::vector<std::string> const lang = APT::Configuration::getLanguages(true);
+ map<string, set<string> > sections;
+ for (map<string, vector<debSectionEntry const*> >::const_iterator a = ArchEntries.begin();
+ a != ArchEntries.end(); ++a) {
+ if (a->first == "source")
+ continue;
+ for (vector<debSectionEntry const*>::const_iterator I = a->second.begin();
+ I != a->second.end(); I++)
+ sections[(*I)->Section].insert(lang.begin(), lang.end());
+ }
+
+ for (map<string, set<string> >::const_iterator s = sections.begin();
+ s != sections.end(); ++s)
+ for (set<string>::const_iterator l = s->second.begin();
+ l != s->second.end(); l++) {
+ if (*l == "none") continue;
+ debTranslationsIndex i = debTranslationsIndex(URI,Dist,s->first,(*l).c_str());
+ i.GetIndexes(Owner);
+ }
+
+ return true;
}
bool debReleaseIndex::IsTrusted() const
@@ -204,73 +236,123 @@ bool debReleaseIndex::IsTrusted() const
return false;
}
-vector <pkgIndexFile *> *debReleaseIndex::GetIndexFiles()
-{
- if (Indexes != NULL)
- return Indexes;
-
- Indexes = new vector <pkgIndexFile*>;
- std::vector<std::string> const lang = APT::Configuration::getLanguages(true);
- for (vector<const debSectionEntry *>::const_iterator I = SectionEntries.begin();
- I != SectionEntries.end(); I++) {
- if ((*I)->IsSrc)
- Indexes->push_back(new debSourcesIndex (URI, Dist, (*I)->Section, IsTrusted()));
- else
- {
- Indexes->push_back(new debPackagesIndex (URI, Dist, (*I)->Section, IsTrusted()));
-
- for (vector<string>::const_iterator l = lang.begin();
- l != lang.end(); l++) {
- if (*l == "none") continue;
- Indexes->push_back(new debTranslationsIndex(URI,Dist,(*I)->Section,(*l).c_str()));
- }
- }
- }
+vector <pkgIndexFile *> *debReleaseIndex::GetIndexFiles() {
+ if (Indexes != NULL)
+ return Indexes;
+
+ Indexes = new vector <pkgIndexFile*>;
+ map<string, vector<debSectionEntry const*> >::const_iterator const src = ArchEntries.find("source");
+ if (src != ArchEntries.end()) {
+ vector<debSectionEntry const*> const SectionEntries = src->second;
+ for (vector<debSectionEntry const*>::const_iterator I = SectionEntries.begin();
+ I != SectionEntries.end(); I++)
+ Indexes->push_back(new debSourcesIndex (URI, Dist, (*I)->Section, IsTrusted()));
+ }
+
+ // Only source release
+ if (Indexes->empty() == false && ArchEntries.size() == 1)
+ return Indexes;
+
+ std::vector<std::string> const lang = APT::Configuration::getLanguages(true);
+ map<string, set<string> > sections;
+ for (map<string, vector<debSectionEntry const*> >::const_iterator a = ArchEntries.begin();
+ a != ArchEntries.end(); ++a) {
+ if (a->first == "source")
+ continue;
+ for (vector<debSectionEntry const*>::const_iterator I = a->second.begin();
+ I != a->second.end(); I++) {
+ Indexes->push_back(new debPackagesIndex (URI, Dist, (*I)->Section, IsTrusted(), a->first));
+ sections[(*I)->Section].insert(lang.begin(), lang.end());
+ }
+ }
+
+ for (map<string, set<string> >::const_iterator s = sections.begin();
+ s != sections.end(); ++s)
+ for (set<string>::const_iterator l = s->second.begin();
+ l != s->second.end(); l++) {
+ if (*l == "none") continue;
+ Indexes->push_back(new debTranslationsIndex(URI,Dist,s->first,(*l).c_str()));
+ }
+
+ return Indexes;
+}
- return Indexes;
+void debReleaseIndex::PushSectionEntry(vector<string> const &Archs, const debSectionEntry *Entry) {
+ for (vector<string>::const_iterator a = Archs.begin();
+ a != Archs.end(); ++a)
+ ArchEntries[*a].push_back(new debSectionEntry(Entry->Section, Entry->IsSrc));
+ delete Entry;
}
-void debReleaseIndex::PushSectionEntry(const debSectionEntry *Entry)
-{
- SectionEntries.push_back(Entry);
+void debReleaseIndex::PushSectionEntry(string const &Arch, const debSectionEntry *Entry) {
+ ArchEntries[Arch].push_back(Entry);
}
-debReleaseIndex::debSectionEntry::debSectionEntry (string Section, bool IsSrc): Section(Section)
-{
- this->IsSrc = IsSrc;
+void debReleaseIndex::PushSectionEntry(const debSectionEntry *Entry) {
+ if (Entry->IsSrc == true)
+ PushSectionEntry("source", Entry);
+ else {
+ for (map<string, vector<const debSectionEntry *> >::iterator a = ArchEntries.begin();
+ a != ArchEntries.end(); ++a) {
+ a->second.push_back(Entry);
+ }
+ }
}
+debReleaseIndex::debSectionEntry::debSectionEntry (string const &Section,
+ bool const &IsSrc): Section(Section), IsSrc(IsSrc)
+{}
+
class debSLTypeDebian : public pkgSourceList::Type
{
protected:
- bool CreateItemInternal(vector<metaIndex *> &List,string URI,
- string Dist,string Section,
- bool IsSrc) const
+ bool CreateItemInternal(vector<metaIndex *> &List, string const &URI,
+ string const &Dist, string const &Section,
+ bool const &IsSrc, map<string, string> const &Options) const
{
- for (vector<metaIndex *>::const_iterator I = List.begin();
+ map<string, string>::const_iterator const arch = Options.find("arch");
+ vector<string> const Archs =
+ (arch != Options.end()) ? VectorizeString(arch->second, ',') :
+ APT::Configuration::getArchitectures();
+
+ for (vector<metaIndex *>::const_iterator I = List.begin();
I != List.end(); I++)
{
- // This check insures that there will be only one Release file
- // queued for all the Packages files and Sources files it
- // corresponds to.
- if (strcmp((*I)->GetType(), "deb") == 0)
+ // We only worry about debian entries here
+ if (strcmp((*I)->GetType(), "deb") != 0)
+ continue;
+
+ debReleaseIndex *Deb = (debReleaseIndex *) (*I);
+ /* This check insures that there will be only one Release file
+ queued for all the Packages files and Sources files it
+ corresponds to. */
+ if (Deb->GetURI() == URI && Deb->GetDist() == Dist)
{
- debReleaseIndex *Deb = (debReleaseIndex *) (*I);
- // This check insures that there will be only one Release file
- // queued for all the Packages files and Sources files it
- // corresponds to.
- if (Deb->GetURI() == URI && Deb->GetDist() == Dist)
+ if (IsSrc == true)
+ Deb->PushSectionEntry("source", new debReleaseIndex::debSectionEntry(Section, IsSrc));
+ else
{
- Deb->PushSectionEntry(new debReleaseIndex::debSectionEntry(Section, IsSrc));
- return true;
+ if (Dist[Dist.size() - 1] == '/')
+ Deb->PushSectionEntry("any", new debReleaseIndex::debSectionEntry(Section, IsSrc));
+ else
+ Deb->PushSectionEntry(Archs, new debReleaseIndex::debSectionEntry(Section, IsSrc));
}
+ return true;
}
}
// No currently created Release file indexes this entry, so we create a new one.
// XXX determine whether this release is trusted or not
- debReleaseIndex *Deb = new debReleaseIndex(URI,Dist);
- Deb->PushSectionEntry (new debReleaseIndex::debSectionEntry(Section, IsSrc));
+ debReleaseIndex *Deb = new debReleaseIndex(URI, Dist);
+ if (IsSrc == true)
+ Deb->PushSectionEntry ("source", new debReleaseIndex::debSectionEntry(Section, IsSrc));
+ else
+ {
+ if (Dist[Dist.size() - 1] == '/')
+ Deb->PushSectionEntry ("any", new debReleaseIndex::debSectionEntry(Section, IsSrc));
+ else
+ Deb->PushSectionEntry (Archs, new debReleaseIndex::debSectionEntry(Section, IsSrc));
+ }
List.push_back(Deb);
return true;
}
@@ -280,10 +362,11 @@ class debSLTypeDeb : public debSLTypeDebian
{
public:
- bool CreateItem(vector<metaIndex *> &List,string URI,
- string Dist,string Section) const
+ bool CreateItem(vector<metaIndex *> &List, string const &URI,
+ string const &Dist, string const &Section,
+ std::map<string, string> const &Options) const
{
- return CreateItemInternal(List, URI, Dist, Section, false);
+ return CreateItemInternal(List, URI, Dist, Section, false, Options);
}
debSLTypeDeb()
@@ -297,10 +380,11 @@ class debSLTypeDebSrc : public debSLTypeDebian
{
public:
- bool CreateItem(vector<metaIndex *> &List,string URI,
- string Dist,string Section) const
+ bool CreateItem(vector<metaIndex *> &List, string const &URI,
+ string const &Dist, string const &Section,
+ std::map<string, string> const &Options) const
{
- return CreateItemInternal(List, URI, Dist, Section, true);
+ return CreateItemInternal(List, URI, Dist, Section, true, Options);
}
debSLTypeDebSrc()
diff --git a/apt-pkg/deb/debmetaindex.h b/apt-pkg/deb/debmetaindex.h
index 8e6a1463b..360fa5419 100644
--- a/apt-pkg/deb/debmetaindex.h
+++ b/apt-pkg/deb/debmetaindex.h
@@ -5,40 +5,44 @@
#include <apt-pkg/metaindex.h>
#include <apt-pkg/sourcelist.h>
+#include <map>
+
class debReleaseIndex : public metaIndex {
public:
class debSectionEntry
{
public:
- debSectionEntry (string Section, bool IsSrc);
- bool IsSrc;
- string Section;
+ debSectionEntry (string const &Section, bool const &IsSrc);
+ string const Section;
+ bool const IsSrc;
};
private:
- vector <const debSectionEntry *> SectionEntries;
+ std::map<string, vector<debSectionEntry const*> > ArchEntries;
public:
- debReleaseIndex(string URI, string Dist);
+ debReleaseIndex(string const &URI, string const &Dist);
~debReleaseIndex();
- virtual string ArchiveURI(string File) const {return URI + File;};
- virtual bool GetIndexes(pkgAcquire *Owner, bool GetAll=false) const;
+ virtual string ArchiveURI(string const &File) const {return URI + File;};
+ virtual bool GetIndexes(pkgAcquire *Owner, bool const &GetAll=false) const;
vector <struct IndexTarget *>* ComputeIndexTargets() const;
- string Info(const char *Type, const string Section) const;
+ string Info(const char *Type, string const &Section, string const &Arch="") const;
string MetaIndexInfo(const char *Type) const;
string MetaIndexFile(const char *Types) const;
string MetaIndexURI(const char *Type) const;
- string IndexURI(const char *Type, const string Section) const;
- string IndexURISuffix(const char *Type, const string Section) const;
- string SourceIndexURI(const char *Type, const string Section) const;
- string SourceIndexURISuffix(const char *Type, const string Section) const;
+ string IndexURI(const char *Type, string const &Section, string const &Arch="native") const;
+ string IndexURISuffix(const char *Type, string const &Section, string const &Arch="native") const;
+ string SourceIndexURI(const char *Type, const string &Section) const;
+ string SourceIndexURISuffix(const char *Type, const string &Section) const;
virtual vector <pkgIndexFile *> *GetIndexFiles();
virtual bool IsTrusted() const;
+ void PushSectionEntry(vector<string> const &Archs, const debSectionEntry *Entry);
+ void PushSectionEntry(string const &Arch, const debSectionEntry *Entry);
void PushSectionEntry(const debSectionEntry *Entry);
};
diff --git a/apt-pkg/deb/debrecords.cc b/apt-pkg/deb/debrecords.cc
index 34ef0d8f2..ec9e395ef 100644
--- a/apt-pkg/deb/debrecords.cc
+++ b/apt-pkg/deb/debrecords.cc
@@ -19,7 +19,7 @@
// ---------------------------------------------------------------------
/* */
debRecordParser::debRecordParser(string FileName,pkgCache &Cache) :
- File(FileName,FileFd::ReadOnly),
+ File(FileName,FileFd::ReadOnlyGzip),
Tags(&File, std::max(Cache.Head().MaxVerFileSize,
Cache.Head().MaxDescFileSize) + 200)
{
diff --git a/apt-pkg/deb/debsrcrecords.h b/apt-pkg/deb/debsrcrecords.h
index c39d78bae..905264daa 100644
--- a/apt-pkg/deb/debsrcrecords.h
+++ b/apt-pkg/deb/debsrcrecords.h
@@ -48,7 +48,7 @@ class debSrcRecordParser : public pkgSrcRecords::Parser
virtual bool Files(vector<pkgSrcRecords::File> &F);
debSrcRecordParser(string const &File,pkgIndexFile const *Index)
- : Parser(Index), Fd(File,FileFd::ReadOnly), Tags(&Fd,102400),
+ : Parser(Index), Fd(File,FileFd::ReadOnlyGzip), Tags(&Fd,102400),
Buffer(0), BufSize(0) {}
~debSrcRecordParser();
};
diff --git a/apt-pkg/deb/debsystem.cc b/apt-pkg/deb/debsystem.cc
index 59f826d96..7056d771d 100644
--- a/apt-pkg/deb/debsystem.cc
+++ b/apt-pkg/deb/debsystem.cc
@@ -18,7 +18,6 @@
#include <apt-pkg/error.h>
#include <apt-pkg/fileutl.h>
#include <apti18n.h>
-
#include <sys/types.h>
#include <unistd.h>
#include <dirent.h>
@@ -79,8 +78,15 @@ bool debSystem::Lock()
{
close(LockFD);
LockFD = -1;
+ const char *cmd;
+ if (getenv("SUDO_USER") != NULL)
+ cmd = "sudo dpkg --configure -a";
+ else
+ cmd = "dpkg --configure -a";
+ // TRANSLATORS: the %s contains the recovery command, usually
+ // dpkg --configure -a
return _error->Error(_("dpkg was interrupted, you must manually "
- "run 'dpkg --configure -a' to correct the problem. "));
+ "run '%s' to correct the problem. "), cmd);
}
LockCount++;
@@ -158,7 +164,7 @@ bool debSystem::Initialize(Configuration &Cnf)
/* These really should be jammed into a generic 'Local Database' engine
which is yet to be determined. The functions in pkgcachegen should
be the only users of these */
- Cnf.CndSet("Dir::State::userstatus","status.user"); // Defunct
+ Cnf.CndSet("Dir::State::extended_states", Cnf.FindDir("Dir::State").append("extended_states"));
Cnf.CndSet("Dir::State::status","/var/lib/dpkg/status");
Cnf.CndSet("Dir::Bin::dpkg","/usr/bin/dpkg");
diff --git a/apt-pkg/deb/debversion.cc b/apt-pkg/deb/debversion.cc
index ad45e9a44..755ffbe96 100644
--- a/apt-pkg/deb/debversion.cc
+++ b/apt-pkg/deb/debversion.cc
@@ -190,8 +190,22 @@ int debVersioningSystem::DoCmpVersion(const char *A,const char *AEnd,
dlhs++;
if (drhs != rhs)
drhs++;
-
- return CmpFragment(dlhs,AEnd,drhs,BEnd);
+
+ // no debian revision need to be treated like -0
+ if (*(dlhs-1) == '-' && *(drhs-1) == '-')
+ return CmpFragment(dlhs,AEnd,drhs,BEnd);
+ else if (*(dlhs-1) == '-')
+ {
+ const char* null = "0";
+ return CmpFragment(dlhs,AEnd,null, null+1);
+ }
+ else if (*(drhs-1) == '-')
+ {
+ const char* null = "0";
+ return CmpFragment(null, null+1, drhs, BEnd);
+ }
+ else
+ return 0;
}
/*}}}*/
// debVS::CheckDep - Check a single dependency /*{{{*/
diff --git a/apt-pkg/deb/dpkgpm.cc b/apt-pkg/deb/dpkgpm.cc
index 5b02cae1d..aa0b04bd5 100644
--- a/apt-pkg/deb/dpkgpm.cc
+++ b/apt-pkg/deb/dpkgpm.cc
@@ -12,6 +12,7 @@
#include <apt-pkg/error.h>
#include <apt-pkg/configuration.h>
#include <apt-pkg/depcache.h>
+#include <apt-pkg/pkgrecords.h>
#include <apt-pkg/strutl.h>
#include <apti18n.h>
#include <apt-pkg/fileutl.h>
@@ -20,10 +21,12 @@
#include <stdlib.h>
#include <fcntl.h>
#include <sys/select.h>
+#include <sys/stat.h>
#include <sys/types.h>
#include <sys/wait.h>
#include <signal.h>
#include <errno.h>
+#include <string.h>
#include <stdio.h>
#include <string.h>
#include <algorithm>
@@ -50,6 +53,7 @@ namespace
std::make_pair("configure", N_("Configuring %s")),
std::make_pair("remove", N_("Removing %s")),
std::make_pair("purge", N_("Completely removing %s")),
+ std::make_pair("disappear", N_("Noting disappearance of %s")),
std::make_pair("trigproc", N_("Running post-installation trigger %s"))
};
@@ -105,7 +109,7 @@ ionice(int PID)
/* */
pkgDPkgPM::pkgDPkgPM(pkgDepCache *Cache)
: pkgPackageManager(Cache), dpkgbuf_pos(0),
- term_out(NULL), PackagesDone(0), PackagesTotal(0)
+ term_out(NULL), history_out(NULL), PackagesDone(0), PackagesTotal(0)
{
}
/*}}}*/
@@ -124,7 +128,19 @@ bool pkgDPkgPM::Install(PkgIterator Pkg,string File)
if (File.empty() == true || Pkg.end() == true)
return _error->Error("Internal Error, No file name for %s",Pkg.Name());
- List.push_back(Item(Item::Install,Pkg,File));
+ // If the filename string begins with DPkg::Chroot-Directory, return the
+ // substr that is within the chroot so dpkg can access it.
+ string const chrootdir = _config->FindDir("DPkg::Chroot-Directory","/");
+ if (chrootdir != "/" && File.find(chrootdir) == 0)
+ {
+ size_t len = chrootdir.length();
+ if (chrootdir.at(len - 1) == '/')
+ len--;
+ List.push_back(Item(Item::Install,Pkg,File.substr(len)));
+ }
+ else
+ List.push_back(Item(Item::Install,Pkg,File));
+
return true;
}
/*}}}*/
@@ -341,7 +357,6 @@ bool pkgDPkgPM::RunScriptsWithPkgs(const char *Cnf)
return true;
}
-
/*}}}*/
// DPkgPM::DoStdin - Read stdin and pass to slave pty /*{{{*/
// ---------------------------------------------------------------------
@@ -407,11 +422,12 @@ void pkgDPkgPM::ProcessDpkgStatusLine(int OutStatusFd, char *line)
'processing: install: pkg'
'processing: configure: pkg'
'processing: remove: pkg'
- 'processing: purge: pkg' - but for apt is it a ignored "unknown" action
+ 'processing: purge: pkg'
+ 'processing: disappear: pkg'
'processing: trigproc: trigger'
*/
- char* list[5];
+ char* list[6];
// dpkg sends multiline error messages sometimes (see
// #374195 for a example. we should support this by
// either patching dpkg to not send multiline over the
@@ -454,11 +470,22 @@ void pkgDPkgPM::ProcessDpkgStatusLine(int OutStatusFd, char *line)
write(OutStatusFd, status.str().c_str(), status.str().size());
if (Debug == true)
std::clog << "send: '" << status.str() << "'" << endl;
+
+ if (strncmp(action, "disappear", strlen("disappear")) == 0)
+ handleDisappearAction(pkg_or_trigger);
return;
}
if(strncmp(action,"error",strlen("error")) == 0)
{
+ // urgs, sometime has ":" in its error string so that we
+ // end up with the error message split between list[3]
+ // and list[4], e.g. the message:
+ // "failed in buffer_write(fd) (10, ret=-1): backend dpkg-deb ..."
+ // concat them again
+ if( list[4] != NULL )
+ list[3][strlen(list[3])] = ':';
+
status << "pmerror:" << list[1]
<< ":" << (PackagesDone/float(PackagesTotal)*100.0)
<< ":" << list[3]
@@ -467,6 +494,8 @@ void pkgDPkgPM::ProcessDpkgStatusLine(int OutStatusFd, char *line)
write(OutStatusFd, status.str().c_str(), status.str().size());
if (Debug == true)
std::clog << "send: '" << status.str() << "'" << endl;
+ pkgFailures++;
+ WriteApportReport(list[1], list[3]);
return;
}
else if(strncmp(action,"conffile",strlen("conffile")) == 0)
@@ -513,6 +542,51 @@ void pkgDPkgPM::ProcessDpkgStatusLine(int OutStatusFd, char *line)
<< " action: " << action << endl;
}
/*}}}*/
+// DPkgPM::handleDisappearAction /*{{{*/
+void pkgDPkgPM::handleDisappearAction(string const &pkgname)
+{
+ // record the package name for display and stuff later
+ disappearedPkgs.insert(pkgname);
+
+ pkgCache::PkgIterator Pkg = Cache.FindPkg(pkgname);
+ if (unlikely(Pkg.end() == true))
+ return;
+ // the disappeared package was auto-installed - nothing to do
+ if ((Cache[Pkg].Flags & pkgCache::Flag::Auto) == pkgCache::Flag::Auto)
+ return;
+ pkgCache::VerIterator PkgVer = Pkg.CurrentVer();
+ if (unlikely(PkgVer.end() == true))
+ return;
+ /* search in the list of dependencies for (Pre)Depends,
+ check if this dependency has a Replaces on our package
+ and if so transfer the manual installed flag to it */
+ for (pkgCache::DepIterator Dep = PkgVer.DependsList(); Dep.end() != true; ++Dep)
+ {
+ if (Dep->Type != pkgCache::Dep::Depends &&
+ Dep->Type != pkgCache::Dep::PreDepends)
+ continue;
+ pkgCache::PkgIterator Tar = Dep.TargetPkg();
+ if (unlikely(Tar.end() == true))
+ continue;
+ // the package is already marked as manual
+ if ((Cache[Tar].Flags & pkgCache::Flag::Auto) != pkgCache::Flag::Auto)
+ continue;
+ pkgCache::VerIterator TarVer = Tar.CurrentVer();
+ for (pkgCache::DepIterator Rep = TarVer.DependsList(); Rep.end() != true; ++Rep)
+ {
+ if (Rep->Type != pkgCache::Dep::Replaces)
+ continue;
+ if (Pkg != Rep.TargetPkg())
+ continue;
+ // okay, they are strongly connected - transfer manual-bit
+ if (Debug == true)
+ std::clog << "transfer manual-bit from disappeared »" << pkgname << "« to »" << Tar.FullName() << "«" << std::endl;
+ Cache[Tar].Flags &= ~Flag::Auto;
+ break;
+ }
+ }
+}
+ /*}}}*/
// DPkgPM::DoDpkgStatusFd /*{{{*/
// ---------------------------------------------------------------------
/*
@@ -551,67 +625,76 @@ void pkgDPkgPM::DoDpkgStatusFd(int statusfd, int OutStatusFd)
}
/*}}}*/
// DPkgPM::WriteHistoryTag /*{{{*/
-void pkgDPkgPM::WriteHistoryTag(string tag, string value)
+void pkgDPkgPM::WriteHistoryTag(string const &tag, string value)
{
- if (value.size() > 0)
- {
- // poor mans rstrip(", ")
- if (value[value.size()-2] == ',' && value[value.size()-1] == ' ')
- value.erase(value.size() - 2, 2);
- fprintf(history_out, "%s: %s\n", tag.c_str(), value.c_str());
- }
+ size_t const length = value.length();
+ if (length == 0)
+ return;
+ // poor mans rstrip(", ")
+ if (value[length-2] == ',' && value[length-1] == ' ')
+ value.erase(length - 2, 2);
+ fprintf(history_out, "%s: %s\n", tag.c_str(), value.c_str());
} /*}}}*/
// DPkgPM::OpenLog /*{{{*/
bool pkgDPkgPM::OpenLog()
{
- string logdir = _config->FindDir("Dir::Log");
+ string const logdir = _config->FindDir("Dir::Log");
if(not FileExists(logdir))
return _error->Error(_("Directory '%s' missing"), logdir.c_str());
// get current time
char timestr[200];
- time_t t = time(NULL);
- struct tm *tmp = localtime(&t);
+ time_t const t = time(NULL);
+ struct tm const * const tmp = localtime(&t);
strftime(timestr, sizeof(timestr), "%F %T", tmp);
// open terminal log
- string logfile_name = flCombine(logdir,
+ string const logfile_name = flCombine(logdir,
_config->Find("Dir::Log::Terminal"));
if (!logfile_name.empty())
{
term_out = fopen(logfile_name.c_str(),"a");
if (term_out == NULL)
- return _error->WarningE(_("Could not open file '%s'"), logfile_name.c_str());
-
+ return _error->WarningE("OpenLog", _("Could not open file '%s'"), logfile_name.c_str());
+ setvbuf(term_out, NULL, _IONBF, 0);
chmod(logfile_name.c_str(), 0600);
fprintf(term_out, "\nLog started: %s\n", timestr);
}
- // write
- string history_name = flCombine(logdir,
+ // write your history
+ string const history_name = flCombine(logdir,
_config->Find("Dir::Log::History"));
if (!history_name.empty())
{
history_out = fopen(history_name.c_str(),"a");
+ if (history_out == NULL)
+ return _error->WarningE("OpenLog", _("Could not open file '%s'"), history_name.c_str());
chmod(history_name.c_str(), 0644);
fprintf(history_out, "\nStart-Date: %s\n", timestr);
string remove, purge, install, upgrade, downgrade;
for (pkgCache::PkgIterator I = Cache.PkgBegin(); I.end() == false; I++)
{
if (Cache[I].NewInstall())
- install += I.Name() + string(" (") + Cache[I].CandVersion + string("), ");
+ {
+ install += I.FullName(false) + string(" (") + Cache[I].CandVersion;
+ if (Cache[I].Flags & pkgCache::Flag::Auto)
+ install+= ", automatic";
+ install += string("), ");
+ }
else if (Cache[I].Upgrade())
- upgrade += I.Name() + string(" (") + Cache[I].CurVersion + string(", ") + Cache[I].CandVersion + string("), ");
+ upgrade += I.FullName(false) + string(" (") + Cache[I].CurVersion + string(", ") + Cache[I].CandVersion + string("), ");
else if (Cache[I].Downgrade())
- downgrade += I.Name() + string(" (") + Cache[I].CurVersion + string(", ") + Cache[I].CandVersion + string("), ");
+ downgrade += I.FullName(false) + string(" (") + Cache[I].CurVersion + string(", ") + Cache[I].CandVersion + string("), ");
else if (Cache[I].Delete())
{
if ((Cache[I].iFlags & pkgDepCache::Purge) == pkgDepCache::Purge)
- purge += I.Name() + string(" (") + Cache[I].CurVersion + string("), ");
+ purge += I.FullName(false) + string(" (") + Cache[I].CurVersion + string("), ");
else
- remove += I.Name() + string(" (") + Cache[I].CurVersion + string("), ");
+ remove += I.FullName(false) + string(" (") + Cache[I].CurVersion + string("), ");
}
}
+ if (_config->Exists("Commandline::AsString") == true)
+ WriteHistoryTag("Commandline", _config->Find("Commandline::AsString"));
WriteHistoryTag("Install", install);
WriteHistoryTag("Upgrade", upgrade);
WriteHistoryTag("Downgrade",downgrade);
@@ -642,11 +725,27 @@ bool pkgDPkgPM::CloseLog()
if(history_out)
{
- if (dpkg_error.size() > 0)
+ if (disappearedPkgs.empty() == false)
+ {
+ string disappear;
+ for (std::set<std::string>::const_iterator d = disappearedPkgs.begin();
+ d != disappearedPkgs.end(); ++d)
+ {
+ pkgCache::PkgIterator P = Cache.FindPkg(*d);
+ disappear.append(*d);
+ if (P.end() == true)
+ disappear.append(", ");
+ else
+ disappear.append(" (").append(Cache[P].CurVersion).append("), ");
+ }
+ WriteHistoryTag("Disappeared", disappear);
+ }
+ if (dpkg_error.empty() == false)
fprintf(history_out, "Error: %s\n", dpkg_error.c_str());
fprintf(history_out, "End-Date: %s\n", timestr);
fclose(history_out);
}
+ history_out = NULL;
return true;
}
@@ -894,6 +993,8 @@ bool pkgDPkgPM::Go(int OutStatusFd)
{
if((*I).Pkg.end() == true)
continue;
+ if (I->Op == Item::Configure && disappearedPkgs.find(I->Pkg.Name()) != disappearedPkgs.end())
+ continue;
Args[n++] = I->Pkg.Name();
Size += strlen(Args[n-1]);
}
@@ -1151,3 +1252,186 @@ void pkgDPkgPM::Reset()
List.erase(List.begin(),List.end());
}
/*}}}*/
+// pkgDpkgPM::WriteApportReport - write out error report pkg failure /*{{{*/
+// ---------------------------------------------------------------------
+/* */
+void pkgDPkgPM::WriteApportReport(const char *pkgpath, const char *errormsg)
+{
+ string pkgname, reportfile, srcpkgname, pkgver, arch;
+ string::size_type pos;
+ FILE *report;
+
+ if (_config->FindB("Dpkg::ApportFailureReport", false) == false)
+ {
+ std::clog << "configured to not write apport reports" << std::endl;
+ return;
+ }
+
+ // only report the first errors
+ if(pkgFailures > _config->FindI("APT::Apport::MaxReports", 3))
+ {
+ std::clog << _("No apport report written because MaxReports is reached already") << std::endl;
+ return;
+ }
+
+ // check if its not a follow up error
+ const char *needle = dgettext("dpkg", "dependency problems - leaving unconfigured");
+ if(strstr(errormsg, needle) != NULL) {
+ std::clog << _("No apport report written because the error message indicates its a followup error from a previous failure.") << std::endl;
+ return;
+ }
+
+ // do not report disk-full failures
+ if(strstr(errormsg, strerror(ENOSPC)) != NULL) {
+ std::clog << _("No apport report written because the error message indicates a disk full error") << std::endl;
+ return;
+ }
+
+ // do not report out-of-memory failures
+ if(strstr(errormsg, strerror(ENOMEM)) != NULL) {
+ std::clog << _("No apport report written because the error message indicates a out of memory error") << std::endl;
+ return;
+ }
+
+ // do not report dpkg I/O errors
+ // XXX - this message is localized, but this only matches the English version. This is better than nothing.
+ if(strstr(errormsg, "short read in buffer_copy (")) {
+ std::clog << _("No apport report written because the error message indicates a dpkg I/O error") << std::endl;
+ return;
+ }
+
+ // get the pkgname and reportfile
+ pkgname = flNotDir(pkgpath);
+ pos = pkgname.find('_');
+ if(pos != string::npos)
+ pkgname = pkgname.substr(0, pos);
+
+ // find the package versin and source package name
+ pkgCache::PkgIterator Pkg = Cache.FindPkg(pkgname);
+ if (Pkg.end() == true)
+ return;
+ pkgCache::VerIterator Ver = Cache.GetCandidateVer(Pkg);
+ if (Ver.end() == true)
+ return;
+ pkgver = Ver.VerStr() == NULL ? "unknown" : Ver.VerStr();
+ pkgRecords Recs(Cache);
+ pkgRecords::Parser &Parse = Recs.Lookup(Ver.FileList());
+ srcpkgname = Parse.SourcePkg();
+ if(srcpkgname.empty())
+ srcpkgname = pkgname;
+
+ // if the file exists already, we check:
+ // - if it was reported already (touched by apport).
+ // If not, we do nothing, otherwise
+ // we overwrite it. This is the same behaviour as apport
+ // - if we have a report with the same pkgversion already
+ // then we skip it
+ reportfile = flCombine("/var/crash",pkgname+".0.crash");
+ if(FileExists(reportfile))
+ {
+ struct stat buf;
+ char strbuf[255];
+
+ // check atime/mtime
+ stat(reportfile.c_str(), &buf);
+ if(buf.st_mtime > buf.st_atime)
+ return;
+
+ // check if the existing report is the same version
+ report = fopen(reportfile.c_str(),"r");
+ while(fgets(strbuf, sizeof(strbuf), report) != NULL)
+ {
+ if(strstr(strbuf,"Package:") == strbuf)
+ {
+ char pkgname[255], version[255];
+ if(sscanf(strbuf, "Package: %s %s", pkgname, version) == 2)
+ if(strcmp(pkgver.c_str(), version) == 0)
+ {
+ fclose(report);
+ return;
+ }
+ }
+ }
+ fclose(report);
+ }
+
+ // now write the report
+ arch = _config->Find("APT::Architecture");
+ report = fopen(reportfile.c_str(),"w");
+ if(report == NULL)
+ return;
+ if(_config->FindB("DPkgPM::InitialReportOnly",false) == true)
+ chmod(reportfile.c_str(), 0);
+ else
+ chmod(reportfile.c_str(), 0600);
+ fprintf(report, "ProblemType: Package\n");
+ fprintf(report, "Architecture: %s\n", arch.c_str());
+ time_t now = time(NULL);
+ fprintf(report, "Date: %s" , ctime(&now));
+ fprintf(report, "Package: %s %s\n", pkgname.c_str(), pkgver.c_str());
+ fprintf(report, "SourcePackage: %s\n", srcpkgname.c_str());
+ fprintf(report, "ErrorMessage:\n %s\n", errormsg);
+
+ // ensure that the log is flushed
+ if(term_out)
+ fflush(term_out);
+
+ // attach terminal log it if we have it
+ string logfile_name = _config->FindFile("Dir::Log::Terminal");
+ if (!logfile_name.empty())
+ {
+ FILE *log = NULL;
+ char buf[1024];
+
+ fprintf(report, "DpkgTerminalLog:\n");
+ log = fopen(logfile_name.c_str(),"r");
+ if(log != NULL)
+ {
+ while( fgets(buf, sizeof(buf), log) != NULL)
+ fprintf(report, " %s", buf);
+ fclose(log);
+ }
+ }
+
+ // log the ordering
+ const char *ops_str[] = {"Install", "Configure","Remove","Purge"};
+ fprintf(report, "AptOrdering:\n");
+ for (vector<Item>::iterator I = List.begin(); I != List.end(); I++)
+ fprintf(report, " %s: %s\n", (*I).Pkg.Name(), ops_str[(*I).Op]);
+
+ // attach dmesg log (to learn about segfaults)
+ if (FileExists("/bin/dmesg"))
+ {
+ FILE *log = NULL;
+ char buf[1024];
+
+ fprintf(report, "Dmesg:\n");
+ log = popen("/bin/dmesg","r");
+ if(log != NULL)
+ {
+ while( fgets(buf, sizeof(buf), log) != NULL)
+ fprintf(report, " %s", buf);
+ fclose(log);
+ }
+ }
+
+ // attach df -l log (to learn about filesystem status)
+ if (FileExists("/bin/df"))
+ {
+ FILE *log = NULL;
+ char buf[1024];
+
+ fprintf(report, "Df:\n");
+ log = popen("/bin/df -l","r");
+ if(log != NULL)
+ {
+ while( fgets(buf, sizeof(buf), log) != NULL)
+ fprintf(report, " %s", buf);
+ fclose(log);
+ }
+ }
+
+ fclose(report);
+
+}
+ /*}}}*/
diff --git a/apt-pkg/deb/dpkgpm.h b/apt-pkg/deb/dpkgpm.h
index 330c788a2..b7b5a6def 100644
--- a/apt-pkg/deb/dpkgpm.h
+++ b/apt-pkg/deb/dpkgpm.h
@@ -32,7 +32,23 @@ class pkgDPkgPM : public pkgPackageManager
FILE *history_out;
string dpkg_error;
+ /** \brief record the disappear action and handle accordingly
+
+ dpkg let packages disappear then they have no files any longer and
+ nothing depends on them. We need to collect this as dpkg as well as
+ APT doesn't know beforehand that the package will disappear, so the
+ only possible option is to tell the user afterwards about it.
+ To enhance the experience we also try to forward the auto-install
+ flag so the disappear-causer(s) are not autoremoved next time -
+ for the transfer to happen the disappeared version needs to depend
+ on the package the flag should be forwarded to and this package
+ needs to declare a Replaces on the disappeared package.
+ \param pkgname Name of the package that disappeared
+ */
+ void handleDisappearAction(string const &pkgname);
+
protected:
+ int pkgFailures;
// progress reporting
struct DpkgState
@@ -49,6 +65,7 @@ class pkgDPkgPM : public pkgPackageManager
// the int is the state that is already done (e.g. a package that is
// going to be install is already in state "half-installed")
map<string,unsigned int> PackageOpsDone;
+
// progress reporting
unsigned int PackagesDone;
unsigned int PackagesTotal;
@@ -68,7 +85,10 @@ class pkgDPkgPM : public pkgPackageManager
// Helpers
bool RunScriptsWithPkgs(const char *Cnf);
bool SendV2Pkgs(FILE *F);
- void WriteHistoryTag(string tag, string value);
+ void WriteHistoryTag(string const &tag, string value);
+
+ // apport integration
+ void WriteApportReport(const char *pkgpath, const char *errormsg);
// dpkg log
bool OpenLog();