Skip to content

Add common interface for pquery #4

Description

@hololeap

This is being used in various places, such as revdep-scanner.

A new subproject inside the cabal-portage project is a good place for this (gentoo-utils?). It should include:

  • A common interface for running commands

    • A re-worked runOpaque using the common error-handling interface

    • A re-worked runTransparent using the common error-handling interface

    • A common interface for handling errors (just an example):

      -- exits with a RunProcessException or else returns captured stdout and stderr
      tryProcess -- better name?
          :: Exception e
          -- Nothing is passed to stdin
          => Maybe (ConduitT ByteString ByteString IO ()) -- extra stuff using stdout (useful for e.g. runTransparent)
          -> Maybe (ConduitT ByteString ByteString IO ()) -- extra stuff using stderr (useful for e.g. runTransparent)
          -> Maybe (ExitCode -> Lazy.Text -> Lazy.Text -> IO (Maybe RunProcessException)) -- tweak exception throwing
          -> CreateProcess -- command to run, arguments, and extra settings
          -> IO (Either RunProcessException (Lazy.Text, Lazy.Text))
      
      data RunProcessException = RPE
          { rpeCP :: CreateProcess
          , rpeExitCode :: ExitCode
          , rpeStdout :: Lazy.Text
          , rpeStderr :: Lazy.Text
          }
    • Should handle errors by displying the command that was run, the exit code, the captured stdout, and the captured stderr, along with any other exceptions thrown.

  • Convenience functions for running common commands, such as pquery, eix, and emerge

  • Convenience functions for running pquery and parsing the output to e.g. HashMaps

  • Orphan instances for portage-hs types (e.g. Hashable) to keep its dependency footprint low

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions