File Listed Twice in Rpm Spec File

what does the rpmbuild warning File listed twice ACTUALLY MEAN?

It means just that - it's listed twice. ;) I've never had a problem with it, but I don't know which will win.

As a side note, you probably shouldn't list /etc on its own, since you don't want to own that.

How to fix the `warning: File listed twice` notice?

In the %files section it would suffice to write:

%files
/etc/mydumpadmin

That will already package the /etc/mydumpadmin folder recursively.

File listed twice in rpm spec file

Unfortunately not. RPM is quite oldschool software, but works fine :-)

But you can use globs too:

%files
%{prefix}/htdocs/*.png
%{prefix}/htdocs/*.html

etc.

This will enable you to include all the rest without some other files you do not want there. That's the way how RPM packagers do it usually.

Problem with multiple listings of the same file in RPM spec

Instead of specifying the directory, you can create a file list and then prune duplicate files from that.

So where you have something like

%files
%dir foo
%config foo/scriptname

You modify those parts to

find $RPM_BUILD_ROOT -type f | sed -e "s|^$RPM_BUILD_ROOT||" > filelist
sed -i "\|^foo/scriptname$|d" filelist

%files -f filelist
%config foo/scriptname

You can also use %{buildroot} in place of $RPM_BUILD_ROOT.

Spec file: File is packed by rpm, but not getting installed in right destination

Either:

  1. someone removed that file. In that case simple dnf reinstall your_package will fix it

  2. or the file is marked as %ghost http://ftp.rpm.org/max-rpm/s1-rpm-inside-files-list-directives.html that is usually for log files. You do not want them to ship, but a package should own them.

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

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.



Related Topics



Leave a reply



Submit