[Aptitude-svn-commit] r3647 - in branches/aptitude-0.3/aptitude: . doc/en src src/cmdline

Daniel Burrows dburrows@costa.debian.org
Wed Jul 13 19:06:32 UTC 2005


Author: dburrows
Date: Wed Jul 13 19:06:29 2005
New Revision: 3647

Modified:
   branches/aptitude-0.3/aptitude/ChangeLog
   branches/aptitude-0.3/aptitude/doc/en/manpage.xml
   branches/aptitude-0.3/aptitude/src/cmdline/cmdline_do_action.cc
   branches/aptitude-0.3/aptitude/src/main.cc
Log:
Allow keeps and keep-alls directly from aptitude's command line.

Modified: branches/aptitude-0.3/aptitude/ChangeLog
==============================================================================
--- branches/aptitude-0.3/aptitude/ChangeLog	(original)
+++ branches/aptitude-0.3/aptitude/ChangeLog	Wed Jul 13 19:06:29 2005
@@ -1,3 +1,11 @@
+2005-07-13  Daniel Burrows  <dburrows@debian.org>
+
+	* doc/en/aptitude.xml, src/cmdline/cmdline_do_action.cc, src/main.cc:
+
+	  Add support for "keep" and "keep-all" commands; the former
+	  cancels actions on a single package, while the latter cancels
+	  all currently contemplated actions.
+
 2005-07-12 Jean-Luc Coulon  <jean-luc.coulon@wanadoo.fr>
 
 	* Updated French translation (sent through the French mailing list)

Modified: branches/aptitude-0.3/aptitude/doc/en/manpage.xml
==============================================================================
--- branches/aptitude-0.3/aptitude/doc/en/manpage.xml	(original)
+++ branches/aptitude-0.3/aptitude/doc/en/manpage.xml	Wed Jul 13 19:06:29 2005
@@ -54,6 +54,7 @@
 	<arg choice='plain'>autoclean</arg>
 	<arg choice='plain'>clean</arg>
 	<arg choice='plain'>forget-new</arg>
+	<arg choice='plain'>keep-all</arg>
 	<arg choice='plain'>update</arg>
 	<arg choice='plain'>upgrade</arg>
       </group>
@@ -70,6 +71,7 @@
 	<arg choice='plain'>download</arg>
 	<arg choice='plain'>forbid-version</arg>
 	<arg choice='plain'>hold</arg>
+	<arg choice='plain'>keep-all</arg>
 	<arg choice='plain'>markauto</arg>
 	<arg choice='plain'>purge</arg>
 	<arg choice='plain'>reinstall</arg>
@@ -281,14 +283,21 @@
       </varlistentry>
 
       <varlistentry>
-	<term><literal>remove</literal>, <literal>purge</literal>, <literal>hold</literal>, <literal>reinstall</literal></term>
+	<term><literal>remove</literal>, <literal>purge</literal>, <literal>hold</literal>, <literal>keep</literal>, <literal>reinstall</literal></term>
 
 	<listitem>
 	  <para>
 	    These commands are the same as
 	    <quote><literal>install</literal></quote>, but apply the
-	    named action to all packages given on the command line
-	    for which it is not <link linkend='parOverrideSpecifiers'>overridden</link>.
+	    named action to all packages given on the command line for
+	    which it is not <link
+	    linkend='parOverrideSpecifiers'>overridden</link>.  The
+	    difference between <literal>hold</literal> and
+	    <literal>keep</literal> is that <literal>hold</literal>
+	    will cause a package to be ignored by future
+	    <literal>upgrade</literal> commands, while
+	    <literal>keep</literal> merely cancels any scheduled
+	    actions on the package.
 	  </para>
 
 	  <para>
@@ -401,6 +410,18 @@
 	</listitem>
       </varlistentry>
 
+      <varlistentry id='manpageKeepAll'>
+	<term><literal>keep-all</literal></term>
+
+	<listitem>
+	  <para>
+	    Cancels all scheduled actions on all packages; any
+	    packages whose sticky state indicates an installation,
+	    removal, or upgrade will have this sticky state cleared.
+	  </para>
+	</listitem>
+      </varlistentry>
+
       <varlistentry>
 	<term><literal>forget-new</literal></term>
 

Modified: branches/aptitude-0.3/aptitude/src/cmdline/cmdline_do_action.cc
==============================================================================
--- branches/aptitude-0.3/aptitude/src/cmdline/cmdline_do_action.cc	(original)
+++ branches/aptitude-0.3/aptitude/src/cmdline/cmdline_do_action.cc	Wed Jul 13 19:06:29 2005
@@ -57,6 +57,8 @@
     default_action=cmdline_purge;
   else if(!strcasecmp(argv[0], "hold"))
     default_action=cmdline_hold;
+  else if(!strcasecmp(argv[0], "keep") || !strcasecmp(argv[0], "keep-all"))
+    default_action=cmdline_keep;
   else if(!strcasecmp(argv[0], "unhold"))
     default_action=cmdline_unhold;
   else if(!strcasecmp(argv[0], "markauto"))
@@ -132,58 +134,75 @@
   // TODO: look for filenames and call dpkg directly if that's the case.
 
   (*apt_cache_file)->begin_action_group();
-  // Mark packages 'n stuff.
-  for(int i=1; i<argc; ++i)
+  // If keep-all is the argument, we expect no patterns and keep all
+  // packages back.
+  if(!strcasecmp(argv[0], "keep-all"))
     {
-      cmdline_pkgaction_type action=default_action;
-      int tmp=strlen(argv[i])-1;
+      if(argc != 1)
+	{
+	  cerr << _("Unexpected pattern argument following \"keep-all\"") << endl;
+	  return -1;
+	}
 
-      // HACK: disable interpreting of escapes if it's an existing
-      //      package name.
-      if((*apt_cache_file)->FindPkg(argv[i]).end())
-	switch(argv[i][tmp])
-	  {
-	  case '-':
-	    action=cmdline_remove;
-	    argv[i][tmp]=0;
-	    break;
-	  case '=':
-	    action=cmdline_hold;
-	    argv[i][tmp]=0;
-	    break;
-	  case '+':
-	    action=cmdline_install;
-	    argv[i][tmp]=0;
-	    break;
-	  case '_':
-	    action=cmdline_purge;
-	    argv[i][tmp]=0;
-	    break;
-	  case ':':
-	    action=cmdline_keep;
-	    argv[i][tmp]=0;
-	    break;
-	  case 'm':
-	  case 'M':
-	    if(tmp>0 && argv[i][tmp-1]=='&')
-	      {
-		argv[i][tmp-1]=0;
-		if(argv[i][tmp]=='m')
-		  action=cmdline_unmarkauto;
-		else
-		  action=cmdline_markauto;
-	      }
-	    else if(tmp>0 && argv[i][tmp-1]=='+' && argv[i][tmp]=='M')
-	      {
-		argv[i][tmp-1]=0;
-		action=cmdline_installauto;
-	      }
-	  }
-
-      cmdline_applyaction(argv[i], action,
-			  to_install, to_hold, to_remove, to_purge,
-			  verbose);
+      for(pkgCache::PkgIterator i=(*apt_cache_file)->PkgBegin();
+	  !i.end(); ++i)
+	(*apt_cache_file)->mark_keep(i, true, false, NULL);
     }
+  else
+    // If we didn't take the keep-all path, mark according to the
+    // action requested.
+    for(int i=1; i<argc; ++i)
+      {
+	cmdline_pkgaction_type action=default_action;
+	int tmp=strlen(argv[i])-1;
+
+	// HACK: disable interpreting of escapes if it's an existing
+	//      package name.
+	if((*apt_cache_file)->FindPkg(argv[i]).end())
+	  switch(argv[i][tmp])
+	    {
+	    case '-':
+	      action=cmdline_remove;
+	      argv[i][tmp]=0;
+	      break;
+	    case '=':
+	      action=cmdline_hold;
+	      argv[i][tmp]=0;
+	      break;
+	    case '+':
+	      action=cmdline_install;
+	      argv[i][tmp]=0;
+	      break;
+	    case '_':
+	      action=cmdline_purge;
+	      argv[i][tmp]=0;
+
+	      break;
+	    case ':':
+	      action=cmdline_keep;
+	      argv[i][tmp]=0;
+	      break;
+	    case 'm':
+	    case 'M':
+	      if(tmp>0 && argv[i][tmp-1]=='&')
+		{
+		  argv[i][tmp-1]=0;
+		  if(argv[i][tmp]=='m')
+		    action=cmdline_unmarkauto;
+		  else
+		    action=cmdline_markauto;
+		}
+	      else if(tmp>0 && argv[i][tmp-1]=='+' && argv[i][tmp]=='M')
+		{
+		  argv[i][tmp-1]=0;
+		  action=cmdline_installauto;
+		}
+	    }
+
+	cmdline_applyaction(argv[i], action,
+			    to_install, to_hold, to_remove, to_purge,
+			    verbose);
+      }
   (*apt_cache_file)->end_action_group(NULL);
 
   if(visual_preview)

Modified: branches/aptitude-0.3/aptitude/src/main.cc
==============================================================================
--- branches/aptitude-0.3/aptitude/src/main.cc	(original)
+++ branches/aptitude-0.3/aptitude/src/main.cc	Wed Jul 13 19:06:29 2005
@@ -395,7 +395,9 @@
 		   (!strcasecmp(argv[optind], "unhold")) ||
 		   (!strcasecmp(argv[optind], "markauto")) ||
 		   (!strcasecmp(argv[optind], "unmarkauto")) ||
-		   (!strcasecmp(argv[optind], "forbid-version")) )
+		   (!strcasecmp(argv[optind], "forbid-version")) ||
+		   (!strcasecmp(argv[optind], "keep")) ||
+		   (!strcasecmp(argv[optind], "keep-all")) )
 	    return cmdline_do_action(argc-optind, argv+optind,
 				     status_fname,
 				     simulate, assume_yes, download_only,




More information about the Aptitude-svn-commit mailing list