debian/rules clean as root or non-root?
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.
But how do I detect if clean needs to be run as root and if I have real
root? I'm thinking of having dh_testroot do
mkdir -p .dh
chown root.root .dh if (UID == 0)
chmod 755 .dh
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.