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

Re: debian/rules clean as root or non-root?

On 2010-02-10 19:02 +0100, Goswin von Brederlow wrote:

> I often see sources where debian/rules clean aborts claiming it needs to
> be run as root. So then I run it with fakeroot. But if the source was
> previously build as root then running fakeroot debian/rules clean might
> not be enough. I think the existing dh_testroot helper is insufficient
> and anoying for the job.

It is both insufficient and unnecessary, I don't use it in my packages.
Neither does "dh clean", BTW.

> But how do I detect if clean needs to be run as root and if I have real
> root?

You run it, and if it fails you probably need real root rights.  Is
there a real problem with that simple approach?

> I'm thinking of having dh_testroot do
> mkdir -p .dh
> chown root.root .dh     if (UID == 0)
> chmod 755 .dh
> touch .dh/root
> Then one can test if real root is required by trying to delete and
> recreate .dh/root. In the clean target it should probably remove .dh
> while other invocations of dh_testroot have to leave the dir and file.

Looks a bit convoluted to me, although it may work.


Reply to: