On Wed, May 21, 2008 at 09:10:19PM -0400, Joey Hess wrote: > When you're implementing this, please add a --no-triggers option (or > something like that) to apt. This will be useful for things like d-i > that call apt multiple times. Then triggers can be skipped during the > multiple apt runs, and run once at the end.
The attached patch should implement supression of triggers with -o DPkg::NoTriggers=true. It also adds --no-triggers to all but the latest dpkg run as outlined in the triggers.txt dpkg documentation. I'm a bit nervos adding it to the debian-sid apt branch right now, I would like to do some more testing first to see if it does not break. Feedback is very welcome of course. Cheers, Michael
=== modified file 'apt-pkg/deb/dpkgpm.cc' --- apt-pkg/deb/dpkgpm.cc 2008-01-31 09:06:00 +0000 +++ apt-pkg/deb/dpkgpm.cc 2008-05-28 12:33:24 +0000 @@ -526,6 +526,11 @@ if (RunScriptsWithPkgs("DPkg::Pre-Install-Pkgs") == false) return false; + + // support subpressing of triggers processing for special + // cases like d-i that runs the triggers handling manually + if(_config->FindB("DPkg::NoTriggers",false) == false) + List.push_back(Item(Item::Triggers,PkgIterator())); // map the dpkg states to the operations that are performed // (this is sorted in the same way as Item::Ops) @@ -572,6 +577,8 @@ // and the PackageOpsTranslations (human readable strings) for (vector<Item>::iterator I = List.begin(); I != List.end();I++) { + if((*I).Pkg.end()) + continue; string name = (*I).Pkg.Name(); PackageOpsDone[name] = 0; for(int i=0; (DpkgStatesOpMap[(*I).Op][i]).state != NULL; i++) @@ -649,6 +656,7 @@ case Item::Configure: Args[n++] = "--configure"; + Args[n++] = "--no-triggers"; Size += strlen(Args[n-1]); break; @@ -658,6 +666,11 @@ Args[n++] = "--auto-deconfigure"; Size += strlen(Args[n-1]); break; + + case Item::Triggers: + Args[n++] = "--configure"; + Args[n++] = "--pending"; + break; } // Write in the file or package names @@ -675,6 +688,8 @@ { for (;I != J && Size < MaxArgBytes; I++) { + if(I->Pkg.end()) + continue; Args[n++] = I->Pkg.Name(); Size += strlen(Args[n-1]); } === modified file 'apt-pkg/deb/dpkgpm.h' --- apt-pkg/deb/dpkgpm.h 2008-01-04 20:33:09 +0000 +++ apt-pkg/deb/dpkgpm.h 2008-05-28 12:21:50 +0000 @@ -53,7 +53,7 @@ struct Item { - enum Ops {Install, Configure, Remove, Purge} Op; + enum Ops {Install, Configure, Remove, Purge, Triggers} Op; string File; PkgIterator Pkg; Item(Ops Op,PkgIterator Pkg,string File = "") : Op(Op),