summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Vogt <mvo@debian.org>2014-01-24 23:05:25 +0100
committerMichael Vogt <mvo@debian.org>2014-01-24 23:05:25 +0100
commit48e48cbdc47a0b29ac1b9d2b7d4eef61be73d06d (patch)
tree6c464b7197ba374f9952aeb1571e15a1453183f2
parentb18dd45f2c71fbdf5c0eef113e9e8e01f84b70a7 (diff)
parent34f7c486b10559997849c15c6b51577ec3f96bc1 (diff)
Merge remote-tracking branch 'mvo/debian/sid' into debian/experimental-no-abi-break
-rw-r--r--.gitignore1
-rw-r--r--apt-private/private-cmndline.cc5
-rw-r--r--apt-private/private-upgrade.cc9
-rw-r--r--apt-private/private-upgrade.h1
-rw-r--r--cmdline/apt-get.cc8
-rw-r--r--cmdline/apt-mark.cc5
-rw-r--r--cmdline/apt.cc32
-rw-r--r--methods/rred.cc39
-rwxr-xr-xtest/integration/test-apt-cli-upgrade34
9 files changed, 87 insertions, 47 deletions
diff --git a/.gitignore b/.gitignore
index 321b15471..69a229c3e 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,3 +1,4 @@
+*~
# build artifacts
/aclocal.m4
/autom4te.cache/
diff --git a/apt-private/private-cmndline.cc b/apt-private/private-cmndline.cc
index cbb40d42e..d6d7bca64 100644
--- a/apt-private/private-cmndline.cc
+++ b/apt-private/private-cmndline.cc
@@ -230,11 +230,6 @@ bool addArgumentsAPT(std::vector<CommandLine::Args> &Args, char const * const Cm
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-upgrade.cc b/apt-private/private-upgrade.cc
index e76b5d7fc..a97e6d25b 100644
--- a/apt-private/private-upgrade.cc
+++ b/apt-private/private-upgrade.cc
@@ -1,3 +1,4 @@
+
// Includes /*{{{*/
#include <apt-pkg/algorithms.h>
#include <apt-pkg/upgrade.h>
@@ -39,6 +40,14 @@ bool DoDistUpgrade(CommandLine &CmdL)
return UpgradeHelper(CmdL, 0);
}
/*}}}*/
+bool DoUpgrade(CommandLine &CmdL) /*{{{*/
+{
+ if (_config->FindB("APT::Get::Upgrade-Allow-New", false) == true)
+ return DoUpgradeWithAllowNewPackages(CmdL);
+ else
+ return DoUpgradeNoNewPackages(CmdL);
+}
+ /*}}}*/
// DoUpgradeNoNewPackages - Upgrade all packages /*{{{*/
// ---------------------------------------------------------------------
/* Upgrade all packages without installing new packages or erasing old
diff --git a/apt-private/private-upgrade.h b/apt-private/private-upgrade.h
index 050d3a668..5efc66bf7 100644
--- a/apt-private/private-upgrade.h
+++ b/apt-private/private-upgrade.h
@@ -5,6 +5,7 @@
bool DoDistUpgrade(CommandLine &CmdL);
+bool DoUpgrade(CommandLine &CmdL);
bool DoUpgradeNoNewPackages(CommandLine &CmdL);
bool DoUpgradeWithAllowNewPackages(CommandLine &CmdL);
diff --git a/cmdline/apt-get.cc b/cmdline/apt-get.cc
index 8a0772ce2..da7d28a1e 100644
--- a/cmdline/apt-get.cc
+++ b/cmdline/apt-get.cc
@@ -1679,14 +1679,6 @@ void SigWinch(int)
#endif
}
/*}}}*/
-bool DoUpgrade(CommandLine &CmdL) /*{{{*/
-{
- if (_config->FindB("APT::Get::Upgrade-Allow-New", false) == true)
- return DoUpgradeWithAllowNewPackages(CmdL);
- else
- return DoUpgradeNoNewPackages(CmdL);
-}
- /*}}}*/
int main(int argc,const char *argv[]) /*{{{*/
{
CommandLine::Dispatch Cmds[] = {{"update",&DoUpdate},
diff --git a/cmdline/apt-mark.cc b/cmdline/apt-mark.cc
index ebb1f9892..d3a3a780b 100644
--- a/cmdline/apt-mark.cc
+++ b/cmdline/apt-mark.cc
@@ -386,6 +386,11 @@ bool ShowHelp(CommandLine &CmdL)
"Commands:\n"
" auto - Mark the given packages as automatically installed\n"
" manual - Mark the given packages as manually installed\n"
+ " hold - Mark a package as held back\n"
+ " unhold - Unset a package set as held back\n"
+ " showauto - Print the list of automatically installed packages\n"
+ " showmanual - Print the list of manually installed packages\n"
+ " showhold - Print the list of package on hold\n"
"\n"
"Options:\n"
" -h This help text.\n"
diff --git a/cmdline/apt.cc b/cmdline/apt.cc
index 07ade6b7c..6fe25e3f3 100644
--- a/cmdline/apt.cc
+++ b/cmdline/apt.cc
@@ -81,7 +81,8 @@ bool ShowHelp(CommandLine &CmdL)
" install - install packages\n"
" remove - remove packages\n"
"\n"
- " upgrade - upgrade the systems packages\n"
+ " upgrade - upgrade the system by installing/upgrading packages\n"
+ "full-upgrade - upgrade the system by removing/installing/upgrading packages\n"
"\n"
" edit-sources - edit the source information file\n"
);
@@ -89,29 +90,29 @@ 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},
+ CommandLine::Dispatch Cmds[] = {
+ // query
+ {"list",&List},
{"search", &FullTextSearch},
{"show", &APT::Cmd::ShowPackage},
+
// package stuff
{"install",&DoInstall},
{"remove", &DoInstall},
{"purge", &DoInstall},
+
// system wide stuff
{"update",&DoUpdate},
- {"upgrade",&DoAptUpgrade},
+ {"upgrade",&DoUpgrade},
+ {"full-upgrade",&DoDistUpgrade},
+ // for compat with muscle memory
+ {"dist-upgrade",&DoDistUpgrade},
+
// misc
{"edit-sources",&EditSources},
+
// helper
{"moo",&DoMoo},
{"help",&ShowHelp},
@@ -131,9 +132,10 @@ int main(int argc, const char *argv[]) /*{{{*/
return 100;
}
- // FIXME: move into a new libprivate/private-install.cc:Install()
- _config->Set("DPkgPM::Progress", "1");
- _config->Set("Apt::Color", "1");
+ // some different defaults
+ _config->CndSet("DPkgPM::Progress", "1");
+ _config->CndSet("Apt::Color", "1");
+ _config->CndSet("APT::Get::Upgrade-Allow-New", true);
// Parse the command line and initialize the package library
CommandLine CmdL(Args.data(), _config);
diff --git a/methods/rred.cc b/methods/rred.cc
index 313166160..d17ab110d 100644
--- a/methods/rred.cc
+++ b/methods/rred.cc
@@ -351,14 +351,27 @@ class Patch {
FileChanges filechanges;
MemBlock add_text;
+ static bool retry_fwrite(char *b, size_t l, FILE *f, Hashes *hash)
+ {
+ size_t r = 1;
+ while (r > 0 && l > 0)
+ {
+ r = fwrite(b, 1, l, f);
+ if (hash)
+ hash->Add((unsigned char*)b, r);
+ l -= r;
+ b += r;
+ }
+ return l == 0;
+ }
+
static void dump_rest(FILE *o, FILE *i, Hashes *hash)
{
char buffer[BLOCK_SIZE];
size_t l;
while (0 < (l = fread(buffer, 1, sizeof(buffer), i))) {
- fwrite(buffer, 1, l, o);
- if (hash)
- hash->Add((unsigned char*)buffer, l);
+ if (!retry_fwrite(buffer, l, o, hash))
+ break;
}
}
@@ -372,10 +385,7 @@ class Patch {
l = strlen(buffer);
if (l == 0 || buffer[l-1] == '\n')
n--;
- fwrite(buffer, 1, l, o);
-
- if (hash)
- hash->Add((unsigned char*)buffer, l);
+ retry_fwrite(buffer, l, o, hash);
}
}
@@ -392,17 +402,8 @@ class Patch {
}
}
- static bool dump_mem(FILE *o, char *p, size_t s, Hashes *hash) {
- size_t r;
- while (s > 0) {
- r = fwrite(p, 1, s, o);
- if (hash)
- hash->Add((unsigned char*)p, s);
- s -= r;
- p += r;
- if (r == 0) return false;
- }
- return true;
+ static void dump_mem(FILE *o, char *p, size_t s, Hashes *hash) {
+ retry_fwrite(p, s, o, hash);
}
public:
@@ -455,7 +456,7 @@ class Patch {
filechanges.add_change(ch);
break;
}
- } else { /* !cmdwaanted */
+ } else { /* !cmdwanted */
if (buffer[0] == '.' && buffer[1] == '\n') {
cmdwanted = true;
filechanges.add_change(ch);
diff --git a/test/integration/test-apt-cli-upgrade b/test/integration/test-apt-cli-upgrade
new file mode 100755
index 000000000..163a55576
--- /dev/null
+++ b/test/integration/test-apt-cli-upgrade
@@ -0,0 +1,34 @@
+#!/bin/sh
+set -e
+
+TESTDIR=$(readlink -f $(dirname $0))
+. $TESTDIR/framework
+
+setupenvironment
+configarchitecture "i386"
+
+insertpackage 'unstable' 'foo' 'all' '2.0' 'Depends: foo-new-dependency'
+insertpackage 'unstable' 'foo-new-dependency' 'all' '2.0'
+insertinstalledpackage 'foo' 'all' '1.0'
+
+setupaptarchive
+
+APTARCHIVE=$(readlink -f ./aptarchive)
+
+# default is to allow new dependencies
+testequal "Calculating upgrade... Done
+The following NEW packages will be installed:
+ foo-new-dependency
+The following packages will be upgraded:
+ foo
+1 upgraded, 1 newly installed, 0 to remove and 0 not upgraded.
+Inst foo-new-dependency (2.0 unstable [all])
+Inst foo [1.0] (2.0 unstable [all])
+Conf foo-new-dependency (2.0 unstable [all])
+Conf foo (2.0 unstable [all])" apt upgrade -qq -s
+
+# ensure
+testequal "Calculating upgrade... Done
+The following packages have been kept back:
+ foo
+0 upgraded, 0 newly installed, 0 to remove and 1 not upgraded." apt upgrade -qq -s --no-new-pkgs