LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Software (https://www.linuxquestions.org/questions/linux-software-2/)
-   -   Trouble Understanding %files in spec file (https://www.linuxquestions.org/questions/linux-software-2/trouble-understanding-files-in-spec-file-854714/)

dilzniksan 01-06-2011 05:03 PM

Trouble Understanding %files in spec file
 
This question is somewhat basic; I am attempting to compile and install an Apache so module via rpm. This as much is accomplished when the rpm is built but when the rpm itself is installed, nothing occurs because I have incorrectly ennumerated the %files section of the spec file.

My question is, how are the files supposed to be listed in the %files section so that they are copied to their proper location? It seems that all the files are processed with $RPM_BUILD_ROOT appended to their location?

Here is the relevant portion of my spec file.

Code:

%description

%prep
%setup -q -n mod_authz_svn_eecs
%{__mkdir_p} -m 755 $RPM_BUILD_ROOT
%install
apxs -i -c mod_authz_svn_eecs.c       
cp /usr/lib/httpd/modules/mod_authz_svn_eecs.so $RPM_BUILD_ROOT/mod_authz_svn_eecs.so


%files
%{_libdir}/httpd/modules/mod_authz_svn_eecs.so
%clean

%post

%changelog

Here are the errors that result from rpmbuild
Code:

chmod 755 /usr/lib/httpd/modules/mod_authz_svn_eecs.so
+ cp /usr/lib/httpd/modules/mod_authz_svn_eecs.so /home/test/rpmbuild/BUILDROOT/mod_authz_svn_eecs-0-0.i386/mod_authz_svn_eecs.so
+ /usr/lib/rpm/brp-compress
+ /usr/lib/rpm/brp-strip
+ /usr/lib/rpm/brp-strip-static-archive
+ /usr/lib/rpm/brp-strip-comment-note
Processing files: mod_authz_svn_eecs-0-0.i686
error: File not found: /home/test/rpmbuild/BUILDROOT/mod_authz_svn_eecs-0-0.i386/usr/lib/mod_authz_svn_eecs.so


RPM build errors:
    File not found: /home/test/rpmbuild/BUILDROOT/mod_authz_svn_eecs-0-0.i386/usr/lib/mod_authz_svn_eecs.so


andrewthomas 01-06-2011 09:17 PM

Quote:

Originally Posted by dilzniksan (Post 4215800)
This question is somewhat basic; I am attempting to compile and install an Apache so module via rpm. This as much is accomplished when the rpm is built but when the rpm itself is installed, nothing occurs because I have incorrectly ennumerated the %files section of the spec file.

My question is, how are the files supposed to be listed in the %files section so that they are copied to their proper location? It seems that all the files are processed with $RPM_BUILD_ROOT appended to their location?

Here is the relevant portion of my spec file.

Code:

%description

%prep
%setup -q -n mod_authz_svn_eecs
%{__mkdir_p} -m 755 $RPM_BUILD_ROOT
%install
apxs -i -c mod_authz_svn_eecs.c       
cp /usr/lib/httpd/modules/mod_authz_svn_eecs.so $RPM_BUILD_ROOT/mod_authz_svn_eecs.so


%files
%{_libdir}/httpd/modules/mod_authz_svn_eecs.so
%clean

%post

%changelog

Here are the errors that result from rpmbuild
Code:

chmod 755 /usr/lib/httpd/modules/mod_authz_svn_eecs.so
+ cp /usr/lib/httpd/modules/mod_authz_svn_eecs.so /home/test/rpmbuild/BUILDROOT/mod_authz_svn_eecs-0-0.i386/mod_authz_svn_eecs.so
+ /usr/lib/rpm/brp-compress
+ /usr/lib/rpm/brp-strip
+ /usr/lib/rpm/brp-strip-static-archive
+ /usr/lib/rpm/brp-strip-comment-note
Processing files: mod_authz_svn_eecs-0-0.i686
error: File not found: /home/test/rpmbuild/BUILDROOT/mod_authz_svn_eecs-0-0.i386/usr/lib/mod_authz_svn_eecs.so


RPM build errors:
    File not found: /home/test/rpmbuild/BUILDROOT/mod_authz_svn_eecs-0-0.i386/usr/lib/mod_authz_svn_eecs.so


I am not sure, but it seems that the line

Code:

cp /usr/lib/httpd/modules/mod_authz_svn_eecs.so $RPM_BUILD_ROOT/mod_authz_svn_eecs.so
probably should be
Code:

cp /usr/lib/httpd/modules/mod_authz_svn_eecs.so $RPM_BUILD_ROOT/usr/lib/mod_authz_svn_eecs.so
so as to avoid
Quote:

File not found: /home/test/rpmbuild/BUILDROOT/mod_authz_svn_eecs-0-0.i386/usr/lib/mod_authz_svn_eecs.so

dilzniksan 01-07-2011 11:21 AM

Fixed spec file, still questions
 
I altered the spec file so that the .so file is properly copied to the %files directory.
Code:

Summary:     
%prep
%setup -q -n mod_authz_svn_eecs
%{__mkdir_p} -m 755 $RPM_BUILD_ROOT%{_libdir}/httpd/modules/
%install
apxs -i -c mod_authz_svn_eecs.c
cp /usr/lib/httpd/modules/mod_authz_svn_eecs.so $RPM_BUILD_ROOT%{_libdir}/httpd/modules/mod_authz_svn_eecs.so

%files
%{_libdir}/httpd/modules/mod_authz_svn_eecs.so
%clean
%post
%changelog

Rpmbuild generates the following:

Code:

Checking for unpackaged file(s): /usr/lib/rpm/check-files /home/test/rpmbuild/BUILDROOT/mod_authz_svn_eecs-0-0.i386
error: Installed (but unpackaged) file(s) found:
  /mod_authz_svn_eecs.so


RPM build errors:
    Installed (but unpackaged) file(s) found:
  /mod_authz_svn_eecs.so

mod_authz_svn_eecs.so is being copied to the root ?!? I am very confused as to how %files installs files.

unSpawn 01-07-2011 06:15 PM

Odd. %{_libdir} should expand to %{_exec_prefix}/%{_lib}, %{_exec_prefix} should expand to %{_prefix} which is '%define _prefix /usr' if you 'rpmbuild --showrc|egrep "^-.*(_prefix|_exec_prefix|libdir)"'. Another way would be to use auto-fill which should make your %files section look like this:
Code:

%files -f %{_tmppath}/%{name}_contents.txt
before that add this to the end of your %install your section:
Code:

find $RPM_BUILD_ROOT -not -type d -printf "%%%attr(%%m,root,root) %%p\n" | sed -e "s|$RPM_BUILD_ROOT||g" > %{_tmppath}/%{name}_contents.txt
and check http://docs.fedoraproject.org/drafts...n/ch09s05.html for more nfo.

dilzniksan 01-10-2011 02:49 PM

working spec file
 
I went ahead and cleaned out all the temporary files from previous builds (which was probably why that errant file was being copied to root) and altered the spec file one last time, the cp in the %install section copies the file to the directory. This spec file works.

Code:

%prep
%setup -q -n mod_authz_svn_eecs
patch -i mod_authz_svn.patch -o mod_authz_svn_eecs.c
%{__mkdir_p} -m 755 $RPM_BUILD_ROOT%{_libdir}/httpd/modules

%install
apxs -i -c mod_authz_svn_eecs.c       
cp /usr/lib/httpd/modules/mod_authz_svn_eecs.so $RPM_BUILD_ROOT%{_libdir}/httpd/modules/


%files
%{_libdir}/httpd/modules/mod_authz_svn_eecs.so
%clean

%post

%changelog



All times are GMT -5. The time now is 06:23 PM.