Multiple tar files (source files) in rpm.spec file

I came up with a centralized registration server in Linux. At this point, I am trying to consolidate in order to simplify downloading to another machine. I want to have one RPM that will install several programs in one shot. I work on a CentOS 7 server. The programs that I am going to pack in rpm will be as follows:

eventlog 2.12 libdbi 0.9.0 freetds 0.91 libdbi-drivers 0.9.0 json-c syslog-ng 3.5.6 

I read quite a lot in RPMs, just hard working on how to get multiple sources into one RPM. The reason I am the source of installing these and not just yum installing them is because of the settings that I need to call in "./configure --enable-example". Therefore, I have a source that installed all these programs on my computer, and then I tar'ed them to backup and try to use this file as a source. Any ideas or anyone who could point me in the right direction would be greatly appreciated.

+6
source share
1 answer

You can specify as many Source lines as you need, and have as many %setup macros in your spec file as you need.

From Using% setup in the Multi-source Spec File section of the online maximum RPM book, we find:

In this example, our spec file will have the following three source tags: [1]

  source: source-zero.tar.gz source1: source-one.tar.gz source2: source-two.tar.gz 

To unpack the first source is not difficult; all that is required is to use% setup without parameters:

 %setup 

This creates the following set of commands:

 cd /usr/src/redhat/BUILD rm -rf cdplayer-1.0 gzip -dc /usr/src/redhat/SOURCES/source-zero.tar.gz | tar -xvvf - if [ $? -ne 0 ]; then exit $? fi cd cdplayer-1.0 cd /usr/src/redhat/BUILD/cdplayer-1.0 chown -R root.root . chmod -R a+rX,gw,ow . 

....

Now add the second source file. It is more interesting here. First, we need to determine which source tag (and therefore which source file) we are talking about. Therefore, we need to use the -a or -b option, depending on the characteristics of the original archive. In this example, let's say that -a is the option we want. By adding this option, plus "1" to point to the source file specified in the source1 tag, we have:

 %setup -a 1 

Since we have already seen that using the -a or -b option leads to duplicate decompression, we need to disable the default decompression by adding the -T option:

 %setup -T -a 1 

Then we need to make sure that the top-level directory is not deleted. Otherwise, the first source file that we just unzipped will disappear. This means that we need to enable the -D option to prevent this from happening. By adding this final version and now including the full macro in our% prep script, we now have:

 %setup %setup -T -D -a 1 

This will result in the following commands:

 cd /usr/src/redhat/BUILD rm -rf cdplayer-1.0 gzip -dc /usr/src/redhat/SOURCES/source-zero.tar.gz | tar -xvvf - if [ $? -ne 0 ]; then exit $? fi cd cdplayer-1.0 cd /usr/src/redhat/BUILD/cdplayer-1.0 chown -R root.root . chmod -R a+rX,gw,ow . cd /usr/src/redhat/BUILD cd cdplayer-1.0 gzip -dc /usr/src/redhat/SOURCES/source-one.tar.gz | tar -xvvf - if [ $? -ne 0 ]; then exit $? fi cd /usr/src/redhat/BUILD/cdplayer-1.0 chown -R root.root . chmod -R a+rX,gw,ow . 

So far so good. Let me include the last source file, but with this, we say that it needs to be unzipped in the cdplayer-1.0 subdirectory called the database. Can we use% setup in this case?

We could if source-two.tgz created a database subdirectory. If not, then this will need to be done manually. For the purposes of our example, suppose that source-two.tgz was not created to include a database subdirectory, so we will have to do it ourselves. Here is our% prep script now:

 %setup %setup -T -D -a 1 mkdir database cd database gzip -dc /usr/src/redhat/SOURCES/source-two.tar.gz | tar -xvvf - 

Here's the result of the script:

 cd /usr/src/redhat/BUILD rm -rf cdplayer-1.0 gzip -dc /usr/src/redhat/SOURCES/source-zero.tar.gz | tar -xvvf - if [ $? -ne 0 ]; then exit $? fi cd cdplayer-1.0 cd /usr/src/redhat/BUILD/cdplayer-1.0 chown -R root.root . chmod -R a+rX,gw,ow . cd /usr/src/redhat/BUILD cd cdplayer-1.0 gzip -dc /usr/src/redhat/SOURCES/source-one.tar.gz | tar -xvvf - if [ $? -ne 0 ]; then exit $? fi mkdir database cd database gzip -dc /usr/src/redhat/SOURCES/source-two.tar.gz | tar -xvvf - 

The three commands we added to unpack the last set of sources were added at the end of the% prep script.

+9
source

Source: https://habr.com/ru/post/984818/


All Articles