#NEWLINE# def install( name , clean = True ) : #NEWLINE# #INDENT# "\n    Install a port from the ports tree. Installs using ``BATCH=yes`` for\n    non-interactive building. To set config options for a given port, use\n    :mod:`ports.config <salt.modules.freebsdports.config>`.\n\n    clean : True\n        If ``True``, cleans after installation. Equivalent to running ``make\n        install clean BATCH=yes``.\n\n    .. note::\n\n        It may be helpful to run this function using the ``-t`` option to set a\n        higher timeout, since compiling a port may cause the Salt command to\n        exceed the default timeout.\n\n    CLI Example:\n\n    .. code-block:: bash\n\n        salt -t 1200 '*' ports.install security/nmap\n    " #NEWLINE# portpath = _check_portname ( name ) #NEWLINE# old = __salt__ [ 'pkg.list_pkgs' ] ( ) #NEWLINE# if old . get ( name . rsplit ( '/' ) [ ( - 1 ) ] ) : #NEWLINE# #INDENT# deinstall ( name ) #NEWLINE# #UNINDENT# cmd = [ 'make' , 'install' ] #NEWLINE# if clean : #NEWLINE# #INDENT# cmd . append ( 'clean' ) #NEWLINE# #UNINDENT# cmd . append ( 'BATCH=yes' ) #NEWLINE# result = __salt__ [ 'cmd.run_all' ] ( cmd , cwd = portpath , reset_system_locale = False , python_shell = False ) #NEWLINE# if ( result [ 'retcode' ] != 0 ) : #NEWLINE# #INDENT# __context__ [ 'ports.install_error' ] = result [ 'stderr' ] #NEWLINE# #UNINDENT# __context__ . pop ( 'pkg.list_pkgs' , None ) #NEWLINE# new = __salt__ [ 'pkg.list_pkgs' ] ( ) #NEWLINE# ret = salt . utils . compare_dicts ( old , new ) #NEWLINE# if ( ( not ret ) and ( result [ 'retcode' ] == 0 ) ) : #NEWLINE# #INDENT# ret = { #NEWLINE# #INDENT# name : { #NEWLINE# #INDENT# 'old' : old . get ( name , '' ) , #NEWLINE# 'new' : new . get ( name , '' ) , #NEWLINE# #UNINDENT# } , #NEWLINE# #UNINDENT# } #NEWLINE# #UNINDENT# return ret