summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Vogt <mvo@debian.org>2014-01-18 08:51:53 +0100
committerMichael Vogt <mvo@debian.org>2014-01-18 08:51:53 +0100
commit47d7761243a02368bb60b7227bd05a19ca4660d1 (patch)
treec298a2054c22aae934e25dd22a023efe76649b89
parentea62d40da6b402ff8d4d346971b98e24f096e521 (diff)
parent8a59cc322ac57c6662949e957611ed718a5f5119 (diff)
Merge remote-tracking branch 'mvo/debian/sid' into debian/experimental-no-abi-break
-rw-r--r--apt-private/private-cacheset.cc9
-rw-r--r--apt-private/private-cmndline.cc6
-rw-r--r--apt-private/private-list.cc12
-rw-r--r--apt-private/private-output.cc8
-rw-r--r--apt-private/private-show.cc5
-rw-r--r--apt-private/private-sources.cc5
-rw-r--r--cmdline/apt.cc41
-rw-r--r--test/integration/framework10
-rwxr-xr-xtest/integration/test-apt-binary47
9 files changed, 116 insertions, 27 deletions
diff --git a/apt-private/private-cacheset.cc b/apt-private/private-cacheset.cc
index 6fb224010..a7dc0e800 100644
--- a/apt-private/private-cacheset.cc
+++ b/apt-private/private-cacheset.cc
@@ -52,6 +52,15 @@ bool GetLocalitySortedVersionSet(pkgCacheFile &CacheFile,
output_set.insert(policy->GetCandidateVer(P));
}
}
+ else if (_config->FindB("APT::Cmd::Manual-Installed") == true)
+ {
+ if (P.CurrentVer() &&
+ ((*DepCache)[P].Flags & pkgCache::Flag::Auto) == false)
+ {
+ pkgPolicy *policy = CacheFile.GetPolicy();
+ output_set.insert(policy->GetCandidateVer(P));
+ }
+ }
else
{
pkgPolicy *policy = CacheFile.GetPolicy();
diff --git a/apt-private/private-cmndline.cc b/apt-private/private-cmndline.cc
index 28309af07..cbb40d42e 100644
--- a/apt-private/private-cmndline.cc
+++ b/apt-private/private-cmndline.cc
@@ -226,9 +226,15 @@ bool addArgumentsAPT(std::vector<CommandLine::Args> &Args, char const * const Cm
{
addArg(0,"installed","APT::Cmd::Installed",0);
addArg(0,"upgradable","APT::Cmd::Upgradable",0);
+ addArg(0,"manual-installed","APT::Cmd::Manual-Installed",0);
addArg('v', "verbose", "APT::Cmd::List-Include-Summary", 0);
addArg('a', "all-versions", "APT::Cmd::All-Versions", 0);
}
+ else if (CmdMatches("upgrade"))
+ {
+ // FIXME: find a better term
+ addArg(0,"dist","APT::Cmd::Dist-Upgrade", CommandLine::Boolean);
+ }
else if (addArgumentsAPTGet(Args, Cmd) || addArgumentsAPTCache(Args, Cmd))
{
// we have no (supported) command-name overlaps so far, so we call
diff --git a/apt-private/private-list.cc b/apt-private/private-list.cc
index a02ebf02d..fbb66d204 100644
--- a/apt-private/private-list.cc
+++ b/apt-private/private-list.cc
@@ -101,11 +101,15 @@ private:
/*}}}*/
void ListAllVersions(pkgCacheFile &CacheFile, pkgRecords &records, /*{{{*/
pkgCache::PkgIterator P,
- std::ostream &outs)
+ std::ostream &outs,
+ bool include_summary=true)
{
for (pkgCache::VerIterator Ver = P.VersionList();
Ver.end() == false; Ver++)
- ListSingleVersion(CacheFile, records, Ver, outs);
+ {
+ ListSingleVersion(CacheFile, records, Ver, outs, include_summary);
+ outs << "\n";
+ }
}
/*}}}*/
// list - list package based on criteria /*{{{*/
@@ -136,7 +140,7 @@ bool List(CommandLine &Cmd)
PackageNameMatcher matcher(patterns);
LocalitySortedVersionSet bag;
- OpTextProgress progress;
+ OpTextProgress progress(*_config);
progress.OverallProgress(0,
Cache->Head().PackageCount,
Cache->Head().PackageCount,
@@ -147,7 +151,7 @@ bool List(CommandLine &Cmd)
std::stringstream outs;
if(_config->FindB("APT::Cmd::All-Versions", false) == true)
{
- ListAllVersions(CacheFile, records, V.ParentPkg(), outs);
+ ListAllVersions(CacheFile, records, V.ParentPkg(), outs, includeSummary);
output_map.insert(std::make_pair<std::string, std::string>(
V.ParentPkg().Name(), outs.str()));
} else {
diff --git a/apt-private/private-output.cc b/apt-private/private-output.cc
index 91d13f31b..a8bbad9e5 100644
--- a/apt-private/private-output.cc
+++ b/apt-private/private-output.cc
@@ -114,11 +114,13 @@ std::string GetVersion(pkgCacheFile &CacheFile, pkgCache::VerIterator V)/*{{{*/
pkgCache::PkgIterator P = V.ParentPkg();
if (V == P.CurrentVer())
{
+ std::string inst_str = DeNull(V.VerStr());
+#if 0 // FIXME: do we want this or something like this?
pkgDepCache *DepCache = CacheFile.GetDepCache();
pkgDepCache::StateCache &state = (*DepCache)[P];
- std::string inst_str = DeNull(V.VerStr());
if (state.Upgradable())
return "**"+inst_str;
+#endif
return inst_str;
}
@@ -224,11 +226,11 @@ void ListSingleVersion(pkgCacheFile &CacheFile, pkgRecords &records, /*{{{*/
else
out << GetVersion(CacheFile, V);
}
- out << " " << GetArchitecture(CacheFile, P) << " ";
+ out << " " << GetArchitecture(CacheFile, P);
if (include_summary)
{
out << std::endl
- << " " << GetShortDescription(CacheFile, records, P)
+ << " " << GetShortDescription(CacheFile, records, P)
<< std::endl;
}
}
diff --git a/apt-private/private-show.cc b/apt-private/private-show.cc
index ddc75dbeb..0aa42ecce 100644
--- a/apt-private/private-show.cc
+++ b/apt-private/private-show.cc
@@ -74,13 +74,12 @@ bool DisplayRecord(pkgCacheFile &CacheFile, pkgCache::VerIterator V,
// write the description
pkgRecords Recs(*Cache);
+ // FIXME: show (optionally) all available translations(?)
pkgCache::DescIterator Desc = V.TranslatedDescription();
if (Desc.end() == false)
{
pkgRecords::Parser &P = Recs.Lookup(Desc.FileList());
- if (strcmp(Desc.LanguageCode(),"") != 0)
- out << "Description-lang: " << Desc.LanguageCode() << std::endl;
- out << "Description" << P.LongDesc();
+ out << "Description: " << P.LongDesc();
}
// write a final newline (after the description)
diff --git a/apt-private/private-sources.cc b/apt-private/private-sources.cc
index 65706e785..41cf6b313 100644
--- a/apt-private/private-sources.cc
+++ b/apt-private/private-sources.cc
@@ -32,6 +32,10 @@ bool EditSources(CommandLine &CmdL)
if (FileExists(sourceslist))
before.FromFile(sourceslist);
+ int lockfd = GetLock(sourceslist);
+ if (lockfd < 0)
+ return false;
+
do {
EditFileInSensibleEditor(sourceslist);
_error->PushToStack();
@@ -46,6 +50,7 @@ bool EditSources(CommandLine &CmdL)
}
_error->RevertToStack();
} while (res == false);
+ close(lockfd);
if (FileExists(sourceslist) && !before.VerifyFile(sourceslist)) {
strprintf(
diff --git a/cmdline/apt.cc b/cmdline/apt.cc
index 4bcae0aba..61d5d938a 100644
--- a/cmdline/apt.cc
+++ b/cmdline/apt.cc
@@ -71,13 +71,16 @@ bool ShowHelp(CommandLine &CmdL)
_("Usage: apt [options] command\n"
"\n"
"CLI for apt.\n"
- "Commands: \n"
+ "Basic commands: \n"
" list - list packages based on package names\n"
" search - search in package descriptions\n"
" show - show package details\n"
"\n"
" update - update list of available packages\n"
+ "\n"
" install - install packages\n"
+ " remove - remove packages\n"
+ "\n"
" upgrade - upgrade the systems packages\n"
"\n"
" edit-sources - edit the source information file\n"
@@ -86,6 +89,15 @@ bool ShowHelp(CommandLine &CmdL)
return true;
}
+// figure out what kind of upgrade the user wants
+bool DoAptUpgrade(CommandLine &CmdL)
+{
+ if (_config->FindB("Apt::Cmd::Dist-Upgrade"))
+ return DoDistUpgrade(CmdL);
+ else
+ return DoUpgradeWithAllowNewPackages(CmdL);
+}
+
int main(int argc, const char *argv[]) /*{{{*/
{
CommandLine::Dispatch Cmds[] = {{"list",&List},
@@ -94,8 +106,9 @@ int main(int argc, const char *argv[]) /*{{{*/
// needs root
{"install",&DoInstall},
{"remove", &DoInstall},
+ {"purge", &DoInstall},
{"update",&DoUpdate},
- {"upgrade",&DoUpgradeWithAllowNewPackages},
+ {"upgrade",&DoAptUpgrade},
// misc
{"edit-sources",&EditSources},
// helper
@@ -105,17 +118,6 @@ int main(int argc, const char *argv[]) /*{{{*/
std::vector<CommandLine::Args> Args = getCommandArgs("apt", CommandLine::GetCommand(Cmds, argc, argv));
- if(!isatty(1))
- {
- std::cerr << std::endl
- << "WARNING WARNING "
- << argv[0]
- << " is *NOT* intended for scripts "
- << "use at your own peril^Wrisk"
- << std::endl
- << std::endl;
- }
-
InitOutput();
// Set up gettext support
@@ -141,6 +143,19 @@ int main(int argc, const char *argv[]) /*{{{*/
return 100;
}
+ if(!isatty(STDOUT_FILENO) &&
+ _config->FindB("Apt::Cmd::Disable-Script-Warning", false) == false)
+ {
+ std::cerr << std::endl
+ << "WARNING: " << argv[0] << " "
+ << "does not have a stable CLI interface yet. "
+ << "Use with caution in scripts."
+ << std::endl
+ << std::endl;
+ }
+ if (!isatty(STDOUT_FILENO) && _config->FindI("quiet", -1) == -1)
+ _config->Set("quiet","1");
+
// See if the help should be shown
if (_config->FindB("help") == true ||
_config->FindB("version") == true ||
diff --git a/test/integration/framework b/test/integration/framework
index 2fe059280..ca2f90050 100644
--- a/test/integration/framework
+++ b/test/integration/framework
@@ -99,6 +99,7 @@ aptconfig() { runapt apt-config $*; }
aptcache() { runapt apt-cache $*; }
aptcdrom() { runapt apt-cdrom $*; }
aptget() { runapt apt-get $*; }
+apt() { runapt apt $*; }
aptftparchive() { runapt apt-ftparchive $*; }
aptkey() { runapt apt-key $*; }
aptmark() { runapt apt-mark $*; }
@@ -202,6 +203,7 @@ setupenvironment() {
echo "DPKG::options:: \"--log=${TMPWORKINGDIRECTORY}/rootdir/var/log/dpkg.log\";" >> aptconfig.conf
echo 'quiet::NoUpdate "true";' >> aptconfig.conf
echo "Acquire::https::CaInfo \"${TESTDIR}/apt.pem\";" > rootdir/etc/apt/apt.conf.d/99https
+ echo "Apt::Cmd::Disable-Script-Warning \"1\";" > rootdir/etc/apt/apt.conf.d/apt-binary
export LC_ALL=C
export PATH="${PATH}:/usr/local/sbin:/usr/sbin:/sbin"
configcompression '.' 'gz' #'bz2' 'lzma' 'xz'
@@ -288,7 +290,7 @@ setupsimplenativepackage() {
local VERSION="$3"
local RELEASE="${4:-unstable}"
local DEPENDENCIES="$5"
- local DESCRIPTION="${6:-"Description: an autogenerated dummy ${NAME}=${VERSION}/${RELEASE}
+ local DESCRIPTION="${6:-"an autogenerated dummy ${NAME}=${VERSION}/${RELEASE}
If you find such a package installed on your system,
something went horribly wrong! They are autogenerated
und used only by testcases and surf no other propose…"}"
@@ -338,7 +340,7 @@ buildsimplenativepackage() {
local VERSION="$3"
local RELEASE="${4:-unstable}"
local DEPENDENCIES="$5"
- local DESCRIPTION="${6:-"Description: an autogenerated dummy ${NAME}=${VERSION}/${RELEASE}
+ local DESCRIPTION="${6:-"an autogenerated dummy ${NAME}=${VERSION}/${RELEASE}
If you find such a package installed on your system,
something went horribly wrong! They are autogenerated
und used only by testcases and surf no other propose…"}"
@@ -535,7 +537,7 @@ insertpackage() {
local VERSION="$4"
local DEPENDENCIES="$5"
local PRIORITY="${6:-optional}"
- local DESCRIPTION="${7:-"Description: an autogenerated dummy ${NAME}=${VERSION}/${RELEASE}
+ local DESCRIPTION="${7:-"an autogenerated dummy ${NAME}=${VERSION}/${RELEASE}
If you find such a package installed on your system,
something went horribly wrong! They are autogenerated
und used only by testcases and surf no other propose…"}"
@@ -595,7 +597,7 @@ insertinstalledpackage() {
local DEPENDENCIES="$4"
local PRIORITY="${5:-optional}"
local STATUS="${6:-install ok installed}"
- local DESCRIPTION="${7:-"Description: an autogenerated dummy ${NAME}=${VERSION}/installed
+ local DESCRIPTION="${7:-"an autogenerated dummy ${NAME}=${VERSION}/installed
If you find such a package installed on your system,
something went horribly wrong! They are autogenerated
und used only by testcases and surf no other propose…"}"
diff --git a/test/integration/test-apt-binary b/test/integration/test-apt-binary
new file mode 100755
index 000000000..8d5df9051
--- /dev/null
+++ b/test/integration/test-apt-binary
@@ -0,0 +1,47 @@
+#!/bin/sh
+set -e
+
+TESTDIR=$(readlink -f $(dirname $0))
+. $TESTDIR/framework
+
+setupenvironment
+configarchitecture "i386"
+
+insertpackage 'unstable' 'foo' 'all' '1.0'
+insertinstalledpackage 'bar' 'i386' '1.0'
+
+insertinstalledpackage 'foobar' 'i386' '1.0'
+insertpackage 'unstable' 'foobar' 'i386' '2.0'
+
+setupaptarchive
+
+APTARCHIVE=$(readlink -f ./aptarchive)
+
+testequal "Listing...
+bar/now 1.0 [installed,local] i386
+foo/unstable 1.0 all
+foobar/unstable 2.0 [upgradable from: 1.0] i386" apt list
+
+testequal "Listing...
+foo/unstable 1.0 all
+foobar/unstable 2.0 [upgradable from: 1.0] i386" apt list "foo*"
+
+testequal "Listing...
+foobar/unstable 2.0 [upgradable from: 1.0] i386" apt list --upgradable
+
+# FIXME: hm, hm - does it make sense to have this different? shouldn't
+# we use "installed,upgradable" consitently?
+testequal "Listing...
+bar/now 1.0 [installed,local] i386
+foobar/now 1.0 [installed,upgradable to: 2.0] i386" apt list --installed
+
+testequal "Listing...
+foobar/unstable 2.0 [upgradable from: 1.0] i386
+foobar/now 1.0 [installed,upgradable to: 2.0] i386
+" apt list foobar --all-versions
+
+testequal "Listing...
+bar/now 1.0 [installed,local] i386
+ an autogenerated dummy bar=1.0/installed
+" apt list bar --verbose
+