PDA

View Full Version : Building my first RPM


john_erlandsson
28th August 2010, 04:04 PM
Hi!

Im having some problems building a package as an RPM. This is the first time i atempt something like this.

The package comes with a .spec file, but it is configured for openSUSE.

I altered it to fit my fedora system, and after a lot of struggling got it to build. But it still exits with an error in the install stage.

cp: cannot stat `/usr/src/kernels/2.6.33.8-149.fc13.i686/modules.order': No such file or directory
make: *** [_modinst_] Error 1
make: Leaving directory `/usr/src/kernels/2.6.33.8-149.fc13.i686'
error: Bad exit status from /var/tmp/rpm-tmp.h62rIF (%install)


I cant find anything in the .spec file that points to the modules.order dir.
On my system the modules.order file is in: /usr/src/kernels/<kernel version>/scripts/ but it is empty.

Any ideas?
Is it a matter of specifying the location of modules.order or is there something wrong with my kernel sources?

This is the original .spec file
# REMOVED THE COMMENTS TO SAVE SPACE
# vim: tw=78
#
#----------------------------------------------------------------------------

Name: @PACKAGE@
Version: @VERSION@
Release: 1

License: GPL
URL: http://etherlab.org/en/ethercat

Provides: @PACKAGE@
Source: %{name}-%{version}.tar.bz2
BuildRoot: /tmp/%{name}-%{version}

BuildRequires: %kernel_module_package_buildreqs

#----------------------------------------------------------------------------
# Main Package
#----------------------------------------------------------------------------

Summary: IgH EtherCAT Master
Group: EtherLab

%description
This is an open-source EtherCAT master implementation for Linux 2.6. See the
FEATURES file for a list of features. For more information, see
http://etherlab.org/en/ethercat.

%kernel_module_package

#----------------------------------------------------------------------------
# Development package
#----------------------------------------------------------------------------

%package devel

Summary: Development files for applications that use the EtherCAT master.
Group: EtherLab

%description devel
This is an open-source EtherCAT master implementation for Linux 2.6. See the
FEATURES file for a list of features. For more information, see
http://etherlab.org/en/ethercat.

#----------------------------------------------------------------------------

%prep
%setup

%build
%configure --enable-tty --enable-generic --enable-e100 \
--with-linux-dir=/usr/src/linux-obj/%_target_cpu/default
make
mkdir obj
for flavor in %flavors_to_build; do
target=obj/$flavor
rm -rf $target
mkdir $target
cp -r config.h globals.h Kbuild master/ devices/ \
examples/ tty/ include/ $target
make -C /usr/src/linux-obj/%_target_cpu/$flavor modules M=$PWD/$target
done

%install
for flavor in %flavors_to_build; do
md5sum obj/$flavor/Module.symvers
done
make DESTDIR=${RPM_BUILD_ROOT} install
for flavor in %flavors_to_build; do
target=obj/$flavor
make -C /usr/src/linux-obj/%_target_cpu/$flavor modules_install \
M=$PWD/$target INSTALL_MOD_PATH=${RPM_BUILD_ROOT} \
INSTALL_MOD_DIR=ethercat
done

%clean
rm -rf ${RPM_BUILD_ROOT}

%files
%defattr(-,root,root)
%doc AUTHORS
%doc COPYING
%doc COPYING.LESSER
%doc ChangeLog
%doc FEATURES
%doc INSTALL
%doc NEWS
%doc README
%doc README.EoE
/etc/init.d/ethercat
/etc/sysconfig/ethercat
/usr/bin/ethercat
/usr/lib/libethercat.so*

%files devel
%defattr(-,root,root)
/usr/include/*.h
/usr/lib/libethercat.a
/usr/lib/libethercat.la

#----------------------------------------------------------------------------

This is my .spec file
#----------------------------------------------------------------------------
# REMOVED THE COMMENTS TO SAVE SPACE
#
# vim: tw=78
#
#----------------------------------------------------------------------------

Name: ethercat
Version: 1.5
Release: 1

License: GPL
URL: http://etherlab.org/en/ethercat

Provides: ethercat
Source: %{name}-%{version}.tar.bz2
BuildRoot: /tmp/%{name}-%{version}

BuildRequires: %kernel_module_package_buildreqs

#----------------------------------------------------------------------------
# Main Package
#----------------------------------------------------------------------------

Summary: IgH EtherCAT Master
Group: EtherLab

%description
This is an open-source EtherCAT master implementation for Linux 2.6. See the
FEATURES file for a list of features. For more information, see
http://etherlab.org/en/ethercat.

%kernel_module_package

#----------------------------------------------------------------------------
# Development package
#----------------------------------------------------------------------------

%package devel

Summary: Development files for applications that use the EtherCAT master.
Group: EtherLab

%description devel
This is an open-source EtherCAT master implementation for Linux 2.6. See the
FEATURES file for a list of features. For more information, see
http://etherlab.org/en/ethercat.

#----------------------------------------------------------------------------

%prep
%setup

%build
./bootstrap
%configure --enable-tty --enable-generic --enable-e100=no --enable-8139too=no --enable-static=no \
--with-linux-dir=%{_usrsrc}/kernels/%{kverrel}${kvariant:+-$kvariant}.%{_target_cpu}

echo "configure complete"
sleep 3

make
mkdir obj
for flavor in %flavors_to_build; do
target=obj/$flavor
rm -rf $target
mkdir $target
cp -r config.h globals.h Kbuild master/ devices/ \
examples/ tty/ include/ $target
make -C %{_usrsrc}/kernels/%{kverrel}${kvariant:+-$kvariant}.%{_target_cpu} modules M=$PWD/$target
done

echo "Make complete"
sleep 3

%install
for flavor in %flavors_to_build; do
md5sum obj/$flavor/Module.symvers
done
make DESTDIR=${RPM_BUILD_ROOT} install
for flavor in %flavors_to_build; do
target=obj/$flavor
make -C %{_usrsrc}/kernels/%{kverrel}${kvariant:+-$kvariant}.%{_target_cpu} modules_install \
M=$PWD/$target INSTALL_MOD_PATH=${RPM_BUILD_ROOT} \
INSTALL_MOD_DIR=ethercat
done

echo "Install complete"
sleep 3

%clean
rm -rf ${RPM_BUILD_ROOT}

%files
%defattr(-,root,root)
%doc AUTHORS
%doc COPYING
%doc COPYING.LESSER
%doc ChangeLog
%doc FEATURES
%doc INSTALL
%doc NEWS
%doc README
%doc README.EoE
/etc/init.d/ethercat
/etc/sysconfig/ethercat
/usr/bin/ethercat
%{_libdir}/libethercat.so*

%files devel
%defattr(-,root,root)
%{_includedir}/*.h
%{_libdir}/libethercat.a
%{_libdir}/libethercat.la

#---------------------------------------------------------------------------

---------- Post added at 05:04 PM CDT ---------- Previous post was at 04:59 PM CDT ----------

I tried compiling this package on openSUSE befor attempting this since it seems to be customized for that distro.
I could not make it work there either until a hero (malcomlewis) on the opensuse forum built an rpm for me.

Thats what gave me the idea to use this method to make it work on Fedora, since im not too comfortable with opensuse.

I looked alot on his .spec file while making my own...

leigh123linux
28th August 2010, 04:07 PM
Change

BuildRequires: %kernel_module_package_buildreqs


to


BuildRequires: kernel-devel

john_erlandsson
28th August 2010, 04:07 PM

I also wonder what the fedora equivalent of the opensuse command "insserv <my module>" is.
I know that im supposed to use chkconfig for this, but not how.

leigh123linux
28th August 2010, 04:11 PM
I also wonder what the fedora equivalent of the opensuse command "insserv <my module>" is.
I know that im supposed to use chkconfig for this, but not how.


Does this link help

https://fedoraproject.org/wiki/Packaging/SysVInitScript

john_erlandsson
28th August 2010, 11:52 PM
still fails:
cp: cannot stat `/usr/src/kernels/2.6.33.8-149.fc13.i686/modules.order': No such file or directory
make: *** [_modinst_] Error 1
make: Leaving directory `/usr/src/kernels/2.6.33.8-149.fc13.i686'
error: Bad exit status from /var/tmp/rpm-tmp.htFdqX (%install)

Thanks for quick reply...

---------- Post added at 05:29 PM CDT ---------- Previous post was at 05:12 PM CDT ----------

That is helpful.
I guess i have to change the .spec file lines
/etc/rc.d/init.d/ethercat
/etc/sysconfig/ethercat

to

%config /etc/rc.d/init.d/ethercat
%config /etc/sysconfig/ethercat

and patch the initscript file with the #chkconfig line as described in that guide.
Still not sure which parameters to give chkconfig, but i will deal with that when my specfile works

---------- Post added at 07:09 PM CDT ---------- Previous post was at 05:29 PM CDT ----------

I tried adding an empty file with
touch /usr/src/kernels/2.6.33.8-149.fc13.i686/modules.order
touch /usr/src/kernels/2.6.33.8-149.fc13.i686/modules.builtin
The installation step then halted wit the error:
make: Entering directory `/usr/src/kernels/2.6.33.8-149.fc13.i686'
make[1]: *** No rule to make target `firmware/acenic/tg1.bin', needed by `/lib/firmware/acenic/tg1.bin'. Stop.
make: *** [_modinst_post] Error 2
make: Leaving directory `/usr/src/kernels/2.6.33.8-149.fc13.i686'
error: Bad exit status from /var/tmp/rpm-tmp.9EEisj (%install)

I am guessing/hoping that this is a result of the two modules files are empty...

Does anyone know what modules.order and modules.builtin are for?
Has anyone encountered something similar?

---------- Post added 2010-08-29 at 12:01 AM CDT ---------- Previous post was 2010-08-28 at 07:09 PM CDT ----------

removed the files that i created with touch and installed the akmods package, wich took me one step further!

now %install completes, but rpmbuild halts at:
Processing files: kmod-ethercat-1.5-1.i686
error: File not found: /home/makerpm/rpmbuild/BUILDROOT/ethercat-1.5-1.i386/lib/modules/2.6.33.8-149.fc13
error: File not found: /home/makerpm/rpmbuild/BUILDROOT/ethercat-1.5-1.i386/lib/firmware


RPM build errors:
File not found: /home/makerpm/rpmbuild/BUILDROOT/ethercat-1.5-1.i386/lib/modules/2.6.33.8-149.fc13
File not found: /home/makerpm/rpmbuild/BUILDROOT/ethercat-1.5-1.i386/lib/firmware


Any thoughts on that?

---------- Post added at 12:52 AM CDT ---------- Previous post was at 12:01 AM CDT ----------

It appears that it stops at the line:
%defattr(-,root,root)

just under %files devel

leigh123linux
29th August 2010, 12:08 AM
Build a srpm and attach it to the forum.


rpm -bs packagename.spec

john_erlandsson
29th August 2010, 12:53 AM
Couldn't attatch to the forum due to traffic.

Source RPM (http://www.lunatech.se/tmp/ethercat-1.5-1.src.rpm)
Specfile (http://www.lunatech.se/tmp/ethercat.spec)

john_erlandsson
29th August 2010, 03:59 PM
Here is a link to the specfile that works in opensuse 11.3
https://build.opensuse.org/package/view_file?file=ethercat.spec&package=ethercat&project=home%3Amalcolmlewis%3ATesting&srcmd5=cb7141442b1f1e1d8b9e5aa87c78e46f

john_erlandsson
30th August 2010, 03:34 PM
I altered the ethercat.spec file to make rpmlint stop wining.

The new specfile is here (http://www.lunatech.se/tmp2/ethercat.spec)
and the new srpm is here (http://www.lunatech.se/tmp2/ethercat-1.5-1.src.rpm)

I am getting nowhere with this build.

It still stops with the message:
Processing files: kmod-ethercat-1.5-1.i686
error: File not found: /home/makerpm/rpmbuild/BUILDROOT/ethercat-1.5-1.i386/lib/modules/2.6.33.8-149.fc13
error: File not found: /home/makerpm/rpmbuild/BUILDROOT/ethercat-1.5-1.i386/lib/firmware


RPM build errors:
File not found: /home/makerpm/rpmbuild/BUILDROOT/ethercat-1.5-1.i386/lib/modules/2.6.33.8-149.fc13
File not found: /home/makerpm/rpmbuild/BUILDROOT/ethercat-1.5-1.i386/lib/firmware

The directory /home/makerpm/rpmbuild/BUILDROOT/ethercat-1.5-1.i386/lib/ only contains a directory called "modules"

What are these files that rpmbuild is looking for?

---------- Post added at 04:34 PM CDT ---------- Previous post was at 02:55 PM CDT ----------

UPDATE:
I got the master running now. I did it the old fashion way (./configure; make; make modules; make install; make modules_install) and it works.

This should mean that there is no dependency issues in my RPMbuilding.

Still very confused about this...