diff options
author | Daniel Drake <dsd@laptop.org> | 2009-12-30 11:18:33 (GMT) |
---|---|---|
committer | Daniel Drake <dsd@laptop.org> | 2009-12-30 12:43:55 (GMT) |
commit | ddaaaefc7fd5ee89b6c6832ab0efdfb0b3f8af29 (patch) | |
tree | 57b9aaefa4aae2d9eae08db6dcaf06e5c5aa93c6 /modules/sugar_activity_group | |
parent | a2a602901dcb28cfe4ea9062e9c65b662daa8fc7 (diff) |
Allow activity group to be set but ignored (#9939)
Diffstat (limited to 'modules/sugar_activity_group')
-rw-r--r-- | modules/sugar_activity_group/README | 11 | ||||
-rw-r--r-- | modules/sugar_activity_group/defaults.ini | 3 | ||||
-rw-r--r-- | modules/sugar_activity_group/kspost.60.nochroot.activities.py | 92 |
3 files changed, 62 insertions, 44 deletions
diff --git a/modules/sugar_activity_group/README b/modules/sugar_activity_group/README index 9fdbe0f..d2c3021 100644 --- a/modules/sugar_activity_group/README +++ b/modules/sugar_activity_group/README @@ -9,3 +9,14 @@ You must specify the activity group URL in the configuration. Example: [sugar_activity_group] url=http://wiki.laptop.org/go/Activities/G1G1 + +The install_activities option (default 1) can be set to 0 to disable the +build-time parsing/download/installation of activities from the activity +group URL. This will cause the activity group URL to be written into the +resultant build but the specified activities will not be downloaded or +installed. e.g.: + +[sugar_activity_group] +url=http://wiki.laptop.org/go/Activities/G1G1 +install_activities=0 + diff --git a/modules/sugar_activity_group/defaults.ini b/modules/sugar_activity_group/defaults.ini new file mode 100644 index 0000000..267189b --- /dev/null +++ b/modules/sugar_activity_group/defaults.ini @@ -0,0 +1,3 @@ +[sugar_activity_group] +install_activities=1 + diff --git a/modules/sugar_activity_group/kspost.60.nochroot.activities.py b/modules/sugar_activity_group/kspost.60.nochroot.activities.py index 30346c9..eb26d51 100644 --- a/modules/sugar_activity_group/kspost.60.nochroot.activities.py +++ b/modules/sugar_activity_group/kspost.60.nochroot.activities.py @@ -170,52 +170,56 @@ if not os.path.exists(cache): baseurl = ooblib.read_config('sugar_activity_group', 'url') -vmaj = int(ooblib.read_config('global', 'olpc_version_major')) -vmin = int(ooblib.read_config('global', 'olpc_version_minor')) -vrel = int(ooblib.read_config('global', 'olpc_version_release')) +install_activities = ooblib.read_config_bool('sugar_activity_group', + 'install_activities') -suffixes = ["%d.%d.%d" % (vmaj, vmin, vrel), "%d.%d" % (vmaj, vmin), ""] +if install_activities: + vmaj = int(ooblib.read_config('global', 'olpc_version_major')) + vmin = int(ooblib.read_config('global', 'olpc_version_minor')) + vrel = int(ooblib.read_config('global', 'olpc_version_release')) -for suffix in suffixes: - if len(suffix) > 0: - grpurl = urlparse.urljoin(baseurl + "/", urllib.quote(suffix)) - else: - grpurl = baseurl - - print >>sys.stderr, "Trying group URL", grpurl - name, desc, results = parse_url(grpurl) - if len(results) == 0 or (name is None and desc is None): - continue - print >>sys.stderr, "Found activity group:", name - - for name, info in results.items(): - (version, url) = only_best_update(info) - print >>sys.stderr, "Examining", name, "v%d" % version - fd = urllib2.urlopen(url) - headers = fd.info() - if not 'Content-length' in headers: - raise Exception("No content length for %s" % url) - length = int(headers['Content-length']) - path = urlparse.urlsplit(fd.geturl())[2] - path = os.path.basename(path) - - localpath = os.path.join(cache, path) - if os.path.exists(localpath): - localsize = os.stat(localpath).st_size - if localsize == length: - print >>sys.stderr, "Not downloading, already in cache." - generate_install_cmd(localpath) - continue - - print >>sys.stderr, "Downloading (%dkB)..." % (length/1024) - localfd = open(localpath, 'w') - localfd.write(fd.read()) - fd.close() - localfd.close() - generate_install_cmd(localpath) - - # only process the first working URL - break + suffixes = ["%d.%d.%d" % (vmaj, vmin, vrel), "%d.%d" % (vmaj, vmin), ""] + + for suffix in suffixes: + if len(suffix) > 0: + grpurl = urlparse.urljoin(baseurl + "/", urllib.quote(suffix)) + else: + grpurl = baseurl + + print >>sys.stderr, "Trying group URL", grpurl + name, desc, results = parse_url(grpurl) + if len(results) == 0 or (name is None and desc is None): + continue + print >>sys.stderr, "Found activity group:", name + + for name, info in results.items(): + (version, url) = only_best_update(info) + print >>sys.stderr, "Examining", name, "v%d" % version + fd = urllib2.urlopen(url) + headers = fd.info() + if not 'Content-length' in headers: + raise Exception("No content length for %s" % url) + length = int(headers['Content-length']) + path = urlparse.urlsplit(fd.geturl())[2] + path = os.path.basename(path) + + localpath = os.path.join(cache, path) + if os.path.exists(localpath): + localsize = os.stat(localpath).st_size + if localsize == length: + print >>sys.stderr, "Not downloading, already in cache." + generate_install_cmd(localpath) + continue + + print >>sys.stderr, "Downloading (%dkB)..." % (length/1024) + localfd = open(localpath, 'w') + localfd.write(fd.read()) + fd.close() + localfd.close() + generate_install_cmd(localpath) + + # only process the first working URL + break print "echo '%s' > $INSTALL_ROOT/home/olpc/Activities/.groups" % baseurl print "chown -R 500:500 $INSTALL_ROOT/home/olpc/{Activities,Library}" |