def file_dict(*packages):
 errors = []
 ret = {}
 pkgs = {}
 cmd = 'dpkg -l {0}'.format(' '.join(packages))
 out = __salt__['cmd.run_all'](cmd, python_shell=False)
 if (out['retcode'] != 0):
  msg = ('Error:  ' + out['stderr'])
  log.error(msg)
  return msg
 out = out['stdout']
 for line in out.splitlines():
  if line.startswith('ii '):
   comps = line.split()
   pkgs[comps[1]] = {'version': comps[2], 'description': ' '.join(comps[3:])}
  if ('No packages found' in line):
   errors.append(line)
 for pkg in pkgs:
  files = []
  cmd = 'dpkg -L {0}'.format(pkg)
  for line in __salt__['cmd.run'](cmd, python_shell=False).splitlines():
   files.append(line)
  ret[pkg] = files
 return {'errors': errors, 'packages': ret}

def file_dict ( * packages ) : errors = [ ] ret = { } pkgs = { } cmd = 'dpkg -l {0}' . format ( ' ' . join ( packages ) ) out = __salt__ [ 'cmd.run_all' ] ( cmd , python_shell = False ) if ( out [ 'retcode' ] != 0 ) : msg = ( 'Error:  ' + out [ 'stderr' ] ) log . error ( msg ) return msg out = out [ 'stdout' ] for line in out . splitlines ( ) : if line . startswith ( 'ii ' ) : comps = line . split ( ) pkgs [ comps [ 1 ] ] = { 'version' : comps [ 2 ] , 'description' : ' ' . join ( comps [ 3 : ] ) } if ( 'No packages found' in line ) : errors . append ( line ) for pkg in pkgs : files = [ ] cmd = 'dpkg -L {0}' . format ( pkg ) for line in __salt__ [ 'cmd.run' ] ( cmd , python_shell = False ) . splitlines ( ) : files . append ( line ) ret [ pkg ] = files return { 'errors' : errors , 'packages' : ret }
list the files that belong to a package .