<div class="gmail_quote">
<div>Hi all,</div>
<div> </div>
<div>I find that the kmod template in rpmfusion(<a href="http://rpmfusion.org/Packaging/KernelModules/Kmods2">http://rpmfusion.org/Packaging/KernelModules/Kmods2</a>) seems a bit old.</div>
<div><a href="http://rpmfusion.org/Packaging/KernelModules/Kmods2"></a> </div>
<div>e.g.</div>
<div>Still using old Old syntax make ... SUBDIRS=$PWD </div>
<div>make install in %install section cannot work properly on many modern kernel modules.</div>
<div> </div>
<div>So I make some minor changes for this template, maybe its useful for someone.</div>
<div> </div>
<div>%build<br>for kernel_version in %{?kernel_versions}; do<br> make %{?_smp_mflags} -C "${kernel_version##*___}" SUBDIRS=${PWD}/_kmod_build_${kernel_version%%___*} modules<br>done<br>-></div>
<div>%build<br>for kernel_version in %{?kernel_versions}; do<br> make %{?_smp_mflags} -C "${kernel_version##*___}" M=${PWD}/_kmod_build_${kernel_version%%___*} modules<br>done<br></div>
<div>%install<br>rm -rf ${RPM_BUILD_ROOT}<br><br>for kernel_version in %{?kernel_versions}; do<br> make install DESTDIR=${RPM_BUILD_ROOT} KMODPATH=%{kmodinstdir_prefix}/${kernel_version%%___*}/%{kmodinstdir_postfix}<br>
# install -D -m 755 _kmod_build_${kernel_version%%___*}/foo/foo.ko ${RPM_BUILD_ROOT}%{kmodinstdir_prefix}/${kernel_version%%___*}/%{kmodinstdir_postfix}/foo.kmod<br>done<br>-></div>
<div>%install<br>rm -rf ${RPM_BUILD_ROOT}<br><br>for kernel_version in %{?kernel_versions}; do<br> make -C "${kernel_version##*___}" M=${PWD}/_kmod_build_${kernel_version%%___*} _emodinst_ INSTALL_MOD_PATH=${RPM_BUILD_ROOT} INSTALL_MOD_DIR=%{kmodinstdir_postfix}</div>
<div>or</div>
<div>#</div>
<div>make -C "${kernel_version##*___}" M=${PWD}/_kmod_build_${kernel_version%%___*} _emodinst_ INSTALL_MOD_PATH=${RPM_BUILD_ROOT} ext-mod-dir=%{kmodinstdir_postfix}<br> done<br></div>
<div> </div>
<div>One thing that I'm still not sure is choosing between INSTALL_MOD_DIR and ext-mod-dir. If we set ext-mod-dir, then all ko files will go into one directory even those ko files are in the subdirectoris of M dir. On the contray, INSTALL_MOD_DIR will preserve subdirectories in M dir. I don't know which one is better.</div>
<div> </div>
<div>e.g.</div>
<div>xtables-addons-kmod</div>
<div>The ko files before installing are located in four dirs M, M/ipset, M/pknock and M/ACCOUNT.</div>
<div> </div>
<div> ext-mod-dir </div>
<div>.:<br>compat_xtables.ko ipt_set.ko xt_length2.ko<br>ip6table_rawpost.ko ipt_SET.ko xt_LOGMARK.ko<br>ip_set_iphash.ko xt_ACCOUNT.ko xt_lscan.ko<br>ip_set_ipmap.ko xt_CHAOS.ko xt_pknock.ko<br>
ip_set_ipporthash.ko xt_condition.ko xt_psd.ko<br>ip_set_iptree.ko xt_DELUDE.ko xt_quota2.ko<br>ip_set_iptreemap.ko xt_DHCPMAC.ko xt_RAWNAT.ko<br>ip_set.ko xt_fuzzy.ko xt_STEAL.ko<br>
ip_set_macipmap.ko xt_geoip.ko xt_SYSRQ.ko<br>ip_set_nethash.ko xt_iface.ko xt_TARPIT.ko<br>ip_set_portmap.ko xt_IPMARK.ko xt_TEE.ko<br>ip_set_setlist.ko xt_ipp2p.ko<br>iptable_rawpost.ko xt_ipv4options.ko</div>
<div> </div>
<div> </div>
<div> </div>
<div> INSTALL_MOD_DIR </div>
<div>.:<br>ACCOUNT xt_DHCPMAC.ko xt_lscan.ko<br>compat_xtables.ko xt_fuzzy.ko xt_psd.ko<br>ip6table_rawpost.ko xt_geoip.ko xt_quota2.ko<br>ipset xt_iface.ko xt_RAWNAT.ko<br>
iptable_rawpost.ko xt_IPMARK.ko xt_STEAL.ko<br>pknock xt_ipp2p.ko xt_SYSRQ.ko<br>xt_CHAOS.ko xt_ipv4options.ko xt_TARPIT.ko<br>xt_condition.ko xt_length2.ko xt_TEE.ko<br>xt_DELUDE.ko xt_LOGMARK.ko</div>
<div>./ACCOUNT:<br>xt_ACCOUNT.ko</div>
<div>./ipset:<br>ip_set_iphash.ko ip_set_iptreemap.ko ip_set_portmap.ko<br>ip_set_ipmap.ko ip_set.ko ip_set_setlist.ko<br>ip_set_ipporthash.ko ip_set_macipmap.ko ipt_set.ko<br>ip_set_iptree.ko ip_set_nethash.ko ipt_SET.ko</div>
<div>./pknock:<br>xt_pknock.ko</div>
<div> </div>
<div>Definitions of INSTALL_MOD_DIR and ext-mod-dir in Makefile.modinst </div>
<div> </div>
<div># Modules built outside the kernel source tree go into extra by default<br>INSTALL_MOD_DIR ?= extra<br>ext-mod-dir = $(INSTALL_MOD_DIR)$(subst $(patsubst %/,%,$(KBUILD_EXTMOD)),,$(@D))</div>
<div>modinst_dir = $(if $(KBUILD_EXTMOD),$(ext-mod-dir),kernel/$(@D))</div>
<div> </div>
<div>Cheers,</div>
<div>Chen Lei</div>
<div> </div>
<div> </div>
<div> </div>
<div> </div>
<div> </div></div>