hello!

Last time i look at new version apt-0.3.4 from potato distribution, and
found new usefull function:
$ apt-get remove package_names
It cool indeed, when I remove package, what have a reverse dependencies,
then apt-get suggest to remove
such packages also. But if I want to remove package, what have a
dependencies, i can remove only this package
without all depends packages. Please look to this patch, what add such
function to apt-get.


p.s. how i can subscribe to deity mailing list. At site www.debian.org i
found only apt-developers 
can write to list?

p.p.s. just now i found, what last version is 0.3.6. May be you already
implement this feature ;-)

--
 wbr, Sergey Golod.     email: [EMAIL PROTECTED]
diff -u -r apt-0.3.4/cmdline/apt-get.cc apt-0.3.4-1/cmdline/apt-get.cc
--- apt-0.3.4/cmdline/apt-get.cc        Mon Apr  5 04:25:05 1999
+++ apt-0.3.4-1/cmdline/apt-get.cc      Sun May  9 23:27:19 1999
@@ -766,6 +766,10 @@
    bool DefRemove = false;
    if (strcasecmp(CmdL.FileList[0],"remove") == 0)
       DefRemove = true;
+
+   bool DefUnInstall = false;
+   if (strcasecmp(CmdL.FileList[0],"uninstall") == 0)
+      DefUnInstall = true;
    
    for (const char **I = CmdL.FileList + 1; *I != 0; I++)
    {
@@ -858,7 +862,49 @@
         Cache->MarkDelete(Pkg);
         continue;
       }
-      
+
+      // Select all packages and it's dependencies
+      if (DefUnInstall == true)
+      {
+        unsigned int MaxDepCount = _config->FindI("APT::Get::Depends-depth",1);
+        string List;
+        
+        if (Pkg->CurrentVer == 0)
+           return _error->Error("Package %s is not installed",S);
+
+        for (pkgCache::DepIterator Dep = Pkg.CurrentVer().DependsList(); 
Dep.end() == false; Dep++)
+        // check only 'Depends' and 'Pre-depends' dependency
+           if (Dep->Type == pkgCache::Dep::Depends || Dep->Type == 
pkgCache::Dep::PreDepends)
+           {
+              // check Dep.TargetPkg() for reverse dependes , then count 
installed packages
+              unsigned int DepCount = 0;
+              
+              for (pkgCache::DepIterator RevDep = 
Dep.TargetPkg().RevDependsList(); RevDep.end() == false; RevDep++)
+              {
+                 if (RevDep.ParentPkg()->CurrentVer == 0)
+                    continue;
+
+                 if (RevDep->Type == pkgCache::Dep::Depends || RevDep->Type == 
pkgCache::Dep::PreDepends)
+                    DepCount++;
+              }
+
+              // only one dependency allowed by default
+              if (DepCount <= MaxDepCount)
+              {
+                 List += string(Dep.TargetPkg().Name()) + " ";        
+
+                 Fix.Remove(Dep.TargetPkg());
+                 Cache->MarkDelete(Dep.TargetPkg());
+              }
+           }
+
+        ShowList(c1out, string("The following packages probally also will be 
UNINSTALLED with '") + Pkg.Name() + "':", List);
+        
+        Fix.Remove(Pkg);
+        Cache->MarkDelete(Pkg);
+        continue;
+      }
+
       // Install it
       Cache->MarkInstall(Pkg,false);
       if (State.Install() == false)
@@ -1105,6 +1151,7 @@
    cout << "   upgrade - Perform an upgrade" << endl;
    cout << "   install - Install new packages (pkg is libc6 not libc6.deb)" << 
endl;
    cout << "   remove - Remove packages" << endl;
+   cout << "   uninstall - Uninstall packages" << endl;
    cout << "   dist-upgrade - Distribution upgrade, see apt-get(8)" << endl;
    cout << "   dselect-upgrade - Follow dselect selections" << endl;
    cout << "   clean - Erase downloaded archive files" << endl;
@@ -1123,6 +1170,7 @@
    cout << "  -u  Show a list of upgraded packages as well" << endl;
    cout << "  -c=? Read this configuration file" << endl;
    cout << "  -o=? Set an arbitary configuration option, eg -o 
dir::cache=/tmp" << endl;
+   cout << "  --depth=? Set maximal depends depth when uninstall packages" << 
endl;
    cout << "See the apt-get(8), sources.list(5) and apt.conf(5) manual" << 
endl;
    cout << "pages for more information." << endl;
    return 100;
@@ -1181,11 +1229,13 @@
       {0,"print-uris","APT::Get::Print-URIs",0},
       {'c',"config-file",0,CommandLine::ConfigFile},
       {'o',"option",0,CommandLine::ArbItem},
+      {0,"depth","APT::Get::Depends-depth",CommandLine::IntLevel},
       {0,0,0,0}};
    CommandLine::Dispatch Cmds[] = {{"update",&DoUpdate},
                                    {"upgrade",&DoUpgrade},
                                    {"install",&DoInstall},
                                    {"remove",&DoInstall},
+                                   {"uninstall",&DoInstall},
                                    {"dist-upgrade",&DoDistUpgrade},
                                    {"dselect-upgrade",&DoDSelectUpgrade},
                                    {"clean",&DoClean},
diff -u -r apt-0.3.4/debian/changelog apt-0.3.4-1/debian/changelog
--- apt-0.3.4/debian/changelog  Mon Apr  5 04:44:43 1999
+++ apt-0.3.4-1/debian/changelog        Sun May  9 23:40:41 1999
@@ -1,3 +1,9 @@
+apt (0.3.4-1) unstable; urgency=low
+
+  * Add uninstall command
+
+ -- Sergey Golod <[EMAIL PROTECTED]>  Sun,  9 May 1999 18:26:44 +0500
+
 apt (0.3.4) unstable; urgency=low
 
   * Release for Ben while he is out of town.

Reply via email to