In building an RPM .spec file, I wanted to create a user during pre-installation. So I had:
%pre
/usr/sbin/useradd -d /home/project/userid userid
This would fail if the directory "/home/project/" doesn't exist. My way to get aound this is to add a mkdir:
%pre
mkdir -p /home/project
/usr/sbin/useradd -d /home/project/userid userid