File microcode_ctl.spec of Package microcode_ctl

#
# spec file for package microcode_ctl
#
# Copyright (c) 2012 SUSE LINUX Products GmbH, Nuernberg, Germany.
#
# All modifications and additions to the file contributed by third parties
# remain the property of their copyright owners, unless otherwise agreed
# upon. The license for this file, and modifications and additions to the
# file, is the same license as for the pristine package itself (unless the
# license for the pristine package is not an Open Source License, in which
# case the license is the MIT License). An "Open Source License" is a
# license that conforms to the Open Source Definition (Version 1.9)
# published by the Open Source Initiative.

# Please submit bugfixes or comments via http://bugs.opensuse.org/
#


Name:           microcode_ctl
%define intel_version 20120606-v2
%define amd_version 2012-09-10
ExclusiveArch:  %ix86 x86_64
Url:            http://www.urbanmyth.org/microcode/
Summary:        Microcode Updates for Intel and AMD64 x86/x86_64 CPUs
License:        GPL-2.0+ and SUSE-Firmware
Group:          Hardware/Other
Version:        1.17
Release:        0
Source0:        microcode_ctl-%{version}.tar.bz2
Source2:        microcode-%{intel_version}.tgz
Source3:        amd-ucode-%{amd_version}.tar.bz2
Source5:        intel-microcode2ucode.c
Patch0:         microcode.ctl_1.17-13.diff.gz
Patch1:         microcode_ctl-1.17-suse_rh_paths.patch
Patch2:         microcode-ctl-cloexec.patch
Supplements:    modalias(devname:cpu/microcode)
Supplements:    modalias(char-major-10-184)
Supplements:    modalias(x86cpu:vendor:0002:family:*:model:*:feature:*)
Supplements:    modalias(x86cpu:vendor:0000:family:*:model:*:feature:*)
BuildRoot:      %{_tmppath}/%{name}-%{version}-build

%description
This utility allows updating the microcode of Intel and AMD x86 and x86-64
CPUs.

%prep
%setup -q -a 3 -a 2
%patch0 -p1
%patch1
%patch2

%build
make CFLAGS="$RPM_OPT_FLAGS -I."
%{__cc} -fwhole-program %{optflags} %{S:5} -o generate_microcode
./generate_microcode microcode.dat

%install
%makeinstall
# AMD
install -D -m 0644 amd-ucode-%{amd_version}/microcode_amd.bin $RPM_BUILD_ROOT/lib/firmware/amd-ucode/microcode_amd.bin
install -m 0644 amd-ucode-%{amd_version}/microcode_amd_fam*.bin $RPM_BUILD_ROOT/lib/firmware/amd-ucode/
install -D -m 0644 amd-ucode-%{amd_version}/README $RPM_BUILD_ROOT/%{_defaultdocdir}/microcode_ctl/amd/README
install -D -m 0644 amd-ucode-%{amd_version}/LICENSE $RPM_BUILD_ROOT/%{_defaultdocdir}/microcode_ctl/amd/LICENSE
install -D -m 0644 amd-ucode-%{amd_version}/INSTALL $RPM_BUILD_ROOT/%{_defaultdocdir}/microcode_ctl/amd/INSTALL
install -D -m 0755 generate_microcode %{buildroot}%{_bindir}/generate_microcode
for file in intel-ucode/*; do
install -D -m 0644 $file %{buildroot}/lib/firmware/$file
done

%post
#if this fails, the user must either reboot or reload manually.
test -f /sys/devices/system/cpu/microcode/reload && /bin/echo 1 > /sys/devices/system/cpu/microcode/reload || exit 0

%clean
rm -rf $RPM_BUILD_ROOT;

%files
%defattr(-,root,root)
%{_bindir}/generate_microcode
/sbin/microcode_ctl
%dir /lib/firmware/amd-ucode
%dir /lib/firmware/intel-ucode
/lib/firmware/intel-ucode/*
/lib/firmware/amd-ucode/microcode_amd.bin
/lib/firmware/amd-ucode/microcode_amd_fam*.bin
%{_mandir}/man8/microcode_ctl.8.gz
%{_defaultdocdir}/microcode_ctl

%changelog