summaryrefslogtreecommitdiff
path: root/cmdline
diff options
context:
space:
mode:
Diffstat (limited to 'cmdline')
-rw-r--r--cmdline/apt-cache.cc10
-rw-r--r--cmdline/apt-get.cc134
-rwxr-xr-xcmdline/apt-key33
-rwxr-xr-xcmdline/apt-report-mirror-failure24
-rw-r--r--cmdline/makefile6
5 files changed, 156 insertions, 51 deletions
diff --git a/cmdline/apt-cache.cc b/cmdline/apt-cache.cc
index 0e950310b..f3bbb9cf3 100644
--- a/cmdline/apt-cache.cc
+++ b/cmdline/apt-cache.cc
@@ -929,7 +929,11 @@ bool XVcg(CommandLine &CmdL)
Shapes[ShapeMap[Pkg->ID]]);
}
-
+
+ delete[] Show;
+ delete[] Flags;
+ delete[] ShapeMap;
+
printf("}\n");
return true;
}
@@ -1269,7 +1273,9 @@ bool DisplayRecord(pkgCache::VerIterator V)
return true;
}
/*}}}*/
-
+// Search - Perform a search /*{{{*/
+// ---------------------------------------------------------------------
+/* This searches the package names and package descriptions for a pattern */
struct ExDescFile
{
pkgCache::DescFile *Df;
diff --git a/cmdline/apt-get.cc b/cmdline/apt-get.cc
index ab6dca388..708ac4cc0 100644
--- a/cmdline/apt-get.cc
+++ b/cmdline/apt-get.cc
@@ -868,8 +868,11 @@ bool InstallPackages(CacheFile &Cache,bool ShwKept,bool Ask = true,
if (unsigned(Buf.f_bfree) < (FetchBytes - FetchPBytes)/Buf.f_bsize)
{
struct statfs Stat;
- if (statfs(OutputDir.c_str(),&Stat) != 0 ||
- unsigned(Stat.f_type) != RAMFS_MAGIC)
+ if (statfs(OutputDir.c_str(),&Stat) != 0
+#if HAVE_STRUCT_STATFS_F_TYPE
+ || unsigned(Stat.f_type) != RAMFS_MAGIC
+#endif
+ )
return _error->Error(_("You don't have enough free space in %s."),
OutputDir.c_str());
}
@@ -1217,17 +1220,25 @@ pkgSrcRecords::Parser *FindSrc(const char *Name,pkgRecords &Recs,
{
// We want to pull the version off the package specification..
string VerTag;
+ string DefRel;
string TmpSrc = Name;
- string::size_type Slash = TmpSrc.rfind('=');
+ const size_t found = TmpSrc.find_last_of("/=");
// honor default release
- string DefRel = _config->Find("APT::Default-Release");
+ if (found != string::npos && TmpSrc[found] == '/')
+ {
+ DefRel = TmpSrc.substr(found+1);
+ TmpSrc = TmpSrc.substr(0,found);
+ }
+ else
+ DefRel = _config->Find("APT::Default-Release");
+
pkgCache::PkgIterator Pkg = Cache.FindPkg(TmpSrc);
- if (Slash != string::npos)
+ if (found != string::npos && TmpSrc[found] == '=')
{
- VerTag = string(TmpSrc.begin() + Slash + 1,TmpSrc.end());
- TmpSrc = string(TmpSrc.begin(),TmpSrc.begin() + Slash);
+ VerTag = TmpSrc.substr(found+1);
+ TmpSrc = TmpSrc.substr(0,found);
}
else if(!Pkg.end() && DefRel.empty() == false)
{
@@ -1249,10 +1260,13 @@ pkgSrcRecords::Parser *FindSrc(const char *Name,pkgRecords &Recs,
pkgCache::Flag::NotSource && Pkg.CurrentVer() != Ver)
continue;
- //std::cout << VF.File().Archive() << std::endl;
- if(VF.File().Archive() && (VF.File().Archive() == DefRel))
+ if((VF.File().Archive() != 0 && VF.File().Archive() == DefRel) ||
+ (VF.File().Codename() != 0 && VF.File().Codename() == DefRel))
{
- VerTag = Ver.VerStr();
+ pkgRecords::Parser &Parse = Recs.Lookup(VF);
+ VerTag = Parse.SourceVer();
+ if (VerTag.empty())
+ VerTag = Ver.VerStr();
break;
}
}
@@ -1306,7 +1320,7 @@ pkgSrcRecords::Parser *FindSrc(const char *Name,pkgRecords &Recs,
// show name mismatches
if (IsMatch == true && Parse->Package() != Src)
- ioprintf(c1out, _("No source package '%s' picking '%s' instead\n"), Parse->Package().c_str(), Src.c_str());
+ ioprintf(c1out, _("No source package '%s' picking '%s' instead\n"), Src.c_str(), Parse->Package().c_str());
if (VerTag.empty() == false)
{
@@ -1400,20 +1414,29 @@ bool DoAutomaticRemove(CacheFile &Cache)
bool Debug = _config->FindI("Debug::pkgAutoRemove",false);
bool doAutoRemove = _config->FindB("APT::Get::AutomaticRemove", false);
bool hideAutoRemove = _config->FindB("APT::Get::HideAutoRemove");
- pkgDepCache::ActionGroup group(*Cache);
+ pkgDepCache::ActionGroup group(*Cache);
if(Debug)
std::cout << "DoAutomaticRemove()" << std::endl;
- if (_config->FindB("APT::Get::Remove",true) == false &&
- doAutoRemove == true)
+ // we don't want to autoremove and we don't want to see it, so why calculating?
+ if (doAutoRemove == false && hideAutoRemove == true)
+ return true;
+
+ if (doAutoRemove == true &&
+ _config->FindB("APT::Get::Remove",true) == false)
{
c1out << _("We are not supposed to delete stuff, can't start "
"AutoRemover") << std::endl;
- doAutoRemove = false;
+ return false;
}
+ bool purgePkgs = _config->FindB("APT::Get::Purge", false);
+ bool smallList = (hideAutoRemove == false &&
+ strcasecmp(_config->Find("APT::Get::HideAutoRemove","").c_str(),"small") == 0);
+
string autoremovelist, autoremoveversions;
+ unsigned long autoRemoveCount = 0;
// look over the cache to see what can be removed
for (pkgCache::PkgIterator Pkg = Cache->PkgBegin(); ! Pkg.end(); ++Pkg)
{
@@ -1422,30 +1445,43 @@ bool DoAutomaticRemove(CacheFile &Cache)
if(Pkg.CurrentVer() != 0 || Cache[Pkg].Install())
if(Debug)
std::cout << "We could delete %s" << Pkg.Name() << std::endl;
-
- // only show stuff in the list that is not yet marked for removal
- if(Cache[Pkg].Delete() == false)
- {
- autoremovelist += string(Pkg.Name()) + " ";
- autoremoveversions += string(Cache[Pkg].CandVersion) + "\n";
- }
+
if (doAutoRemove)
{
if(Pkg.CurrentVer() != 0 &&
Pkg->CurrentState != pkgCache::State::ConfigFiles)
- Cache->MarkDelete(Pkg, _config->FindB("APT::Get::Purge", false));
+ Cache->MarkDelete(Pkg, purgePkgs);
else
Cache->MarkKeep(Pkg, false, false);
}
+ else
+ {
+ // only show stuff in the list that is not yet marked for removal
+ if(Cache[Pkg].Delete() == false)
+ {
+ // we don't need to fill the strings if we don't need them
+ if (smallList == true)
+ ++autoRemoveCount;
+ else
+ {
+ autoremovelist += string(Pkg.Name()) + " ";
+ autoremoveversions += string(Cache[Pkg].CandVersion) + "\n";
+ }
+ }
+ }
}
}
- if (!hideAutoRemove)
- ShowList(c1out, _("The following packages were automatically installed and are no longer required:"), autoremovelist, autoremoveversions);
- if (!doAutoRemove && !hideAutoRemove && autoremovelist.size() > 0)
+ // if we don't remove them, we should show them!
+ if (doAutoRemove == false && (autoremovelist.empty() == false || autoRemoveCount != 0))
+ {
+ if (smallList == false)
+ ShowList(c1out, _("The following packages were automatically installed and are no longer required:"), autoremovelist, autoremoveversions);
+ else
+ ioprintf(c1out, _("%lu packages were automatically installed and are no longer required.\n"), autoRemoveCount);
c1out << _("Use 'apt-get autoremove' to remove them.") << std::endl;
-
- // Now see if we destroyed anything
- if (Cache->BrokenCount() != 0)
+ }
+ // Now see if we had destroyed anything (if we had done anything)
+ else if (Cache->BrokenCount() != 0)
{
c1out << _("Hmm, seems like the AutoRemover destroyed something which really\n"
"shouldn't happen. Please file a bug report against apt.") << endl;
@@ -2106,6 +2142,33 @@ bool DoSource(CommandLine &CmdL)
if (Last == 0)
return _error->Error(_("Unable to find a source package for %s"),Src.c_str());
+ string srec = Last->AsStr();
+ string::size_type pos = srec.find("\nVcs-");
+ while (pos != string::npos)
+ {
+ pos += strlen("\nVcs-");
+ string vcs = srec.substr(pos,srec.find(":",pos)-pos);
+ if(vcs == "Browser")
+ {
+ pos = srec.find("\nVcs-", pos);
+ continue;
+ }
+ pos += vcs.length()+2;
+ string::size_type epos = srec.find("\n", pos);
+ string uri = srec.substr(pos,epos-pos).c_str();
+ ioprintf(c1out, _("NOTICE: '%s' packaging is maintained in "
+ "the '%s' version control system at:\n"
+ "%s\n"),
+ Src.c_str(), vcs.c_str(), uri.c_str());
+ if(vcs == "Bzr")
+ ioprintf(c1out,_("Please use:\n"
+ "bzr get %s\n"
+ "to retrieve the latest (possibly unreleased) "
+ "updates to the package.\n"),
+ uri.c_str());
+ break;
+ }
+
// Back track
vector<pkgSrcRecords::File> Lst;
if (Last->Files(Lst) == false)
@@ -2179,8 +2242,11 @@ bool DoSource(CommandLine &CmdL)
if (unsigned(Buf.f_bfree) < (FetchBytes - FetchPBytes)/Buf.f_bsize)
{
struct statfs Stat;
- if (statfs(OutputDir.c_str(),&Stat) != 0 ||
- unsigned(Stat.f_type) != RAMFS_MAGIC)
+ if (statfs(OutputDir.c_str(),&Stat) != 0
+#if HAVE_STRUCT_STATFS_F_TYPE
+ || unsigned(Stat.f_type) != RAMFS_MAGIC
+#endif
+ )
return _error->Error(_("You don't have enough free space in %s"),
OutputDir.c_str());
}
@@ -2550,7 +2616,10 @@ bool DoBuildDep(CommandLine &CmdL)
// Now we check the state of the packages,
if (Cache->BrokenCount() != 0)
- return _error->Error(_("Build-dependencies for %s could not be satisfied."),*I);
+ {
+ ShowBroken(cout, Cache, false);
+ return _error->Error(_("Build-dependencies for %s could not be satisfied."),*I);
+ }
}
if (InstallPackages(Cache, false, true) == false)
@@ -2752,7 +2821,6 @@ int main(int argc,const char *argv[]) /*{{{*/
{"remove",&DoInstall},
{"purge",&DoInstall},
{"autoremove",&DoInstall},
- {"purge",&DoInstall},
{"dist-upgrade",&DoDistUpgrade},
{"dselect-upgrade",&DoDSelectUpgrade},
{"build-dep",&DoBuildDep},
diff --git a/cmdline/apt-key b/cmdline/apt-key
index 7bb30240e..b579e5a53 100755
--- a/cmdline/apt-key
+++ b/cmdline/apt-key
@@ -10,13 +10,10 @@ GPG_CMD="gpg --ignore-time-conflict --no-options --no-default-keyring --secret-k
GPG="$GPG_CMD --keyring /etc/apt/trusted.gpg"
-MASTER_KEYRING=""
-ARCHIVE_KEYRING_URI=""
-#MASTER_KEYRING=/usr/share/keyrings/debian-master-keyring.gpg
-#ARCHIVE_KEYRING_URI=http://ftp.debian.org/debian/debian-archive-keyring.gpg
-
-ARCHIVE_KEYRING=/usr/share/keyrings/debian-archive-keyring.gpg
-REMOVED_KEYS=/usr/share/keyrings/debian-archive-removed-keys.gpg
+MASTER_KEYRING=/usr/share/keyrings/ubuntu-master-keyring.gpg
+ARCHIVE_KEYRING=/usr/share/keyrings/ubuntu-archive-keyring.gpg
+REMOVED_KEYS=/usr/share/keyrings/ubuntu-archive-removed-keys.gpg
+ARCHIVE_KEYRING_URI=http://archive.ubuntu.com/ubuntu/project/ubuntu-archive-keyring.gpg
add_keys_with_verify_against_master_keyring() {
ADD_KEYRING=$1
@@ -80,26 +77,30 @@ net_update() {
update() {
if [ ! -f $ARCHIVE_KEYRING ]; then
echo >&2 "ERROR: Can't find the archive-keyring"
- echo >&2 "Is the debian-archive-keyring package installed?"
+ echo >&2 "Is the ubuntu-keyring package installed?"
exit 1
fi
# add new keys from the package;
# we do not use add_keys_with_verify_against_master_keyring here,
- # because "update" is run on regular package updates. A
+ # because we "update" is run on regular package updates. A
# attacker might as well replace the master-archive-keyring file
# in the package and add his own keys. so this check wouldn't
# add any security. we *need* this check on net-update though
$GPG_CMD --quiet --batch --keyring $ARCHIVE_KEYRING --export | $GPG --import
- # remove no-longer supported/used keys
- keys=`$GPG_CMD --keyring $REMOVED_KEYS --with-colons --list-keys | grep ^pub | cut -d: -f5`
- for key in $keys; do
- if $GPG --list-keys --with-colons | grep ^pub | cut -d: -f5 | grep -q $key; then
- $GPG --quiet --batch --delete-key --yes ${key}
- fi
- done
+ if [ -r "$REMOVED_KEYS" ]; then
+ # remove no-longer supported/used keys
+ keys=`$GPG_CMD --keyring $REMOVED_KEYS --with-colons --list-keys | grep ^pub | cut -d: -f5`
+ for key in $keys; do
+ if $GPG --list-keys --with-colons | grep ^pub | cut -d: -f5 | grep -q $key; then
+ $GPG --quiet --batch --delete-key --yes ${key}
+ fi
+ done
+ else
+ echo "Warning: removed keys keyring $REMOVED_KEYS missing or not readable" >&2
+ fi
}
diff --git a/cmdline/apt-report-mirror-failure b/cmdline/apt-report-mirror-failure
new file mode 100755
index 000000000..ef77d4954
--- /dev/null
+++ b/cmdline/apt-report-mirror-failure
@@ -0,0 +1,24 @@
+#!/usr/bin/python
+
+import sys
+import urllib
+import apt_pkg
+
+apt_pkg.init()
+url = apt_pkg.Config.Find("Acquire::Mirror::ReportFailures", "")
+ #"http://people.ubuntu.com:9000/mirror-failure")
+ #"http://localhost:9000/mirror-failure")
+if not url:
+ sys.exit(0)
+
+print "Reporting mirror failure to '%s'" % url
+
+data = {}
+data['mirror'] = sys.argv[1]
+data['failurl'] = sys.argv[2]
+data['error'] = sys.argv[3]
+f = urllib.urlopen(url, urllib.urlencode(data))
+f.read()
+f.close()
+
+
diff --git a/cmdline/makefile b/cmdline/makefile
index 3260e375b..5ae6fb0f1 100644
--- a/cmdline/makefile
+++ b/cmdline/makefile
@@ -58,3 +58,9 @@ SOURCE=apt-mark
TO=$(BIN)
TARGET=program
include $(COPY_H)
+
+# The apt-key program
+SOURCE=apt-report-mirror-failure
+TO=$(BIN)
+TARGET=program
+include $(COPY_H)