Re: debian/rules clean as root or non-root?
Sven Joachim <email@example.com> writes:
> 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.
If you build the package as real root and it creates a new directory
(like installing into debian/package/ always does) then you can not
clean without being real root. So the check isn't unnecessary.
The anoying think is that dh_testroot is supposed to say when you lack
root priviledges but it isn't good enough to distinguish between the
need for fakeroot and real root.
>> But how do I detect if clean needs to be run as root and if I have real
> You run it, and if it fails you probably need real root rights. Is
> there a real problem with that simple approach?
And how many source do you know where clean will always properly report
errors? If you did run only debian/rules build as root the error might
get ignored and lost in the output.
>> 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.
It reproduces the error scenario and I think only error scenario. But if
anyone can think of another test speak up.