Hi,

There are many scripts in use that parse the web interface for
snapshots and releases.linaro.org. This is far from ideal because
changes to the web interface can result in the scripts breaking. To
alleviate this problem an API has been introduced. The API is very
simple, just two new URLs and a new header when downloading files.

<server>/api/ls/<path to file> returns a JSON document containing all the
     data shown by a file listing on the web interface. It can target
     either a directory of a file.

<server>/api/license/<path to file> returns a JSON document containing
     the licence information for the file pointed to. Both the license text
     and the digest used to accept the license are returned. Including the
     digest means that the choice of digest used internally can change without
     re-writing clients - to the client this is just a magic string and they
     don't need to care how it is generated.

When downloading a file you simply include the header
LICENSE_ACCEPTED, its value being a space separated list of license
digests representing the licenses that you have accepted.

e.g.
(license text and digest removed for brevity)

http://snapshots.linaro.org/api/ls/quantal/hwpacks/snowball/latest
{
    "files": [
        {
            "mtime": "15-Mar-2013 08:29",
            "name":
"hwpack_linaro-snowball_20130315-269_armhf_supported.manifest.txt",
            "size": "762",
            "type": "text",
            "url":
"/quantal/hwpacks/snowball/latest/hwpack_linaro-snowball_20130315-269_armhf_supported.manifest.txt"
        },
        {
            "mtime": "15-Mar-2013 08:31",
            "name":
"hwpack_linaro-snowball_20130315-269_armhf_supported.tar.gz",
            "size": "18.1M",
            "type": "other",
            "url":
"/quantal/hwpacks/snowball/latest/hwpack_linaro-snowball_20130315-269_armhf_supported.tar.gz"
        }
    ]
}

http://snapshots.linaro.org/api/license/quantal/hwpacks/snowball/latest/hwpack_linaro-snowball_20130315-269_armhf_supported.tar.gz
{
  "licenses": [
    {
      "text": "license text...",
      "digest": "license digest..."
    }
  ]
}

wget --header="LICENSE_ACCEPTED: license digest..."
http://snapshots.linaro.org/quantal/hwpacks/snowball/latest/hwpack_linaro-snowball_20130315-269_armhf_supported.tar.gz

There is a example client script that illustrates how to use the API here:
http://bazaar.launchpad.net/~linaro-automation/linaro-license-protection/trunk/view/head:/scripts/download.py

Usage: download.py <URL>

If URL points to a directory all files are downloaded.
If URL points to a file, just that file is downloaded.

It prints the license(s) for each file and waits for the user to
accept each one. It also stores which licenses the user has accepted
so they don't need to be re-accepted if the text hasn't changed.

-- 
James Tunnicliffe

_______________________________________________
linaro-dev mailing list
linaro-dev@lists.linaro.org
http://lists.linaro.org/mailman/listinfo/linaro-dev

Reply via email to