#NEWLINE# def install_from_source( version = DEFAULT_VERSION , checkinstall = False ) : #NEWLINE# #INDENT# '\n    Install Node JS from source.\n\n    If *checkinstall* is ``True``, a distribution package will be built.\n\n    ::\n\n        import fabtools\n\n        # Install Node.js\n        fabtools.nodejs.install_nodejs()\n\n    .. note:: This function may not work for old versions of Node.js.\n\n    ' #NEWLINE# from fabtools.require.deb import packages as require_deb_packages #NEWLINE# from fabtools.require.rpm import packages as require_rpm_packages #NEWLINE# from fabtools.require import file as require_file #NEWLINE# family = distrib_family ( ) #NEWLINE# if ( family == 'debian' ) : #NEWLINE# #INDENT# packages = [ 'build-essential' , 'libssl-dev' , 'python' ] #NEWLINE# if checkinstall : #NEWLINE# #INDENT# packages . append ( 'checkinstall' ) #NEWLINE# #UNINDENT# require_deb_packages ( packages ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( family == 'redhat' ) : #NEWLINE# #INDENT# packages = [ 'gcc' , 'gcc-c++' , 'make' , 'openssl-devel' , 'python' ] #NEWLINE# if checkinstall : #NEWLINE# #INDENT# packages . append ( 'checkinstall' ) #NEWLINE# #UNINDENT# require_rpm_packages ( packages ) #NEWLINE# #UNINDENT# #UNINDENT# filename = ( 'node-v%s.tar.gz' % packages ) #NEWLINE# foldername = filename [ 0 : ( - 7 ) ] #NEWLINE# require_file ( url = ( 'http://nodejs.org/dist/v%(version)s/%(filename)s' % { #NEWLINE# #INDENT# 'version' : version , #NEWLINE# 'filename' : filename , #NEWLINE# #UNINDENT# } ) ) #NEWLINE# run ( ( 'tar -xzf %s' % filename ) ) #NEWLINE# with cd ( foldername ) : #NEWLINE# #INDENT# run ( './configure' ) #NEWLINE# run ( ( 'make -j%d' % ( cpus ( ) + 1 ) ) ) #NEWLINE# if checkinstall : #NEWLINE# #INDENT# run_as_root ( ( 'checkinstall -y --pkgname=nodejs --pkgversion=%(version) --showinstall=no make install' % locals ( ) ) ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# run_as_root ( 'make install' ) #NEWLINE# #UNINDENT# #UNINDENT# run ( ( 'rm -rf %(filename)s %(foldername)s' % locals ( ) ) )