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

Re: Writing a Spacewalk plugin for Apt-Get



On 02/17/2011 04:57 PM, Michael Vogt wrote:
> On Thu, Feb 17, 2011 at 04:45:08PM +0100, Šimon Lukašík wrote:
> [..]
>> APT::Update::Pre-Invoke cannot be used.
>>
>> This hook is called before the update action, but after the sources.list
>> is processed. This would only force people to run `apt-get update` twice
>> in row. So this solution would not work smooth with other programs using
>> libapt.
> 
> This could be fixed in the code by moving the sources.list reading
> after the hook. I don't know enough about your project to know if that
> is helpful or not, just wanted to mention it.
> 
> Cheers,
>  Michael
>  

Hello Michael,

I have prepared patch for this.

Basically, I introduced a new boolean option. If the option is set
source.list will be re-read after APT::Update::Pre-Invoke and before
acquiring.

Since I must not break api, there is a few glitches:
(1) It changes behavior of APT::Update::Pre-Invoke. Previously it was
not run, when sources.list was empty.
(2) Now, It can change content of 'List' reference. On the other hand
parameter is not const.
(3) It assumes that 'List' parameter presents the whole sources.list.
Which may not be always true.

Anyway, I tested common apt frontends and it worked well. It's certainly
far more better than modifing pkgSourceList, which is issued quite often.

Could You please review/comment?

Many thanks,
Šimon
# Bazaar merge directive format 2 (Bazaar 0.90)
# revision_id: xlukas08@stud.fit.vutbr.cz-20110220132218-\
#   ne6u2j30o8lgk999
# target_branch: http://bzr.debian.org/apt/debian-sid/
# testament_sha1: ed543f2399f0aaf1ac12b0f779a8d2909d76e666
# timestamp: 2011-02-20 14:23:22 +0100
# base_revision_id: bubulle@debian.org-20110218045523-lmlle671u9hspyhj
# 
# Begin patch
=== modified file 'apt-pkg/algorithms.cc'
--- apt-pkg/algorithms.cc	2011-02-10 16:51:44 +0000
+++ apt-pkg/algorithms.cc	2011-02-20 13:22:18 +0000
@@ -1458,12 +1458,17 @@
    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",true) == true)
+       if (List.ReadMainList() == false)
+           return false;
+
    // Populate it with the source selection
    if (List.GetIndexes(&Fetcher) == false)
 	 return false;
-
-   // Run scripts
-   RunScripts("APT::Update::Pre-Invoke");
    
    // check arguments
    if(PulseInterval>0)

# Begin bundle
IyBCYXphYXIgcmV2aXNpb24gYnVuZGxlIHY0CiMKQlpoOTFBWSZTWd8St1IAAcrfgAiQUef//3Mm
XgC////wUAQZPbss3a23drjZrCSSDUyaNTxMQymnpT9U8kxHpNGjI03qR6QSUpN6NTaTyp+pGEYN
JiAwIaDQMgJIgRqjwp6m1D1A1DTT00hoGjammQA5gAJkwAJhMEwhgCMACSgTRGp5omVPaU3qngUP
1NRo8UeoGmg00gchhlzUbdloaYk38vOxVGUmrS2EVyMiVry0hZeKQmDw7+8lE1HzqzMvHwOCNGD0
XPBhpZFOfWb9Y/Z+uEKJ+b/KCIudFk7/NWxL+44A6dG30wdbtbsg3rCnRKlC+viQoPfI9DZK3hTd
AoTfK6uNsQzi4OiJKVIKnZ9CohjmyWtLak6cIJbi0OaNUNkuXcREz1DXEhr9FqQbzuSLI6lYprgS
mTXGMPFeY5ttFslcZMuqFBFxx2EBFSxWSFL+d7hVFLh0ENT1bigvvGOI/ZBRLC6CKBVJyq7HiYgo
FIesB0B6VI48hWaZlNo4iefN4qahuOm4cYESYjKvNEdiNgq2hWbmqT/QaidVjJS+iQ4ZFUjGvuKK
ma05RldUdBRfok0mkmXjuHM03CSFnBrlcQMcX4C5VUywbGd9aJOyzTl0SgwWzmlIc5ugWEVcyyfi
My8kQTCxNosS4zM5inK1SaPP2Xg4quCKdWVhCf49ouvMwZuYjow5H9kzDUnBxIvkx1GHaceyB7h7
Ox74vmuESsShKtS0xamTG5pbxNXdHxyrJbiEu17GLJq7zKETpWtadhzqX+Vq8amhVTbrXDA1z74j
EmIQ1mJOePRMZzeGXetf35FpY4CNcV33nWoUy5AZK5dMTIwL0SS0WJmw5LYjh5ya/C2ZUbvNHF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