File microcode_ctl.spec of Package microcode_ctl

# spec file for package microcode_ctl
# Copyright (c) 2011 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

# norootforbuild

Name:           microcode_ctl
%define intel_version 20110915
%define amd_version 2011-01-11
License:        GPLv2+ ; "the microcode itself has this license: ..."
ExclusiveArch:  %ix86 x86_64
Group:          Hardware/Other
Summary:        Microcode Updates for Intel CPUs
Version:        1.17
Release:        127
Source0:        microcode_ctl-%{version}.tar.bz2
Source1:        microcode.init
Source2:        microcode-%{intel_version}.tar.bz2
Source3:        amd-ucode-%{amd_version}.tar.bz2
Patch0:         microcode.ctl_1.17-13.diff.gz
Patch1:         microcode_ctl-1.17-suse_rh_paths.patch
Patch2:         microcode-ctl-cloexec.patch
BuildRoot:      %{_tmppath}/%{name}-%{version}-build
Requires(pre):  %insserv_prereq

This utility allows updating the microcode of Intel and AMD x86 and x86-64

%setup -q -a 3
%patch0 -p1


mkdir -p ${RPM_BUILD_ROOT}/etc/init.d
install -m 0755 %SOURCE1 ${RPM_BUILD_ROOT}/etc/init.d/microcode.ctl
mkdir -p ${RPM_BUILD_ROOT}/usr/sbin
ln -s /etc/init.d/microcode.ctl ${RPM_BUILD_ROOT}/usr/sbin/rcmicrocode.ctl

bunzip2 -dc %SOURCE2 > %{buildroot}/lib/firmware/microcode.dat

install -D -m 0644 amd-ucode-%{amd_version}/microcode_amd.bin $RPM_BUILD_ROOT/lib/firmware/amd-ucode/microcode_amd.bin
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 service on affected Intel/AMD machines by default
# Remove this after openSUSE 11.4 when the kernel can autoload microcode.ko

if grep Intel /proc/cpuinfo > /dev/null ; then
    %{fillup_and_insserv -fY microcode.ctl}
elif grep -q -i AuthenticAMD /proc/cpuinfo; then
    fam=`head /proc/cpuinfo |sed -n -e 's/cpu family.*: \([0-9]\+\)/\1/p'`
    # Only try to update when family >= 16 (0x10, fam 10h)
    if [ $fam -ge 16 >& /dev/null ];then
	%{fillup_and_insserv -fY microcode.ctl}


%dir /lib/firmware/amd-ucode
%doc %{_defaultdocdir}/microcode_ctl