]> git.saurik.com Git - apt.git/commitdiff
* merged from the apt--auto-mark branch
authorMichael Vogt <egon@bottom>
Thu, 14 Dec 2006 10:34:01 +0000 (11:34 +0100)
committerMichael Vogt <egon@bottom>
Thu, 14 Dec 2006 10:34:01 +0000 (11:34 +0100)
1  2 
cmdline/apt-get.cc
doc/apt-get.8.xml

diff --combined cmdline/apt-get.cc
index be4b46857193c799075f380e1b9dc7916aad37bc,9b6e36e210144614576b678b08b7ffae05062b6e..6949dc6eb53df5477dd0d5c4be45830af32ebe05
@@@ -629,8 -629,6 +629,8 @@@ void CacheFile::Sort(
     and verifies that the system is OK. */
  bool CacheFile::CheckDeps(bool AllowBroken)
  {
 +   bool FixBroken = _config->FindB("APT::Get::Fix-Broken",false);
 +
     if (_error->PendingError() == true)
        return false;
  
     if (pkgApplyStatus(*DCache) == false)
        return false;
     
 +   if (_config->FindB("APT::Get::Fix-Policy-Broken",false) == true)
 +   {
 +      FixBroken = true;
 +      if ((DCache->PolicyBrokenCount() > 0))
 +      {
 +       // upgrade all policy-broken packages with ForceImportantDeps=True
 +       for (pkgCache::PkgIterator I = Cache->PkgBegin(); !I.end(); I++)
 +          if ((*DCache)[I].NowPolicyBroken() == true) 
 +             DCache->MarkInstall(I,true,0, false, true);
 +      }
 +   }
 +
     // Nothing is broken
     if (DCache->BrokenCount() == 0 || AllowBroken == true)
        return true;
  
     // Attempt to fix broken things
 -   if (_config->FindB("APT::Get::Fix-Broken",false) == true)
 +   if (FixBroken == true)
     {
        c1out << _("Correcting dependencies...") << flush;
        if (pkgFixBroken(*DCache) == false || DCache->BrokenCount() != 0)
@@@ -1160,11 -1146,9 +1160,11 @@@ bool TryToInstall(pkgCache::PkgIterato
     else
        ExpectedInst++;
     
 -   // Install it with autoinstalling enabled.
 -   if (State.InstBroken() == true && BrokenFix == false)
 +   // Install it with autoinstalling enabled (if we not respect the minial
 +   // required deps or the policy)
 +   if ((State.InstBroken() == true || State.InstPolicyBroken() == true) && BrokenFix == false)
        Cache.MarkInstall(Pkg,true);
 +
     return true;
  }
                                                                        /*}}}*/
@@@ -1409,7 -1393,7 +1409,7 @@@ bool DoUpdate(CommandLine &CmdL
  bool DoAutomaticRemove(CacheFile &Cache)
  {
     bool Debug = _config->FindI("Debug::pkgAutoRemove",false);
-    bool doAutoRemove = _config->FindB("APT::Get::AutomaticRemove");
+    bool doAutoRemove = _config->FindB("APT::Get::AutomaticRemove", false);
     pkgDepCache::ActionGroup group(*Cache);
     
  
@@@ -1485,51 -1469,6 +1485,51 @@@ bool DoUpgrade(CommandLine &CmdL
     return InstallPackages(Cache,true);
  }
                                                                        /*}}}*/
 +// DoInstallTask - Install task from the command line                 /*{{{*/
 +// ---------------------------------------------------------------------
 +/* Install named task */
 +bool TryInstallTask(pkgDepCache &Cache, pkgProblemResolver &Fix, 
 +                  bool BrokenFix,
 +                  unsigned int& ExpectedInst, 
 +                  const char *taskname)
 +{
 +   const char *start, *end;
 +   pkgCache::PkgIterator Pkg;
 +   char buf[64*1024];
 +   regex_t Pattern;
 +
 +   // get the records
 +   pkgRecords Recs(Cache);
 +
 +   // build regexp for the task
 +   char S[300];
 +   snprintf(S, sizeof(S), "^Task:.*[^a-z]%s[^a-z].*\n", taskname);
 +   regcomp(&Pattern,S, REG_EXTENDED | REG_NOSUB | REG_NEWLINE);
 +   
 +   bool found = false;
 +   bool res = true;
 +   for (Pkg = Cache.PkgBegin(); Pkg.end() == false; Pkg++)
 +   {
 +      pkgCache::VerIterator ver = Cache[Pkg].CandidateVerIter(Cache);
 +      if(ver.end())
 +       continue;
 +      pkgRecords::Parser &parser = Recs.Lookup(ver.FileList());
 +      parser.GetRec(start,end);
 +      strncpy(buf, start, end-start);
 +      buf[end-start] = 0x0;
 +      if (regexec(&Pattern,buf,0,0,0) != 0)
 +       continue;
 +      res &= TryToInstall(Pkg,Cache,Fix,false,BrokenFix,ExpectedInst);
 +      found = true;
 +   }
 +   
 +   if(!found)
 +      _error->Error(_("Couldn't find task %s"),taskname);
 +
 +   regfree(&Pattern);
 +   return res;
 +}
 +
  // DoInstall - Install packages from the command line                 /*{{{*/
  // ---------------------------------------------------------------------
  /* Install named packages */
@@@ -2621,7 -2560,6 +2621,6 @@@ void GetInitialize(
     _config->Set("APT::Get::Fix-Broken",false);
     _config->Set("APT::Get::Force-Yes",false);
     _config->Set("APT::Get::List-Cleanup",true);
-    _config->Set("APT::Get::AutomaticRemove",false);
  }
                                                                        /*}}}*/
  // SigWinch - Window size change signal handler                               /*{{{*/
@@@ -2679,8 -2617,6 +2678,8 @@@ int main(int argc,const char *argv[]
        {0,"arch-only","APT::Get::Arch-Only",0},
        {0,"auto-remove","APT::Get::AutomaticRemove",0},
        {0,"allow-unauthenticated","APT::Get::AllowUnauthenticated",0},
 +      {0,"install-recommends","APT::Install-Recommends",CommandLine::Boolean},
 +      {0,"fix-policy","APT::Get::Fix-Policy-Broken",0},
        {'c',"config-file",0,CommandLine::ConfigFile},
        {'o',"option",0,CommandLine::ArbItem},
        {0,0,0,0}};
diff --combined doc/apt-get.8.xml
index 17f663a3519db91f23687291877b3b7c67f53917,db852d0077bcbfe2a5408629728b51b9e2624e55..3c245b83bc6092c92e8f0b018755f9fd3bc31fe9
@@@ -47,6 -47,7 +47,7 @@@
           <arg>check</arg>
           <arg>clean</arg>
           <arg>autoclean</arg>
+          <arg>autoremove</arg>
        </group>   
     </cmdsynopsis>
   </refsynopsisdiv>
       <literal>APT::Clean-Installed</literal> will prevent installed packages from being
       erased if it is set to off.</para></listitem>
       </varlistentry>
+      <varlistentry><term>autoremove</term>
+      <listitem><para><literal>autoremove</literal> is used to remove packages that were automatically
+      installed to satisfy dependencies for some package and that are no more needed.</para></listitem>
+      </varlistentry>
     </variablelist>
   </refsect1>
   
       Configuration Item: <literal>APT::Get::Remove</literal>.</para></listitem>
       </varlistentry>
  
+      <varlistentry><term><option>--auto-remove</option></term>
+      <listitem><para>If the command is either <literal>install</literal> or <literal>remove</literal>,
+      then this option acts like running <literal>autoremove</literal> command, removing the unused
+      dependency packages. Configuration Item: <literal>APT::Get::AutomaticRemove</literal>.
+      </para></listitem>
+      </varlistentry>
       <varlistentry><term><option>--only-source</option></term>
       <listitem><para>Only has meaning for the
       <literal>source</literal> and <literal>build-dep</literal>
  
   <refsect1><title>See Also</title>
     <para>&apt-cache;, &apt-cdrom;, &dpkg;, &dselect;, &sources-list;,
 -   &apt-conf;, &apt-config;,
 +   &apt-conf;, &apt-config;, &apt-secure;, 
     The APT User's guide in &guidesdir;, &apt-preferences;, the APT Howto.</para>
   </refsect1>