<s> '''<STR_LIT>''' <EOL> from waflib . TaskGen import feature <EOL> import waflib . Logs as msg <EOL> from orch . util import urlopen , get_unpacker <EOL> from orch . wafutil import exec_command <EOL> import orch . features <EOL> orch . features . register_defaults ( <EOL> '<STR_LIT>' , <EOL> source_urlfile = '<STR_LIT>' , <EOL> source_archive_ext = '<STR_LIT>' , <EOL> source_archive_file = '<STR_LIT>' , <EOL> source_archive_path = '<STR_LIT>' , <EOL> source_archive_checksum = '<STR_LIT>' , <EOL> source_unpacked = '<STR_LIT>' , <EOL> source_unpacked_path = '<STR_LIT>' , <EOL> unpacked_target = '<STR_LIT>' , <EOL> source_unpacked_target = '<STR_LIT>' , <EOL> ) <EOL> @ feature ( '<STR_LIT>' ) <EOL> def feature_tarball ( tgen ) : <EOL> '''<STR_LIT>''' <EOL> tgen . step ( '<STR_LIT>' , <EOL> rule = "<STR_LIT>" % ( tgen . worch . source_url , tgen . worch . source_urlfile ) , <EOL> update_outputs = True , <EOL> target = tgen . worch . source_urlfile ) <EOL> def dl_task ( task ) : <EOL> src = task . inputs [ <NUM_LIT:0> ] <EOL> tgt = task . outputs [ <NUM_LIT:0> ] <EOL> url = src . read ( ) . strip ( ) <EOL> try : <EOL> web = urlopen ( url ) <EOL> tgt . write ( web . read ( ) , '<STR_LIT:wb>' ) <EOL> except Exception : <EOL> import traceback <EOL> traceback . print_exc ( ) <EOL> msg . error ( tgen . worch . format ( "<STR_LIT>" ) ) <EOL> raise <EOL> checksum = tgen . worch . source_archive_checksum <EOL> if not checksum : <EOL> return <EOL> hasher_name , ref = checksum . split ( "<STR_LIT::>" ) <EOL> import hashlib , os <EOL> hasher = getattr ( hashlib , hasher_name ) ( ) <EOL> hasher . update ( tgt . read ( '<STR_LIT:rb>' ) ) <EOL> data = hasher . hexdigest ( ) <EOL> if data != ref : <EOL> msg . error ( tgen . worch . format ( "<STR_LIT>" % ( ref , data ) ) ) <EOL> try : <EOL> os . remove ( tgt . abspath ( ) ) <EOL> except IOError : <EOL> pass <EOL> return <NUM_LIT:1> <EOL> return <EOL> tgen . step ( '<STR_LIT>' , <EOL> rule = dl_task , <EOL> source = tgen . worch . source_urlfile , <EOL> target = tgen . worch . source_archive_path ) <EOL> def unpack_task ( task ) : <EOL> cmd = get_unpacker ( task . inputs [ <NUM_LIT:0> ] . abspath ( ) ) <EOL> return exec_command ( task , cmd ) <EOL> tgen . step ( '<STR_LIT>' , <EOL> rule = unpack_task , <EOL> source = tgen . worch . source_archive_path , <EOL> target = tgen . worch . source_unpacked_target ) <EOL> return </s>
