Browse Source

add "apt full-upgrade" and tweak "apt upgrade"

There is a new "apt full-upgrade" that performs a apt-get dist-upgrade.
"apt dist-upgrade" is still supported as a alias. The "apt upgrade" code
is changed so that it mirrors the behavior of
"apt-get upgrade --with-new-pkgs" and also honors
"apt uprade --no-new-pkgs".
tags/devuan/2.0.1+devuan1
Michael Vogt 6 years ago
parent
commit
59e81cec3e
7 changed files with 62 additions and 28 deletions
  1. +1
    -0
      .gitignore
  2. +0
    -5
      apt-private/private-cmndline.cc
  3. +9
    -0
      apt-private/private-upgrade.cc
  4. +1
    -0
      apt-private/private-upgrade.h
  5. +0
    -8
      cmdline/apt-get.cc
  6. +17
    -15
      cmdline/apt.cc
  7. +34
    -0
      test/integration/test-apt-cli-upgrade

+ 1
- 0
.gitignore View File

@@ -1,3 +1,4 @@
*~
# build artifacts
/aclocal.m4
/autom4te.cache/


+ 0
- 5
apt-private/private-cmndline.cc View File

@@ -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


+ 9
- 0
apt-private/private-upgrade.cc View File

@@ -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


+ 1
- 0
apt-private/private-upgrade.h View File

@@ -5,6 +5,7 @@


bool DoDistUpgrade(CommandLine &CmdL);
bool DoUpgrade(CommandLine &CmdL);
bool DoUpgradeNoNewPackages(CommandLine &CmdL);
bool DoUpgradeWithAllowNewPackages(CommandLine &CmdL);



+ 0
- 8
cmdline/apt-get.cc View File

@@ -1677,14 +1677,6 @@ void SigWinch(int)
if (ioctl(1, TIOCGWINSZ, &ws) != -1 && ws.ws_col >= 5)
ScreenWidth = ws.ws_col - 1;
#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[]) /*{{{*/


+ 17
- 15
cmdline/apt.cc View File

@@ -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);


+ 34
- 0
test/integration/test-apt-cli-upgrade View File

@@ -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

Loading…
Cancel
Save