Issue
Where in the spec file can I put instructions to install/move around files when I run the install command?
rpm -ivh myrpm-1.0-12.rpm
In my RPM I have a tar ball filled with files (php files) I want to place them onto my servers in a set directory.
I run.
rpmbuild -ba
This executes the commands below, that I don't want to execute at this time.
%install
mkdir -p $RPM_BUILD_ROOT/usr/local/mypath/here
cp -r . $RPM_BUILD_ROOT/usr/local/mypath/here
I want these commands to be executed by the time of the install by the end user
rpm -ivh myrpm-1.0-12.rpm
In the RPM documentation it says that on of the steps of installing an RPM is... "Unpacking files from the package and putting them in the proper place:"
This is the step most people think of when they think about installing software. Each package file contains a list of files that are to be installed, as well as their destination on your system. In addition, many other file attributes, such as permissions and ownerships, are set correctly by RPM.
I don't know where to put these commands.
I've also tried putting the commands in %build
and it acts that same.
Solution
RPM build time is the exact time to extract these files.
The original tar ball is supposed to be part of the "source RPM file", and the "binary RPM file" (bad wording; should maybe be better "install RPM file" in this case) is supposed to hold the exact layout of the target file system the RPM is responsible for.
This layout is defined in the %install
section. Usually, you have the sequence %prep
, %build
and %install
. %prep
unpacks your sources into the working directory, %build
builds them adnd %install
moves the stoff to the "build root" which defines the files supposed to be there. If you don't have anything to build, as in your case, you omit %build
and maybe just unpack in the %install
section.
This is as well the only way the RPM system can know the names of the files so you can query their package with rpm -qf $FILENAME
. (except with ghost files, but that's not very elegant).
You can add a %post
scriptlet which unpacks a tarball at install time, but, as said, that would be far from elegant.
Answered By - glglgl Answer Checked By - Gilberto Lyons (WPSolving Admin)