[Sugar-devel] [PATCH sugar-toolkit] Remove incomplete MANIFEST support

Sascha Silbe silbe at activitycentral.com
Sun Jul 3 11:54:01 EDT 2011


From: Bernie Innocenti <bernie at codewiz.org>

This incomplete feature contributes to confuse new activity authors and
slightly complicates our bundle installation logic.

The day someone finds something useful to do with the MANIFEST
specification, we can revert this patch in no time.

Signed-off-by: Bernie Innocenti <bernie at codewiz.org>
Tested-by: Bernie Innocenti <bernie at codewiz.org>
Tested-by: James Cameron <quozl at laptop.org>
Tested-by: Sascha Silbe <silbe at activitycentral.com>
Reviewed-by: Sascha Silbe <silbe at activitycentral.com>
[rebased on git master]
Signed-off-by: Sascha Silbe <silbe at activitycentral.com>
---
Just installed Backup [1] on an XO-1 running Sugar 0.82.1 using a
bundle without MANIFEST. It installs and starts up fine, no obvious
breakage. Dextrose has been shipping this patch for a long time with no
reported issues either.

I'm going to push this to master within the next few days.

[1] http://activities.sugarlabs.org/en-US/sugar/addon/4326

 src/sugar/activity/bundlebuilder.py |   48 ++---------------
 src/sugar/bundle/activitybundle.py  |   99 +----------------------------------
 src/sugar/bundle/bundle.py          |    9 ---
 3 files changed, 6 insertions(+), 150 deletions(-)

diff --git a/src/sugar/activity/bundlebuilder.py b/src/sugar/activity/bundlebuilder.py
index 5885a35..fdd68ec 100644
--- a/src/sugar/activity/bundlebuilder.py
+++ b/src/sugar/activity/bundlebuilder.py
@@ -142,37 +142,9 @@ class Builder(object):
             f.close()

     def get_files(self):
-        files = self.config.bundle.get_files()
-
-        if not files:
-            logging.error('No files found, fixing the MANIFEST.')
-            self.fix_manifest()
-            files = self.config.bundle.get_files()
-
-        return files
-
-    def check_manifest(self):
-        missing_files = []
-
         allfiles = list_files(self.config.source_dir,
                               IGNORE_DIRS, IGNORE_FILES)
-        for path in allfiles:
-            if path not in self.config.bundle.manifest:
-                missing_files.append(path)
-
-        return missing_files
-
-    def fix_manifest(self):
-        self.build()
-
-        manifest = self.config.bundle.manifest
-
-        for path in self.check_manifest():
-            manifest.append(path)
-
-        f = open(os.path.join(self.config.source_dir, 'MANIFEST'), 'wb')
-        for line in manifest:
-            f.write(line + '\n')
+        return allfiles


 class Packager(object):
@@ -198,13 +170,6 @@ class XOPackager(Packager):
         bundle_zip = zipfile.ZipFile(self.package_path, 'w',
                                      zipfile.ZIP_DEFLATED)

-        missing_files = self.builder.check_manifest()
-        if missing_files:
-            logging.warn('These files are not included in the manifest ' \
-                         'and will not be present in the bundle:\n\n' +
-                         '\n'.join(missing_files) +
-                         '\n\nUse fix_manifest if you want to add them.')
-
         for f in self.builder.get_files():
             bundle_zip.write(os.path.join(self.config.source_dir, f),
                              os.path.join(self.config.bundle_root_dir, f))
@@ -311,14 +276,11 @@ def cmd_dist_xo(config, args):


 def cmd_fix_manifest(config, args):
-    """Add missing files to the manifest"""
+    '''Add missing files to the manifest (OBSOLETE)'''

-    if args:
-        print 'Usage: %prog fix_manifest'
-        return
-
-    builder = Builder(config)
-    builder.fix_manifest()
+    print "WARNING: the fix_manifest command is obsolete"
+    print "the MANIFEST file is no longer used in bundles, please remove it"
+    pass


 def cmd_dist_source(config, args):
diff --git a/src/sugar/bundle/activitybundle.py b/src/sugar/bundle/activitybundle.py
index 56c0487..542fa00 100644
--- a/src/sugar/bundle/activitybundle.py
+++ b/src/sugar/bundle/activitybundle.py
@@ -63,7 +63,6 @@ class ActivityBundle(Bundle):
         self._tags = None
         self._activity_version = '0'
         self._installation_time = os.stat(path).st_mtime
-        self._manifest = None

         info_file = self.get_file('activity/activity.info')
         if info_file is None:
@@ -77,74 +76,6 @@ class ActivityBundle(Bundle):
         if self._local_name == None:
             self._local_name = self._name

-    def _get_manifest(self):
-        if self._manifest is None:
-            self._manifest = self._read_manifest()
-        return self._manifest
-
-    manifest = property(_get_manifest, None, None,
-        "NOTICE: this property is potentially quite slow, so better make sure "
-        "that it's not called at performance-critical points like shell or "
-        "activity startup.")
-
-    def _raw_manifest(self):
-        f = self.get_file('MANIFEST')
-        if not f:
-            logging.warning('Activity directory lacks a MANIFEST file.')
-            return []
-
-        ret = [line.strip() for line in f.readlines()]
-        f.close()
-        return ret
-
-    def _read_manifest(self):
-        """return a list with the lines in MANIFEST, with invalid lines
-        replaced by empty lines.
-
-        Since absolute order carries information on file history, it should
-        be preserved. For instance, when renaming a file, you should leave
-        the new name on the same line as the old one.
-        """
-        logging.debug('STARTUP: Reading manifest')
-        lines = self._raw_manifest()
-
-        # Remove trailing newlines, they do not help keep absolute position.
-        while lines and lines[-1] == '':
-            lines = lines[:-1]
-
-        for num, line in enumerate(lines):
-            if not line:
-                continue
-
-            # Remove duplicates
-            if line in lines[0:num]:
-                lines[num] = ''
-                logging.warning('Bundle %s: duplicate entry in MANIFEST: %s',
-                    self._name, line)
-                continue
-
-            # Remove MANIFEST
-            if line == 'MANIFEST':
-                lines[num] = ''
-                logging.warning('Bundle %s: MANIFEST includes itself: %s',
-                    self._name, line)
-
-            # Remove invalid files
-            if not self.is_file(line):
-                lines[num] = ''
-                logging.warning('Bundle %s: invalid entry in MANIFEST: %s',
-                    self._name, line)
-
-        return lines
-
-    def get_files(self, manifest=None):
-        files = [line for line in (manifest or self.manifest) if line]
-
-        if self.is_file('MANIFEST'):
-            files.append('MANIFEST')
-
-        return files
-
     def _parse_info(self, info_file):
         cp = ConfigParser()
         cp.readfp(info_file)
@@ -309,41 +240,13 @@ class ActivityBundle(Bundle):
         """Get whether there should be a visible launcher for the activity"""
         return self._show_launcher

-    def install(self, install_dir=None, strict_manifest=False):
+    def install(self, install_dir=None):
         if install_dir is None:
             install_dir = env.get_user_activities_path()

         self._unzip(install_dir)

         install_path = os.path.join(install_dir, self._zip_root_dir)
-
-        # List installed files
-        manifestfiles = self.get_files(self._raw_manifest())
-        paths = []
-        for root, dirs_, files in os.walk(install_path):
-            rel_path = root[len(install_path) + 1:]
-            for f in files:
-                paths.append(os.path.join(rel_path, f))
-
-        # Check the list against the MANIFEST
-        for path in paths:
-            if path in manifestfiles:
-                manifestfiles.remove(path)
-            elif path != 'MANIFEST':
-                logging.warning('Bundle %s: %s not in MANIFEST', self._name,
-                    path)
-                if strict_manifest:
-                    os.remove(os.path.join(install_path, path))
-
-        # Is anything in MANIFEST left over after accounting for all files?
-        if manifestfiles:
-            err = ('Bundle %s: files in MANIFEST not included: %s' %
-                   (self._name, str(manifestfiles)))
-            if strict_manifest:
-                raise MalformedBundleException(err)
-            else:
-                logging.warning(err)
-
         self.install_mime_type(install_path)

         return install_path
diff --git a/src/sugar/bundle/bundle.py b/src/sugar/bundle/bundle.py
index aae3a09..e61a0b6 100644
--- a/src/sugar/bundle/bundle.py
+++ b/src/sugar/bundle/bundle.py
@@ -78,14 +78,6 @@ class Bundle(object):
                                                '%s' % (self._path, exception))
             self._check_zip_bundle()

-        # manifest = self._get_file(self._infodir + '/contents')
-        # if manifest is None:
-        #     raise MalformedBundleException('No manifest file')
-
-        # signature = self._get_file(self._infodir + '/contents.sig')
-        # if signature is None:
-        #     raise MalformedBundleException('No signature file')
-
     def __del__(self):
         if self._zip_file is not None:
             self._zip_file.close()
@@ -174,7 +166,6 @@ class Bundle(object):
         # correctly by hand, but handling all the oddities of
         # Windows/UNIX mappings, extension attributes, deprecated
         # features, etc makes it impractical.
-        # FIXME: use manifest
         if os.spawnlp(os.P_WAIT, 'unzip', 'unzip', '-o', self._path,
                       '-x', 'mimetype', '-d', install_dir):
             # clean up install dir after failure
--
1.7.4.1



More information about the Sugar-devel mailing list