diff options
Diffstat (limited to 'apt-private')
-rw-r--r-- | apt-private/acqprogress.cc | 2 | ||||
-rw-r--r-- | apt-private/makefile | 12 | ||||
-rw-r--r-- | apt-private/private-cacheset.cc | 8 | ||||
-rw-r--r-- | apt-private/private-cmndline.cc | 4 | ||||
-rw-r--r-- | apt-private/private-list.cc | 20 | ||||
-rw-r--r-- | apt-private/private-list.h | 2 | ||||
-rw-r--r-- | apt-private/private-main.cc | 9 | ||||
-rw-r--r-- | apt-private/private-main.h | 1 | ||||
-rw-r--r-- | apt-private/private-output.cc | 25 | ||||
-rw-r--r-- | apt-private/private-search.cc | 8 |
10 files changed, 70 insertions, 21 deletions
diff --git a/apt-private/acqprogress.cc b/apt-private/acqprogress.cc index fe7a45e12..0f5b53e50 100644 --- a/apt-private/acqprogress.cc +++ b/apt-private/acqprogress.cc @@ -267,7 +267,7 @@ bool AcqTextStatus::Pulse(pkgAcquire *Owner) else cout << '\r' << BlankLine << '\r' << Buffer << flush; if (_config->FindB("Apt::Color", false) == true) - cout << _config->Find("APT::Color::Neutral"); + cout << _config->Find("APT::Color::Neutral") << flush; memset(BlankLine,' ',strlen(Buffer)); BlankLine[strlen(Buffer)] = 0; diff --git a/apt-private/makefile b/apt-private/makefile index 09736c6d3..9a3fbdb29 100644 --- a/apt-private/makefile +++ b/apt-private/makefile @@ -8,9 +8,6 @@ HEADER_TARGETDIRS = apt-private # Bring in the default rules include ../buildlib/defaults.mak -# The library name and version (indirectly used from init.h) -include ../buildlib/libversion.mak - # The library name LIBRARY=apt-private MAJOR=0.0 @@ -18,12 +15,7 @@ MINOR=0 SLIBS=$(PTHREADLIB) -lapt-pkg CXXFLAGS += -fvisibility=hidden -fvisibility-inlines-hidden -PRIVATES=list install download output cachefile cacheset update upgrade cmndline moo search show main utils sources -SOURCE += $(foreach private, $(PRIVATES), private-$(private).cc) -HEADERS += $(foreach private, $(PRIVATES), private-$(private).h) - -SOURCE+= acqprogress.cc -HEADERS+= acqprogress.h private-cacheset.h +SOURCE = $(wildcard *.cc) +HEADERS = $(addprefix apt-private/,$(wildcard *.h)) -HEADERS := $(addprefix apt-private/,$(HEADERS)) include $(LIBRARY_H) diff --git a/apt-private/private-cacheset.cc b/apt-private/private-cacheset.cc index 4a63c7e81..e37e7b227 100644 --- a/apt-private/private-cacheset.cc +++ b/apt-private/private-cacheset.cc @@ -73,7 +73,13 @@ bool GetLocalitySortedVersionSet(pkgCacheFile &CacheFile, else { pkgPolicy *policy = CacheFile.GetPolicy(); - output_set.insert(policy->GetCandidateVer(P)); + if (policy->GetCandidateVer(P).IsGood()) + output_set.insert(policy->GetCandidateVer(P)); + else + // no candidate, this may happen for packages in + // dpkg "deinstall ok config-file" state - we pick the first ver + // (which should be the only one) + output_set.insert(P.VersionList()); } } progress.Done(); diff --git a/apt-private/private-cmndline.cc b/apt-private/private-cmndline.cc index 682be0a19..a21a9dc8c 100644 --- a/apt-private/private-cmndline.cc +++ b/apt-private/private-cmndline.cc @@ -116,7 +116,7 @@ static bool addArgumentsAPTConfig(std::vector<CommandLine::Args> &Args, char con static bool addArgumentsAPTGet(std::vector<CommandLine::Args> &Args, char const * const Cmd)/*{{{*/ { if (CmdMatches("install", "remove", "purge", "upgrade", "dist-upgrade", - "dselect-upgrade", "autoremove")) + "dselect-upgrade", "autoremove", "full-upgrade")) { addArg(0, "show-progress", "DpkgPM::Progress", 0); addArg('f', "fix-broken", "APT::Get::Fix-Broken", 0); @@ -163,7 +163,7 @@ static bool addArgumentsAPTGet(std::vector<CommandLine::Args> &Args, char const if (CmdMatches("install", "remove", "purge", "upgrade", "dist-upgrade", "deselect-upgrade", "autoremove", "clean", "autoclean", "check", - "build-dep")) + "build-dep", "full-upgrade")) { addArg('s', "simulate", "APT::Get::Simulate", 0); addArg('s', "just-print", "APT::Get::Simulate", 0); diff --git a/apt-private/private-list.cc b/apt-private/private-list.cc index 7664ca134..b69002103 100644 --- a/apt-private/private-list.cc +++ b/apt-private/private-list.cc @@ -99,14 +99,13 @@ static void ListAllVersions(pkgCacheFile &CacheFile, pkgRecords &records,/*{{{*/ /*}}}*/ // list - list package based on criteria /*{{{*/ // --------------------------------------------------------------------- -bool List(CommandLine &Cmd) +bool DoList(CommandLine &Cmd) { pkgCacheFile CacheFile; pkgCache *Cache = CacheFile.GetPkgCache(); - pkgRecords records(CacheFile); - if (unlikely(Cache == NULL)) return false; + pkgRecords records(CacheFile); const char **patterns; const char *all_pattern[] = { "*", NULL}; @@ -131,10 +130,11 @@ bool List(CommandLine &Cmd) Cache->Head().PackageCount, _("Listing")); GetLocalitySortedVersionSet(CacheFile, bag, matcher, progress); + bool ShowAllVersions = _config->FindB("APT::Cmd::All-Versions", false); for (LocalitySortedVersionSet::iterator V = bag.begin(); V != bag.end(); ++V) { std::stringstream outs; - if(_config->FindB("APT::Cmd::All-Versions", false) == true) + if(ShowAllVersions == true) { ListAllVersions(CacheFile, records, V.ParentPkg(), outs, includeSummary); output_map.insert(std::make_pair<std::string, std::string>( @@ -152,6 +152,18 @@ bool List(CommandLine &Cmd) std::cout << (*K).second << std::endl; + // be nice and tell the user if there is more to see + if (bag.size() == 1 && ShowAllVersions == false) + { + // start with -1 as we already displayed one version + int versions = -1; + pkgCache::VerIterator Ver = *bag.begin(); + for ( ; Ver.end() == false; Ver++) + versions++; + if (versions > 0) + _error->Notice(P_("There is %i additional version. Please use the '-a' switch to see it", "There are %i additional versions. Please use the '-a' switch to see them.", versions), versions); + } + return true; } diff --git a/apt-private/private-list.h b/apt-private/private-list.h index 461f527cb..aa2677764 100644 --- a/apt-private/private-list.h +++ b/apt-private/private-list.h @@ -5,7 +5,7 @@ class CommandLine; -APT_PUBLIC bool List(CommandLine &Cmd); +APT_PUBLIC bool DoList(CommandLine &Cmd); #endif diff --git a/apt-private/private-main.cc b/apt-private/private-main.cc index 2d3965172..668b1733a 100644 --- a/apt-private/private-main.cc +++ b/apt-private/private-main.cc @@ -8,9 +8,18 @@ #include <iostream> #include <string.h> #include <unistd.h> +#include <signal.h> #include <apti18n.h> + +void InitSignals() +{ + // Setup the signals + signal(SIGPIPE,SIG_IGN); +} + + void CheckSimulateMode(CommandLine &CmdL) { // simulate user-friendly if apt-get has no root privileges diff --git a/apt-private/private-main.h b/apt-private/private-main.h index 23d4aca68..a03bf4441 100644 --- a/apt-private/private-main.h +++ b/apt-private/private-main.h @@ -6,5 +6,6 @@ class CommandLine; APT_PUBLIC void CheckSimulateMode(CommandLine &CmdL); +APT_PUBLIC void InitSignals(); #endif diff --git a/apt-private/private-output.cc b/apt-private/private-output.cc index bbd8545ad..7f3eef6c2 100644 --- a/apt-private/private-output.cc +++ b/apt-private/private-output.cc @@ -22,6 +22,7 @@ #include <iostream> #include <langinfo.h> #include <unistd.h> +#include <signal.h> #include <apti18n.h> /*}}}*/ @@ -32,8 +33,24 @@ std::ostream c0out(0); std::ostream c1out(0); std::ostream c2out(0); std::ofstream devnull("/dev/null"); + + unsigned int ScreenWidth = 80 - 1; /* - 1 for the cursor */ +// SigWinch - Window size change signal handler /*{{{*/ +// --------------------------------------------------------------------- +/* */ +static void SigWinch(int) +{ + // Riped from GNU ls +#ifdef TIOCGWINSZ + struct winsize ws; + + if (ioctl(1, TIOCGWINSZ, &ws) != -1 && ws.ws_col >= 5) + ScreenWidth = ws.ws_col - 1; +#endif +} + /*}}}*/ bool InitOutput() /*{{{*/ { if (!isatty(STDOUT_FILENO) && _config->FindI("quiet", -1) == -1) @@ -47,6 +64,10 @@ bool InitOutput() /*{{{*/ if (_config->FindI("quiet",0) > 1) c1out.rdbuf(devnull.rdbuf()); + // deal with window size changes + signal(SIGWINCH,SigWinch); + SigWinch(0); + if(!isatty(1)) { _config->Set("APT::Color", "false"); @@ -146,6 +167,10 @@ static std::string GetArchitecture(pkgCacheFile &CacheFile, pkgCache::PkgIterato pkgCache::VerIterator inst = P.CurrentVer(); pkgCache::VerIterator cand = policy->GetCandidateVer(P); + // this may happen for packages in dpkg "deinstall ok config-file" state + if (inst.IsGood() == false && cand.IsGood() == false) + return P.VersionList().Arch(); + return inst ? inst.Arch() : cand.Arch(); } /*}}}*/ diff --git a/apt-private/private-search.cc b/apt-private/private-search.cc index 8106333b6..ecd5d7fad 100644 --- a/apt-private/private-search.cc +++ b/apt-private/private-search.cc @@ -68,8 +68,12 @@ bool FullTextSearch(CommandLine &CmdL) /*{{{*/ const char *pattern = patterns[i]; all_found &= ( strstr(V.ParentPkg().Name(), pattern) != NULL || - parser.ShortDesc().find(pattern) != std::string::npos || - parser.LongDesc().find(pattern) != std::string::npos); + strcasestr(parser.ShortDesc().c_str(), pattern) != NULL || + strcasestr(parser.LongDesc().c_str(), pattern) != NULL); + // search patterns are AND by default so we can skip looking further + // on the first mismatch + if(all_found == false) + break; } if (all_found) { |