尝试在 Fedora 上为 acpi_call 构建 (a)kmod 包,无法安装

尝试在 Fedora 上为 acpi_call 构建 (a)kmod 包,无法安装

我想为 Fedora 打包一个简单的内核模块 acpi_call。为此我遵循了RPM Fusion 上的 kmods2 说明并得到以下 SPEC 文件:

# Copyright © 2016 Martin Ueding <[email protected]>

# A lot of boilerplate taken from
# http://rpmfusion.org/Packaging/KernelModules/Kmods2

#define buildforkernels newest
#define buildforkernels current
%define buildforkernels akmod

%define kmod_name acpi_call

%global debug_package %{nil}

Name:           %{kmod_name}
Version:        1.1.0
Release:        1%{?dist}
Summary:        Call ACPI methods by writing to /proc

License:        GPL3+
Source0:        https://github.com/mkottman/acpi_call/archive/v%{version}.tar.gz#/%{name}-%{version}.tar.gz

BuildRequires:  %{_bindir}/kmodtool

Requires: %{name}-kmod >= %{version}
Provides: %{name}-kmod-common = %{version}

# needed for plague to make sure it builds for i586 and i686
ExclusiveArch:  i586 i686 x86_64 ppc ppc64

# get the proper build-sysbuild package from the repo, which
# tracks in all the kernel-devel packages
BuildRequires:  %{_bindir}/kmodtool

%{!?kernels:BuildRequires: buildsys-build-rpmfusion-kerneldevpkgs-%{?buildforkernels:%{buildforkernels}}%{!?buildforkernels:current}-%{_target_cpu} }

# kmodtool does its magic here
%{expand:%(kmodtool --target %{_target_cpu} --repo rpmfusion --kmodname %{name} %{?buildforkernels:--%{buildforkernels}} %{?kernels:--for-kernels "%{?kernels}"} 2>/dev/null) }

%description

A kernel simple module that enables you to call ACPI methods by writing the
method name followed by arguments to /proc/acpi/call.

This module is to be considered a proof-of-concept and has been superseeded by
projects like bbswitch. It allows you to tamper with your system and should be
used with caution.

%prep

# error out if there was something wrong with kmodtool
%{?kmodtool_check}

%autosetup -n %{kmod_name}-%{version}

# print kmodtool output for debugging purposes:
kmodtool  --target %{_target_cpu}  --repo %{repo} --kmodname %{name} %{?buildforkernels:--%{buildforkernels}} %{?kernels:--for-kernels "%{?kernels}"} 2>/dev/null

for kernel_version in %{?kernel_versions} ; do
    cp -a foo-%{version} _kmod_build_${kernel_version%%___*}
done

%build

for kernel_version in %{?kernel_versions}; do
    make %{?_smp_mflags} -C "${kernel_version##*___}" SUBDIRS=${PWD}/_kmod_build_${kernel_version%%___*} modules
done

%install

rm -rf ${RPM_BUILD_ROOT}

for kernel_version in %{?kernel_versions}; do
    make install DESTDIR=${RPM_BUILD_ROOT} KMODPATH=%{kmodinstdir_prefix}/${kernel_version%%___*}/%{kmodinstdir_postfix}
    # install -D -m 755 _kmod_build_${kernel_version%%___*}/foo/foo.ko  ${RPM_BUILD_ROOT}%{kmodinstdir_prefix}/${kernel_version%%___*}/%{kmodinstdir_postfix}/foo.ko
done
%{?akmod_install}

%clean

rm -rf $RPM_BUILD_ROOT

%changelog

* Sat Jul 23 2016 Martin Ueding <[email protected]> 1.1.0-1
- Initial packaging

这个粘贴对于具有语法突出显示的版本。

它确实可以编译,rpmbuild -ba acpi_call.spec并且我确实得到了两个文件:

  • akmod-acpi_call-1.1.0-1.fc24.x86_64.rpm
  • kmod-acpi_call-1.1.0-1.fc24.x86_64.rpm

当我尝试使用 安装它们时dnf,我无法安装它们,因为-common缺少软件包:

# dnf install akmod-acpi_call-1.1.0-1.fc24.x86_64.rpm kmod-acpi_call-1.1.0-1.fc24.x86_64.rpm 
Last metadata expiration check: 0:47:46 ago on Sat Jul 23 11:03:54 2016.
Error: nothing provides acpi_call-kmod-common >= 1.1.0 needed by akmod-acpi_call-1.1.0-1.fc24.x86_64.
nothing provides acpi_call-kmod-common >= 1.1.0 needed by akmod-acpi_call-1.1.0-1.fc24.x86_64
(try to add '--allowerasing' to command line to replace conflicting packages)

我现在被困在这里了。没有-common创建任何软件包,并且安装这些软件包dnf似乎也不起作用。

我怎样才能把它放入一个包中?

答案1

kmodtool 需要一个*-kmod-common规范。这可以是非常简单的包,只包含基础知识。

%define modname yourmod

Name:           %{modname}-kmod-common

Version:        1.0
Release:        1%{?dist}.1
Summary:        Common files for your mod
Group:          System Environment/Kernel
License:        GPL
Source0:        ${name}-%{version}.tar.gz
BuildRoot:      %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)
BuildArch:      noarch

一个很好的例子是https://github.com/neatbasis/sunhme2g

构建它rpmbuild然后你可以打包所有东西createrepo

相关内容