Exclude or delete directory path from %files in rpm.spec file

Prem picture Prem · Mar 18, 2016 · Viewed 9.9k times · Source

My spec files path looks like below :

/opt/OV
/opt/OV/NonOV
/opt/OV/NonOV/ABCD
/opt/OV/NonOV/ABCD/ABC
/opt/OV/NonOV/ABCD/ABC/Test1
/opt/OV/NonOV/ABCD/ABC/Test1/test1.txt
/opt/OV/NonOV/ABCD/ABC/Test2
/opt/OV/NonOV/ABCD/ABC/Test2/test2.txt
/opt/OV/newconfig
/opt/OV/newconfig/inventory
/opt/OV/newconfig/inventory/HPOvXYZ.xml

I don't want to this path to be included in spec file /opt/OV/newconfig/inventory" because if more than one rpm has this common path it gives error "conflict with file from package."

I have checked with %excludes command like below:

%files
%exclude /opt/OV/newconfig/inventory

So problem with this command is, it is excluding directly and files recursively. The rpm.spec files path look like this:

/opt/OV
/opt/OV/NonOV
/opt/OV/NonOV/ABCD
/opt/OV/NonOV/ABCD/ABC
/opt/OV/NonOV/ABCD/ABC/Test1
/opt/OV/NonOV/ABCD/ABC/Test1/test1.txt
/opt/OV/NonOV/ABCD/ABC/Test2
/opt/OV/NonOV/ABCD/ABC/Test2/test2.txt
/opt/OV/newconfig

It is excluding /opt/OV/newconfig/inventory/HPOvXYZ.xml this path as well. Is there any command so the I an exclude/delete only directory path.

Thanks in Advance.

Answer

msuchy picture msuchy · Mar 21, 2016
%files
/opt/OV
%exclude %dir /opt/OV/newconfig/inventory

This will leave /opt/OV/newconfig/inventory/HPOvXYZ.xml in the file list.