I have come up with a a centralized logging server on linux. At this point I am trying to consolidate to make things a little easier to load onto another machine. I want to have one RPM that will install multiple programs in one shot. I am working on a CentOS 7 server. the programs that I am looking to pack into an rpm would be:
eventlog 2.12
libdbi 0.9.0
freetds 0.91
libdbi-drivers 0.9.0
json-c
syslog-ng 3.5.6
I have been doing quite a bit of reading into RPM's, just having a hard time understanding how to get multiple sources into one RPM. The reason I am source installing these and not just yum installing them is because of the configures i need to call within the "./configure --enable-example". So I have source installed all these programs on my machine and then I tar'ed them back up and trying to use that file as a source. Any ideas or anyone that could point me in the right direction would be greatly appreciated.
You can list as many Source
lines as you need and have as many %setup
macro calls in your spec file as you need to match.
From the Using %setup in a Multi-source Spec File section of the in the online Maximum RPM book we find:
For the purposes of 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 hard; all that's required is to use %setup with no options:
%setup
This produces 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,g-w,o-w .
....
Now let's add the second source file. Things get a bit more interesting here. First, we need to identify which source tag (and therefore, which source file) we're talking about. So we need to use either the -a or -b option, depending on the characteristics of the source archive. For this example, let's say that -a is the option we want. Adding that option, plus a "1" to point to the source file specified in the source1 tag, we have:
%setup -a 1
Since we've already seen that using the -a or -b option results in duplicate unpacking, we need to disable the default unpacking by adding the -T option:
%setup -T -a 1
Next, we need to make sure that the top-level directory isn't deleted. Otherwise, the first source file we just unpacked would be gone. That means we need to include the -D option to prevent that from happening. Adding this final option, and including the now complete 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,g-w,o-w . 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,g-w,o-w .
So far, so good. Let's include the last source file, but with this one, we'll say that it needs to be unpacked in a subdirectory of cdplayer-1.0 called database. Can we use %setup in this case?
We could, if source-two.tgz created the database subdirectory. If not, then it'll be necessary to do it by hand. For the purposes of our example, let's say that source-two.tgz wasn't created to include the database subdirectory, so we'll have to do it ourselves. Here's 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 resulting 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,g-w,o-w . 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 to the end of the %prep script.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With