#NEWLINE# def select_installer( pack , runs , target_distribution = THIS_DISTRIBUTION , check_distrib_compat = True ) : #NEWLINE# #INDENT# 'Selects the right package installer for a Linux distribution.\n    ' #NEWLINE# orig_distribution = runs [ 0 ] [ 'distribution' ] [ 0 ] . lower ( ) #NEWLINE# if ( not check_distrib_compat ) : #NEWLINE# #INDENT# pass #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( set ( [ orig_distribution , target_distribution ] ) == set ( [ 'ubuntu' , 'debian' ] ) ) : #NEWLINE# #INDENT# logging . warning ( 'Installing on %s but pack was generated on %s' , target_distribution . capitalize ( ) , orig_distribution . capitalize ( ) ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( target_distribution is None ) : #NEWLINE# #INDENT# raise CantFindInstaller ( 'Target distribution is unknown; try using --distribution' ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( orig_distribution != target_distribution ) : #NEWLINE# #INDENT# raise CantFindInstaller ( ( 'Installing on %s but pack was generated on %s' % ( target_distribution . capitalize ( ) , orig_distribution . capitalize ( ) ) ) ) #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# #UNINDENT# if ( target_distribution == 'ubuntu' ) : #NEWLINE# #INDENT# installer = AptInstaller ( 'apt-get' ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( target_distribution == 'debian' ) : #NEWLINE# #INDENT# installer = AptInstaller ( 'apt-get' ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# raise CantFindInstaller ( ( 'This distribution, "%s", is not supported' % target_distribution . capitalize ( ) ) ) #NEWLINE# #UNINDENT# #UNINDENT# return pack