def unpack(self, target_dir, clean_dir=True): # check archive file's integrity if not util.check_file_hash(self.archiveFile, self.archive.sha1sum): ctx.ui.warning( _("Archive File: {}\n * Expected sha1 value: {}\n * Received sha1 value: {}\n" .format(self.url.filename(), self.archive.sha1sum, util.sha1_file(self.archiveFile)))) if not ctx.get_option('ignore_verify'): raise SourceArchiveError(_("unpack: check_file_hash failed.")) else: ctx.ui.warning( _("* Archive verification passed. Such problems may occur during the build process." )) try: archive = Archive(self.archiveFile, self.archive.type) except UnknownArchiveType: raise SourceArchiveError( _("Unknown archive type '{0}' is given for '{1}'.").format( self.archive.type, self.url.filename())) except ArchiveHandlerNotInstalled: raise SourceArchiveError( _("Inary needs \'{}\' to unpack this archive but it is not installed." ).format(self.archive.type)) target_dir = os.path.join(target_dir, self.archive.target or "") archive.unpack(target_dir, clean_dir)
def is_cached(self, interactive=True): if not os.access(self.archiveFile, os.R_OK): return False # check hash if util.check_file_hash(self.archiveFile, self.archive.sha1sum): if interactive: ctx.ui.info(_('\"{}\" [cached]').format(self.archive.name)) return True return False
def is_cached(self, interactive=True): if not os.access(self.archiveFile, os.R_OK): return False # check hash if util.check_file_hash( self.archiveFile, self.archive.sha1sum) or ctx.get_option('ignore_verify'): if interactive and ctx.config.get_option('debug'): ctx.ui.info(_('\"{}\" [cached]').format(self.archive.name)) return True return False
def unpack(self, target_dir, clean_dir=True): # check archive file's integrity if not util.check_file_hash(self.archiveFile, self.archive.sha1sum): raise SourceArchiveError(_("unpack: check_file_hash failed.")) try: archive = Archive(self.archiveFile, self.archive.type) except UnknownArchiveType: raise SourceArchiveError( _("Unknown archive type '{0}' is given for '{1}'.").format( self.archive.type, self.url.filename())) except ArchiveHandlerNotInstalled: raise SourceArchiveError( _("Inary needs \'{}\' to unpack this archive but it is not installed." ).format(self.archive.type)) target_dir = os.path.join(target_dir, self.archive.target or "") archive.unpack(target_dir, clean_dir)