<s> import re , sys , os , shutil , select <EOL> import codecs <EOL> try : <EOL> import ConfigParser <EOL> except ImportError : <EOL> import configparser as ConfigParser <EOL> import subprocess <EOL> import tempfile <EOL> import stdeb <EOL> from stdeb import log , __version__ as __stdeb_version__ <EOL> if hasattr ( os , '<STR_LIT>' ) : <EOL> link_func = os . link <EOL> else : <EOL> link_func = shutil . copyfile <EOL> __all__ = [ '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , <EOL> '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , <EOL> '<STR_LIT>' , '<STR_LIT>' , <EOL> '<STR_LIT>' , '<STR_LIT>' ] <EOL> DH_MIN_VERS = '<STR_LIT>' <EOL> DH_IDEAL_VERS = '<STR_LIT>' <EOL> PYTHON_ALL_MIN_VERS = '<STR_LIT>' <EOL> try : <EOL> from exceptions import Exception <EOL> except ImportError : <EOL> pass <EOL> class CalledProcessError ( Exception ) : pass <EOL> class CantSatisfyRequirement ( Exception ) : pass <EOL> def check_call ( * popenargs , ** kwargs ) : <EOL> retcode = subprocess . call ( * popenargs , ** kwargs ) <EOL> if retcode == <NUM_LIT:0> : <EOL> return <EOL> raise CalledProcessError ( retcode ) <EOL> if sys . version_info [ <NUM_LIT:0> ] == <NUM_LIT:2> : <EOL> help_str_py2 = '<STR_LIT>' <EOL> help_str_py3 = '<STR_LIT>' <EOL> else : <EOL> assert sys . version_info [ <NUM_LIT:0> ] == <NUM_LIT:3> <EOL> help_str_py2 = '<STR_LIT>' <EOL> help_str_py3 = '<STR_LIT>' <EOL> stdeb_cmdline_opts = [ <EOL> ( '<STR_LIT>' , '<STR_LIT:d>' , <EOL> "<STR_LIT>" ) , <EOL> ( '<STR_LIT>' , '<STR_LIT:a>' , <EOL> '<STR_LIT>' ) , <EOL> ( '<STR_LIT>' , None , <EOL> "<STR_LIT>" ) , <EOL> ( '<STR_LIT>' , '<STR_LIT:z>' , <EOL> "<STR_LIT>" ) , <EOL> ( '<STR_LIT>' , None , <EOL> '<STR_LIT>' ) , <EOL> ( '<STR_LIT>' , '<STR_LIT:m>' , <EOL> '<STR_LIT>' <EOL> '<STR_LIT>' ) , <EOL> ( '<STR_LIT>' , '<STR_LIT:x>' , <EOL> '<STR_LIT>' ) , <EOL> ( '<STR_LIT>' , '<STR_LIT:p>' , <EOL> '<STR_LIT>' <EOL> '<STR_LIT>' ) , <EOL> ( '<STR_LIT>' , '<STR_LIT:l>' , <EOL> '<STR_LIT>' <EOL> '<STR_LIT>' ) , <EOL> ( '<STR_LIT>' , '<STR_LIT:q>' , <EOL> '<STR_LIT>' ) , <EOL> ( '<STR_LIT>' , '<STR_LIT:r>' , <EOL> '<STR_LIT>' ) , <EOL> ( '<STR_LIT>' , '<STR_LIT:i>' , <EOL> '<STR_LIT>' ) , <EOL> ( '<STR_LIT>' , None , <EOL> '<STR_LIT>' <EOL> '<STR_LIT>' ) , <EOL> ( '<STR_LIT>' , None , <EOL> '<STR_LIT>' <EOL> '<STR_LIT>' ) , <EOL> ( '<STR_LIT>' , None , <EOL> '<STR_LIT>' <EOL> '<STR_LIT>' ) , <EOL> ( '<STR_LIT>' , None , <EOL> '<STR_LIT>' <EOL> '<STR_LIT>' ) , <EOL> ( '<STR_LIT>' , None , <EOL> help_str_py2 ) , <EOL> ( '<STR_LIT>' , None , <EOL> help_str_py3 ) , <EOL> ( '<STR_LIT>' , None , <EOL> '<STR_LIT>' ) , <EOL> ( '<STR_LIT>' , None , <EOL> '<STR_LIT>' ) , <EOL> ( '<STR_LIT>' , None , <EOL> '<STR_LIT>' <EOL> '<STR_LIT>' ) , <EOL> ( '<STR_LIT>' , None , <EOL> '<STR_LIT>' ) , <EOL> ( '<STR_LIT>' , None , <EOL> '<STR_LIT>' ) , <EOL> ] <EOL> stdeb_cfg_options = [ <EOL> ( '<STR_LIT>' , None , <EOL> '<STR_LIT>' ) , <EOL> ( '<STR_LIT>' , None , <EOL> '<STR_LIT>' ) , <EOL> ( '<STR_LIT>' , None , <EOL> '<STR_LIT>' ) , <EOL> ( '<STR_LIT>' , None , <EOL> '<STR_LIT>' ) , <EOL> ( '<STR_LIT>' , None , <EOL> '<STR_LIT>' ) , <EOL> ( '<STR_LIT>' , None , '<STR_LIT>' ) , <EOL> ( '<STR_LIT>' , None , '<STR_LIT>' ) , <EOL> ( '<STR_LIT>' , None , '<STR_LIT>' ) , <EOL> ( '<STR_LIT>' , None , '<STR_LIT>' ) , <EOL> ( '<STR_LIT>' , None , '<STR_LIT>' ) , <EOL> ( '<STR_LIT>' , None , '<STR_LIT>' ) , <EOL> ( '<STR_LIT>' , None , '<STR_LIT>' ) , <EOL> ( '<STR_LIT>' , None , '<STR_LIT>' ) , <EOL> ( '<STR_LIT>' , None , '<STR_LIT>' ) , <EOL> ( '<STR_LIT>' , None , '<STR_LIT>' ) , <EOL> ( '<STR_LIT>' , None , '<STR_LIT>' ) , <EOL> ( '<STR_LIT>' , None , '<STR_LIT>' ) , <EOL> ( '<STR_LIT>' , None , '<STR_LIT>' ) , <EOL> ( '<STR_LIT>' , None , '<STR_LIT>' ) , <EOL> ( '<STR_LIT>' , None , '<STR_LIT>' ) , <EOL> ( '<STR_LIT>' , None , '<STR_LIT>' ) , <EOL> ( '<STR_LIT>' , None , '<STR_LIT>' ) , <EOL> ( '<STR_LIT>' , None , '<STR_LIT>' ) , <EOL> ( '<STR_LIT>' , None , '<STR_LIT>' ) , <EOL> ( '<STR_LIT>' , None , '<STR_LIT>' ) , <EOL> ( '<STR_LIT>' , None , '<STR_LIT>' ) , <EOL> ( '<STR_LIT>' , None , '<STR_LIT>' ) , <EOL> ( '<STR_LIT>' , None , '<STR_LIT>' ) , <EOL> ( '<STR_LIT>' , None , '<STR_LIT>' ) , <EOL> ( '<STR_LIT>' , None , '<STR_LIT>' ) , <EOL> ( '<STR_LIT>' , None , '<STR_LIT>' ) , <EOL> ( '<STR_LIT>' , None , '<STR_LIT>' ) , <EOL> ( '<STR_LIT>' , None , '<STR_LIT>' ) , <EOL> ( '<STR_LIT>' , None , '<STR_LIT>' ) , <EOL> ( '<STR_LIT>' , None , '<STR_LIT>' ) , <EOL> ( '<STR_LIT>' , None , '<STR_LIT>' ) , <EOL> ( '<STR_LIT>' , None , '<STR_LIT>' ) , <EOL> ] <EOL> stdeb_cmd_bool_opts = [ <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> ] <EOL> class NotGiven : pass <EOL> def process_command ( args , cwd = None ) : <EOL> if not isinstance ( args , ( list , tuple ) ) : <EOL> raise RuntimeError ( "<STR_LIT>" ) <EOL> check_call ( args , cwd = cwd ) <EOL> def recursive_hardlink ( src , dst ) : <EOL> dst = os . path . abspath ( dst ) <EOL> orig_dir = os . path . abspath ( os . curdir ) <EOL> os . chdir ( src ) <EOL> try : <EOL> for root , dirs , files in os . walk ( os . curdir ) : <EOL> for file in files : <EOL> fullpath = os . path . normpath ( os . path . join ( root , file ) ) <EOL> dirname , fname = os . path . split ( fullpath ) <EOL> dstdir = os . path . normpath ( os . path . join ( dst , dirname ) ) <EOL> if not os . path . exists ( dstdir ) : <EOL> os . makedirs ( dstdir ) <EOL> newpath = os . path . join ( dstdir , fname ) <EOL> if os . path . exists ( newpath ) : <EOL> if os . path . samefile ( fullpath , newpath ) : <EOL> continue <EOL> else : <EOL> os . unlink ( newpath ) <EOL> link_func ( fullpath , newpath ) <EOL> finally : <EOL> os . chdir ( orig_dir ) <EOL> def debianize_name ( name ) : <EOL> "<STR_LIT>" <EOL> name = name . replace ( '<STR_LIT:_>' , '<STR_LIT:->' ) <EOL> name = name . lower ( ) <EOL> return name <EOL> def source_debianize_name ( name ) : <EOL> "<STR_LIT>" <EOL> name = name . replace ( '<STR_LIT:_>' , '<STR_LIT:->' ) <EOL> name = name . replace ( '<STR_LIT:.>' , '<STR_LIT:->' ) <EOL> name = name . lower ( ) <EOL> return name <EOL> def debianize_version ( name ) : <EOL> "<STR_LIT>" <EOL> name = name . replace ( '<STR_LIT>' , '<STR_LIT>' ) <EOL> name = name . lower ( ) <EOL> return name <EOL> def dpkg_compare_versions ( v1 , op , v2 ) : <EOL> args = [ '<STR_LIT>' , '<STR_LIT>' , v1 , op , v2 ] <EOL> cmd = subprocess . Popen ( args ) <EOL> returncode = cmd . wait ( ) <EOL> if returncode : <EOL> return False <EOL> else : <EOL> return True <EOL> def get_cmd_stdout ( args ) : <EOL> cmd = subprocess . Popen ( args , stdout = subprocess . PIPE ) <EOL> returncode = cmd . wait ( ) <EOL> if returncode : <EOL> log . error ( '<STR_LIT>' , '<STR_LIT:U+0020>' . join ( args ) ) <EOL> raise RuntimeError ( '<STR_LIT>' , returncode ) <EOL> return cmd . stdout . read ( ) <EOL> def normstr ( s ) : <EOL> try : <EOL> result = str ( s , '<STR_LIT:utf-8>' ) <EOL> except TypeError : <EOL> result = s <EOL> return result <EOL> def get_date_822 ( ) : <EOL> """<STR_LIT>""" <EOL> cmd = '<STR_LIT>' <EOL> if not os . path . exists ( cmd ) : <EOL> raise ValueError ( '<STR_LIT>' % cmd ) <EOL> args = [ cmd , '<STR_LIT>' ] <EOL> result = get_cmd_stdout ( args ) . strip ( ) <EOL> result = normstr ( result ) <EOL> return result <EOL> def get_version_str ( pkg ) : <EOL> args = [ '<STR_LIT>' , '<STR_LIT>' , <EOL> '<STR_LIT>' , pkg ] <EOL> stdout = get_cmd_stdout ( args ) <EOL> return stdout . strip ( ) . decode ( '<STR_LIT:ascii>' ) <EOL> def load_module ( name , fname ) : <EOL> import imp <EOL> suffix = '<STR_LIT>' <EOL> found = False <EOL> for description in imp . get_suffixes ( ) : <EOL> if description [ <NUM_LIT:0> ] == suffix : <EOL> found = True <EOL> break <EOL> assert found <EOL> fd = open ( fname , mode = '<STR_LIT:r>' ) <EOL> try : <EOL> module = imp . load_module ( name , fd , fname , description ) <EOL> finally : <EOL> fd . close ( ) <EOL> return module <EOL> def get_deb_depends_from_setuptools_requires ( requirements , on_failure = "<STR_LIT>" ) : <EOL> """<STR_LIT>""" <EOL> assert on_failure in ( "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" ) , on_failure <EOL> import pkg_resources <EOL> depends = [ ] <EOL> parsed_reqs = [ ] <EOL> for extra , reqs in pkg_resources . split_sections ( requirements ) : <EOL> if extra : continue <EOL> parsed_reqs . extend ( pkg_resources . parse_requirements ( reqs ) ) <EOL> if not parsed_reqs : <EOL> return depends <EOL> if not os . path . exists ( '<STR_LIT>' ) : <EOL> raise ValueError ( '<STR_LIT>' <EOL> '<STR_LIT>' ) <EOL> egginfore = ( "<STR_LIT>" <EOL> % '<STR_LIT:|>' . join ( req . project_name . replace ( '<STR_LIT:->' , '<STR_LIT:_>' ) for req in parsed_reqs ) ) <EOL> args = [ "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" , egginfore ] <EOL> if <NUM_LIT:1> : <EOL> dry_run_args = args [ : ] + [ '<STR_LIT>' , '<STR_LIT>' ] <EOL> cmd = subprocess . Popen ( dry_run_args , stderr = subprocess . PIPE ) <EOL> returncode = cmd . wait ( ) <EOL> if returncode : <EOL> err_output = cmd . stderr . read ( ) <EOL> raise RuntimeError ( '<STR_LIT>' + <EOL> err_output . strip ( ) ) <EOL> try : <EOL> cmd = subprocess . Popen ( args , stdin = subprocess . PIPE , <EOL> stdout = subprocess . PIPE , <EOL> universal_newlines = True ) <EOL> except Exception as le : <EOL> log . error ( '<STR_LIT>' , '<STR_LIT:U+0020>' . join ( args ) ) <EOL> raise RuntimeError ( '<STR_LIT>' % ( le , args ) ) <EOL> returncode = cmd . wait ( ) <EOL> if returncode : <EOL> log . error ( '<STR_LIT>' , '<STR_LIT:U+0020>' . join ( args ) ) <EOL> raise RuntimeError ( '<STR_LIT>' % ( returncode , <EOL> args ) ) <EOL> inlines = cmd . stdout . readlines ( ) <EOL> dd = { } <EOL> E = re . compile ( egginfore , re . I ) <EOL> D = re . compile ( "<STR_LIT>" , re . I ) <EOL> eggsndebs = set ( ) <EOL> for l in inlines : <EOL> if l : <EOL> emo = E . search ( l ) <EOL> assert emo , l <EOL> dmo = D . search ( l ) <EOL> assert dmo , l <EOL> eggsndebs . add ( ( emo . group ( <NUM_LIT:1> ) , dmo . group ( <NUM_LIT:1> ) ) ) <EOL> for ( egginfo , debname ) in eggsndebs : <EOL> pydist = pkg_resources . Distribution . from_filename ( egginfo ) <EOL> try : <EOL> dd . setdefault ( <EOL> pydist . project_name . lower ( ) , { } ) . setdefault ( <EOL> pydist , set ( ) ) . add ( debname ) <EOL> except ValueError as le : <EOL> log . warn ( "<STR_LIT>" <EOL> "<STR_LIT>" <EOL> "<STR_LIT>" % ( egginfo , debname , le , ) ) <EOL> pass <EOL> ops = { '<STR_LIT:<>' : '<STR_LIT>' , '<STR_LIT:>>' : '<STR_LIT>' , '<STR_LIT>' : '<STR_LIT:=>' , '<STR_LIT>' : '<STR_LIT>' , '<STR_LIT>' : '<STR_LIT>' } <EOL> for req in parsed_reqs : <EOL> reqname = req . project_name . lower ( ) <EOL> gooddebs = set ( ) <EOL> for pydist , debs in dd . get ( reqname , { } ) . iteritems ( ) : <EOL> if pydist in req : <EOL> gooddebs |= ( debs ) <EOL> else : <EOL> log . info ( "<STR_LIT>" <EOL> "<STR_LIT>" <EOL> "<STR_LIT>" <EOL> "<STR_LIT>" <EOL> % ( '<STR_LIT:U+002CU+0020>' . join ( debs ) , req . project_name , req ) ) <EOL> if not gooddebs : <EOL> if on_failure == '<STR_LIT>' : <EOL> log . warn ( <EOL> "<STR_LIT>" <EOL> "<STR_LIT>" <EOL> "<STR_LIT>" % ( req . project_name , req . specs ) ) <EOL> elif on_failure == "<STR_LIT>" : <EOL> raise CantSatisfyRequirement ( <EOL> "<STR_LIT>" <EOL> "<STR_LIT>" <EOL> "<STR_LIT>" % ( req . project_name , req . specs ) , req ) <EOL> elif on_failure == "<STR_LIT>" : <EOL> log . warn ( "<STR_LIT>" <EOL> "<STR_LIT>" <EOL> "<STR_LIT>" <EOL> "<STR_LIT>" <EOL> "<STR_LIT>" <EOL> "<STR_LIT>" % ( req . project_name , <EOL> req . specs , reqname ) ) <EOL> gooddebs . add ( "<STR_LIT>" + reqname ) <EOL> elif len ( gooddebs ) == <NUM_LIT:1> : <EOL> log . info ( "<STR_LIT>" <EOL> "<STR_LIT>" <EOL> "<STR_LIT>" <EOL> "<STR_LIT>" <EOL> % ( req . project_name , tuple ( gooddebs ) [ <NUM_LIT:0> ] , req . specs ) ) <EOL> else : <EOL> log . warn ( "<STR_LIT>" <EOL> "<STR_LIT>" <EOL> "<STR_LIT>" <EOL> "<STR_LIT>" <EOL> % ( req . project_name , '<STR_LIT:U+002CU+0020>' . join ( gooddebs ) , ) ) <EOL> alts = [ ] <EOL> for deb in gooddebs : <EOL> added_any_alt = False <EOL> for spec in req . specs : <EOL> alts . append ( "<STR_LIT>" % ( deb , ops [ spec [ <NUM_LIT:0> ] ] , spec [ <NUM_LIT:1> ] ) ) <EOL> added_any_alt = True <EOL> if not added_any_alt : <EOL> alts . append ( "<STR_LIT:%s>" % deb ) <EOL> if len ( alts ) : <EOL> depends . append ( '<STR_LIT>' . join ( alts ) ) <EOL> return depends <EOL> def make_tarball ( tarball_fname , directory , cwd = None ) : <EOL> "<STR_LIT>" <EOL> if tarball_fname . endswith ( '<STR_LIT>' ) : opts = '<STR_LIT>' <EOL> else : opts = '<STR_LIT>' <EOL> args = [ '<STR_LIT>' , opts , tarball_fname , directory ] <EOL> process_command ( args , cwd = cwd ) <EOL> def expand_tarball ( tarball_fname , cwd = None ) : <EOL> "<STR_LIT>" <EOL> if tarball_fname . endswith ( '<STR_LIT>' ) : opts = '<STR_LIT>' <EOL> elif tarball_fname . endswith ( '<STR_LIT>' ) : opts = '<STR_LIT>' <EOL> else : opts = '<STR_LIT>' <EOL> args = [ '<STR_LIT>' , opts , tarball_fname ] <EOL> process_command ( args , cwd = cwd ) <EOL> def expand_zip ( zip_fname , cwd = None ) : <EOL> "<STR_LIT>" <EOL> unzip_path = '<STR_LIT>' <EOL> if not os . path . exists ( unzip_path ) : <EOL> log . error ( '<STR_LIT>' . format ( unzip_path ) ) <EOL> sys . exit ( <NUM_LIT:1> ) <EOL> args = [ unzip_path , zip_fname ] <EOL> res = subprocess . Popen ( <EOL> [ args [ <NUM_LIT:0> ] , '<STR_LIT>' , args [ <NUM_LIT:1> ] ] , cwd = cwd , <EOL> stdout = subprocess . PIPE , <EOL> stderr = subprocess . PIPE , <EOL> ) <EOL> contents = [ ] <EOL> for line in res . stdout . readlines ( ) [ <NUM_LIT:3> : - <NUM_LIT:2> ] : <EOL> contents . append ( line . split ( ) [ - <NUM_LIT:1> ] ) <EOL> commonprefix = os . path . commonprefix ( contents ) <EOL> if not commonprefix : <EOL> extdir = os . path . join ( cwd , os . path . basename ( zip_fname [ : - <NUM_LIT:4> ] ) ) <EOL> args . extend ( [ '<STR_LIT>' , os . path . abspath ( extdir ) ] ) <EOL> process_command ( args , cwd = cwd ) <EOL> def expand_sdist_file ( sdist_file , cwd = None ) : <EOL> lower_sdist_file = sdist_file . lower ( ) <EOL> if lower_sdist_file . endswith ( '<STR_LIT>' ) : <EOL> expand_zip ( sdist_file , cwd = cwd ) <EOL> elif lower_sdist_file . endswith ( '<STR_LIT>' ) : <EOL> expand_tarball ( sdist_file , cwd = cwd ) <EOL> elif lower_sdist_file . endswith ( '<STR_LIT>' ) : <EOL> expand_tarball ( sdist_file , cwd = cwd ) <EOL> else : <EOL> raise RuntimeError ( '<STR_LIT>' ) <EOL> def repack_tarball_with_debianized_dirname ( orig_sdist_file , <EOL> repacked_sdist_file , <EOL> debianized_dirname , <EOL> original_dirname ) : <EOL> working_dir = tempfile . mkdtemp ( ) <EOL> expand_sdist_file ( orig_sdist_file , cwd = working_dir ) <EOL> fullpath_original_dirname = os . path . join ( working_dir , original_dirname ) <EOL> fullpath_debianized_dirname = os . path . join ( working_dir , debianized_dirname ) <EOL> assert os . path . exists ( fullpath_original_dirname ) <EOL> assert len ( os . listdir ( working_dir ) ) == <NUM_LIT:1> <EOL> if fullpath_original_dirname != fullpath_debianized_dirname : <EOL> os . rename ( fullpath_original_dirname , <EOL> fullpath_debianized_dirname ) <EOL> make_tarball ( repacked_sdist_file , debianized_dirname , cwd = working_dir ) <EOL> shutil . rmtree ( working_dir ) <EOL> def dpkg_buildpackage ( * args , ** kwargs ) : <EOL> cwd = kwargs . pop ( '<STR_LIT>' , None ) <EOL> if len ( kwargs ) != <NUM_LIT:0> : <EOL> raise ValueError ( '<STR_LIT>' ) <EOL> "<STR_LIT>" <EOL> args = [ '<STR_LIT>' ] + list ( args ) <EOL> process_command ( args , cwd = cwd ) <EOL> def dpkg_source ( b_or_x , arg1 , cwd = None ) : <EOL> "<STR_LIT>" <EOL> assert b_or_x in [ '<STR_LIT>' , '<STR_LIT>' ] <EOL> args = [ '<STR_LIT>' , b_or_x , arg1 ] <EOL> process_command ( args , cwd = cwd ) <EOL> def apply_patch ( patchfile , cwd = None , posix = False , level = <NUM_LIT:0> ) : <EOL> """<STR_LIT>""" <EOL> if not os . path . exists ( patchfile ) : <EOL> raise RuntimeError ( '<STR_LIT>' % patchfile ) <EOL> fd = open ( patchfile , mode = '<STR_LIT:r>' ) <EOL> level_str = '<STR_LIT>' % level <EOL> args = [ '<STR_LIT>' , level_str ] <EOL> if posix : <EOL> args . append ( '<STR_LIT>' ) <EOL> log . info ( '<STR_LIT>' , '<STR_LIT:U+0020>' . join ( args ) , patchfile ) <EOL> log . info ( '<STR_LIT>' , cwd ) <EOL> res = subprocess . Popen ( <EOL> args , cwd = cwd , <EOL> stdin = fd , <EOL> stdout = subprocess . PIPE , <EOL> stderr = subprocess . PIPE , <EOL> ) <EOL> returncode = None <EOL> while returncode is None : <EOL> returncode = res . poll ( ) <EOL> ready = select . select ( [ res . stdout , res . stderr ] , [ ] , [ ] , <NUM_LIT:0.1> ) <EOL> if res . stdout in ready [ <NUM_LIT:0> ] : <EOL> sys . stdout . write ( res . stdout . read ( <NUM_LIT:1> ) ) <EOL> sys . stdout . flush ( ) <EOL> if res . stderr in ready [ <NUM_LIT:0> ] : <EOL> sys . stderr . write ( res . stderr . read ( <NUM_LIT:1> ) ) <EOL> sys . stderr . flush ( ) <EOL> sys . stdout . write ( res . stdout . read ( ) ) <EOL> sys . stdout . flush ( ) <EOL> sys . stderr . write ( res . stderr . read ( ) ) <EOL> sys . stderr . flush ( ) <EOL> if returncode : <EOL> log . error ( '<STR_LIT>' , '<STR_LIT:U+0020>' . join ( args ) ) <EOL> log . error ( '<STR_LIT>' , cwd ) <EOL> raise RuntimeError ( '<STR_LIT>' % returncode ) <EOL> def parse_vals ( cfg , section , option ) : <EOL> """<STR_LIT>""" <EOL> try : <EOL> vals = cfg . get ( section , option ) <EOL> except ConfigParser . NoSectionError as err : <EOL> if section != '<STR_LIT>' : <EOL> vals = cfg . get ( '<STR_LIT>' , option ) <EOL> else : <EOL> raise err <EOL> vals = vals . split ( '<STR_LIT:#>' ) [ <NUM_LIT:0> ] <EOL> vals = vals . strip ( ) <EOL> vals = vals . split ( '<STR_LIT:U+002C>' ) <EOL> vals = [ v . strip ( ) for v in vals ] <EOL> vals = [ v for v in vals if len ( v ) ] <EOL> return vals <EOL> def parse_val ( cfg , section , option ) : <EOL> """<STR_LIT>""" <EOL> vals = parse_vals ( cfg , section , option ) <EOL> if len ( vals ) == <NUM_LIT:0> : <EOL> return '<STR_LIT>' <EOL> else : <EOL> assert len ( vals ) == <NUM_LIT:1> , ( section , option , vals , type ( vals ) ) <EOL> return vals [ <NUM_LIT:0> ] <EOL> def apt_cache_info ( apt_cache_cmd , package_name ) : <EOL> if apt_cache_cmd not in ( '<STR_LIT>' , '<STR_LIT>' ) : <EOL> raise NotImplementedError ( <EOL> "<STR_LIT>" % apt_cache_cmd ) <EOL> result_list = [ ] <EOL> args = [ "<STR_LIT>" , apt_cache_cmd , package_name ] <EOL> cmd = subprocess . Popen ( args , <EOL> stdin = subprocess . PIPE , <EOL> stderr = subprocess . PIPE , <EOL> stdout = subprocess . PIPE ) <EOL> returncode = cmd . wait ( ) <EOL> if returncode : <EOL> errline = cmd . stderr . read ( ) <EOL> if not ( returncode == <NUM_LIT:100> and errline == "<STR_LIT>" ) : <EOL> log . error ( '<STR_LIT>' , '<STR_LIT:U+0020>' . join ( args ) ) <EOL> raise RuntimeError ( '<STR_LIT>' % ( returncode , <EOL> args ) ) <EOL> inlines = cmd . stdout . read ( ) <EOL> version_blocks = inlines . split ( '<STR_LIT>' ) <EOL> for version_block in version_blocks : <EOL> block_dict = { } <EOL> if len ( version_block ) == <NUM_LIT:0> : <EOL> continue <EOL> version_lines = version_block . split ( '<STR_LIT:\n>' ) <EOL> assert version_lines [ <NUM_LIT:0> ] . startswith ( '<STR_LIT>' ) <EOL> block_dict [ '<STR_LIT>' ] = version_lines [ <NUM_LIT:0> ] [ len ( '<STR_LIT>' ) : ] <EOL> if apt_cache_cmd == '<STR_LIT>' : <EOL> assert version_lines [ <NUM_LIT:1> ] . startswith ( '<STR_LIT>' ) <EOL> block_dict [ '<STR_LIT>' ] = version_lines [ <NUM_LIT:1> ] [ len ( '<STR_LIT>' ) : ] <EOL> block_dict [ '<STR_LIT>' ] = block_dict [ '<STR_LIT>' ] . split ( '<STR_LIT:U+002CU+0020>' ) <EOL> elif apt_cache_cmd == '<STR_LIT>' : <EOL> for start in ( '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' ) : <EOL> key = start [ : - <NUM_LIT:2> ] <EOL> for line in version_lines [ <NUM_LIT:2> : ] : <EOL> if line . startswith ( start ) : <EOL> unsplit_line_result = line [ len ( start ) : ] <EOL> split_result = unsplit_line_result . split ( '<STR_LIT:U+002CU+0020>' ) <EOL> block_dict [ key ] = split_result <EOL> if key not in block_dict : <EOL> block_dict [ key ] = [ ] <EOL> result_list . append ( block_dict ) <EOL> return result_list <EOL> def check_cfg_files ( cfg_files , module_name ) : <EOL> """<STR_LIT>""" <EOL> cfg = ConfigParser . SafeConfigParser ( ) <EOL> cfg . read ( cfg_files ) <EOL> if cfg . has_section ( module_name ) : <EOL> section_items = cfg . items ( module_name ) <EOL> else : <EOL> section_items = [ ] <EOL> default_items = cfg . items ( '<STR_LIT>' ) <EOL> n_items = len ( section_items ) + len ( default_items ) <EOL> if n_items == <NUM_LIT:0> : <EOL> log . warn ( '<STR_LIT>' <EOL> '<STR_LIT>' % ( module_name , ) ) <EOL> class DebianInfo : <EOL> """<STR_LIT>""" <EOL> def __init__ ( self , <EOL> cfg_files = NotGiven , <EOL> module_name = NotGiven , <EOL> default_distribution = NotGiven , <EOL> guess_maintainer = NotGiven , <EOL> upstream_version = NotGiven , <EOL> has_ext_modules = NotGiven , <EOL> description = NotGiven , <EOL> long_description = NotGiven , <EOL> patch_file = None , <EOL> patch_level = None , <EOL> setup_requires = None , <EOL> debian_version = None , <EOL> have_script_entry_points = None , <EOL> use_setuptools = False , <EOL> guess_conflicts_provides_replaces = False , <EOL> sdist_dsc_command = None , <EOL> with_python2 = None , <EOL> with_python3 = None , <EOL> no_python2_scripts = None , <EOL> no_python3_scripts = None , <EOL> force_x_python3_version = False , <EOL> allow_virtualenv_install_location = False , <EOL> ) : <EOL> if cfg_files is NotGiven : raise ValueError ( "<STR_LIT>" ) <EOL> if module_name is NotGiven : raise ValueError ( <EOL> "<STR_LIT>" ) <EOL> if default_distribution is NotGiven : raise ValueError ( <EOL> "<STR_LIT>" ) <EOL> if guess_maintainer is NotGiven : raise ValueError ( <EOL> "<STR_LIT>" ) <EOL> if upstream_version is NotGiven : raise ValueError ( <EOL> "<STR_LIT>" ) <EOL> if has_ext_modules is NotGiven : raise ValueError ( <EOL> "<STR_LIT>" ) <EOL> if description is NotGiven : raise ValueError ( <EOL> "<STR_LIT>" ) <EOL> if long_description is NotGiven : raise ValueError ( <EOL> "<STR_LIT>" ) <EOL> cfg_defaults = self . _make_cfg_defaults ( <EOL> module_name = module_name , <EOL> default_distribution = default_distribution , <EOL> guess_maintainer = guess_maintainer , <EOL> ) <EOL> if len ( cfg_files ) : <EOL> check_cfg_files ( cfg_files , module_name ) <EOL> cfg = ConfigParser . SafeConfigParser ( cfg_defaults ) <EOL> for cfg_file in cfg_files : <EOL> with codecs . open ( cfg_file , mode = '<STR_LIT:r>' , encoding = '<STR_LIT:utf-8>' ) as fd : <EOL> cfg . readfp ( fd ) <EOL> if sdist_dsc_command is not None : <EOL> for longopt , shortopt , desc in stdeb_cfg_options : <EOL> opt_name = longopt [ : - <NUM_LIT:1> ] <EOL> name = opt_name . replace ( '<STR_LIT:->' , '<STR_LIT:_>' ) <EOL> value = getattr ( sdist_dsc_command , name ) <EOL> if value is not None : <EOL> if not cfg . has_section ( module_name ) : <EOL> cfg . add_section ( module_name ) <EOL> cfg . set ( module_name , opt_name , value ) <EOL> self . stdeb_version = __stdeb_version__ <EOL> self . module_name = module_name <EOL> self . source = parse_val ( cfg , module_name , '<STR_LIT>' ) <EOL> self . package = parse_val ( cfg , module_name , '<STR_LIT>' ) <EOL> self . package3 = parse_val ( cfg , module_name , '<STR_LIT>' ) <EOL> forced_upstream_version = parse_val ( cfg , module_name , <EOL> '<STR_LIT>' ) <EOL> if forced_upstream_version == '<STR_LIT>' : <EOL> upstream_version_prefix = parse_val ( cfg , module_name , <EOL> '<STR_LIT>' ) <EOL> upstream_version_suffix = parse_val ( cfg , module_name , <EOL> '<STR_LIT>' ) <EOL> self . upstream_version = ( upstream_version_prefix + <EOL> debianize_version ( upstream_version ) + <EOL> upstream_version_suffix ) <EOL> else : <EOL> if ( debianize_version ( forced_upstream_version ) != <EOL> forced_upstream_version ) : <EOL> raise ValueError ( '<STR_LIT>' <EOL> '<STR_LIT>' % ( <EOL> forced_upstream_version , <EOL> debianize_version ( forced_upstream_version ) ) ) <EOL> self . upstream_version = forced_upstream_version <EOL> self . epoch = parse_val ( cfg , module_name , '<STR_LIT>' ) <EOL> if self . epoch != '<STR_LIT>' and not self . epoch . endswith ( '<STR_LIT::>' ) : <EOL> self . epoch = self . epoch + '<STR_LIT::>' <EOL> self . packaging_version = parse_val ( cfg , module_name , '<STR_LIT>' ) <EOL> if debian_version is not None : <EOL> self . packaging_version = debian_version <EOL> self . dsc_version = '<STR_LIT>' % ( <EOL> self . upstream_version , <EOL> self . packaging_version ) <EOL> self . full_version = '<STR_LIT>' % ( <EOL> self . epoch , <EOL> self . upstream_version , <EOL> self . packaging_version ) <EOL> self . distname = parse_val ( cfg , module_name , '<STR_LIT>' ) <EOL> self . maintainer = '<STR_LIT:U+002CU+0020>' . join ( parse_vals ( cfg , module_name , '<STR_LIT>' ) ) <EOL> self . uploaders = parse_vals ( cfg , module_name , '<STR_LIT>' ) <EOL> self . date822 = get_date_822 ( ) <EOL> build_deps = [ ] <EOL> if use_setuptools : <EOL> if with_python2 : <EOL> build_deps . append ( '<STR_LIT>' ) <EOL> if with_python3 : <EOL> build_deps . append ( '<STR_LIT>' ) <EOL> if setup_requires is not None and len ( setup_requires ) : <EOL> build_deps . extend ( <EOL> get_deb_depends_from_setuptools_requires ( setup_requires ) ) <EOL> depends = [ '<STR_LIT>' , '<STR_LIT>' ] <EOL> depends3 = [ '<STR_LIT>' , '<STR_LIT>' ] <EOL> need_custom_binary_target = False <EOL> if has_ext_modules : <EOL> self . architecture = '<STR_LIT>' <EOL> if with_python2 : <EOL> build_deps . append ( '<STR_LIT>' % PYTHON_ALL_MIN_VERS ) <EOL> depends . append ( '<STR_LIT>' ) <EOL> self . architecture3 = '<STR_LIT>' <EOL> if with_python3 : <EOL> build_deps . append ( '<STR_LIT>' ) <EOL> depends3 . append ( '<STR_LIT>' ) <EOL> else : <EOL> self . architecture = '<STR_LIT:all>' <EOL> if with_python2 : <EOL> build_deps . append ( '<STR_LIT>' % PYTHON_ALL_MIN_VERS ) <EOL> self . architecture3 = '<STR_LIT:all>' <EOL> if with_python3 : <EOL> build_deps . append ( '<STR_LIT>' ) <EOL> self . copyright_file = parse_val ( cfg , module_name , '<STR_LIT>' ) <EOL> self . mime_file = parse_val ( cfg , module_name , '<STR_LIT>' ) <EOL> self . shared_mime_file = parse_val ( cfg , module_name , '<STR_LIT>' ) <EOL> if self . mime_file == '<STR_LIT>' and self . shared_mime_file == '<STR_LIT>' : <EOL> self . dh_installmime_indep_line = '<STR_LIT>' <EOL> else : <EOL> need_custom_binary_target = True <EOL> self . dh_installmime_indep_line = '<STR_LIT>' <EOL> mime_desktop_files = parse_vals ( cfg , module_name , '<STR_LIT>' ) <EOL> if len ( mime_desktop_files ) : <EOL> need_custom_binary_target = True <EOL> self . dh_desktop_indep_line = '<STR_LIT>' <EOL> else : <EOL> self . dh_desktop_indep_line = '<STR_LIT>' <EOL> self . install_file_lines = [ ] <EOL> for mime_desktop_file in mime_desktop_files : <EOL> self . install_file_lines . append ( <EOL> '<STR_LIT>' % mime_desktop_file ) <EOL> depends . extend ( parse_vals ( cfg , module_name , '<STR_LIT>' ) ) <EOL> depends3 . extend ( parse_vals ( cfg , module_name , '<STR_LIT>' ) ) <EOL> self . depends = '<STR_LIT:U+002CU+0020>' . join ( depends ) <EOL> self . depends3 = '<STR_LIT:U+002CU+0020>' . join ( depends3 ) <EOL> self . debian_section = parse_val ( cfg , module_name , '<STR_LIT>' ) <EOL> self . description = re . sub ( '<STR_LIT>' , '<STR_LIT:U+0020>' , description ) . strip ( ) <EOL> if long_description != '<STR_LIT>' : <EOL> ld2 = [ ] <EOL> for line in long_description . split ( '<STR_LIT:\n>' ) : <EOL> ls = line . strip ( ) <EOL> if len ( ls ) : <EOL> ld2 . append ( '<STR_LIT:U+0020>' + line ) <EOL> else : <EOL> ld2 . append ( '<STR_LIT>' ) <EOL> ld2 = ld2 [ : <NUM_LIT:20> ] <EOL> self . long_description = '<STR_LIT:\n>' . join ( ld2 ) <EOL> else : <EOL> self . long_description = '<STR_LIT>' <EOL> if have_script_entry_points : <EOL> build_deps . append ( '<STR_LIT>' % DH_IDEAL_VERS ) <EOL> else : <EOL> build_deps . append ( '<STR_LIT>' % DH_MIN_VERS ) <EOL> build_deps . extend ( parse_vals ( cfg , module_name , '<STR_LIT>' ) ) <EOL> self . build_depends = '<STR_LIT:U+002CU+0020>' . join ( build_deps ) <EOL> suggests = '<STR_LIT:U+002CU+0020>' . join ( parse_vals ( cfg , module_name , '<STR_LIT>' ) ) <EOL> suggests3 = '<STR_LIT:U+002CU+0020>' . join ( parse_vals ( cfg , module_name , '<STR_LIT>' ) ) <EOL> recommends = '<STR_LIT:U+002CU+0020>' . join ( parse_vals ( cfg , module_name , '<STR_LIT>' ) ) <EOL> recommends3 = '<STR_LIT:U+002CU+0020>' . join ( parse_vals ( cfg , module_name , '<STR_LIT>' ) ) <EOL> self . source_stanza_extras = '<STR_LIT>' <EOL> build_conflicts = parse_vals ( cfg , module_name , '<STR_LIT>' ) <EOL> if len ( build_conflicts ) : <EOL> self . source_stanza_extras += ( '<STR_LIT>' + <EOL> '<STR_LIT:U+002CU+0020>' . join ( build_conflicts ) + '<STR_LIT:\n>' ) <EOL> self . patch_file = parse_val ( cfg , module_name , '<STR_LIT>' ) <EOL> if patch_file is not None : <EOL> if self . patch_file != '<STR_LIT>' : <EOL> raise RuntimeError ( '<STR_LIT>' <EOL> '<STR_LIT>' ) <EOL> else : <EOL> self . patch_file = patch_file <EOL> self . patch_level = parse_val ( cfg , module_name , '<STR_LIT>' ) <EOL> if self . patch_level != '<STR_LIT>' : <EOL> if patch_level is not None : <EOL> raise RuntimeError ( '<STR_LIT>' <EOL> '<STR_LIT>' ) <EOL> else : <EOL> self . patch_level = int ( self . patch_level ) <EOL> else : <EOL> if patch_level is not None : <EOL> self . patch_level = patch_level <EOL> else : <EOL> self . patch_level = <NUM_LIT:0> <EOL> xs_python_version = parse_vals ( cfg , module_name , '<STR_LIT>' ) <EOL> if len ( xs_python_version ) != <NUM_LIT:0> : <EOL> self . source_stanza_extras += ( '<STR_LIT>' + <EOL> '<STR_LIT:U+002CU+0020>' . join ( xs_python_version ) + '<STR_LIT:\n>' ) <EOL> x_python3_version = parse_vals ( cfg , module_name , '<STR_LIT>' ) <EOL> x_python3_version = [ v . strip ( '<STR_LIT:">' ) for v in x_python3_version ] <EOL> if len ( x_python3_version ) != <NUM_LIT:0> : <EOL> self . source_stanza_extras += ( '<STR_LIT>' + <EOL> '<STR_LIT:U+002CU+0020>' . join ( x_python3_version ) + '<STR_LIT:\n>' ) <EOL> dpkg_shlibdeps_params = parse_val ( <EOL> cfg , module_name , '<STR_LIT>' ) <EOL> if dpkg_shlibdeps_params : <EOL> need_custom_binary_target = True <EOL> self . dh_binary_arch_lines = """<STR_LIT>""" % dpkg_shlibdeps_params <EOL> else : <EOL> self . dh_binary_arch_lines = '<STR_LIT>' <EOL> self . dh_binary_indep_lines = '<STR_LIT>' <EOL> conflicts = parse_vals ( cfg , module_name , '<STR_LIT>' ) <EOL> conflicts3 = parse_vals ( cfg , module_name , '<STR_LIT>' ) <EOL> provides = parse_vals ( cfg , module_name , '<STR_LIT>' ) <EOL> provides3 = parse_vals ( cfg , module_name , '<STR_LIT>' ) <EOL> replaces = parse_vals ( cfg , module_name , '<STR_LIT>' ) <EOL> replaces3 = parse_vals ( cfg , module_name , '<STR_LIT>' ) <EOL> if guess_conflicts_provides_replaces : <EOL> cpr_binaries = set ( ) <EOL> for version_info in apt_cache_info ( '<STR_LIT>' , self . package ) : <EOL> for binary in version_info [ '<STR_LIT>' ] : <EOL> cpr_binaries . add ( binary ) <EOL> break <EOL> for orig_binary in cpr_binaries : <EOL> for version_info in apt_cache_info ( '<STR_LIT>' , orig_binary ) : <EOL> provides . extend ( version_info [ '<STR_LIT>' ] ) <EOL> provides3 . extend ( version_info [ '<STR_LIT>' ] ) <EOL> conflicts . extend ( version_info [ '<STR_LIT>' ] ) <EOL> conflicts3 . extend ( version_info [ '<STR_LIT>' ] ) <EOL> replaces . extend ( version_info [ '<STR_LIT>' ] ) <EOL> replaces3 . extend ( version_info [ '<STR_LIT>' ] ) <EOL> if self . package in cpr_binaries : <EOL> cpr_binaries . remove ( self . package ) <EOL> cpr_binaries = list ( cpr_binaries ) <EOL> conflicts . extend ( cpr_binaries ) <EOL> conflicts3 . extend ( cpr_binaries ) <EOL> provides . extend ( cpr_binaries ) <EOL> provides3 . extend ( cpr_binaries ) <EOL> replaces . extend ( cpr_binaries ) <EOL> replaces3 . extend ( cpr_binaries ) <EOL> conflicts = list ( set ( conflicts ) ) <EOL> conflicts3 = list ( set ( conflicts3 ) ) <EOL> provides = list ( set ( provides ) ) <EOL> provides3 = list ( set ( provides3 ) ) <EOL> replaces = list ( set ( replaces ) ) <EOL> replaces3 = list ( set ( replaces3 ) ) <EOL> self . package_stanza_extras = '<STR_LIT>' <EOL> self . package_stanza_extras3 = '<STR_LIT>' <EOL> if len ( conflicts ) : <EOL> self . package_stanza_extras += ( '<STR_LIT>' + <EOL> '<STR_LIT:U+002CU+0020>' . join ( conflicts ) + '<STR_LIT:\n>' ) <EOL> if len ( conflicts3 ) : <EOL> self . package_stanza_extras3 += ( '<STR_LIT>' + <EOL> '<STR_LIT:U+002CU+0020>' . join ( conflicts3 ) + '<STR_LIT:\n>' ) <EOL> if len ( provides ) : <EOL> self . package_stanza_extras += ( '<STR_LIT>' + <EOL> '<STR_LIT:U+002CU+0020>' . join ( provides ) + '<STR_LIT:\n>' ) <EOL> if len ( provides3 ) : <EOL> self . package_stanza_extras3 += ( '<STR_LIT>' + <EOL> '<STR_LIT:U+002CU+0020>' . join ( provides3 ) + '<STR_LIT:\n>' ) <EOL> if len ( replaces ) : <EOL> self . package_stanza_extras += ( '<STR_LIT>' + <EOL> '<STR_LIT:U+002CU+0020>' . join ( replaces ) + '<STR_LIT:\n>' ) <EOL> if len ( replaces3 ) : <EOL> self . package_stanza_extras3 += ( '<STR_LIT>' + <EOL> '<STR_LIT:U+002CU+0020>' . join ( replaces3 ) + '<STR_LIT:\n>' ) <EOL> if len ( recommends ) : <EOL> self . package_stanza_extras += ( '<STR_LIT>' + recommends + '<STR_LIT:\n>' ) <EOL> if len ( recommends3 ) : <EOL> self . package_stanza_extras3 += ( '<STR_LIT>' + recommends3 + '<STR_LIT:\n>' ) <EOL> if len ( suggests ) : <EOL> self . package_stanza_extras += ( '<STR_LIT>' + suggests + '<STR_LIT:\n>' ) <EOL> if len ( suggests3 ) : <EOL> self . package_stanza_extras3 += ( '<STR_LIT>' + suggests3 + '<STR_LIT:\n>' ) <EOL> self . dirlist = "<STR_LIT>" <EOL> if not ( with_python2 or with_python3 ) : <EOL> raise RuntimeError ( '<STR_LIT>' ) <EOL> sequencer_with = [ ] <EOL> if with_python2 : <EOL> sequencer_with . append ( '<STR_LIT>' ) <EOL> if with_python3 : <EOL> sequencer_with . append ( '<STR_LIT>' ) <EOL> num_binary_packages = len ( sequencer_with ) <EOL> no_script_lines = [ ] <EOL> if no_python2_scripts : <EOL> self . no_python2_scripts_cli_args = '<STR_LIT>' <EOL> no_script_lines . append ( <EOL> '<STR_LIT>' % ( self . package , ) ) <EOL> else : <EOL> self . no_python2_scripts_cli_args = '<STR_LIT>' <EOL> if no_python3_scripts : <EOL> self . no_python3_scripts_cli_args = '<STR_LIT>' <EOL> no_script_lines . append ( <EOL> '<STR_LIT>' % ( self . package3 , ) ) <EOL> else : <EOL> self . no_python3_scripts_cli_args = '<STR_LIT>' <EOL> self . scripts_cleanup = '<STR_LIT:\n>' . join ( [ '<STR_LIT:U+0020>' + s for s in no_script_lines ] ) <EOL> if sys . prefix != '<STR_LIT>' : <EOL> if not allow_virtualenv_install_location : <EOL> self . install_prefix = '<STR_LIT>' <EOL> else : <EOL> self . install_prefix = '<STR_LIT>' % sys . prefix <EOL> else : <EOL> self . install_prefix = '<STR_LIT>' <EOL> rules_override_clean_target_pythons = [ ] <EOL> rules_override_build_target_pythons = [ ] <EOL> rules_override_install_target_pythons = [ ] <EOL> if with_python2 : <EOL> rules_override_clean_target_pythons . append ( <EOL> RULES_OVERRIDE_CLEAN_TARGET_PY2 % self . __dict__ <EOL> ) <EOL> rules_override_build_target_pythons . append ( <EOL> RULES_OVERRIDE_BUILD_TARGET_PY2 % self . __dict__ <EOL> ) <EOL> rules_override_install_target_pythons . append ( <EOL> RULES_OVERRIDE_INSTALL_TARGET_PY2 % self . __dict__ <EOL> ) <EOL> if with_python3 : <EOL> rules_override_clean_target_pythons . append ( <EOL> RULES_OVERRIDE_CLEAN_TARGET_PY3 % self . __dict__ <EOL> ) <EOL> rules_override_build_target_pythons . append ( <EOL> RULES_OVERRIDE_BUILD_TARGET_PY3 % self . __dict__ <EOL> ) <EOL> rules_override_install_target_pythons . append ( <EOL> RULES_OVERRIDE_INSTALL_TARGET_PY3 % self . __dict__ <EOL> ) <EOL> self . rules_override_clean_target_pythons = '<STR_LIT:\n>' . join ( rules_override_clean_target_pythons ) <EOL> self . rules_override_build_target_pythons = '<STR_LIT:\n>' . join ( rules_override_build_target_pythons ) <EOL> self . rules_override_install_target_pythons = '<STR_LIT:\n>' . join ( rules_override_install_target_pythons ) <EOL> self . override_dh_auto_clean = RULES_OVERRIDE_CLEAN_TARGET % self . __dict__ <EOL> self . override_dh_auto_build = RULES_OVERRIDE_BUILD_TARGET % self . __dict__ <EOL> self . override_dh_auto_install = RULES_OVERRIDE_INSTALL_TARGET % self . __dict__ <EOL> if force_x_python3_version and with_python3 and x_python3_version and x_python3_version [ <NUM_LIT:0> ] : <EOL> version = x_python3_version [ <NUM_LIT:0> ] <EOL> if not version . endswith ( '<STR_LIT>' ) : <EOL> version += '<STR_LIT>' <EOL> self . override_dh_python3 = RULES_OVERRIDE_PYTHON3 % { <EOL> '<STR_LIT>' : ( <EOL> '<STR_LIT>' + <EOL> '<STR_LIT>' + <EOL> '<STR_LIT>' ) % ( version , self . package3 ) <EOL> } <EOL> else : <EOL> self . override_dh_python3 = '<STR_LIT>' <EOL> sequencer_options = [ '<STR_LIT>' + '<STR_LIT:U+002C>' . join ( sequencer_with ) ] <EOL> sequencer_options . append ( '<STR_LIT>' ) <EOL> self . sequencer_options = '<STR_LIT:U+0020>' . join ( sequencer_options ) <EOL> setup_env_vars = parse_vals ( cfg , module_name , '<STR_LIT>' ) <EOL> self . exports = "<STR_LIT>" <EOL> if len ( setup_env_vars ) : <EOL> self . exports += '<STR_LIT:\n>' <EOL> self . exports += '<STR_LIT>' <EOL> self . exports += '<STR_LIT:\n>' . join ( [ '<STR_LIT>' % v for v in setup_env_vars ] ) <EOL> self . exports += '<STR_LIT:\n>' <EOL> self . udev_rules = parse_val ( cfg , module_name , '<STR_LIT>' ) <EOL> if need_custom_binary_target : <EOL> if self . architecture == '<STR_LIT:all>' : <EOL> self . binary_target_lines = ( RULES_BINARY_ALL_TARGET % self . __dict__ + RULES_BINARY_INDEP_TARGET % self . __dict__ ) <EOL> else : <EOL> self . binary_target_lines = ( RULES_BINARY_TARGET % self . __dict__ + RULES_BINARY_INDEP_TARGET % self . __dict__ + RULES_BINARY_ARCH_TARGET % self . __dict__ ) <EOL> else : <EOL> self . binary_target_lines = '<STR_LIT>' <EOL> if with_python2 : <EOL> self . control_py2_stanza = CONTROL_PY2_STANZA % self . __dict__ <EOL> else : <EOL> self . control_py2_stanza = '<STR_LIT>' <EOL> if with_python3 : <EOL> self . control_py3_stanza = CONTROL_PY3_STANZA % self . __dict__ <EOL> else : <EOL> self . control_py3_stanza = '<STR_LIT>' <EOL> self . with_python2 = with_python2 <EOL> self . with_python3 = with_python3 <EOL> self . no_python2_scripts = no_python2_scripts <EOL> self . no_python3_scripts = no_python3_scripts <EOL> def _make_cfg_defaults ( self , <EOL> module_name = NotGiven , <EOL> default_distribution = NotGiven , <EOL> guess_maintainer = NotGiven , <EOL> ) : <EOL> defaults = { } <EOL> default_re = re . compile ( r'<STR_LIT>' ) <EOL> for longopt , shortopt , description in stdeb_cfg_options : <EOL> assert longopt . endswith ( '<STR_LIT:=>' ) <EOL> assert longopt . lower ( ) == longopt <EOL> key = longopt [ : - <NUM_LIT:1> ] <EOL> matchobj = default_re . search ( description ) <EOL> if matchobj is not None : <EOL> groups = matchobj . groups ( ) <EOL> assert len ( groups ) == <NUM_LIT:1> <EOL> value = groups [ <NUM_LIT:0> ] <EOL> if value == '<STR_LIT>' : <EOL> assert key == '<STR_LIT:source>' <EOL> value = source_debianize_name ( module_name ) <EOL> elif value == '<STR_LIT>' : <EOL> assert key == '<STR_LIT>' <EOL> value = '<STR_LIT>' + debianize_name ( module_name ) <EOL> elif value == '<STR_LIT>' : <EOL> assert key == '<STR_LIT>' <EOL> value = '<STR_LIT>' + debianize_name ( module_name ) <EOL> elif value == '<STR_LIT>' : <EOL> assert key == '<STR_LIT>' <EOL> value = guess_maintainer <EOL> if key == '<STR_LIT>' : <EOL> if default_distribution is not None : <EOL> value = default_distribution <EOL> log . warn ( '<STR_LIT>' <EOL> '<STR_LIT>' <EOL> '<STR_LIT>' ) <EOL> else : <EOL> value = '<STR_LIT>' <EOL> defaults [ key ] = value <EOL> return defaults <EOL> def build_dsc ( debinfo , <EOL> dist_dir , <EOL> repackaged_dirname , <EOL> orig_sdist = None , <EOL> patch_posix = <NUM_LIT:0> , <EOL> remove_expanded_source_dir = <NUM_LIT:0> , <EOL> debian_dir_only = False , <EOL> sign_dsc = False , <EOL> ) : <EOL> """<STR_LIT>""" <EOL> if debian_dir_only : <EOL> fullpath_repackaged_dirname = os . path . abspath ( os . curdir ) <EOL> else : <EOL> fullpath_repackaged_dirname = os . path . join ( dist_dir , repackaged_dirname ) <EOL> if not debian_dir_only : <EOL> repackaged_orig_tarball = ( '<STR_LIT>' % <EOL> debinfo . __dict__ ) <EOL> repackaged_orig_tarball_path = os . path . join ( dist_dir , <EOL> repackaged_orig_tarball ) <EOL> if orig_sdist is not None : <EOL> if os . path . exists ( repackaged_orig_tarball_path ) : <EOL> os . unlink ( repackaged_orig_tarball_path ) <EOL> link_func ( orig_sdist , repackaged_orig_tarball_path ) <EOL> else : <EOL> make_tarball ( repackaged_orig_tarball , <EOL> repackaged_dirname , <EOL> cwd = dist_dir ) <EOL> if debinfo . patch_file != '<STR_LIT>' : <EOL> apply_patch ( debinfo . patch_file , <EOL> posix = patch_posix , <EOL> level = debinfo . patch_level , <EOL> cwd = fullpath_repackaged_dirname ) <EOL> for fname in [ '<STR_LIT>' , '<STR_LIT>' ] : <EOL> if os . path . exists ( os . path . join ( fullpath_repackaged_dirname , fname ) ) : <EOL> sys . stderr . write ( '<STR_LIT:*>' * <NUM_LIT:1000> + '<STR_LIT:\n>' ) <EOL> sys . stderr . write ( '<STR_LIT>' <EOL> '<STR_LIT>' <EOL> '<STR_LIT>' <EOL> '<STR_LIT>' ) <EOL> sys . stderr . write ( '<STR_LIT:*>' * <NUM_LIT:1000> + '<STR_LIT:\n>' ) <EOL> debian_dir = os . path . join ( fullpath_repackaged_dirname , '<STR_LIT>' ) <EOL> if not os . path . exists ( debian_dir ) : <EOL> os . mkdir ( debian_dir ) <EOL> changelog = CHANGELOG_FILE % debinfo . __dict__ <EOL> with codecs . open ( os . path . join ( debian_dir , '<STR_LIT>' ) , <EOL> mode = '<STR_LIT:w>' , encoding = '<STR_LIT:utf-8>' ) as fd : <EOL> fd . write ( changelog ) <EOL> if debinfo . uploaders : <EOL> debinfo . uploaders = '<STR_LIT>' % '<STR_LIT:U+002CU+0020>' . join ( debinfo . uploaders ) <EOL> else : <EOL> debinfo . uploaders = '<STR_LIT>' <EOL> control = CONTROL_FILE % debinfo . __dict__ <EOL> with codecs . open ( os . path . join ( debian_dir , '<STR_LIT>' ) , <EOL> mode = '<STR_LIT:w>' , encoding = '<STR_LIT:utf-8>' ) as fd : <EOL> fd . write ( control ) <EOL> debinfo . percent_symbol = '<STR_LIT:%>' <EOL> rules = RULES_MAIN % debinfo . __dict__ <EOL> rules = rules . replace ( '<STR_LIT:U+0020>' , '<STR_LIT:\t>' ) <EOL> rules_fname = os . path . join ( debian_dir , '<STR_LIT>' ) <EOL> with codecs . open ( rules_fname , <EOL> mode = '<STR_LIT:w>' , encoding = '<STR_LIT:utf-8>' ) as fd : <EOL> fd . write ( rules ) <EOL> os . chmod ( rules_fname , <NUM_LIT> ) <EOL> fd = open ( os . path . join ( debian_dir , '<STR_LIT>' ) , mode = '<STR_LIT:w>' ) <EOL> fd . write ( '<STR_LIT>' ) <EOL> fd . close ( ) <EOL> if debinfo . mime_file != '<STR_LIT>' : <EOL> if not os . path . exists ( debinfo . mime_file ) : <EOL> raise ValueError ( <EOL> '<STR_LIT>' % ( <EOL> debinfo . mime_file , ) ) <EOL> link_func ( debinfo . mime_file , <EOL> os . path . join ( debian_dir , debinfo . package + '<STR_LIT>' ) ) <EOL> if debinfo . shared_mime_file != '<STR_LIT>' : <EOL> if not os . path . exists ( debinfo . shared_mime_file ) : <EOL> raise ValueError ( <EOL> '<STR_LIT>' % ( <EOL> debinfo . shared_mime_file , ) ) <EOL> link_func ( debinfo . shared_mime_file , <EOL> os . path . join ( debian_dir , <EOL> debinfo . package + '<STR_LIT>' ) ) <EOL> if debinfo . copyright_file != '<STR_LIT>' : <EOL> link_func ( debinfo . copyright_file , <EOL> os . path . join ( debian_dir , '<STR_LIT>' ) ) <EOL> if len ( debinfo . install_file_lines ) : <EOL> fd = open ( os . path . join ( debian_dir , '<STR_LIT>' % debinfo . package ) , mode = '<STR_LIT:w>' ) <EOL> fd . write ( '<STR_LIT:\n>' . join ( debinfo . install_file_lines ) + '<STR_LIT:\n>' ) <EOL> fd . close ( ) <EOL> if debinfo . udev_rules != '<STR_LIT>' : <EOL> fname = debinfo . udev_rules <EOL> if not os . path . exists ( fname ) : <EOL> raise ValueError ( '<STR_LIT>' ) <EOL> link_func ( fname , <EOL> os . path . join ( debian_dir , '<STR_LIT>' % debinfo . package ) ) <EOL> os . mkdir ( os . path . join ( debian_dir , '<STR_LIT:source>' ) ) <EOL> fd = open ( os . path . join ( debian_dir , '<STR_LIT:source>' , '<STR_LIT>' ) , mode = '<STR_LIT:w>' ) <EOL> fd . write ( '<STR_LIT>' ) <EOL> fd . close ( ) <EOL> fd = open ( os . path . join ( debian_dir , '<STR_LIT:source>' , '<STR_LIT>' ) , mode = '<STR_LIT:w>' ) <EOL> fd . write ( '<STR_LIT>' ) <EOL> fd . close ( ) <EOL> if debian_dir_only : <EOL> return <EOL> debianized_package_dirname = fullpath_repackaged_dirname + '<STR_LIT>' <EOL> if os . path . exists ( debianized_package_dirname ) : <EOL> raise RuntimeError ( '<STR_LIT>' % <EOL> debianized_package_dirname ) <EOL> os . rename ( fullpath_repackaged_dirname , debianized_package_dirname ) <EOL> if orig_sdist is not None : <EOL> tmp_dir = os . path . join ( dist_dir , '<STR_LIT>' ) <EOL> os . mkdir ( tmp_dir ) <EOL> try : <EOL> expand_tarball ( orig_sdist , cwd = tmp_dir ) <EOL> orig_tarball_top_contents = os . listdir ( tmp_dir ) <EOL> assert len ( orig_tarball_top_contents ) == <NUM_LIT:1> <EOL> orig_dirname = orig_tarball_top_contents [ <NUM_LIT:0> ] <EOL> fullpath_orig_dirname = os . path . join ( tmp_dir , orig_dirname ) <EOL> shutil . rmtree ( fullpath_orig_dirname ) <EOL> finally : <EOL> shutil . rmtree ( tmp_dir ) <EOL> if <NUM_LIT:1> : <EOL> debhelper_version_str = get_version_str ( '<STR_LIT>' ) <EOL> if len ( debhelper_version_str ) == <NUM_LIT:0> : <EOL> log . warn ( '<STR_LIT>' <EOL> '<STR_LIT>' <EOL> '<STR_LIT>' % DH_MIN_VERS ) <EOL> else : <EOL> if not dpkg_compare_versions ( <EOL> debhelper_version_str , '<STR_LIT>' , DH_MIN_VERS ) : <EOL> log . warn ( '<STR_LIT>' <EOL> '<STR_LIT>' <EOL> '<STR_LIT>' % ( <EOL> DH_MIN_VERS , ) ) <EOL> python_defaults_version_str = get_version_str ( '<STR_LIT>' ) <EOL> if len ( python_defaults_version_str ) == <NUM_LIT:0> : <EOL> log . warn ( '<STR_LIT>' <EOL> '<STR_LIT>' <EOL> '<STR_LIT>' % PYTHON_ALL_MIN_VERS ) <EOL> else : <EOL> if not dpkg_compare_versions ( <EOL> python_defaults_version_str , '<STR_LIT>' , PYTHON_ALL_MIN_VERS ) : <EOL> log . warn ( '<STR_LIT>' <EOL> '<STR_LIT>' <EOL> '<STR_LIT>' % ( <EOL> PYTHON_ALL_MIN_VERS , ) ) <EOL> os . rename ( fullpath_repackaged_dirname + '<STR_LIT>' , <EOL> fullpath_repackaged_dirname ) <EOL> if sign_dsc : <EOL> args = ( ) <EOL> else : <EOL> args = ( '<STR_LIT>' , '<STR_LIT>' ) <EOL> dpkg_buildpackage ( '<STR_LIT>' , '<STR_LIT>' , * args , cwd = fullpath_repackaged_dirname ) <EOL> if <NUM_LIT:1> : <EOL> shutil . rmtree ( fullpath_repackaged_dirname ) <EOL> if not remove_expanded_source_dir : <EOL> dsc_name = debinfo . source + '<STR_LIT:_>' + debinfo . dsc_version + '<STR_LIT>' <EOL> dpkg_source ( '<STR_LIT>' , dsc_name , <EOL> cwd = dist_dir ) <EOL> CHANGELOG_FILE = """<STR_LIT>""" <EOL> CONTROL_FILE = """<STR_LIT>""" <EOL> CONTROL_PY2_STANZA = """<STR_LIT>""" <EOL> CONTROL_PY3_STANZA = """<STR_LIT>""" <EOL> RULES_MAIN = """<STR_LIT>""" <EOL> RULES_OVERRIDE_CLEAN_TARGET_PY2 = "<STR_LIT>" <EOL> RULES_OVERRIDE_CLEAN_TARGET_PY3 = "<STR_LIT>" <EOL> RULES_OVERRIDE_CLEAN_TARGET = """<STR_LIT>""" <EOL> RULES_OVERRIDE_BUILD_TARGET_PY2 = "<STR_LIT>" <EOL> RULES_OVERRIDE_BUILD_TARGET_PY3 = "<STR_LIT>" <EOL> RULES_OVERRIDE_BUILD_TARGET = """<STR_LIT>""" <EOL> RULES_OVERRIDE_INSTALL_TARGET_PY2 = "<STR_LIT>" <EOL> RULES_OVERRIDE_INSTALL_TARGET_PY3 = "<STR_LIT>" <EOL> RULES_OVERRIDE_INSTALL_TARGET = """<STR_LIT>""" <EOL> RULES_OVERRIDE_PYTHON3 = """<STR_LIT>""" <EOL> RULES_BINARY_TARGET = """<STR_LIT>""" <EOL> RULES_BINARY_ALL_TARGET = """<STR_LIT>""" <EOL> RULES_BINARY_ARCH_TARGET = """<STR_LIT>""" <EOL> RULES_BINARY_INDEP_TARGET = """<STR_LIT>""" </s>
