def _create_rpmmacros(runas='root'):
    '''
    Create the .rpmmacros file in user's home directory
    '''
    home = os.path.expanduser('~')
    rpmbuilddir = os.path.join(home, 'rpmbuild')
    if not os.path.isdir(rpmbuilddir):
        __salt__['file.makedirs_perms'](name=rpmbuilddir, user=runas, group='mock')

    mockdir = os.path.join(home, 'mock')
    if not os.path.isdir(mockdir):
        __salt__['file.makedirs_perms'](name=mockdir, user=runas, group='mock')

    rpmmacros = os.path.join(home, '.rpmmacros')
    with salt.utils.files.fopen(rpmmacros, 'w') as afile:
        afile.write(
            salt.utils.stringutils.to_str('%_topdir {0}\n'.format(rpmbuilddir))
        )
        afile.write('%signature gpg\n')
        afile.write('%_source_filedigest_algorithm 8\n')
        afile.write('%_binary_filedigest_algorithm 8\n')
        afile.write('%_gpg_name packaging@saltstack.com\n')
def _create_rpmmacros ( runas = 'root' ) : home = os . path . expanduser ( '~' ) rpmbuilddir = os . path . join ( home , 'rpmbuild' ) if not os . path . isdir ( rpmbuilddir ) : __salt__ [ 'file.makedirs_perms' ] ( name = rpmbuilddir , user = runas , group = 'mock' ) mockdir = os . path . join ( home , 'mock' ) if not os . path . isdir ( mockdir ) : __salt__ [ 'file.makedirs_perms' ] ( name = mockdir , user = runas , group = 'mock' ) rpmmacros = os . path . join ( home , '.rpmmacros' ) with salt . utils . files . fopen ( rpmmacros , 'w' ) as afile : afile . write ( salt . utils . stringutils . to_str ( '%_topdir {0}\n' . format ( rpmbuilddir ) ) ) afile . write ( '%signature gpg\n' ) afile . write ( '%_source_filedigest_algorithm 8\n' ) afile . write ( '%_binary_filedigest_algorithm 8\n' ) afile . write ( '%_gpg_name packaging@saltstack.com\n' )
Create the .rpmmacros file in user's home directory