I have created my own .rpm file. The installation works prefect on the command line but doesn't work properly when i am doing it from the GUI.

The only thing that doesn't work from the GUI is the %post script. I try to invoke the browser post installation, works when i run through the command line but not through GUI.

Here is the .spec file used for rpm building

Summary:Sample RPM package for testing post install script


Sample rpm for testing post install script

%setup -n sample_rpm

mkdir -p "$RPM_BUILD_ROOT/opt/sample_rpm"
cp -R * "$RPM_BUILD_ROOT/opt/sample_rpm"

exec "/usr/bin/firefox" "http://www.google.com" &




Thanks in advance!


First define a macro e.g:

%define runcommand() ( /usr/bin/firefox http://google.com ) 

Then under the %post section run %runcommand. Since the package requires root access and root the %post macro won't be able to find a DISPLAY. Exporting DISPLAY environment variable should solve this problem. For example

export DISPLAY=":0.0"

Finally, use rpmlint -i sample_rpm.spec to check if there are errors. If no errors there, build the package using rpmbuild -ba sample_rpm.spec

  • No luck! this is the error i get - > No protocol specified Error: cannot open display: :0.0 warning: %post(sample_rpm-1.0-1.el6.x86_64) scriptlet failed, exit status 1 – Avinash Nair Jun 11 '15 at 10:27
  • @AvinashNair Ok, so what does echo "$DISPLAY" tell you prior building the rpm? Try then su -c 'rpm -ivh sample_rpm' and tell me what you get. – Valentin Bajrami Jun 11 '15 at 15:25
  • Prior to building the rpm $DISPLAY is empty – Avinash Nair Jun 15 '15 at 8:57
  • @AvinashNair use the snippet in my answer and see if this changes anything. – Valentin Bajrami Jun 22 '15 at 19:57

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.