LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Red Hat (http://www.linuxquestions.org/questions/red-hat-31/)
-   -   Need help with building an RPM and performing a check in the build phase (http://www.linuxquestions.org/questions/red-hat-31/need-help-with-building-an-rpm-and-performing-a-check-in-the-build-phase-689628/)

jakev383 12-10-2008 01:26 PM

Need help with building an RPM and performing a check in the build phase
 
I'm building an RPM, and can successfully do so.
I'd like to add a check in my .spec file to see if a uid is already in use and exit the whole process if it is already in use. I tried this in %prep:
Code:

if [ -z `/bin/cat /etc/passwd | /bin/grep 89` ]; then
        /bin/echo "User id 89 is already is use. Cannot continue!"
        exit 1
fi

As well as this during %build :
Code:

if [ -z `/bin/grep 89 /etc/passwd` ]; then
        /bin/echo "User id 89 is already is use. Cannot continue!"
        exit 1
fi

And it keeps going through even though it's already in use (I created a user with uid 89 to test).
Anyone have any suggestions?
Thanks in advance.

unSpawn 12-10-2008 02:44 PM

The %prep phase only concerns building the package so this does not make a lot of sense to me: after all you can not control where the package will be built. If you still want to kill it you could try something like 'getent passwd 89 >/dev/null 2>&1||pkill -9 -f "rpmbuild -"' thought that doesn't leave the process any time to clean up the build dir or whatever else.


All times are GMT -5. The time now is 10:18 PM.