You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

1761 lines
58 KiB

// -*- mode: cpp; mode: fold -*-
// Description /*{{{*/
Merge from CVS Patches applied: * apt@arch.ubuntu.com/apt--MAIN--0--patch-1304 Basque correction. * apt@arch.ubuntu.com/apt--MAIN--0--patch-1305 Updated Brazilian Portuguese and Greek (256396 and 2567... * apt@arch.ubuntu.com/apt--MAIN--0--patch-1306 New Korean translation from Changwoo Ryu <cwryu@debian.... * apt@arch.ubuntu.com/apt--MAIN--0--patch-1307 German translation now available in two flavours: with ... * apt@arch.ubuntu.com/apt--MAIN--0--patch-1308 Finalize 0.5.26 * apt@arch.ubuntu.com/apt--MAIN--0--patch-1309 Remove duplicate entry * apt@arch.ubuntu.com/apt--MAIN--0--patch-1310 Note about archtable when architecture test fails * apt@arch.ubuntu.com/apt--MAIN--0--patch-1311 0.5.26 (really) * apt@arch.ubuntu.com/apt--MAIN--0--patch-1312 German translation now available in two flavours: with ... * apt@arch.ubuntu.com/apt--MAIN--0--patch-1313 New Finnish translation from Tapio Lehtonen <tale@debia... * apt@arch.ubuntu.com/apt--MAIN--0--patch-1314 New Bosnian translation from Safir ��e��erovi�� <sapphi... * apt@arch.ubuntu.com/apt--MAIN--0--patch-1315 Fix Italian incontrario * apt@arch.ubuntu.com/apt--MAIN--0--patch-1316 * Bring configure-index up to date with documented opti... * apt@arch.ubuntu.com/apt--MAIN--0--patch-1317 configure-index contains example values, not strictly d... * apt@arch.ubuntu.com/apt--MAIN--0--patch-1318 Updated Spanish from Ruben Porras (Closes:#260483) * apt@arch.ubuntu.com/apt--MAIN--0--patch-1319 Updated Danish from Claus Hindsgaul (Closes: #260569) * apt@arch.ubuntu.com/apt--MAIN--0--patch-1320 Updated Slovak from Peter Mann (Closes: #260627) * apt@arch.ubuntu.com/apt--MAIN--0--patch-1321 Updated Portuguese from Miguel Figueiredo (Closes: #261423) * apt@arch.ubuntu.com/apt--MAIN--0--patch-1322 * Add Polish translation of offline.sgml (Closes: #259229) * apt@arch.ubuntu.com/apt--MAIN--0--patch-1323 urgency=high * apt@arch.ubuntu.com/apt--MAIN--0--patch-1324 Sync with new POT. * apt@arch.ubuntu.com/apt--MAIN--0--patch-1325 Updated Hungarian from Kelemen G��bor <kelemeng@gnome.hu>. * apt@arch.ubuntu.com/apt--MAIN--0--patch-1326 Updated Greek from George Papamichelakis (Closes: #265004) * apt@arch.ubuntu.com/apt--MAIN--0--patch-1327 Updated Simplified Chinese from Tchaikov (Closes: #265190) * apt@arch.ubuntu.com/apt--MAIN--0--patch-1328 Updated French by Christian Perrier (Closes: #265816) * apt@arch.ubuntu.com/apt--MAIN--0--patch-1329 Updated Japanese by Kenshi Muto (Closes: #265630) * apt@arch.ubuntu.com/apt--MAIN--0--patch-1330 Updated French by Christian Perrier (Closes: #265816) * apt@arch.ubuntu.com/apt--MAIN--0--patch-1331 - Updated Catalan from Jordi Mallach * apt@arch.ubuntu.com/apt--MAIN--0--patch-1332 Updated Dutch from Bart Cornelis (Closes: #268258) * apt@arch.ubuntu.com/apt--MAIN--0--patch-1333 Updated Portuguese from Miguel Figueiredo (Closes: #268265) * apt@arch.ubuntu.com/apt--MAIN--0--patch-1334 Updated Dutch from Bart Cornelis (Closes: #268258) * apt@arch.ubuntu.com/apt--MAIN--0--patch-1335 APT::Get::APT::Get::No-List-Cleanup -> APT::Get::List-C... * apt@arch.ubuntu.com/apt--MAIN--0--patch-1336 Updated Polish from Robert Luberda <robert@debian.org> ... * apt@arch.ubuntu.com/apt--MAIN--0--patch-1337 Updated Danish from Claus Hindsgaul (Closes: #269417) * apt@arch.ubuntu.com/apt--MAIN--0--patch-1338 Updated Norwegian Nynorsk from H��vard Korsvoll <korsvo... * apt@arch.ubuntu.com/apt--MAIN--0--patch-1339 Updated Russian from Yuri Kozlov <yuray@id.ru> (Closes:... * apt@arch.ubuntu.com/apt--MAIN--0--patch-1340 Updated Italian from Samuele Giovanni Tonon (Closes: #2... * apt@arch.ubuntu.com/apt--MAIN--0--patch-1341 Updated Dutch from Bart Cornelis (Closes: #278697) * apt@arch.ubuntu.com/apt--MAIN--0--patch-1342 Updated Slovak from Peter Mann (Closes: #279481)
18 years ago
// $Id: apt-get.cc,v 1.156 2004/08/28 01:05:16 mdz Exp $
/* ######################################################################
apt-get - Cover for dpkg
This is an allout cover for dpkg implementing a safer front end. It is
based largely on libapt-pkg.
The syntax is different,
apt-get [opt] command [things]
Where command is:
update - Resyncronize the package files from their sources
upgrade - Smart-Download the newest versions of all packages
dselect-upgrade - Follows dselect's changes to the Status: field
and installes new and removes old packages
dist-upgrade - Powerful upgrader designed to handle the issues with
a new distribution.
install - Download and install a given package (by name, not by .deb)
check - Update the package cache and check for broken packages
clean - Erase the .debs downloaded to /var/cache/apt/archives and
the partial dir too
##################################################################### */
/*}}}*/
// Include Files /*{{{*/
#include <config.h>
#include <apt-pkg/acquire-item.h>
#include <apt-pkg/algorithms.h>
#include <apt-pkg/aptconfiguration.h>
#include <apt-pkg/cachefile.h>
#include <apt-pkg/cacheset.h>
#include <apt-pkg/clean.h>
#include <apt-pkg/cmndline.h>
#include <apt-pkg/debmetaindex.h>
#include <apt-pkg/depcache.h>
#include <apt-pkg/error.h>
#include <apt-pkg/fileutl.h>
#include <apt-pkg/indexfile.h>
#include <apt-pkg/indexrecords.h>
#include <apt-pkg/init.h>
#include <apt-pkg/md5.h>
#include <apt-pkg/metaindex.h>
#include <apt-pkg/pkgrecords.h>
#include <apt-pkg/pkgsystem.h>
#include <apt-pkg/progress.h>
#include <apt-pkg/sourcelist.h>
#include <apt-pkg/srcrecords.h>
#include <apt-pkg/strutl.h>
#include <apt-pkg/version.h>
#include <apt-pkg/acquire.h>
#include <apt-pkg/configuration.h>
#include <apt-pkg/macros.h>
#include <apt-pkg/pkgcache.h>
#include <apt-pkg/cacheiterators.h>
#include <apt-pkg/upgrade.h>
#include <apt-private/acqprogress.h>
#include <apt-private/private-cacheset.h>
#include <apt-private/private-cachefile.h>
#include <apt-private/private-cmndline.h>
#include <apt-private/private-download.h>
#include <apt-private/private-install.h>
#include <apt-private/private-main.h>
#include <apt-private/private-moo.h>
#include <apt-private/private-output.h>
#include <apt-private/private-update.h>
#include <apt-private/private-upgrade.h>
#include <apt-private/private-utils.h>
#include <errno.h>
#include <signal.h>
#include <stddef.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/ioctl.h>
#include <sys/stat.h>
#include <sys/statfs.h>
#include <sys/statvfs.h>
#include <sys/wait.h>
#include <unistd.h>
#include <algorithm>
#include <fstream>
#include <iostream>
#include <set>
#include <string>
#include <vector>
#include <apti18n.h>
/*}}}*/
using namespace std;
// TryToInstallBuildDep - Try to install a single package /*{{{*/
// ---------------------------------------------------------------------
/* This used to be inlined in DoInstall, but with the advent of regex package
name matching it was split out.. */
static bool TryToInstallBuildDep(pkgCache::PkgIterator Pkg,pkgCacheFile &Cache,
pkgProblemResolver &Fix,bool Remove,bool BrokenFix,
bool AllowFail = true)
{
if (Cache[Pkg].CandidateVer == 0 && Pkg->ProvidesList != 0)
{
CacheSetHelperAPTGet helper(c1out);
helper.showErrors(false);
pkgCache::VerIterator Ver = helper.canNotFindNewestVer(Cache, Pkg);
if (Ver.end() == false)
Pkg = Ver.ParentPkg();
else if (helper.showVirtualPackageErrors(Cache) == false)
return AllowFail;
}
if (_config->FindB("Debug::BuildDeps",false) == true)
{
if (Remove == true)
cout << " Trying to remove " << Pkg << endl;
else
cout << " Trying to install " << Pkg << endl;
}
if (Remove == true)
{
TryToRemove RemoveAction(Cache, &Fix);
RemoveAction(Pkg.VersionList());
} else if (Cache[Pkg].CandidateVer != 0) {
TryToInstall InstallAction(Cache, &Fix, BrokenFix);
InstallAction(Cache[Pkg].CandidateVerIter(Cache));
InstallAction.doAutoInstall();
} else
return AllowFail;
return true;
}
/*}}}*/
// helper that can go wit hthe next ABI break
#if (APT_PKG_MAJOR >= 4 && APT_PKG_MINOR < 13)
static std::string MetaIndexFileNameOnDisk(metaIndex *metaindex)
{
// FIXME: this cast is the horror, the horror
debReleaseIndex *r = (debReleaseIndex*)metaindex;
// see if we have a InRelease file
std::string PathInRelease = r->MetaIndexFile("InRelease");
if (FileExists(PathInRelease))
return PathInRelease;
// and if not return the normal one
if (FileExists(PathInRelease))
return r->MetaIndexFile("Release");
return "";
}
#endif
// GetReleaseForSourceRecord - Return Suite for the given srcrecord /*{{{*/
// ---------------------------------------------------------------------
/* */
static std::string GetReleaseForSourceRecord(pkgSourceList *SrcList,
pkgSrcRecords::Parser *Parse)
{
// try to find release
const pkgIndexFile& CurrentIndexFile = Parse->Index();
for (pkgSourceList::const_iterator S = SrcList->begin();
S != SrcList->end(); ++S)
{
vector<pkgIndexFile *> *Indexes = (*S)->GetIndexFiles();
for (vector<pkgIndexFile *>::const_iterator IF = Indexes->begin();
IF != Indexes->end(); ++IF)
{
if (&CurrentIndexFile == (*IF))
{
#if (APT_PKG_MAJOR >= 4 && APT_PKG_MINOR < 13)
std::string path = MetaIndexFileNameOnDisk(*S);
#else
std::string path = (*S)->LocalFileName();
#endif
if (path != "")
{
indexRecords records;
records.Load(path);
return records.GetSuite();
}
}
}
}
return "";
}
/*}}}*/
// FindSrc - Find a source record /*{{{*/
// ---------------------------------------------------------------------
/* */
static pkgSrcRecords::Parser *FindSrc(const char *Name,pkgRecords &Recs,
pkgSrcRecords &SrcRecs,string &Src,
CacheFile &CacheFile)
{
string VerTag, UserRequestedVerTag;
string ArchTag = "";
string RelTag = _config->Find("APT::Default-Release");
string TmpSrc = Name;
pkgDepCache *Cache = CacheFile.GetDepCache();
// extract release
size_t found = TmpSrc.find_last_of("/");
if (found != string::npos)
{
RelTag = TmpSrc.substr(found+1);
TmpSrc = TmpSrc.substr(0,found);
}
// extract the version
found = TmpSrc.find_last_of("=");
if (found != string::npos)
{
VerTag = UserRequestedVerTag = TmpSrc.substr(found+1);
TmpSrc = TmpSrc.substr(0,found);
}
// extract arch
found = TmpSrc.find_last_of(":");
if (found != string::npos)
{
ArchTag = TmpSrc.substr(found+1);
TmpSrc = TmpSrc.substr(0,found);
}
/* Lookup the version of the package we would install if we were to
install a version and determine the source package name, then look
in the archive for a source package of the same name. */
bool MatchSrcOnly = _config->FindB("APT::Get::Only-Source");
pkgCache::PkgIterator Pkg;
if (ArchTag != "")
Pkg = Cache->FindPkg(TmpSrc, ArchTag);
else
Pkg = Cache->FindPkg(TmpSrc);
// if we can't find a package but the user qualified with a arch,
// error out here
if (Pkg.end() && ArchTag != "")
{
Src = Name;
_error->Error(_("Can not find a package for architecture '%s'"),
ArchTag.c_str());
return 0;
}
if (MatchSrcOnly == false && Pkg.end() == false)
{
if(VerTag != "" || RelTag != "" || ArchTag != "")
{
bool fuzzy = false;
// we have a default release, try to locate the pkg. we do it like
// this because GetCandidateVer() will not "downgrade", that means
// "apt-get source -t stable apt" won't work on a unstable system
for (pkgCache::VerIterator Ver = Pkg.VersionList();; ++Ver)
{
// try first only exact matches, later fuzzy matches
if (Ver.end() == true)
{
if (fuzzy == true)
break;
fuzzy = true;
Ver = Pkg.VersionList();
// exit right away from the Pkg.VersionList() loop if we
// don't have any versions
if (Ver.end() == true)
break;
}
// ignore arches that are not for us
if (ArchTag != "" && Ver.Arch() != ArchTag)
continue;
// pick highest version for the arch unless the user wants
// something else
if (ArchTag != "" && VerTag == "" && RelTag == "")
if(Cache->VS().CmpVersion(VerTag, Ver.VerStr()) < 0)
VerTag = Ver.VerStr();
// We match against a concrete version (or a part of this version)
if (VerTag.empty() == false &&
(fuzzy == true || Cache->VS().CmpVersion(VerTag, Ver.VerStr()) != 0) && // exact match
(fuzzy == false || strncmp(VerTag.c_str(), Ver.VerStr(), VerTag.size()) != 0)) // fuzzy match
continue;
for (pkgCache::VerFileIterator VF = Ver.FileList();
VF.end() == false; ++VF)
{
/* If this is the status file, and the current version is not the
version in the status file (ie it is not installed, or somesuch)
then it is not a candidate for installation, ever. This weeds
out bogus entries that may be due to config-file states, or
other. */
if ((VF.File()->Flags & pkgCache::Flag::NotSource) ==
pkgCache::Flag::NotSource && Pkg.CurrentVer() != Ver)
continue;
// or we match against a release
if(VerTag.empty() == false ||
(VF.File().Archive() != 0 && VF.File().Archive() == RelTag) ||
(VF.File().Codename() != 0 && VF.File().Codename() == RelTag))
{
pkgRecords::Parser &Parse = Recs.Lookup(VF);
Src = Parse.SourcePkg();
// no SourcePkg name, so it is the "binary" name
if (Src.empty() == true)
Src = TmpSrc;
// the Version we have is possibly fuzzy or includes binUploads,
// so we use the Version of the SourcePkg (empty if same as package)
VerTag = Parse.SourceVer();
if (VerTag.empty() == true)
VerTag = Ver.VerStr();
break;
}
}
if (Src.empty() == false)
break;
}
}
if (Src == "" && ArchTag != "")
{
if (VerTag != "")
_error->Error(_("Can not find a package '%s' with version '%s'"),
Pkg.FullName().c_str(), VerTag.c_str());
if (RelTag != "")
_error->Error(_("Can not find a package '%s' with release '%s'"),
Pkg.FullName().c_str(), RelTag.c_str());
Src = Name;
return 0;
}
if (Src.empty() == true)
{
// if we don't have found a fitting package yet so we will
// choose a good candidate and proceed with that.
// Maybe we will find a source later on with the right VerTag
// or RelTag
pkgCache::VerIterator Ver = Cache->GetCandidateVer(Pkg);
if (Ver.end() == false)
{
pkgRecords::Parser &Parse = Recs.Lookup(Ver.FileList());
Src = Parse.SourcePkg();
if (VerTag.empty() == true)
VerTag = Parse.SourceVer();
}
}
}
if (Src.empty() == true)
{
Src = TmpSrc;
}
else
{
/* if we have a source pkg name, make sure to only search
for srcpkg names, otherwise apt gets confused if there
is a binary package "pkg1" and a source package "pkg1"
with the same name but that comes from different packages */
MatchSrcOnly = true;
if (Src != TmpSrc)
{
ioprintf(c1out, _("Picking '%s' as source package instead of '%s'\n"), Src.c_str(), TmpSrc.c_str());
}
}
// The best hit
pkgSrcRecords::Parser *Last = 0;
unsigned long Offset = 0;
string Version;
pkgSourceList *SrcList = CacheFile.GetSourceList();
/* Iterate over all of the hits, which includes the resulting
binary packages in the search */
pkgSrcRecords::Parser *Parse;
while (true)
{
SrcRecs.Restart();
while ((Parse = SrcRecs.Find(Src.c_str(), MatchSrcOnly)) != 0)
{
const string Ver = Parse->Version();
// See if we need to look for a specific release tag
if (RelTag != "" && UserRequestedVerTag == "")
{
const string Rel = GetReleaseForSourceRecord(SrcList, Parse);
if (Rel == RelTag)
{
Last = Parse;
Offset = Parse->Offset();
Version = Ver;
}
}
// Ignore all versions which doesn't fit
if (VerTag.empty() == false &&
Cache->VS().CmpVersion(VerTag, Ver) != 0) // exact match
continue;
// Newer version or an exact match? Save the hit
if (Last == 0 || Cache->VS().CmpVersion(Version,Ver) < 0) {
Last = Parse;
Offset = Parse->Offset();
Version = Ver;
}
// was the version check above an exact match?
// If so, we don't need to look further
if (VerTag.empty() == false && (VerTag == Ver))
break;
}
if (UserRequestedVerTag == "" && Version != "" && RelTag != "")
9 years ago
ioprintf(c1out, "Selected version '%s' (%s) for %s\n",
Version.c_str(), RelTag.c_str(), Src.c_str());
if (Last != 0 || VerTag.empty() == true)
break;
_error->Error(_("Can not find version '%s' of package '%s'"), VerTag.c_str(), TmpSrc.c_str());
return 0;
}
if (Last == 0 || Last->Jump(Offset) == false)
return 0;
return Last;
}
/*}}}*/
/* mark packages as automatically/manually installed. {{{*/
static bool DoMarkAuto(CommandLine &CmdL)
{
bool Action = true;
int AutoMarkChanged = 0;
OpTextProgress progress;
CacheFile Cache;
if (Cache.Open() == false)
return false;
if (strcasecmp(CmdL.FileList[0],"markauto") == 0)
Action = true;
else if (strcasecmp(CmdL.FileList[0],"unmarkauto") == 0)
Action = false;
for (const char **I = CmdL.FileList + 1; *I != 0; I++)
{
const char *S = *I;
// Locate the package
pkgCache::PkgIterator Pkg = Cache->FindPkg(S);
if (Pkg.end() == true) {
return _error->Error(_("Couldn't find package %s"),S);
}
else
{
if (!Action)
ioprintf(c1out,_("%s set to manually installed.\n"), Pkg.Name());
else
ioprintf(c1out,_("%s set to automatically installed.\n"),
Pkg.Name());
Cache->MarkAuto(Pkg,Action);
AutoMarkChanged++;
}
}
_error->Notice(_("This command is deprecated. Please use 'apt-mark auto' and 'apt-mark manual' instead."));
if (AutoMarkChanged && ! _config->FindB("APT::Get::Simulate",false))
return Cache->writeStateFile(NULL);
return false;
}
/*}}}*/
// DoDSelectUpgrade - Do an upgrade by following dselects selections /*{{{*/
// ---------------------------------------------------------------------
/* Follows dselect's selections */
static bool DoDSelectUpgrade(CommandLine &)
{
CacheFile Cache;
if (Cache.OpenForInstall() == false || Cache.CheckDeps() == false)
return false;
pkgDepCache::ActionGroup group(Cache);
// Install everything with the install flag set
pkgCache::PkgIterator I = Cache->PkgBegin();
for (;I.end() != true; ++I)
{
/* Install the package only if it is a new install, the autoupgrader
will deal with the rest */
if (I->SelectedState == pkgCache::State::Install)
Cache->MarkInstall(I,false);
}
/* Now install their deps too, if we do this above then order of
the status file is significant for | groups */
for (I = Cache->PkgBegin();I.end() != true; ++I)
{
/* Install the package only if it is a new install, the autoupgrader
will deal with the rest */
if (I->SelectedState == pkgCache::State::Install)
Cache->MarkInstall(I,true);
}
// Apply erasures now, they override everything else.
for (I = Cache->PkgBegin();I.end() != true; ++I)
{
// Remove packages
if (I->SelectedState == pkgCache::State::DeInstall ||
I->SelectedState == pkgCache::State::Purge)
Cache->MarkDelete(I,I->SelectedState == pkgCache::State::Purge);
}
/* Resolve any problems that dselect created, allupgrade cannot handle
such things. We do so quite aggressively too.. */
if (Cache->BrokenCount() != 0)
{
pkgProblemResolver Fix(Cache);
// Hold back held packages.
if (_config->FindB("APT::Ignore-Hold",false) == false)
{
for (pkgCache::PkgIterator I = Cache->PkgBegin(); I.end() == false; ++I)
{
if (I->SelectedState == pkgCache::State::Hold)
{
Fix.Protect(I);
Cache->MarkKeep(I);
}
}
}
if (Fix.Resolve() == false)
{
ShowBroken(c1out,Cache,false);
* merged from main Patches applied: * apt@packages.debian.org/apt--main--0--patch-100 Use debian.org address in mainline * apt@packages.debian.org/apt--main--0--patch-101 Update pot file * apt@packages.debian.org/apt--main--0--patch-102 Open 0.6.40 * apt@packages.debian.org/apt--main--0--patch-103 Patch from Jordi Mallach to mark some additional strings for translation * apt@packages.debian.org/apt--main--0--patch-104 Updated Catalan translation from Jordi Mallach * apt@packages.debian.org/apt--main--0--patch-105 Merge from bubulle@debian.org--2005/apt--main--0 * apt@packages.debian.org/apt--main--0--patch-106 Restore lost changelog entries * apt@packages.debian.org/apt--main--0--patch-107 Merge michael.vogt@ubuntu.com--2005/apt--progress-reporting--0 * apt@packages.debian.org/apt--main--0--patch-108 Merge michael.vogt@ubuntu.com--2005/apt--progress-reporting--0 * apt@packages.debian.org/apt--main--0--patch-109 Merge michael.vogt@ubuntu.com--2005/apt--progress-reporting--0 * apt@packages.debian.org/apt--main--0--patch-110 Merge michael.vogt@ubuntu.com--2005/apt--progress-reporting--0 * bubulle@debian.org--2005/apt--main--0--patch-90 Merge with Matt * bubulle@debian.org--2005/apt--main--0--patch-91 Updated Slovak translation * bubulle@debian.org--2005/apt--main--0--patch-92 Add apt-key French man page * bubulle@debian.org--2005/apt--main--0--patch-93 Update Greek translations * bubulle@debian.org--2005/apt--main--0--patch-94 Merge with Matt * bubulle@debian.org--2005/apt--main--0--patch-95 Sync PO files with the POT file/French translation update * michael.vogt@ubuntu.com--2005/apt--progress-reporting--0--base-0 tag of apt@packages.debian.org/apt--main--0--patch-85 * michael.vogt@ubuntu.com--2005/apt--progress-reporting--0--patch-1 * inital proof of concept code, understands what dpkg tells it already * michael.vogt@ubuntu.com--2005/apt--progress-reporting--0--patch-2 * progress reporting works now * michael.vogt@ubuntu.com--2005/apt--progress-reporting--0--patch-3 * added "APT::Status-Fd" variable * michael.vogt@ubuntu.com--2005/apt--progress-reporting--0--patch-4 * do i18n now too * michael.vogt@ubuntu.com--2005/apt--progress-reporting--0--patch-5 * define N_(x) if it is not defined already * michael.vogt@ubuntu.com--2005/apt--progress-reporting--0--patch-6 * PackageManager::DoInstall(int status_fd) added (does not break the ABI) * michael.vogt@ubuntu.com--2005/apt--progress-reporting--0--patch-7 * merged with apt--fixes--0 to make it build again * michael.vogt@ubuntu.com--2005/apt--progress-reporting--0--patch-8 * added support for "error" and "conffile-prompt" messages from dpkg * michael.vogt@ubuntu.com--2005/apt--progress-reporting--0--patch-9 merge with main * michael.vogt@ubuntu.com--2005/apt--progress-reporting--0--patch-10 * use sizeof() for all snprintf() uses; fix a potential line break problem in the status reading code; changed the N_() to _() calls * michael.vogt@ubuntu.com--2005/apt--progress-reporting--0--patch-11 * added APT::KeepFDs configuration list for file descriptors that apt should leave open (needed for various frontends like debconf, synaptic) * michael.vogt@ubuntu.com--2005/apt--progress-reporting--0--patch-12 * fixed a API breakage * michael.vogt@ubuntu.com--2005/apt--progress-reporting--0--patch-13 * doc added, should be releasable now * michael.vogt@ubuntu.com--2005/apt--progress-reporting--0--patch-14 * merged with apt--main--0 * michael.vogt@ubuntu.com--2005/apt--progress-reporting--0--patch-15 * more source comments, added Debug::DpkgPM debug code to inspect the dpkg<->apt communication, broke the abi (ok with matt) * michael.vogt@ubuntu.com--2005/apt--progress-reporting--0--patch-16 * the progress reporting has it's own "Debug::pkgDPkgProgressReporting" debug variable now * michael.vogt@ubuntu.com--2005/apt--progress-reporting--0--patch-17 * merged PackageOps and TranslatedPackageOps into a single Map with the new DpkgState struct * michael.vogt@ubuntu.com--2005/apt--progress-reporting--0--patch-18 * clear the APT::Keep-Fds configuration when it's no longer needed * michael.vogt@ubuntu.com--2005/apt--progress-reporting--0--patch-19 * rewrote the reading from dpkg so that it never blocks * michael.vogt@ubuntu.com--2005/apt--progress-reporting--0--patch-20 * merged the two status arrays into one * michael.vogt@ubuntu.com--2005/apt--progress-reporting--0--patch-21 * added support for download progress reporting too (for Kamion and base-config) * michael.vogt@ubuntu.com--2005/apt--progress-reporting--0--patch-22 * ABI break; added Configuration::Clear(string List, {int,string} value) added (to remove a single Value from a list); test/conf_clear.cc added * michael.vogt@ubuntu.com--2005/apt--progress-reporting--0--patch-23 * remvoed a debug string * michael.vogt@ubuntu.com--2005/apt--progress-reporting--0--patch-24 * soname changed, fixed a bug in the parsing code when dpkg send the same state more than once (at the end) * michael.vogt@ubuntu.com--2005/apt--progress-reporting--0--patch-25 * merged with apt@packages.debian.org/apt--main--0, added changelog entry for the 0.6.40.1 upload * michael.vogt@ubuntu.com--2005/apt--progress-reporting--0--patch-26 * fix a bug when out-of-order states are send from dpkg * michael.vogt@ubuntu.com--2005/apt--progress-reporting--0--patch-27 * changelog update * michael.vogt@ubuntu.com--2005/apt--progress-reporting--0--patch-28 * a real changelog entry now * michael.vogt@ubuntu.com--2005/apt--progress-reporting--0--patch-29 * changelog finalized * michael.vogt@ubuntu.com--2005/apt--progress-reporting--0--patch-30 * propper (and sane) support for pmerror and pmconffile added
17 years ago
return _error->Error(_("Internal error, problem resolver broke stuff"));
}
}
// Now upgrade everything
if (pkgAllUpgrade(Cache) == false)
{
ShowBroken(c1out,Cache,false);
* merged from main Patches applied: * apt@packages.debian.org/apt--main--0--patch-100 Use debian.org address in mainline * apt@packages.debian.org/apt--main--0--patch-101 Update pot file * apt@packages.debian.org/apt--main--0--patch-102 Open 0.6.40 * apt@packages.debian.org/apt--main--0--patch-103 Patch from Jordi Mallach to mark some additional strings for translation * apt@packages.debian.org/apt--main--0--patch-104 Updated Catalan translation from Jordi Mallach * apt@packages.debian.org/apt--main--0--patch-105 Merge from bubulle@debian.org--2005/apt--main--0 * apt@packages.debian.org/apt--main--0--patch-106 Restore lost changelog entries * apt@packages.debian.org/apt--main--0--patch-107 Merge michael.vogt@ubuntu.com--2005/apt--progress-reporting--0 * apt@packages.debian.org/apt--main--0--patch-108 Merge michael.vogt@ubuntu.com--2005/apt--progress-reporting--0 * apt@packages.debian.org/apt--main--0--patch-109 Merge michael.vogt@ubuntu.com--2005/apt--progress-reporting--0 * apt@packages.debian.org/apt--main--0--patch-110 Merge michael.vogt@ubuntu.com--2005/apt--progress-reporting--0 * bubulle@debian.org--2005/apt--main--0--patch-90 Merge with Matt * bubulle@debian.org--2005/apt--main--0--patch-91 Updated Slovak translation * bubulle@debian.org--2005/apt--main--0--patch-92 Add apt-key French man page * bubulle@debian.org--2005/apt--main--0--patch-93 Update Greek translations * bubulle@debian.org--2005/apt--main--0--patch-94 Merge with Matt * bubulle@debian.org--2005/apt--main--0--patch-95 Sync PO files with the POT file/French translation update * michael.vogt@ubuntu.com--2005/apt--progress-reporting--0--base-0 tag of apt@packages.debian.org/apt--main--0--patch-85 * michael.vogt@ubuntu.com--2005/apt--progress-reporting--0--patch-1 * inital proof of concept code, understands what dpkg tells it already * michael.vogt@ubuntu.com--2005/apt--progress-reporting--0--patch-2 * progress reporting works now * michael.vogt@ubuntu.com--2005/apt--progress-reporting--0--patch-3 * added "APT::Status-Fd" variable * michael.vogt@ubuntu.com--2005/apt--progress-reporting--0--patch-4 * do i18n now too * michael.vogt@ubuntu.com--2005/apt--progress-reporting--0--patch-5 * define N_(x) if it is not defined already * michael.vogt@ubuntu.com--2005/apt--progress-reporting--0--patch-6 * PackageManager::DoInstall(int status_fd) added (does not break the ABI) * michael.vogt@ubuntu.com--2005/apt--progress-reporting--0--patch-7 * merged with apt--fixes--0 to make it build again * michael.vogt@ubuntu.com--2005/apt--progress-reporting--0--patch-8 * added support for "error" and "conffile-prompt" messages from dpkg * michael.vogt@ubuntu.com--2005/apt--progress-reporting--0--patch-9 merge with main * michael.vogt@ubuntu.com--2005/apt--progress-reporting--0--patch-10 * use sizeof() for all snprintf() uses; fix a potential line break problem in the status reading code; changed the N_() to _() calls * michael.vogt@ubuntu.com--2005/apt--progress-reporting--0--patch-11 * added APT::KeepFDs configuration list for file descriptors that apt should leave open (needed for various frontends like debconf, synaptic) * michael.vogt@ubuntu.com--2005/apt--progress-reporting--0--patch-12 * fixed a API breakage * michael.vogt@ubuntu.com--2005/apt--progress-reporting--0--patch-13 * doc added, should be releasable now * michael.vogt@ubuntu.com--2005/apt--progress-reporting--0--patch-14 * merged with apt--main--0 * michael.vogt@ubuntu.com--2005/apt--progress-reporting--0--patch-15 * more source comments, added Debug::DpkgPM debug code to inspect the dpkg<->apt communication, broke the abi (ok with matt) * michael.vogt@ubuntu.com--2005/apt--progress-reporting--0--patch-16 * the progress reporting has it's own "Debug::pkgDPkgProgressReporting" debug variable now * michael.vogt@ubuntu.com--2005/apt--progress-reporting--0--patch-17 * merged PackageOps and TranslatedPackageOps into a single Map with the new DpkgState struct * michael.vogt@ubuntu.com--2005/apt--progress-reporting--0--patch-18 * clear the APT::Keep-Fds configuration when it's no longer needed * michael.vogt@ubuntu.com--2005/apt--progress-reporting--0--patch-19 * rewrote the reading from dpkg so that it never blocks * michael.vogt@ubuntu.com--2005/apt--progress-reporting--0--patch-20 * merged the two status arrays into one * michael.vogt@ubuntu.com--2005/apt--progress-reporting--0--patch-21 * added support for download progress reporting too (for Kamion and base-config) * michael.vogt@ubuntu.com--2005/apt--progress-reporting--0--patch-22 * ABI break; added Configuration::Clear(string List, {int,string} value) added (to remove a single Value from a list); test/conf_clear.cc added * michael.vogt@ubuntu.com--2005/apt--progress-reporting--0--patch-23 * remvoed a debug string * michael.vogt@ubuntu.com--2005/apt--progress-reporting--0--patch-24 * soname changed, fixed a bug in the parsing code when dpkg send the same state more than once (at the end) * michael.vogt@ubuntu.com--2005/apt--progress-reporting--0--patch-25 * merged with apt@packages.debian.org/apt--main--0, added changelog entry for the 0.6.40.1 upload * michael.vogt@ubuntu.com--2005/apt--progress-reporting--0--patch-26 * fix a bug when out-of-order states are send from dpkg * michael.vogt@ubuntu.com--2005/apt--progress-reporting--0--patch-27 * changelog update * michael.vogt@ubuntu.com--2005/apt--progress-reporting--0--patch-28 * a real changelog entry now * michael.vogt@ubuntu.com--2005/apt--progress-reporting--0--patch-29 * changelog finalized * michael.vogt@ubuntu.com--2005/apt--progress-reporting--0--patch-30 * propper (and sane) support for pmerror and pmconffile added
17 years ago
return _error->Error(_("Internal error, problem resolver broke stuff"));
}
return InstallPackages(Cache,false);
}
/*}}}*/
// DoClean - Remove download archives /*{{{*/
// ---------------------------------------------------------------------
/* */
static bool DoClean(CommandLine &)
{
std::string const archivedir = _config->FindDir("Dir::Cache::archives");
std::string const pkgcache = _config->FindFile("Dir::cache::pkgcache");
std::string const srcpkgcache = _config->FindFile("Dir::cache::srcpkgcache");
if (_config->FindB("APT::Get::Simulate") == true)
{
cout << "Del " << archivedir << "* " << archivedir << "partial/*"<< endl
<< "Del " << pkgcache << " " << srcpkgcache << endl;
return true;
}
// Lock the archive directory
FileFd Lock;
if (_config->FindB("Debug::NoLocking",false) == false)
{
int lock_fd = GetLock(archivedir + "lock");
if (lock_fd < 0)
return _error->Error(_("Unable to lock the download directory"));
Lock.Fd(lock_fd);
}
pkgAcquire Fetcher;
Fetcher.Clean(archivedir);
Fetcher.Clean(archivedir + "partial/");
pkgCacheFile::RemoveCaches();
return true;
}
/*}}}*/
// DoAutoClean - Smartly remove downloaded archives /*{{{*/
// ---------------------------------------------------------------------
/* This is similar to clean but it only purges things that cannot be
downloaded, that is old versions of cached packages. */
class LogCleaner : public pkgArchiveCleaner
{
protected:
virtual void Erase(const char *File,string Pkg,string Ver,struct stat &St)
{
c1out << "Del " << Pkg << " " << Ver << " [" << SizeToStr(St.st_size) << "B]" << endl;
if (_config->FindB("APT::Get::Simulate") == false)
unlink(File);
};
};
static bool DoAutoClean(CommandLine &)
{
// Lock the archive directory
FileFd Lock;
if (_config->FindB("Debug::NoLocking",false) == false)
{
int lock_fd = GetLock(_config->FindDir("Dir::Cache::Archives") + "lock");
if (lock_fd < 0)
return _error->Error(_("Unable to lock the download directory"));
Lock.Fd(lock_fd);
}
CacheFile Cache;
if (Cache.Open() == false)
return false;
LogCleaner Cleaner;
return Cleaner.Go(_config->FindDir("Dir::Cache::archives"),*Cache) &&
Cleaner.Go(_config->FindDir("Dir::Cache::archives") + "partial/",*Cache);
}
/*}}}*/
// DoDownload - download a binary /*{{{*/
// ---------------------------------------------------------------------
static bool DoDownload(CommandLine &CmdL)
{
CacheFile Cache;
if (Cache.ReadOnlyOpen() == false)
return false;
APT::CacheSetHelper helper(c0out);
APT::VersionSet verset = APT::VersionSet::FromCommandLine(Cache,
CmdL.FileList + 1, APT::VersionSet::CANDIDATE, helper);
if (verset.empty() == true)
return false;
AcqTextStatus Stat(ScreenWidth, _config->FindI("quiet", 0));
pkgAcquire Fetcher;
if (Fetcher.Setup(&Stat) == false)
return false;
pkgRecords Recs(Cache);
pkgSourceList *SrcList = Cache.GetSourceList();
// reuse the usual acquire methods for deb files, but don't drop them into
// the usual directories - keep everything in the current directory
std::vector<std::string> storefile(verset.size());
std::string const