From f6970a6bbbb772230e1f8d2ffd30a8ae0298dfe9 Mon Sep 17 00:00:00 2001
From: Bernie Innocenti <bernie@codewiz.org>
Date: Tue, 16 Feb 2010 20:59:19 -0300
Subject: [PATCH] Fallback to /ofw on missing DMI in olpc-configure
Organization: Sugar Labs Foundation

This fallback is necessary even if we ship an updated
OpenFirmware which enables SMBIOS within the signed OS
image, laptops will continue running with the previous
firmware until plugged to AC during boot.

If we run olpc-configure with no SMBIOS on first boot,
wrong keyboard settings will be stored permanently.
---
 etc/rc.d/init.d/olpc-configure |   22 +++++++++++++---------
 1 files changed, 13 insertions(+), 9 deletions(-)

diff --git a/etc/rc.d/init.d/olpc-configure b/etc/rc.d/init.d/olpc-configure
index 2ef93fc..175da3a 100755
--- a/etc/rc.d/init.d/olpc-configure
+++ b/etc/rc.d/init.d/olpc-configure
@@ -16,16 +16,20 @@ XO_VERSION=0
 
 get_xo_version() {
 	# This requires an OFW that runs setup-smbios at boot.
-	[ -e "/sys/class/dmi/id/product_name" ] || return
-
-	name=$(</sys/class/dmi/id/product_name)
-	version=$(</sys/class/dmi/id/product_version)
-	if [ "${name}" == "XO" ]; then
-		if [ "${version}" == "1" ]; then
-			XO_VERSION="1"
-		elif [ "${version}" == "1.5" ]; then
-			XO_VERSION="1.5"
+	if [ -e "/sys/class/dmi/id/product_name" ]; then
+		local name=$(</sys/class/dmi/id/product_name)
+		local version=$(</sys/class/dmi/id/product_version)
+		if [ "${name}" == "XO" ]; then
+			if [ "${version}" == "1" ]; then
+				XO_VERSION="1"
+			elif [ "${version}" == "1.5" ]; then
+				XO_VERSION="1.5"
+			fi
 		fi
+	elif [ -e "/ofw/banner-name" ]; then
+		case "$(</ofw/banner-name)" in
+			OLPC\ B*|OLPC\ C*) XO_VERSION="1" ;;
+		esac
 	fi
 }
 
-- 
1.6.6.1

