Trouble with spec file / paths

Hi, I need a kick into my backside. I am currently trying to build a package for mjpg-streamer. I decided to have the following layout:

  • The executable goes into /usr/bin

  • Some modules required by the executable should end up in /usr/share/mjpg-streamer/lib

  • A couple of html scripts used by the executable go into /usr/share/mjpg-streamer/www to avoid conflicts with apache.

The application compiles with build but then throws errors during the checks. This is the spec file:

# norootforbuild
Summary: Streams JPEG files from the webcam to a viewer
Name: mjpg-streamer
Version: 2.0
Release: 1
License: GPLv2
Group: Applications/Multimedia
Source: %{name}-%{version}.tar.bz2
Patch0: %{name}.Makefile.patch
URL: http://mjpg-streamer.sourceforge.net/
BuildRequires: libjpeg-devel SDL-devel unzip
Requires: libjpeg SDL
%if 0%{?suse_version} < 1120
BuildRoot: %{_tmppath}/%{name}-%{version}
%endif

Autoreqprov: on

%description
MJPG-streamer takes JPGs from Linux-UVC compatible webcams, filesystem or
other input plugins and streams them as M-JPEG via HTTP to webbrowsers, VLC
and other software. It is the successor of uvc-streamer, a Linux-UVC
streaming application with Pan/Tilt.

%prep
%setup -q -n %{name}-%{version}
%patch0

%build
make %{?_smp_mflags}

%install
make DESTDIR="%{buildroot}" install

%if 0%{?suse_version} < 1120
%clean
%{__rm} -rf '%{buildroot}'
%endif

%files
%defattr(-,root,root)
%doc README CHANGELOG LICENSE start.sh
%{_bindir}/mjpg_streamer
%{_datadir}/%{name}/lib/input_control.so
%{_datadir}/%{name}/lib/input_file.so
 . . . (many more)
%{_datadir}/%{name}/www/index.html
%{_datadir}/%{name}/www/java_control.html

The Makefile of this application installs like this:

Executing(%install): /bin/sh -e /var/tmp/rpm-tmp.86268                          
+ umask 022                                                                     
+ cd /usr/src/packages/BUILD                                                    
+ cd mjpg-streamer-2.0                                                          
+ make DESTDIR=/var/tmp/mjpg-streamer-2.0 install                               
install --mode=755 -d /var/tmp/mjpg-streamer-2.0/usr/bin                        
install --mode=755 mjpg_streamer /var/tmp/mjpg-streamer-2.0/usr/bin             
install --mode=755 -d /var/tmp/mjpg-streamer-2.0/usr/share/mjpg_streamer/lib    
install --mode=755 input_uvc.so output_file.so output_http.so input_testpicture.so output_autofocus.so input_gspcav1.so input_file.so input_control.so output_viewer.so /var/tmp/mjpg-streamer-2.0/usr/share/mjpg_streamer/lib/                 
install --mode=755 -d /var/tmp/mjpg-streamer-2.0/usr/share/mjpg_streamer/www    
install --mode=644 -D www/* /var/tmp/mjpg-streamer-2.0/usr/share/mjpg_streamer/www                                                                              
+ RPM_BUILD_ROOT=/var/tmp/mjpg-streamer-2.0                                     
+ export RPM_BUILD_ROOT

And then it throws errors:

Processing files: mjpg-streamer-2.0-1                                           
error: File not found: /var/tmp/mjpg-streamer-2.0/usr/share/mjpg-streamer/lib/input_control.so                                                                  
error: File not found: /var/tmp/mjpg-streamer-2.0/usr/share/mjpg-streamer/lib/input_file.so
Executing(%doc): /bin/sh -e /var/tmp/rpm-tmp.92581                              
+ umask 022                                                                     
+ cd /usr/src/packages/BUILD                                                    
+ cd mjpg-streamer-2.0                                                          
+ DOCDIR=/var/tmp/mjpg-streamer-2.0/usr/share/doc/packages/mjpg-streamer        
+ export DOCDIR                                                                 
+ rm -rf /var/tmp/mjpg-streamer-2.0/usr/share/doc/packages/mjpg-streamer        
+ /bin/mkdir -p /var/tmp/mjpg-streamer-2.0/usr/share/doc/packages/mjpg-streamer 
+ cp -pr README CHANGELOG LICENSE start.sh /var/tmp/mjpg-streamer-2.0/usr/share/doc/packages/mjpg-streamer                                                      
+ exit 0                                                                        
Checking for unpackaged file(s): /usr/lib/rpm/check-files /var/tmp/mjpg-streamer-2.0                                                                            
error: Installed (but unpackaged) file(s) found:                                
   /usr/share/mjpg_streamer/lib/input_control.so                                
   /usr/share/mjpg_streamer/lib/input_file.so
   . . . (many more)

as a consequence:

RPM build errors:
    File not found: /var/tmp/mjpg-streamer-2.0/usr/share/mjpg-streamer/lib/input_control.so                                                                     
    File not found: /var/tmp/mjpg-streamer-2.0/usr/share/mjpg-streamer/lib/input_file.so
    Installed (but unpackaged) file(s) found:                                   
   /usr/share/mjpg_streamer/lib/input_control.so                                
   /usr/share/mjpg_streamer/lib/input_file.so

What am I doing wrong?

Hi
Your installing the files in mjpg-streamer-2.0 but I’m guessing your
%files section is pointing to mjpg_streamer (See no -2.0).


Cheers Malcolm °¿° (Linux Counter #276890)
SUSE Linux Enterprise Desktop 11 (x86_64) Kernel 2.6.27.45-0.1-default
up 1 day 13:11, 3 users, load average: 0.02, 0.10, 0.15
GPU GeForce 8600 GTS Silent - CUDA Driver Version: 190.53

Your installing the files in mjpg-streamer-2.0 but I’m guessing your
%files section is pointing to mjpg_streamer (See no -2.0).

I tried to change this to:

%files
%defattr(-,root,root)
%doc README CHANGELOG LICENSE start.sh
%{_bindir}/mjpg_streamer
%{_datadir}/%{name}-%{version}/lib/input_control.so
.....

but this did not help. So I reverted the change back. When I go and have a look I see:

cd /var/tmp/mjpg-streamer-2.0
host:/var/tmp/mjpg-streamer-2.0 # find . -name input_control.so
./var/tmp/mjpg-streamer-2.0/usr/share/mjpg_streamer/lib/input_control.so
./usr/src/packages/BUILD/mjpg-streamer-2.0/input_control.so
./usr/src/packages/BUILD/mjpg-streamer-2.0/plugins/input_control/input_control.so

but it says:

RPM build errors:
    File not found: /var/tmp/mjpg-streamer-2.0/usr/share/mjpg-streamer/lib/input_control.so

I have the strange feeling that I’m overlooking something obvious or have some deep misconception.

Hi
Can you provide a link to your OBS project?


Cheers Malcolm °¿° (Linux Counter #276890)
SUSE Linux Enterprise Desktop 11 (x86_64) Kernel 2.6.27.45-0.1-default
up 1 day 14:12, 3 users, load average: 0.27, 0.24, 0.18
GPU GeForce 8600 GTS Silent - CUDA Driver Version: 190.53

Yes, shortly. For the time I was trying to get it working locally with the build utility, but I will upload it that you can see the whole picture.

In general:

NEVER install architecture dependent files (I would bet those so-files are) into /usr/share/whatever, rpmlint will cry out loud about this, even if you manage to fix the above problem.

The link is:

https://build.opensuse.org/package/show?package=mjpg-streamer&project=home%3Avodoo

NEVER install architecture dependent files (I would bet those so-files are) into /usr/share/whatever, rpmlint will cry out loud about this, even if you manage to fix the above problem.

I hear your voice. You would suggest to put them into the big basket at /usr/lib ???

No!

Not /usr/lib, but %{_libdir}, which is not the same.

Use macros as often as possible, this will save you a lot of work and prevent lots of trouble.

Smile; on my machine it’s the same. But of course I use the makro. Effect of this change is: no more error message regarding the *.so modules.

However, the html files are system independent and these still don’t install.

Hi
In you patch, your installing the binary as bin add a trailing / You
have it right for the lib files (as Akoellh pointed out but the wronng
location). Also don’t for get to include a ldconfig for the libraries;
http://en.opensuse.org/Packaging/Scriptlet_Snippets#Shared_libraries


Cheers Malcolm °¿° (Linux Counter #276890)
SUSE Linux Enterprise Desktop 11 (x86_64) Kernel 2.6.27.45-0.1-default
up 1 day 14:56, 4 users, load average: 0.02, 0.16, 0.26
GPU GeForce 8600 GTS Silent - CUDA Driver Version: 190.53

In you patch, your installing the binary as bin add a trailing / You have it right for the lib files (as Akoellh pointed out but the wrong location). Also don’t for get to include a ldconfig for the libraries; Packaging/Scriptlet Snippets - openSUSE

Hi again, and thank you for this help.

I added the trailing slash and did put the lib files at %{_libdir}. They install ok now (still wonder why they didn’t at the wrong place before). This suggests to me that I have to change something in the %files section as well to make the www stuff install.

BTW these *.so files are loaded by the executable at runtime with the dlopen() function and found at a location set in the LD_LIBRARY_PATH environment variable. This should work even without ldconfig.

If %makeinstall does not do the job for you, then install them “by hand” in your %install section or use the %doc-macro if applicable.

Hi
Your libdir is still not correct for 64bit builds, the www files are
in mjpg_streamer whilst %{name} is mjpg-streamer


Cheers Malcolm °¿° (Linux Counter #276890)
SUSE Linux Enterprise Desktop 11 (x86_64) Kernel 2.6.27.45-0.1-default
up 1 day 16:30, 5 users, load average: 0.48, 0.27, 0.20
GPU GeForce 8600 GTS Silent - CUDA Driver Version: 190.53

Your libdir is still not correct for 64bit builds, the www files are in mjpg_streamer whilst %{name} is mjpg-streamer

Bingo! The subtle difference between an underscore and a hyphen. I see some light coming through the fog. I fix this and report back.

Better put them into %{__libdir}/<package>/
Packaging/Shared Libraries - openSUSE

Hi
Put the so files under the rpm name, also your files section only needs
to be something like;


%files
%defattr(-,root,root)
%doc README CHANGELOG LICENSE start.sh
%{_bindir}/mjpg_streamer
%{_libdir}/%{name}/*.so
%{_datadir}/mjpg_streamer/www/*


Cheers Malcolm °¿° (Linux Counter #276890)
SUSE Linux Enterprise Desktop 11 (x86_64) Kernel 2.6.27.45-0.1-default
up 1 day 16:51, 5 users, load average: 0.35, 0.29, 0.21
GPU GeForce 8600 GTS Silent - CUDA Driver Version: 190.53

Hi again, saying thank you to all of you.

I have learnt a lot within a short time and the package builds successful now for 11.0 / 11.1 and 11.2. It still needs quite a bit of cleaning up and being documented the SUSE way. I will do this within the next few days, hoping it will be useful for the community.

Going to bed now, it’s half past midnight here.