LinuxQuestions.org
LinuxAnswers - the LQ Linux tutorial section.
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: 26,953
Blog Entries: 54

Rep: Reputation: 2732Reputation: 2732Reputation: 2732Reputation: 2732Reputation: 2732Reputation: 2732Reputation: 2732Reputation: 2732Reputation: 2732Reputation: 2732Reputation: 2732
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


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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


All times are GMT -5. The time now is 07:47 PM.

Main Menu
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
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration