diff options
author | Anas Nashif <anas.nashif@intel.com> | 2012-11-05 10:52:25 -0800 |
---|---|---|
committer | Anas Nashif <anas.nashif@intel.com> | 2012-12-29 07:06:38 -0800 |
commit | 6a71e80e00b5ad6dbe05cb6e9d1d7342d2448554 (patch) | |
tree | bff677f5870ce595b2a6a6b2b564d05ec14e7453 | |
parent | 0221a881b50d2db43965dc61f9817148fad57575 (diff) | |
download | kmod-6a71e80e00b5ad6dbe05cb6e9d1d7342d2448554.tar.gz kmod-6a71e80e00b5ad6dbe05cb6e9d1d7342d2448554.tar.bz2 kmod-6a71e80e00b5ad6dbe05cb6e9d1d7342d2448554.zip |
add packaging
-rw-r--r-- | packaging/fix-32bits.diff | 79 | ||||
-rw-r--r-- | packaging/kmod-so-version.diff | 24 | ||||
-rw-r--r-- | packaging/kmod.spec | 141 |
3 files changed, 244 insertions, 0 deletions
diff --git a/packaging/fix-32bits.diff b/packaging/fix-32bits.diff new file mode 100644 index 0000000..60b72c6 --- /dev/null +++ b/packaging/fix-32bits.diff @@ -0,0 +1,79 @@ +diff --git a/testsuite/init_module.c b/testsuite/init_module.c +index 814998a..ed8b9fc 100644 +--- a/testsuite/init_module.c ++++ b/testsuite/init_module.c +@@ -16,6 +16,7 @@ + */ + + #include <assert.h> ++#include <elf.h> + #include <errno.h> + #include <dirent.h> + #include <fcntl.h> +@@ -206,6 +207,12 @@ static inline bool module_is_inkernel(const char *modname) + return ret; + } + ++static uint8_t elf_identify(void *mem) ++{ ++ uint8_t *p = mem; ++ return p[EI_CLASS]; ++} ++ + TS_EXPORT long init_module(void *mem, unsigned long len, const char *args); + + /* +@@ -225,6 +232,8 @@ long init_module(void *mem, unsigned long len, const char *args) + const void *buf; + uint64_t bufsize; + int err; ++ uint8_t class; ++ off_t offset; + + init_retcodes(); + +@@ -237,13 +246,20 @@ long init_module(void *mem, unsigned long len, const char *args) + kmod_elf_unref(elf); + + /* +- * We couldn't find the module's name inside the ELF file. Just exit +- * as if it was successful ++ * We couldn't find the parse the ELF file. Just exit as if it was ++ * successful + */ + if (err < 0) + return 0; + +- modname = (char *)buf + offsetof(struct module, name); ++ /* We need to open both 32 and 64 bits module - hack! */ ++ class = elf_identify(mem); ++ if (class == ELFCLASS64) ++ offset = MODULE_NAME_OFFSET_64; ++ else ++ offset = MODULE_NAME_OFFSET_32; ++ ++ modname = (char *)buf + offset; + mod = find_module(modules, modname); + if (mod != NULL) { + errno = mod->errcode; +diff --git a/testsuite/stripped-module.h b/testsuite/stripped-module.h +index 9f97dae..19862f3 100644 +--- a/testsuite/stripped-module.h ++++ b/testsuite/stripped-module.h +@@ -13,6 +13,7 @@ struct list_head { + }; + + #define MODULE_NAME_LEN (64 - sizeof(unsigned long)) ++ + struct module + { + enum module_state state; +@@ -24,4 +25,8 @@ struct module + char name[MODULE_NAME_LEN]; + }; + ++/* padding */ ++#define MODULE_NAME_OFFSET_64 4 + 4 + 2 * 8 ++#define MODULE_NAME_OFFSET_32 4 + 2 * 4 ++ + #endif diff --git a/packaging/kmod-so-version.diff b/packaging/kmod-so-version.diff new file mode 100644 index 0000000..37ed83d --- /dev/null +++ b/packaging/kmod-so-version.diff @@ -0,0 +1,24 @@ +Index: kmod-9/Makefile.am +=================================================================== +--- kmod-9.orig/Makefile.am ++++ kmod-9/Makefile.am +@@ -33,10 +33,6 @@ SED_PROCESS = \ + %.pc: %.pc.in Makefile + $(SED_PROCESS) + +-LIBKMOD_CURRENT=3 +-LIBKMOD_REVISION=3 +-LIBKMOD_AGE=1 +- + noinst_LTLIBRARIES = libkmod/libkmod-util.la + libkmod_libkmod_util_la_SOURCES = libkmod/libkmod-hash.c \ + libkmod/libkmod-hash.h \ +@@ -65,7 +61,7 @@ EXTRA_DIST += libkmod/libkmod.sym + EXTRA_DIST += libkmod/COPYING libkmod/README + + libkmod_libkmod_la_LDFLAGS = $(AM_LDFLAGS) \ +- -version-info $(LIBKMOD_CURRENT):$(LIBKMOD_REVISION):$(LIBKMOD_AGE) \ ++ -version-number 2:1 \ + -Wl,--version-script=$(top_srcdir)/libkmod/libkmod.sym + libkmod_libkmod_la_DEPENDENCIES = libkmod/libkmod-util.la \ + ${top_srcdir}/libkmod/libkmod.sym diff --git a/packaging/kmod.spec b/packaging/kmod.spec new file mode 100644 index 0000000..452254f --- /dev/null +++ b/packaging/kmod.spec @@ -0,0 +1,141 @@ +Name: kmod +Version: 9 +Release: 0 +License: LGPL-2.1+ and GPL-2.0+ +%define lname libkmod +Summary: Utilities to load modules into the kernel +Url: http://www.politreco.com/2011/12/announce-kmod-2/ +Group: System/Kernel + +#Git-Web: http://git.kernel.org/?p=utils/kernel/kmod/kmod.git;a=summary +#Git-Clone: git://git.kernel.org/pub/scm/utils/kernel/kmod/kmod +Source: %{name}-%{version}.tar.xz +Source2: %{name}-%{version}.tar.sign +Patch1: kmod-so-version.diff +Patch2: fix-32bits.diff + +BuildRequires: autoconf +BuildRequires: automake +BuildRequires: libtool +BuildRequires: pkgconfig >= 0.21 +BuildRequires: xz +BuildRequires: pkgconfig(liblzma) >= 4.99 +BuildRequires: pkgconfig(zlib) +BuildRoot: %{_tmppath}/%{name}-%{version}-build + +%description +kmod is a set of tools to handle common tasks with Linux kernel +modules like insert, remove, list, check properties, resolve +dependencies and aliases. + +These tools are designed on top of libkmod, a library that is shipped +with kmod. The aim is to be compatible with tools, configurations and +indexes from module-init-tools project. + +%package compat +License: GPL-2.0+ +Summary: Compat symlinks for kernel module utilities +Group: System/Kernel +Conflicts: module-init-tools +Requires(pre): filesystem + +%description compat +kmod is a set of tools to handle common tasks with Linux kernel +modules like insert, remove, list, check properties, resolve +dependencies and aliases. + +This package contains traditional name symlinks (lsmod, etc.) + +%package -n %lname +License: LGPL-2.1+ +Summary: Library to interact with Linux kernel modules +Group: System/Libraries + +%description -n %lname +libkmod was created to allow programs to easily insert, remove and +list modules, also checking its properties, dependencies and aliases. + +%package -n libkmod-devel +License: LGPL-2.1+ +Summary: Development files for libkmod +Group: Development/Libraries/C and C++ +Requires: %lname = %{version} + +%description -n libkmod-devel +libkmod was created to allow programs to easily insert, remove and +list modules, also checking its properties, dependencies and aliases. + +This package contains the development headers for the library found +in %lname. + +%prep +%setup -q +%patch1 -p1 +%patch2 -p1 + +%build +autoreconf -fi +# The extra --includedir gives us the possibility to detect dependent +# packages which fail to properly use pkgconfig. +%configure \ + --with-xz \ + --with-zlib \ + --includedir=%{_includedir}/%{name}-%{version} \ + --with-rootlibdir=%{_libdir} \ + --bindir=%{_bindir} +make %{?_smp_mflags} + +%check +make check + +%install +%make_install +rm -f %{buildroot}/%{_libdir}/*.la + +# kmod-compat +mkdir -p %{buildroot}/%{_sbindir} +ln -s %{_bindir}/kmod %{buildroot}/%{_bindir}/lsmod +for i in depmod insmod lsmod modinfo modprobe rmmod; do + ln -s %{_bindir}/kmod %{buildroot}/%{_sbindir}/$i +done; + + +%post -n %lname -p /sbin/ldconfig + +%postun -n %lname -p /sbin/ldconfig + +%files +%defattr(-,root,root) +%{_bindir}/kmod +%{_mandir}/man5/modules.dep.bin.5* + +%files -n %lname +%defattr(-,root,root) +%{_libdir}/libkmod.so.2* + +%files -n libkmod-devel +%defattr(-,root,root) +%{_includedir}/* +%{_libdir}/pkgconfig/libkmod.pc +%{_libdir}/libkmod.so + +%files compat +%defattr(-,root,root) +%{_bindir}/lsmod +%{_sbindir}/depmod +%{_sbindir}/insmod +%{_sbindir}/lsmod +%{_sbindir}/modinfo +%{_sbindir}/modprobe +%{_sbindir}/rmmod +%{_mandir}/man5/depmod.d.5* +%{_mandir}/man5/modprobe.d.5* +%{_mandir}/man5/modules.dep.5* +%{_mandir}/man8/depmod.8* +%{_mandir}/man8/insmod.8* +%{_mandir}/man8/lsmod.8* +%{_mandir}/man8/modinfo.8* +%{_mandir}/man8/modprobe.8* +%{_mandir}/man8/rmmod.8* + +%changelog |