Last active
January 16, 2023 02:21
-
-
Save biqqles/eed4e4fb5803f908039038372aad719b to your computer and use it in GitHub Desktop.
Recursively collect eopkg revdeps
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- solo.hs // usage: solo <pkgs> | |
import Data.Function ((&)) | |
import Data.List (isInfixOf, isSuffixOf, nub, sort) | |
import Data.List.Split (splitOn) | |
import System.Environment (getArgs) | |
import System.Process (readProcess) | |
import Text.Regex.PCRE ((=~)) | |
eopkg_info :: [String] -> IO [String] | |
eopkg_info pkgs = do | |
info <- readProcess "eopkg" ("info" : pkgs) [] | |
return $ splitOn "\n\n" info | |
revdeps_of :: [String] -> IO [String] | |
revdeps_of pkgs = do | |
infos <- eopkg_info pkgs | |
return $ infos | |
& filter is_remote | |
& map extract_revdeps | |
& concat | |
& filter (not.is_subpackage) | |
where | |
is_remote = isInfixOf "Package found" | |
is_subpackage pkg = any (`isSuffixOf` pkg) ["dbginfo", "devel"] | |
extract_revdeps :: String -> [String] | |
extract_revdeps info = (info =~ "[^:]+\\z") & words | |
collect_revdeps :: [String] -> IO [String] | |
collect_revdeps start = do | |
revdeps <- revdeps_of start | |
if null revdeps then | |
return start | |
else do | |
tree <- collect_revdeps revdeps | |
return (start ++ revdeps ++ tree) | |
main = getArgs | |
>>= collect_revdeps | |
>>= putStr.unlines.sort.nub |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment