Upgrades and image manifests

2007-06-19 Thread Alexander Larsson
Hi, 

My name is Alexander Larsson, and I just started working on the field
upgrade system of the olpc laptops. I have some ideas I'd like to
explain and get feedback on.

The olpc uses a full-image system, as opposed to the per-package
versioning scheme of deb or rpms. So, an upgrade consists of replacing
your system files with a full copy of a later (or earlier) version of
the system image. We want to support both upgrading from a central
server or from another laptop, and we want to minimize the data we have
to download for an upgrade.

To support this we create a manifest that describes each image, and we
save a copy of the current image manifest installed on the laptop. The
manifest format is very similar to the git tree object, and describes
each file by listing name, metadata and sha1 hash value of the contents.

Here is a small example:
-
link 777 500:500 foo bar
blob 664 500:500 4e1243bd22c66e76c2ba9eddc1f91394e57f9f83 changed.txt
blob 664 500:500 65ef9261ad6cfaa8403f2fa66d8edfada1445e5a common
blob 664 500:500 f660633c832712eba3c6edd39151987e46bc3f87 image1.txt
blob 711 500:500 empty logfs.pdf
dir 775 500:500 subdir1
blob 664 500:500 empty subdir1/file1.txt
blob 664 500:500 7448d8798a4380162d4b56f9b452e2f6f9e24e7a subdir1/file2.txt
---

Given a manifest for the current image and a manifest for the image to
upgrade to it is very simple and cheap to calculate what changes you
need to make to transform the image (on the client), and what sha1 blobs
you need to download. You can then download the file blobs from whatever
source you have (they are self-verifying, since they are named by the
sha1 hash of the content) and do the upgrade.

It is very simple to host the blobs. We just put them all in a directory
named by sha1 and export that with a http server. One can also host
multiple versions of an image in the same directory, while minimizing
the space used for common data. (Possibly one might want to gzip the
blobs too.)

I've written some code (attached) to generate and manipulate manifests
like these. There are three tools:

* generate-manifest: This generates a manifest files given a path to a
directory containing the image tree. You can also make it populate a
directory of sha1-named blobs by giving it a blob directory with -b.

* diff-manifest: Gives a simple visual diff between two manifests. If
you pass it -b it will instead give a list of all blobs required to
update between the two manifests.

* upgrade-manifest: Updates an image from one manifest to another, given
a path of a directory with the required blobs.

Using these tools I upgraded from
olpc-redhat-stream-development-build-406-20070507_2141-devel_ext3-tree
to olpc-redhat-stream-development-build-406-20070507_2157-ext3-tree in a
directory on my development machine, so it seems to work so far.

For finding and downloading updates I was thinking of using avahi to
publish the image id + version, and then downloading the data and
manifests using http. That way that clients can detect machines around
them with later versions and auto-download (and apply automatically or
later). The individual laptops can publish the version of the image they
are using, and a school server can publish several versions. From the
point of view of the individual laptop searching for upgrades they will
look the same. Of course, we'd have to sign the manifests with some key
to make sure you can't just auto-upgrade any machine to a rouge image.

Now over to the questions I have:

I'd like to put this code in a repository somewhere. Where should I put
it?

Does OLPC use selinux or xattrs? Because if so we have to extend the
manifest format.

We need a library to do http downloads. I see we're shipping libcurl on
the laptop. Is it ok to use this library? 
(We also need a very simple http sever that maps sha1 - file in system
image for laptop-to-laptop upgrades, but I think we can do that without
using a library.)

Is using avahi/mDNS on the mesh network ok?









manifest-0.1.tar.gz
Description: application/compressed-tar
___
Devel mailing list
Devel@lists.laptop.org
http://lists.laptop.org/listinfo/devel


OLPC battery class

2007-06-19 Thread Richard Hughes
Hi,

I've been looking at adding OLPC battery support into HAL so it can be
used with OHM and the power meter in sugar.

Putting it bluntly, the generic battery class is a bit of a misnomer,
as it's very OLPC specific. It also violates key sysfs rules such as
one-value per file, and it's not going to be pretty adding the current
battery/ac_adapter interface to HAL.

So far we have:

capacity_percentage 13
current 940
nameOLPC Battery
status  present charging
status_cap  present low full charging discharging overtemp critical
technology  NiMH
temp1   29101
temp1_name  battery
temp2   48753
temp2_name  ambient
typebattery
voltage 7101

Specific problems:

* 'capacity' is probably the wrong word to use, in common use it means
the battery capacity compared to when nit was new, to measure how the
battery has degraded over time.

* 'status' and 'status_cap' violate the one-value-per file mentality of
sysfs. This means we have to do string processing in HAL, rather than
just read the value of a flag. status_cap shouldn't be used at at all -
if the capability does not exist to report this, then do not export the
attribute (so no file in sysfs). See below for an example.

* 'temp1' - why not temperature_ambient?

* 'temp2' - why not temperature_internal?

* Why is the AC adapter exported as a battery of type ac? This is simply
wrong, they are _completely_ different types of device.

So, I would envisage a generic battery class to look like (munging
together OPLC and acpi stuff for the example):

* BATTERY CLASS *
description OLPC Battery
present 1
charging1
discharging 0
over_temperature0
percentage  13
technology  NiMH
internal_temperature29101
ambient_temperature 48753
voltage 7101
current 700
charge_now  940
charge_design   1100
charge_last_full997
charge_unit mAh
model_numberX2344
serial_number   300360
vendor  Sanyo

* AC CLASS *
present 1
description OLPC AC Adapter

Now, I'm prepared to put my money where my mouth is and offer to rewrite
the kernel code to the above, and then write the (now trivial) HAL
interface for this. Any problems/comments?

Richard.


___
Devel mailing list
Devel@lists.laptop.org
http://lists.laptop.org/listinfo/devel