How can I apply a -p0 patch from any working directory?
Looking at the source code of GNU patch, this behavior is built in since version 2.7. As of GNU patch 2.7.1, only relative paths not containing ..
are accepted, unless the current directory is the root directory.
To apply a patch containing absolute paths, you can use
(cd / && sudo patch -p0) <foo.patch
In recent versions of GNU patch, you can simply
sudo patch -d/ -p0 <foo.patch