[PATCH] remove unused MANIFEST support MANIFEST contains a list of files in a bundle.

Bernie Innocenti bernie at codewiz.org
Thu May 20 19:58:04 EDT 2010


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>
---
 src/sugar/activity/bundlebuilder.py |   49 +++---------------
 src/sugar/bundle/activitybundle.py  |   98 +----------------------------------
 src/sugar/bundle/bundle.py          |    9 ---
 3 files changed, 8 insertions(+), 148 deletions(-)

diff --git a/src/sugar/activity/bundlebuilder.py b/src/sugar/activity/bundlebuilder.py
index 555fe98..1c8021d 100644
--- a/src/sugar/activity/bundlebuilder.py
+++ b/src/sugar/activity/bundlebuilder.py
@@ -135,37 +135,10 @@ 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 allfiles
 
-        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")
 
 class Packager(object):
     def __init__(self, config):
@@ -186,18 +159,10 @@ class XOPackager(Packager):
     def package(self):
         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))
-
         bundle_zip.close()
 
 class SourcePackager(Packager):
@@ -290,15 +255,15 @@ def cmd_dist_xo(config, args):
     packager = XOPackager(Builder(config))
     packager.package()
 
+
+
 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
+    print "WARNING: the fix_manifest command is obsolete"
+    print "the MANIFEST file is no longer used in bundles, please remove it"
+    pass
 
-    builder = Builder(config)
-    builder.fix_manifest()
 
 def cmd_dist_source(config, args):
     '''Create a tar source package'''
diff --git a/src/sugar/bundle/activitybundle.py b/src/sugar/bundle/activitybundle.py
index 268576e..1e80a8a 100644
--- a/src/sugar/bundle/activitybundle.py
+++ b/src/sugar/bundle/activitybundle.py
@@ -56,7 +56,6 @@ class ActivityBundle(Bundle):
         self._show_launcher = True
         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:
@@ -67,74 +66,6 @@ class ActivityBundle(Bundle):
         if linfo_file:
             self._parse_linfo(linfo_file)
 
-    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)
@@ -277,40 +208,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)
 
         xdg_data_home = os.getenv('XDG_DATA_HOME',
                                   os.path.expanduser('~/.local/share'))
diff --git a/src/sugar/bundle/bundle.py b/src/sugar/bundle/bundle.py
index a1b2686..d220686 100644
--- a/src/sugar/bundle/bundle.py
+++ b/src/sugar/bundle/bundle.py
@@ -68,14 +68,6 @@ class Bundle(object):
             self._zip_file = zipfile.ZipFile(self._path)
             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()
@@ -164,7 +156,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.1

-- 
James Cameron
http://quozl.linux.org.au/


More information about the Sugar-devel mailing list