<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def extract(self, destdir, decompress='auto'):
 """Extract the entire MAR file into a directory. Args: destdir (str):
 A local directory on disk into which the contents of this MAR file will be extracted. Required parent directories will be created as necessary. decompress (obj, optional):
 Controls whether files are decompressed when extracted. Must be one of 'auto' or None. Defaults to 'auto'. """

        for e in self.mardata.index.entries:
            name = e.name
            entry_path = safejoin(destdir, name)
            entry_dir = os.path.dirname(entry_path)
            mkdir(entry_dir)
            with open(entry_path, 'wb') as f:
                write_to_file(self.extract_entry(e, decompress), f)
                os.chmod(entry_path, e.flags)