diff -u microcode.ctl-1.17/debian/update-intel-microcode microcode.ctl-1.17/debian/update-intel-microcode --- microcode.ctl-1.17/debian/update-intel-microcode +++ microcode.ctl-1.17/debian/update-intel-microcode @@ -1,75 +1,68 @@ -#!/bin/sh -# Copyright (c) 2008 by Giacomo A. Catenazzi -# This file is licensed with GPL version 2 (or at your option any later versions) -# For the full license, see http://fsf.org - -set -e - -# This script will download and update the Intel microcode - -# Check wget -if ! which wget > /dev/null 2> /dev/null; then - echo "wget not found. Please install wget" 1>&2 - exit 1 -fi -if ! grep -sq GenuineIntel /proc/cpuinfo; then - echo "microcode.ctl: Yet we provide only microcodes for Intel processors" 1>&2 - echo "Your CPU seems not an Intel processor" 1>&2 - exit 1 -fi - -REMOTE_RSS='http://feeds.downloadcenter.intel.com/rss/?p=483&lang=eng' -REMOTE_DATA="$(wget -t 2 -T 20 -nv -q -O - "$REMOTE_RSS" | perl -pe 's|^.+?Firmware(20[0-9]*)latest.+?([^<]*\1[^<]*).*$|\1 \2\n|' - || echo 'ERROR')" -if [ "0$REMOTE_DATA" = "0" -o "0$REMOTE_DATA" = "0ERROR" ] ; then - echo "Error: could not find remote data in $REMOTE_RSS" 1>&2 - echo "...exiting" 1>&2 - exit 1 -fi -REMOTE_FILE=$(echo $REMOTE_DATA | sed -ne 's#^\(.*\) \(http://.*\)$#\2#p' -) -REMOTE_DATE=$(echo $REMOTE_DATA | sed -ne 's#^\(.*\) \(http://.*\)$#\1#p' -) - -LOCAL_DIR=/usr/share/misc -LOCAL_FILE="$LOCAL_DIR/intel-microcode.dat" - -if [ -f "$LOCAL_FILE" ] ; then - LOCAL_DATE=$(sed -ne 's#^/\*\(.*\)\*/.*$#\1#p' "$LOCAL_FILE" | head -n 1 | date "+%Y%m%d" -f - ) - echo "Local version: $LOCAL_DATE" - echo "Remote version: $REMOTE_DATE" - - if [ "0$REMOTE_DATE" = "0" ] ; then - echo "could not extract the actual data of remote microcode" - exit 1 - elif [ "0$REMOTE_DATE" -le "0$LOCAL_DATE" ] ; then - echo "No need to download a new microcode" 1>&2 - exit 0 - fi -else - echo "Local version: (none)" - echo "Remote version: $REMOTE_DATE" -fi - -echo "Downloading a new version of microcode." - -case "$REMOTE_FILE" in - *.tgz | *.tar.gz ) FILTER=" tar xzOf - " ;; - *.dat.gz ) FILTER=" gzip -cd " ;; - * ) FILTER=" cat - " ;; -esac - - -if wget -t 2 -T 20 -nv -q -O - "$REMOTE_FILE" | $FILTER > "$LOCAL_FILE".tmp ; then - mv "$LOCAL_FILE".tmp "$LOCAL_FILE" - echo "microcode downloaded sucessfully" 1>&2 -else - echo "Error on downloading the microcode." 1>&2 - echo "Install microcode manually. (See /usr/share/doc/microcode.ctl/README.Debian)" 1>&2 - exit 1 -fi - -# load the new microcode - - -if [ "-$1" != "--no-reload" ] ; then - /etc/init.d/microcode.ctl reload -fi +#!/usr/bin/python +# download latest Intel processor microcode +# (c) Daniel J Blueman 2010, GPL v3 license [http://fsf.org/] + +import os +import sys +import socket +import urllib2 +import tempfile +import subprocess + +url = 'http://downloadcenter.intel.com/JSONDataProvider.aspx?DownloadType=Firmware&ProductFamily=Processors&ProductLine=Desktop&ProductProduct=Intel%C2%AE%20Core%E2%84%A2%20i7%20Processor&sortDir=descending&Hits=10&&lang=eng&pg=1&refresh=filters&dataType=json&type=GET' +try: + data = urllib2.urlopen(url).read() +except urllib2.HTTPError, e: + print 'failed to download microcode index - %s' % e.code + sys.exit(1) +except urllib2.URLError, e: + print 'failed to download microcode index - %s' % e.reason + sys.exit(1) + +results = eval(data.replace('null', 'None'))['results'] +newest = None + +# check for numerically highest date +for result in results: + if newest == None or result['version'] > newest['version']: + newest = result + +srcurl = 'http://downloadmirror.intel.com/%s/eng/microcode-%s.tgz' % (newest['title']['downloadid'], newest['version']) + +try: + src = urllib2.urlopen(srcurl) +except urllib2.HTTPError, e: + print 'failed to download microcode from %s - %s' % (srcurl, e.code) + sys.exit(1) +except urllib2.URLError, e: + print 'failed to download microcode from %s - %s' % (srcurl, e.reason) + sys.exit(1) + +os.chdir('/tmp') +unpackedname = 'microcode-%s.dat' % newest['version'] + +try: + fd, tmpfile = tempfile.mkstemp() + dst = os.fdopen(fd, 'w') + dst.write(src.read()) + src.close() + dst.close() + subprocess.check_call(['/bin/tar', '-xzf', tmpfile], shell = False) +except socket.timeout: + print 'failed to download microcode from %s - read timed out' % srcurl + sys.exit(1) +finally: + os.unlink(tmpfile) + +dstpath = '/usr/share/misc/intel-microcode.dat' + +try: + os.rename(unpackedname, dstpath) + os.chown(dstpath, 0, 0) +except OSError, e: + print 'failed to install microcode to %s - %s' % (dstpath, e.strerror) + os.unlink(unpackedname) + sys.exit(1) + +print 'successfully downloaded Intel %s microcode' % newest['version'] diff -u microcode.ctl-1.17/debian/microcode.ctl.postinst microcode.ctl-1.17/debian/microcode.ctl.postinst --- microcode.ctl-1.17/debian/microcode.ctl.postinst +++ microcode.ctl-1.17/debian/microcode.ctl.postinst @@ -3,7 +3,6 @@ # # see: dh_installdeb(1) - set -e . /usr/share/debconf/confmodule @@ -44,9 +43,9 @@ db_get microcode.ctl/check-new if [ "$RET" = true ] ; then - update-intel-microcode --no-reload 1>&2 || true + update-intel-microcode 1>&2 || true else - echo "You have choose not to check for new microcoded. To change" 1>&2 + echo "You have choose not to check for new microcode. To change" 1>&2 echo 'run "dpkg-reconfigure -plow microcode.ctl"' 1>&2 fi @@ -69 +67,0 @@ - diff -u microcode.ctl-1.17/debian/update-intel-microcode.8 microcode.ctl-1.17/debian/update-intel-microcode.8 --- microcode.ctl-1.17/debian/update-intel-microcode.8 +++ microcode.ctl-1.17/debian/update-intel-microcode.8 @@ -1,32 +1,25 @@ -.TH MICROCODE_CTL "8" "17 May 2007" "update-intel-microcode" +.TH MICROCODE_CTL "8" "12 May 2010" "update-intel-microcode" .SH NAME -update-intel-microcode \- check and download new intel microcode +update-intel-microcode \- download current Intel processor microcode .SH SYNOPSIS .B update-intel-microcode -[\fI\--no-reload\fR] .br .SH DESCRIPTION .PP -The update-intel-microcode is a script that check if there is a new -microcode data for the Intel CPU. Eventually it downloads, installs -and loads the new microcode data, used by the microcode_ctl(8) -utility. There is an optional argument: -.br -.PP -\fB--no-reload\fR After installing the microcode, it dosn't try to -load the new microcode in the CPU. +The update-intel-microcode is a script that downloads the current +microcode for Intel processors, installing it on the filesystem. .PD .SH EXAMPLE .TP update-intel-microcode -checks, and eventually downloads, installs and loads a new microcode. +downloads and installs the current Intel processor microcode. .SH FILES .TP /usr/share/misc/intel-microcode.dat The default microcode location .PD .SH AUTHOR -This utility is written by Giacomo Catenazzi for Debian. +This utility is written by Daniel J Blueman for Debian. .br .SH "SEE ALSO" .BR microcode_ctl (8) diff -u microcode.ctl-1.17/debian/control microcode.ctl-1.17/debian/control --- microcode.ctl-1.17/debian/control +++ microcode.ctl-1.17/debian/control @@ -1,7 +1,8 @@ Source: microcode.ctl Section: contrib/utils Priority: optional -Maintainer: Giacomo Catenazzi +Maintainer: Ubuntu Developers +XSBC-Original-Maintainer: Giacomo Catenazzi Build-Depends: cdbs, debhelper (>= 5), po-debconf Standards-Version: 3.8.3 Homepage: http://www.urbanmyth.org/microcode/ diff -u microcode.ctl-1.17/debian/changelog microcode.ctl-1.17/debian/changelog --- microcode.ctl-1.17/debian/changelog +++ microcode.ctl-1.17/debian/changelog @@ -1,3 +1,10 @@ +microcode.ctl (1.17-13ubuntu1) lucid; urgency=low + + * Rewrote update-intel-microcode script to robustly parse and + download updated microcode correctly (Closes: #569488) + + -- Daniel J Blueman Wed, 12 May 2010 14:10:06 +0100 + microcode.ctl (1.17-13) unstable; urgency=low * update-intel-microcode: retrieve the first firmware in the RSS