[Apt-Rpm] updating sources.list through lua script

Panu Matilainen pmatilai at laiskiainen.org
Sun Apr 20 00:49:51 PDT 2008


On Fri, 18 Apr 2008, Johan Huysmans wrote:

> Hi All,
>
> I want to achieve following situation.
> You run "apt-get update".
> When running that command it will check that the a specific system
> variable is set, if it is that case, that server must be used.
> If it is not set it must check that server 1 is available, if so it must
> use that server, if not check and use the 2nd server.
>
> I'm running a lua script in "Scripts::AptGet::Update::Pre" that updates
> the sources.list file.
> The file gets updated, but the actual apt-get update still happens with
> the old server configured, running apt-get update again uses the correct
> server.
> Apparently this is because the configuration (including the sources.list
> file) gets read before the Pre script got executed.

Hmm... yup, Scripts::AptGet::Update::Pre indeed runs after sources.list 
gets read in. Which seems to kind of defeat the whole point of the slot, 
makes me wonder if there was some reason for it being that way.
One possibility would be adding yet another slot that runs just before 
sources.list read-in.

> Is there a way to tell in the lua script to re-read the configuration?
> Or can you adapt the configuration loaded in APT?

Neither is possible, at the moment at least.

> Or any other feasible solution?

There is one slot that runs before sources.list[.] is read: Scripts::Init.
The main configuration is available to Lua at that point but little else 
as this happens very early in the initialization process. Scripts::Init 
also runs on each and every invocation of any program using libapt-pkg so 
care must be taken to handle non-root use and such.

 	- Panu -





More information about the Apt-Rpm mailing list