File microcode_ctl.spec of Package microcode_ctl

#
# spec file for package microcode_ctl
#
# Copyright (c) 2018 SUSE LINUX 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/
#

# norootforbuild
# needssslcertforbuild


Name:           microcode_ctl
BuildRequires:  pesign-obs-integration
%define data_version 20180312
%define amd_version  20180104
License:        GPL-2.0+
ExclusiveArch:  %ix86 x86_64
Url:            http://www.urbanmyth.org/microcode/
Group:          Hardware/Other
AutoReqProv:    on
Requires(post): coreutils
Summary:        Microcode Updates for Intel CPUs
Version:        1.17
Release:        103.1.2
Source0:        microcode_ctl-%{version}.tar.bz2
Source1:        microcode.init
Source2:        microcode-%{data_version}.dat.bz2
Source3:        microcode_ctl-1.17-rpmlintrc
Source4:        microcode_amd.bin
Source5:        AMD-MICROCODE-LICENSE
Source6:        AMD-MICROCODE-README
Source7:        microcode_amd_fam15h.bin
Source8:        microcode_amd_fam15h.bin.README
Source9:        microcode_amd.bin.README
Source10:       microcode_amd_fam16h.bin
Source11:       microcode_amd_fam17h.bin
Source12:       intel-microcode2ucode.c
Patch0:         microcode-select.diff
%define prefix  /usr
BuildRoot:      %{_tmppath}/%{name}-%{version}-build
PreReq:         %insserv_prereq

%description
This utility allows updating the microcode of Intel x86 and x86-64
CPUs. This feature is supported by Pentium II and newer CPUs.



Authors:
--------
    Simon Trimmer <simon@veritas.com>

%prep
%setup
%patch0 -p1

%build
tar -O -xf %SOURCE2 > microcode.dat
make CFLAGS="$RPM_OPT_FLAGS -I."
%{__cc} -fwhole-program %{optflags} %SOURCE12 -o generate_microcode
./generate_microcode microcode.dat

%install
make DESTDIR=${RPM_BUILD_ROOT} \
	PREFIX=/ \
	MANDIR=%{_mandir}/man8 \
	install
mkdir -p ${RPM_BUILD_ROOT}/etc/init.d
rm -f $RPM_BUILD_ROOT/etc/init.d/microcode_ctl
install -m 0755 $RPM_SOURCE_DIR/microcode.init \
        ${RPM_BUILD_ROOT}/etc/init.d/microcode.ctl
install -D -m 0444 microcode.dat $RPM_BUILD_ROOT/etc/microcode.dat
install -D -m 0644 %SOURCE4 $RPM_BUILD_ROOT/lib/firmware/amd-ucode/microcode_amd.bin
install -D -m 0644 %{SOURCE5} %{buildroot}/%{_docdir}/%{name}/AMD-MICROCODE-LICENSE-%{amd_version}
install -D -m 0644 %SOURCE6 %{buildroot}/%{_docdir}/%{name}/AMD-MICROCODE-README-%{amd_version}
install -D -m 0644 %SOURCE7 $RPM_BUILD_ROOT/lib/firmware/amd-ucode/microcode_amd_fam15h.bin
install -D -m 0644 %SOURCE10 $RPM_BUILD_ROOT/lib/firmware/amd-ucode/microcode_amd_fam16h.bin
install -D -m 0644 %SOURCE11 $RPM_BUILD_ROOT/lib/firmware/amd-ucode/microcode_amd_fam17h.bin
install -D -m 0644 %SOURCE8  %{buildroot}/%{_docdir}/%{name}/microcode_amd_fam15h.bin.README
install -D -m 0644 %SOURCE9  %{buildroot}/%{_docdir}/%{name}/microcode_amd.bin.README
install -D -m 0644 README %{buildroot}/%{_docdir}/%{name}/README
install -D -m 0644 Changelog %{buildroot}/%{_docdir}/%{name}/Changelog
for file in intel-ucode/*; do
install -D -m 0644 $file %{buildroot}/lib/firmware/$file
done
export BRP_PESIGN_FILES="/lib/firmware"

%post
if [ -L /etc/init.d/rcS.d/*microcode.ctl ];then
    rm -f /etc/init.d/rcS.d/*microcode.ctl
fi
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}
    fi
fi
if [ -L /etc/init.d/rcS.d/*microcode.ctl ];then
    rm -f /etc/init.d/rcS.d/*microcode.ctl
fi

%preun
%stop_on_removal

%postun
%{insserv_cleanup}

%clean
[ "$RPM_BUILD_ROOT" != "/" ] && [ -d $RPM_BUILD_ROOT ] && rm -rf $RPM_BUILD_ROOT;

%files
%defattr(-,root,root)
/etc/microcode.dat
%dir /lib/firmware/amd-ucode
/lib/firmware/amd-ucode/microcode_amd.bin
/lib/firmware/amd-ucode/microcode_amd_fam15h.bin
/lib/firmware/amd-ucode/microcode_amd_fam16h.bin
/lib/firmware/amd-ucode/microcode_amd_fam17h.bin
%dir /lib/firmware/intel-ucode
/lib/firmware/intel-ucode/*
/etc/init.d/microcode.ctl
/sbin/microcode_ctl
%doc %{_mandir}/man8/microcode_ctl.8.gz
%doc %{_docdir}/%{name}

%changelog
* Wed Apr  6 2018 zenitur@ya.ru
- Update Intel microcode to version 20180312
* Wed Jan 10 2018 zenitur@ya.ru
- Update Intel microcode to version 20180108
- Update AMD microcode to version 20180104
- Add microcode_amd_fam16h.bin
- Add microcode_amd_fam17h.bin (bsc#1068032 CVE-2017-5715)
* Thu Jun 11 2015 lchiquitto@suse.de
- Replace microcode.dat in microcode-20150121.dat.bz2 with the
  correct (Jan 21 2015) version. (bsc#932708, bsc#934181)
* Wed Mar 25 2015 trenn@suse.de
- Update Intel microcode to version 20150121 (bnc#913005)
* Wed Aug 13 2014 bwiedemann@suse.com
- Require coreutils during post for head (bnc#891765)
* Wed Jul 16 2014 trenn@suse.de
- Update Intel microcode to version 20140624 (bnc#885215)
* Mon May  5 2014 trenn@suse.de
- Update Intel microcode to version 20140430 (bnc#876073)
* Thu Feb 27 2014 trenn@suse.de
- Update Intel microcode to version 20140122
  bnc#865828
* Fri Sep 27 2013 trenn@suse.de
- Update Intel microcode to version 20130906
  bnc#841723
* Thu Aug 15 2013 lchiquitto@suse.de
- Intel's microcode is now shipped as a compressed tarball (bnc#825259)
* Tue Aug 13 2013 trenn@suse.de
- Update to latest Intel microcode (bnc#825259)
  microcode-20130808.dat.bz2
- Changed license tag in spec file from GPL v2 or later to GPL-2.0+
  on request from legal (bnc#825259)
* Fri Apr  5 2013 trenn@suse.de
- Use kernel firmware loader interface instead of /dev/cpu/microcode
  to allow signed Intel microcode loading (bnc#813166])
- Sign microcode Intel and AMD one (bnc#812835)
* Wed Apr  3 2013 jlee@suse.com
- Add #needssslcertforbuild to microcode_amd.spec for generate
  firmware sign files. (bnc#812835)
* Tue Feb 26 2013 trenn@suse.de
- Update Intel microcode to version: 20130222 (bnc#806259, bnc#806270,
  FATE#313641)
* Thu Oct 18 2012 trenn@suse.de
- Update to latest AMD microcode version: 2012-09-10 (bnc#784917)
* Tue Oct  2 2012 trenn@suse.de
- Update to the latest, fixed Intel microcode release 20120606-v2
  (bnc#779550)
* Mon Jul  2 2012 trenn@suse.de
- Update Intel CPU microcode binary to version 20120606 (bnc#769610)
* Sun Mar  4 2012 trenn@suse.de
- Update to latest AMD microcode, including the extra fam15h.bin
  file (bnc#749963).
* Wed Jan 11 2012 trenn@suse.de
- Update Intel microcode to version 20111110
  bnc#736671
  Changelog is hidden, but one change is mentioned in the bug:
    Intel discovered a security issue with TXT and SINIT in
    earlier microcode releases.
- Removed duplicate changelog entry
* Fri Sep 23 2011 trenn@suse.de
- Update Intel microcode to version 20110915
* Tue Aug 30 2011 trenn@suse.de
- Make sure microcode.ctl service is not started in runlevel S
  also in update case (bnc#700225,bnc#610768)
  insserv -d microcode.ctl
  did for some reason not work -> remove the link manually if
  it exists as suggested by Werner Fink.
* Fri Aug 12 2011 trenn@suse.de
- Do not try to load microcode on virtualized guests (bnc#702462)
  Xen Dom0 allows microcode update.
* Tue May 31 2011 trenn@suse.de
- Update Intel microcode to version 20110428 (fate#311832)
* Tue Apr 19 2011 trenn@suse.de
- Add AMD microcode update support (bnc#647728, fate#310629)
* Wed Jun 23 2010 trenn@suse.de
- Do not start microcode.ctl in runlevel S as pre-requires are
  missing there and the boot process could get stalled for several
  mintues (one minute per core) (bnc#610768)
* Fri Feb 12 2010 trenn@suse.de
- Updated microcode file to: 20100209
  Fate#306807
  and thrown out old files.
* Tue Feb  2 2010 ro@suse.de
- Updated microcode file to: 20090927
  Fate#306807 (again)
* Wed Sep  2 2009 pth@suse.de
- Updated microcode file to: 20090330
  Fate: 306807
* Wed Oct 15 2008 bwalle@suse.de
- Fix syntax error in microcode.init (bnc#435518).
- Add rpmlintrc.
- Fix %%install-no-mkdir-buildroot warning of rpmlint.
* Wed Sep 17 2008 trenn@suse.de
- Updated microcode file to: 20080910
  Fate: 303949
* Wed Aug 13 2008 bwalle@suse.de
- exit with "skipped" status when the microcode module does not
  exist for a given kernel like the (old) VMI flavour (bnc#415117)
* Thu Jul 24 2008 bwalle@suse.de
- remove dependency on kernel since that's no real functional
  dependency
* Mon May  5 2008 bwalle@suse.de
- return '4' for status, which is not implemented (bnc#383794)
* Sun Apr  6 2008 bwalle@suse.de
- update microcode version to 20080401 (bnc#374261)
* Thu Feb 21 2008 bwalle@suse.de
- update microcode version to 20080220 (bnc#363537)
* Tue Feb  5 2008 bwalle@suse.de
- update microcode version to 20080131 (fate#302618)
* Fri Jan 11 2008 bwalle@suse.de
- update microcode version to 20080108 (#302618)
* Tue Oct  9 2007 bwalle@suse.de
- updated microcode version to 20070907 (#302618)
* Thu Aug 16 2007 bwalle@suse.de
- udpate microcode version to 20070815 (#302336)
* Thu Jul 12 2007 bwalle@suse.de
- Don't unload the microcode driver to re-load the microcode on
  resume (#290586)
* Wed Jun 20 2007 bwalle@suse.de
- fix script name in fillup_and_insserv macro
* Tue Jun 19 2007 bwalle@suse.de
- make init script name LSB conformant
- move microcode_ctl binary to /sbin, removing the need of a
  remove file system dependency for the init script
- added missing 'Short-Descripton' tag in the init script
- add a 'reload' section to the init script
* Thu Apr 26 2007 bwalle@suse.de
- updgraded to latest microcode from Intel (1.17)
* Thu Jan 25 2007 bwalle@suse.de
- upgraded to latest microcode from intel (1.16)
* Thu Jan 25 2007 bwalle@suse.de
- only start the service if we have a Intel CPU
* Wed Nov 15 2006 bwalle@suse.de
- microcode_ctl-1.15: Latest microcode from Intel
  (19th September 2006)
- updated RPM dependencies because a kernel patch is required
  in the microcode code of the kernel so that this new
  update works
* Fri Jul 28 2006 garloff@suse.de
- microcode_ctl-1.14: Latest microcode from intel.
* Tue Feb 28 2006 garloff@suse.de
- Resubmit with new tarball: Upstream packager had screwed up
  linefeeds in microcode.dat [#141543].
* Wed Jan 25 2006 mls@suse.de
- converted neededforbuild to BuildRequires
* Mon Jan 23 2006 garloff@suse.de
- microcode_ctl-1.13: Jan 5 drop got integrated into official 1.13.
* Wed Jan 11 2006 garloff@suse.de
- Update microcode with Jan 5 drop (which is supposed to be
  part of microcode_ctl-1.13) [#141543].
* Mon Nov 28 2005 garloff@suse.de
- Don't try to update microcode on non-intel systems [#122040].
* Wed Oct  5 2005 garloff@suse.de
- Update to 1.12: New microcode from intel. [#116907]
- Does not contain the problematic m02f110a/m02f2205.inc anymore,
  so drop remove patch.
* Mon Jun 20 2005 garloff@suse.de
- microcode-remove-f11-and-f22.diff: Remove microcode for CPUs
  F11 and F22 (m02f110a.inc and m02f2205.inc) [bug #88273].
* Wed May 11 2005 garloff@suse.de
- Fix script activation on install [bug #80224].
* Mon Feb 21 2005 garloff@suse.de
- Update to 1.11: Remove some old -i references.
* Fri Oct 29 2004 garloff@suse.de
- Update to version: 1.10: updated with new microcode from Intel,
  applied patch from Tigran for x86_64 support and some cleanups
- The -i switch has gone, drop from init script.
* Thu Oct 21 2004 garloff@suse.de
- Update to version 1.09: Newer microcode from intel.
- Allow building on x86_64.
* Sun Aug 15 2004 garloff@suse.de
- Update to version 1.08: Newer microcode from intel.
* Wed Feb 25 2004 stepan@suse.de
- add norootforbuild
- add updates from Jesus Molina (specify microcode with -s option)
* Thu Jun  5 2003 ro@suse.de
- remove unpackaged files from buildroot
* Tue Aug 20 2002 mmj@suse.de
- Use macros for fillup and insserv, and use PreReq
* Mon Jul 15 2002 kukuk@suse.de
- Replace BuildArch with ExclusiveArch.
* Fri Feb  8 2002 grimmer@suse.de
- update to version 1.06
- reworked spec file a bit (macros, cleanups)
- updated init script (Copyright)
* Sat Jun  2 2001 bjacke@suse.de
- initial build (package for i386 only)