LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 03-24-2006, 12:00 PM   #1
toncelli
LQ Newbie
 
Registered: Mar 2006
Posts: 1

Rep: Reputation: 0
How to create an RPM post script that can be relocated?


Hi,
I am trying to create an RPM package where the post script is able to figure out if the package get relocated. I need that because the RPM is installing some *.so links into /usr/lib and they need to point to the right location.
Thanks
 
Old 03-24-2006, 07:02 PM   #2
unSpawn
Moderator
 
Registered: May 2001
Posts: 29,415
Blog Entries: 55

Rep: Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600
If %post has access to any args given to rpm (dunno), maybe you could parse $@ for the arg thats shift 1 at --relocate?
 
Old 08-25-2010, 03:16 PM   #3
hacknskate
LQ Newbie
 
Registered: Aug 2010
Posts: 1

Rep: Reputation: 0
Accessing relocatable rpm install directory prefix from %post script

I found similar questions in several forums (none with answers). So I'm resurrecting this thread with the answer.

Problem:
The default prefix is %{_prefix} but the %post section of the spec file can only use it when the rpm is being built, we need to know the prefix when the rpm is being installed.

Solution:
Use the environment variable $RPM_INSTALL_PREFIX to determine where the package prefix is at install time.

e.g.
Prefix: /usr

%post
#Soft link example
ln -s %{_prefix}/lib/mylib.so $RPM_INSTALL_PREFIX/lib/mylib.so

#Echo example
if [ $RPM_INSTALL_PREFIX == %{_prefix} ]
then
echo "package installed in default location: %{_prefix}"
else
echo "package installed in user-defined location: $RPM_INSTALL_PREFIX"
fi

In the above example %{_prefix} is changed to the default prefix "/usr" when the script is written and the environment variable $RPM_INSTALL_PREFIX is replaced with the one given on the commandline at install time. i.e. rpm -i --prefix /usr/local package.rpm
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
how to create and post to a message queue in linux stephenwalter Programming 0 01-07-2006 06:35 AM
Question about rpm spec files and %post scripts rpg Linux - Software 5 01-06-2006 07:20 AM
dpkg: post-removal script exiting -danu Linux - Software 4 10-24-2005 07:47 AM
write a script to automatically post to a blog??? Hosiah Linux - General 11 10-14-2005 11:30 AM
Why was the relocated /tmp write permission automatically reset (lost)? wirawan0 Mandriva 2 06-26-2004 07:33 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 09:34 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration