]> git.saurik.com Git - apt.git/commitdiff
cmdline/apt-get.cc: Add apt-get markauto, showauto and unmarkauto commands.
authorJulian Andres Klode <jak@debian.org>
Tue, 4 May 2010 15:52:36 +0000 (17:52 +0200)
committerJulian Andres Klode <jak@debian.org>
Tue, 4 May 2010 15:52:36 +0000 (17:52 +0200)
cmdline/apt-get.cc
cmdline/apt-mark
debian/changelog

index 26c731978bc442aae4fbd9cbde5ea03f4817b318..8f9faf158bb1f27097e46dad6a10be4e1be6d0c5 100644 (file)
@@ -2013,6 +2013,60 @@ bool DoInstall(CommandLine &CmdL)
 
    return InstallPackages(Cache,false);   
 }
+
+/* show automatically installed packages. */
+bool DoShowAuto(CommandLine &CmdL)
+{
+   OpProgress progress;
+   pkgCacheFile Cache;
+   if (Cache.Open(progress, false) == false)
+      return false;
+
+   for (pkgCache::PkgIterator P = Cache->PkgBegin(); P.end() == false; P++)
+      if (Cache[P].Flags & pkgCache::Flag::Auto)
+          ioprintf(c1out,_("%s\n"), P.Name());
+   return true;
+}
+
+/* mark packages as automatically/manually installed. */
+bool DoMarkAuto(CommandLine &CmdL)
+{
+   bool Action = true;
+   int AutoMarkChanged = 0;
+   OpTextProgress progress;
+   CacheFile Cache;
+   if (Cache.Open() == false)
+      return false;
+
+   if (strcasecmp(CmdL.FileList[0],"markauto") == 0)
+      Action = true;
+   else if (strcasecmp(CmdL.FileList[0],"unmarkauto") == 0)
+      Action = false;
+
+   for (const char **I = CmdL.FileList + 1; *I != 0; I++)
+   {
+      const char *S = *I;
+      // Locate the package
+      pkgCache::PkgIterator Pkg = Cache->FindPkg(S);
+      if (Pkg.end() == true) {
+         return _error->Error(_("Couldn't find package %s"),S);
+      }
+      else
+      {
+         if (!Action)
+            ioprintf(c1out,_("%s set to manually installed.\n"), Pkg.Name());
+         else
+            ioprintf(c1out,_("%s set to automatically installed.\n"),
+                      Pkg.Name());
+
+         Cache->MarkAuto(Pkg,Action);
+         AutoMarkChanged++;
+      }
+   }
+   if (AutoMarkChanged && ! _config->FindB("APT::Get::Simulate",false))
+      return Cache->writeStateFile(NULL);
+   return false;
+}
                                                                        /*}}}*/
 // DoDistUpgrade - Automatic smart upgrader                            /*{{{*/
 // ---------------------------------------------------------------------
@@ -2798,6 +2852,9 @@ bool ShowHelp(CommandLine &CmdL)
       "   clean - Erase downloaded archive files\n"
       "   autoclean - Erase old downloaded archive files\n"
       "   check - Verify that there are no broken dependencies\n"
+      "   markauto - Mark the given packages as automatically installed\n"
+      "   unmarkauto - Mark the given packages as manually installed\n"
+      "   showauto - Display a list of automatically installed packages\n"
       "\n"
       "Options:\n"
       "  -h  This help text.\n"
@@ -2904,6 +2961,9 @@ int main(int argc,const char *argv[])                                     /*{{{*/
                                    {"purge",&DoInstall},
                                   {"autoremove",&DoInstall},
                                   {"purge",&DoInstall},
+                                  {"showauto",&DoShowAuto},
+                                  {"markauto",&DoMarkAuto},
+                                  {"unmarkauto",&DoMarkAuto},
                                    {"dist-upgrade",&DoDistUpgrade},
                                    {"dselect-upgrade",&DoDSelectUpgrade},
                                   {"build-dep",&DoBuildDep},
index 12768b7088069fa9968ead5c89148325207bb048..c64d4356cc101e3c6dafcc7c0d04f646d7cad9b4 100755 (executable)
@@ -8,7 +8,7 @@ import os.path
 try:
     import apt_pkg
 except ImportError:
-    print "Error importing apt_pkg, is python-apt installed?"
+    print >> sys.stderr, "Error importing apt_pkg, is python-apt installed?"
     sys.exit(1)
     
 actions = { "markauto" : 1,
@@ -68,6 +68,7 @@ if __name__ == "__main__":
     # option parsing
     parser = OptionParser()
     parser.usage = "%prog [options] {markauto|unmarkauto} packages..."
+    parser.epilog = "apt-mark is deprecated, use apt-get markauto/unmarkauto."
     parser.add_option("-f", "--file", action="store", type="string",
                       dest="filename",
                       help="read/write a different file")
index b316f95480dd56079e883c0cbb3dc159088aae3e..eed15ccb87761a3dd1799c1adcb6937a6374eebc 100644 (file)
@@ -65,6 +65,8 @@ apt (0.7.26~exp4) UNRELEASEDexperimental; urgency=low
       an object which will be set to NULL when the object is deallocated.
   * [ABI break] apt-pkg/acquire{-worker,-item,}.h:
     - subclass pkgAcquire::{Worker,Item,ItemDesc} from WeakPointable.
+  * cmdline/apt-get.cc:
+    - Add apt-get markauto, showauto and unmarkauto commands.
 
  -- David Kalnischkies <kalnischkies@gmail.com>  Sat, 03 Apr 2010 14:58:39 +0200