]> git.saurik.com Git - apt.git/commitdiff
Merge remote-tracking branch 'mvo/debian/sid' into debian/experimental-no-abi-break
authorMichael Vogt <mvo@debian.org>
Sat, 18 Jan 2014 07:51:53 +0000 (08:51 +0100)
committerMichael Vogt <mvo@debian.org>
Sat, 18 Jan 2014 07:51:53 +0000 (08:51 +0100)
apt-private/private-cacheset.cc
apt-private/private-cmndline.cc
apt-private/private-list.cc
apt-private/private-output.cc
apt-private/private-show.cc
apt-private/private-sources.cc
cmdline/apt.cc
test/integration/framework
test/integration/test-apt-binary [new file with mode: 0755]

index 6fb2240103c437f99f37ce91d900dd347c7a73b8..a7dc0e800154f6c14135ec2be283c36ed09d789a 100644 (file)
@@ -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();
index 28309af07304c515250d26ef32902023b5ab73f3..cbb40d42e7281d48111e4fc0d7ec440868e38a4b 100644 (file)
@@ -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
index a02ebf02d091676e8d5c601a6b5cdc9133c9793c..fbb66d20425e9e4b8f21b395e7e5ff0e41be8f2c 100644 (file)
@@ -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 {
index 91d13f31b8728ec69d07d08f56cb9f6bfdf4338a..a8bbad9e590c8de9195eafce8dea64fdc3b19b20 100644 (file)
@@ -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;
       }
    }
index ddc75dbeb479520eed3fdff47a4f4d190958b003..0aa42ecce9e550d9bf001d5229d2b54f81805e0c 100644 (file)
@@ -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)
index 65706e785fcdf451caa214e858fa903e0f900ee5..41cf6b31323cf912792fbbd52f52cf41f81d8c8e 100644 (file)
@@ -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(
index 4bcae0aba8ac71a07f9bc30d4e2679e899d83af7..61d5d938aba4c7267bf2a1218a1f290801ed26d8 100644 (file)
@@ -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 ||
index 2fe059280f3b0baf4ef7948364ddb5ae3bfad25d..ca2f9005054d7b4d890a2a4cb654ad406c63d76f 100644 (file)
@@ -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 (executable)
index 0000000..8d5df90
--- /dev/null
@@ -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
+