Sfoglia il codice sorgente

support running "--simulate" as user

Michael Vogt 17 anni fa
parent
commit
55a5a46c23
3 ha cambiato i file con 18 aggiunte e 1 eliminazioni
  1. 12 1
      cmdline/apt-get.cc
  2. 1 0
      debian/changelog
  3. 5 0
      doc/apt-get.8.xml

+ 12 - 1
cmdline/apt-get.cc

@@ -2788,7 +2788,18 @@ int main(int argc,const char *argv[])
       ShowHelp(CmdL);
       return 0;
    }
-   
+
+   // simulate user-friendly if apt-get has no root privileges
+   if (getuid() != 0 && _config->FindB("APT::Get::Simulate") == true)
+   {
+      cout << _("NOTE: This is only a simulation!\n"
+        "      apt-get needs root privileges for real execution.\n"
+        "      Keep also in mind that locking is deactivated,\n"
+        "      so don't depend on the relevance to the real current situation!"
+        ) << std::endl;
+      _config->Set("Debug::NoLocking",true);
+   }
+
    // Deal with stdout not being a tty
    if (!isatty(STDOUT_FILENO) && _config->FindI("quiet",0) < 1)
       _config->Set("quiet","1");

+ 1 - 0
debian/changelog

@@ -21,6 +21,7 @@ apt (0.7.22) UNRELEASED; urgency=low
   * [ABI break] support '#' in apt.conf and /etc/apt/preferences
     (closes: #189866)
   * [ABI break] Allow pinning by codename (closes: #97564)
+  * support running "--simulate" as user
 
   [ Julian Andres Klode ]
   * apt-pkg/contrib/configuration.cc: Fix a small memory leak in

+ 5 - 0
doc/apt-get.8.xml

@@ -363,6 +363,11 @@
      actually change the system. 
      Configuration Item: <literal>APT::Get::Simulate</literal>.</para>
 
+     <para>Simulation run as user will deactivate locking (<literal>Debug::NoLocking</literal>)
+     automatical and display a notice indicating that this is only a simulation.
+     Neigther NoLocking nor the notice will be triggered if run as root (root should know what
+     he is doing without further warnings by <literal>apt-get</literal>).</para>
+
      <para>Simulate prints out
      a series of lines each one representing a dpkg operation, Configure (Conf),
      Remove (Remv), Unpack (Inst). Square brackets indicate broken packages with