[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Bug#677871: RFE - allow PreInvoke scripts to modify sources.list



Package: apt
Version: 0.9.6
Severity:|wishlist
Tags: patch

One year ago Simon Lukasik send patch to apt mailing list which will allow plugins in PreInvoke to modify sources.list.

This week on BSP at Sazlburg I rebased (together with bzed) it to current code and tested it (with http and ftp methods. And apt-get, aptitude and synoptic frontends).

The motivation for this is apt-spacewalk which should be uploaded to Debian today.

This breaks little bit ABI. But that new method AcquireUpdate was created just month ago and nobody use it yet.
I consulted the move of RunScripts("APT::Update::Pre-Invoke") to ListUpdate() with DonKult and he said it is ok.

Attached is patch which modify the code and man page of apt.conf. As bonus it include documentation of other options,
which were presented in code in past, but not documented.

Mirek Suchy

|

diff -aur apt.orig/apt-pkg/algorithms.cc apt/apt-pkg/algorithms.cc
--- apt.orig/apt-pkg/algorithms.cc	2012-06-17 11:00:29.000000000 +0200
+++ apt/apt-pkg/algorithms.cc	2012-06-17 13:40:05.000000000 +0200
@@ -1497,6 +1497,14 @@
    if (Fetcher.Setup(&Stat, _config->FindDir("Dir::State::Lists")) == false)
       return false;
 
+   // Run scripts
+   RunScripts("APT::Update::Pre-Invoke");
+
+   // Refresh source lists, Pre-Invoke might change content
+   if (_config->FindB("APT::Update::List-Refresh",false) == true)
+       if (List.ReadMainList() == false)
+           return false;
+
    // Populate it with the source selection
    if (List.GetIndexes(&Fetcher) == false)
 	 return false;
@@ -1509,14 +1517,13 @@
 /* This is a simple wrapper to update the cache with a provided acquire
  * If you only need control over Status and the used SourcesList use
  * ListUpdate method instead.
+ * If you are calling AcquireUpdate directly you should call
+ * APT::Update::Pre-Invoke sripts on your own and reload source lists
+ * if needed.
  */
 bool AcquireUpdate(pkgAcquire &Fetcher, int const PulseInterval,
 		   bool const RunUpdateScripts, bool const ListCleanup)
 {
-   // Run scripts
-   if (RunUpdateScripts == true)
-      RunScripts("APT::Update::Pre-Invoke");
-
    pkgAcquire::RunResult res;
    if(PulseInterval > 0)
       res = Fetcher.Run(PulseInterval);
diff -aur apt.orig/doc/apt.conf.5.xml apt/doc/apt.conf.5.xml
--- apt.orig/doc/apt.conf.5.xml	2012-06-17 01:35:56.000000000 +0200
+++ apt/doc/apt.conf.5.xml	2012-06-17 13:41:03.000000000 +0200
@@ -243,6 +243,10 @@
      </para></listitem>
      </varlistentry>
 
+     <varlistentry><term><option>Update</option></term>
+     <listitem><para>Thig group is used in update phase. See UPDATE group below.</para></listitem>
+     </varlistentry>
+
      <varlistentry><term><option>Cache-Start</option></term><term><option>Cache-Grow</option></term><term><option>Cache-Limit</option></term>
      <listitem><para>APT uses since version 0.7.26 a resizable memory mapped cache file to store the available
      information. <literal>Cache-Start</literal> acts as a hint of the size the cache will grow to,
@@ -557,6 +561,46 @@
    </variablelist>
  </refsect1>
 
+
+ <refsect1><title>The Update Group</title>
+   <para>The <literal>Update</literal> group of options controls the
+   update phase.</para>
+
+   <variablelist>
+     <varlistentry><term><option>Pre-Invoke, Post-Invoke</option></term>
+     <listitem><para>
+     This is a list of shell commands to run before/after the package index files
+     are synchronized from their sources. This must be specified in list notation.
+     The commands are invoked in order using /bin/sh.
+     </para></listitem>
+     </varlistentry>
+
+   <variablelist>
+     <varlistentry><term><option>Post-Invoke-Success</option></term>
+     <listitem><para>
+     This is a list of shell commands to run after the package index files
+     are successfully synchronized from their sources. This must be specified in list notation.
+     The commands are invoked in order using /bin/sh.
+     This is run immediatelly before Post-Invoke. 
+     </para></listitem>
+     </varlistentry>
+
+   <variablelist>
+     <varlistentry><term><option>List-Refresh</option></term>
+     <listitem><para>
+     If you modify &sources.list; in Pre-Invoke, you should set this boolean value to true.
+     If set to true, then &sources.list; are re-read after Pre-Invoke scripts are run.
+     Default is set to false.
+     Note, that it is not recommended to modify directly main &sources.list, but rather
+     your own file in /etc/apt/sources.list.d directory.
+     This is run immediatelly before Post-Invoke.
+     </para></listitem>
+     </varlistentry>
+
+   </variablelist>
+ </refsect1>
+
+
  <refsect1><title>Directories</title>
 
    <para>The <literal>Dir::State</literal> section has directories that pertain to local 

Reply to: