コード例 #1
0
ファイル: debian.py プロジェクト: guspur/reconstructor.engine
 def extract_live_fs(self):
     '''Extracts squashfs_filename to self.__squashfs_dir'''
     try:
         # temp mount point for iso
         tmpMntIsoDir = os.path.join(tempfile.gettempdir(), 'r_iso')
         if not fs_tools.mount(self.__src_iso_filename, tmpMntIsoDir):
             self.log.error('Error mounting %s; check log for details...' % (self._src_iso_filename))
             return
         # extract
         squash_tools.extract_squash_fs(unsquashfs_cmd=self.__unsquash, filename=self.__live_fs_filename, dest_dir=self.__live_fs_dir)
         info_file = os.path.join(self.__iso_fs_dir, '.disk' + os.sep + 'info')
         if os.path.exists(info_file):
             f = open(info_file, 'r')
             info = f.read()
             f.close()
             try:
                 self.__debian_version = info.split()[2].split('.')[0]
                 self.log.debug('Found Debian version {0}'.format(self.__debian_version))
             except:
                 # ignore errors
                 pass
         return True
     except Exception, d:
         self.log.error('Error extracting live squash filesystem: %s' % (d))
         return False
コード例 #2
0
 def extract_live_fs(self):
     '''Extracts squashfs_filename to self.__squashfs_dir'''
     try:
         # temp mount point for iso
         tmpMntIsoDir = os.path.join(tempfile.gettempdir(), 'r_iso')
         if not fs_tools.mount(self.__src_iso_filename, tmpMntIsoDir):
             self.log.error('Error mounting %s; check log for details...' %
                            (self._src_iso_filename))
             return
         # extract
         # fedora uses an ext image -- extract that first, then copy the contents
         tmpdir = tempfile.mkdtemp()
         tmpImgDir = tempfile.mkdtemp()
         self.log.debug('Extracting squash filesystem: %s' %
                        (self.__live_fs_filename))
         squash_tools.extract_squash_fs(unsquashfs_cmd=self.__unsquash,
                                        filename=self.__live_fs_filename,
                                        dest_dir=tmpdir)
         # mount the ext image
         self.log.debug('Mounting filesystem...')
         fs_tools.mount(
             os.path.join(tmpdir, 'LiveOS' + os.sep + 'ext3fs.img'),
             tmpImgDir)
         commands.getoutput('rsync -a %s/ %s/' %
                            (tmpImgDir, self.__live_fs_dir))
         return True
     except Exception, d:
         self.log.error('Error extracting live squash filesystem: %s' % (d))
         return False
コード例 #3
0
 def extract_live_fs(self):
     '''Extracts squashfs_filename to self.__squashfs_dir'''
     try:
         # temp mount point for iso
         tmpMntIsoDir = os.path.join(tempfile.gettempdir(), 'r_iso')
         if not fs_tools.mount(self.__src_iso_filename, tmpMntIsoDir):
             self.log.error('Error mounting %s; check log for details...' %
                            (self._src_iso_filename))
             return
         # extract
         squash_tools.extract_squash_fs(unsquashfs_cmd=self.__unsquash,
                                        filename=self.__live_fs_filename,
                                        dest_dir=self.__live_fs_dir)
         info_file = os.path.join(self.__iso_fs_dir,
                                  '.disk' + os.sep + 'info')
         if os.path.exists(info_file):
             f = open(info_file, 'r')
             info = f.read()
             f.close()
             try:
                 self.__debian_version = info.split()[2].split('.')[0]
                 self.log.debug('Found Debian version {0}'.format(
                     self.__debian_version))
             except:
                 # ignore errors
                 pass
         return True
     except Exception, d:
         self.log.error('Error extracting live squash filesystem: %s' % (d))
         return False
コード例 #4
0
ファイル: ubuntu.py プロジェクト: jrdbrr/reconstructor.engine
 def extract_live_fs(self):
     '''Extracts squashfs_filename to self.__squashfs_dir'''
     try:
         # temp mount point for iso
         tmpMntIsoDir = os.path.join(tempfile.gettempdir(), 'r_iso')
         if not fs_tools.mount(self.__src_iso_filename, tmpMntIsoDir):
             self.log.error('Error mounting %s; check log for details...' % (self._src_iso_filename))
             return
         # extract
         squash_tools.extract_squash_fs(unsquashfs_cmd=self.__unsquash, filename=self.__live_fs_filename, dest_dir=self.__live_fs_dir)
         return True
     except Exception, d:
         self.log.error('Error extracting live squash filesystem: %s' % (d))
         return False
コード例 #5
0
 def extract_live_fs(self):
     '''Extracts squashfs_filename to self.__squashfs_dir'''
     try:
         # temp mount point for iso
         tmpMntIsoDir = os.path.join(tempfile.gettempdir(), 'r_iso')
         if not fs_tools.mount(self.__src_iso_filename, tmpMntIsoDir):
             self.log.error('Error mounting %s; check log for details...' % (self._src_iso_filename))
             return
         # extract
         squash_tools.extract_squash_fs(unsquashfs_cmd=self.__unsquash, filename=self.__live_fs_filename, dest_dir=self.__live_fs_dir)
         return True
     except Exception, d:
         self.log.error('Error extracting live squash filesystem: %s' % (d))
         return False
コード例 #6
0
 def testExtractSquashFs(self):
     self.assertTrue(
         squash_tools.create_squash_fs(source_dir=self.squash_root,
                                       dest_filename=self.squash_file,
                                       overwrite=True))
     self.assertTrue(
         squash_tools.extract_squash_fs(filename=self.squash_file,
                                        dest_dir=self.tmp_squash_dir),
         'Error extracting squash filesystem...')
     self.assertTrue(
         os.listdir(self.tmp_squash_dir) != 0,
         'Error extracting squash filesystem: directory empty...')
コード例 #7
0
ファイル: fedora.py プロジェクト: guspur/reconstructor.engine
 def extract_live_fs(self):
     '''Extracts squashfs_filename to self.__squashfs_dir'''
     try:
         # temp mount point for iso
         tmpMntIsoDir = os.path.join(tempfile.gettempdir(), 'r_iso')
         if not fs_tools.mount(self.__src_iso_filename, tmpMntIsoDir):
             self.log.error('Error mounting %s; check log for details...' % (self._src_iso_filename))
             return
         # extract
         # fedora uses an ext image -- extract that first, then copy the contents
         tmpdir = tempfile.mkdtemp()
         tmpImgDir = tempfile.mkdtemp()
         self.log.debug('Extracting squash filesystem: %s' % (self.__live_fs_filename))
         squash_tools.extract_squash_fs(unsquashfs_cmd=self.__unsquash, filename=self.__live_fs_filename, dest_dir=tmpdir)
         # mount the ext image
         self.log.debug('Mounting filesystem...')
         fs_tools.mount(os.path.join(tmpdir, 'LiveOS' + os.sep + 'ext3fs.img'), tmpImgDir)
         commands.getoutput('rsync -a %s/ %s/' % (tmpImgDir, self.__live_fs_dir))
         return True
     except Exception, d:
         self.log.error('Error extracting live squash filesystem: %s' % (d))
         return False
コード例 #8
0
ファイル: tests.py プロジェクト: guspur/reconstructor.engine
 def testExtractSquashFs(self):
     self.assertTrue(squash_tools.create_squash_fs(source_dir=self.squash_root, dest_filename=self.squash_file, overwrite=True))
     self.assertTrue(squash_tools.extract_squash_fs(filename=self.squash_file, dest_dir=self.tmp_squash_dir), 'Error extracting squash filesystem...')
     self.assertTrue(os.listdir(self.tmp_squash_dir) != 0, 'Error extracting squash filesystem: directory empty...')