fedora-repoquery 0.9.1 → 1.0
raw patch · 9 files changed
+173/−74 lines, 9 files
Files
- ChangeLog.md +12/−0
- README.md +55/−39
- fedora-repoquery.cabal +1/−1
- src/BodhiRelease.hs +10/−0
- src/Main.hs +61/−20
- src/Query.hs +11/−7
- src/Release.hs +14/−1
- src/Types.hs +1/−0
- test/tests.hs +8/−6
ChangeLog.md view
@@ -1,5 +1,17 @@ # Version history for fedora-repoquery +# 1.0 (2026-11-25)+- new `--whatrequires-source`: a triple repoquery+- new `--minor` option for epel10 that adds active minor release+- new `--all-centos`+- rename `--repo-arch` (`-a`) to `--basearch`+- `--wo` alias for `--whatobsoletes`+- `dnf string --options` now error if followed by "-option"+- `--help`: add `--queryformat` abbreviations+- Query: `--qf` add aliases 's' and 'srpm'+- `--sourcerpms` cannot use `--queryformat`+- `frpq -a ...` now errors without a release+ ## 0.9.1 (2026-06-28) - fix IO memory leak due to lazy String IO with typed-process (thank you to Efraim Kaov for reporting this)
README.md view
@@ -10,11 +10,11 @@ `$ fedora-repoquery rawhide firefox` ```-firefox-152.0.2-1.fc45.x86_64 (fedora-rawhide)+firefox-160.0-1.fc46.x86_64 (fedora-rawhide) ```-(note it is shorter to write `fedora-repoquery 45`).+(note it is shorter to write `fedora-repoquery 46`). -`$ fedora-repoquery 43 --requires filesystem`+`$ fedora-repoquery 44 --requires filesystem` ``` group(mail)@@ -32,12 +32,13 @@ ``` bash-5.2.26-4.el10.x86_64 (c10s-BaseOS) bash-5.2.26-6.el10.x86_64 (c10s-BaseOS)+bash-5.2.26-7.el10.x86_64 (c10s-BaseOS) ``` `$ fedora-repoquery eln kernel` ```-kernel-7.2.0-0.rc0.260626g4edcdefd4083.12.eln157.x86_64 (eln-BaseOS)+kernel-7.4.0-0.rc4.33.eln159.x86_64 (eln-BaseOS) ``` Without a release argument, the system yum repo configuration is used:@@ -45,70 +46,80 @@ `$ fedora-repoquery pandoc-cli` ```-pandoc-cli-3.7.0.2-40.fc44.x86_64 (rawhide)+pandoc-cli-3.7.0.2-41.fc45.x86_64 (rawhide) ``` `$ fedora-repoquery --whatrequires pandoc` ```-openqa-devel-5^20260604git6376095-3.fc45.noarch (rawhide)-pandoc-pdf-3.7.0.2-40.fc44.x86_64 (rawhide)-python3-pypandoc-1.17-2.fc45.noarch (rawhide)+openqa-devel-5^20260604git6376095-7.fc46.noarch (rawhide)+pandoc-pdf-3.7.0.2-41.fc45.x86_64 (rawhide)+python3-pypandoc-1.17-3.fc45.noarch (rawhide) ``` -Use the --time (-T) option to display repo timestamps:+Use the --time (-T) option to display repo timestamps to stderr: ```-$ fedora-repoquery -T 43 fedrq-2025-10-26 01:59:02 +08 <https://mirror.freedif.org/fedora/fedora/linux/releases/43/>-2026-03-12 09:53:14 +08 <https://mirror.freedif.org/fedora/fedora/linux/updates/43/>+$ fedora-repoquery -T 45 fedrq+2026-11-03 19:32:59 +08 <https://mirror.freedif.org/fedora/fedora/linux/releases/45/>+2026-11-25 09:57:50 +08 <https://mirror.freedif.org/fedora/fedora/linux/updates/45/> -fedrq-1.5.0-5.fc43.noarch (f43)+fedrq-1.8.0-1.fc45.noarch (f45)+fedrq-1.9.1-1.fc45.noarch (f45-updates) ``` Repo timestamp(s) are output when there are no query args after the release version: -`$ fedora-repoquery 44`+`$ fedora-repoquery 45` ```-2026-04-24 23:40:25 +08 <https://mirror.freedif.org/fedora/fedora/linux/releases/44/>-2026-06-28 08:55:58 +08 <https://mirror.freedif.org/fedora/fedora/linux/updates/44/>+2026-11-03 19:32:59 +08 <https://mirror.freedif.org/fedora/fedora/linux/releases/45/>+2026-11-25 09:57:50 +08 <https://mirror.freedif.org/fedora/fedora/linux/updates/45/> ``` One can also query multiple releases (or arch's): -`$ fedora-repoquery 43 44 python3.x86_64`+`$ fedora-repoquery 44 45 python3.x86_64` ```-python3-3.14.0-1.fc43.x86_64 (f43)-python3-3.14.6-1.fc43.x86_64 (f43-updates)+python3-3.14.10-1.fc44.x86_64 (f44-updates) python3-3.14.3-2.fc44.x86_64 (f44)-python3-3.14.6-1.fc44.x86_64 (f44-updates)+python3-3.15.0-1.fc45.x86_64 (f45)+python3-3.15.2-1.fc45.x86_64 (f45-updates) ``` +Since 1.0, a `--wrsrc` triple repoquery is supported:++`$ fedora-repoquery 45 --whatrequires-source mpich --latest-limit 1 | wc -l`++```+191+```+which uses the local system arch (use `--source` to limit to src packages).+ There is an option to use the CloudFront cache: -`$ fedora-repoquery --cf 44 rust`+`$ fedora-repoquery --cf 45 rust` ```-rust-1.94.1-1.fc44.x86_64 (f44-cf)-rust-1.96.0-1.fc44.x86_64 (f44-updates-cf)+rust-1.100.0-1.fc45.x86_64 (f45-updates-cf)+rust-1.98.1-1.fc45.x86_64 (f45-cf) ``` which may be faster than dl.fp.o and fresher than other mirrors sometimes. Querying of epel10 minor versions is supported: -`$ fedora-repoquery epel10.2 nix`+`$ fedora-repoquery epel10.3 nix` ```-nix-2.31.5-3.el10_2.x86_64 (epel10.2)+nix-2.31.6-1.el10_3.x86_64 (epel10.3) ``` ## Help `$ fedora-repoquery --version` ```-0.9.1+1.0 ``` `$ fedora-repoquery --help`@@ -119,9 +130,10 @@ Usage: fedora-repoquery [--version] [-4|--dnf4] [(-q|--quiet) | (-v|--verbose)] [--dynamic] [-T|--time] [-K|--koji] [(-m|--mirror URL) | --cf | (-d|--dl)]- [(-F|--all-fedora) | (-E|--all-epel) | --all-releases]+ [(-F|--all-fedora) | (-E|--all-epel) | --all-releases |+ --all-centos] [--minor] [(-s|--source) | (-A|--all-archs) |- [-a|--repo-arch ARCH]] [-t|--testing] [-D|--debug]+ [-a|--basearch ARCH]] [-t|--testing] [-D|--debug] [(-z|--cache-size) | (-e|--cache-clean-empty) | --list-releases | --help-dnf | [--advisories ARG | --advisory-severities ARG |@@ -135,20 +147,22 @@ --security | --srpm | --unneeded | --upgrades | --userinstalled | --whatconflicts ARG | (--wd|--whatdepends ARG) | --whatenhances ARG |- --whatobsoletes ARG | (--whatprovides|--wp ARG) |- --whatrecommends ARG | (--whatrequires|--wr ARG) |- --whatsuggests ARG | --whatsupplements ARG |- --conflicts | --depends | --enhances | --files |- (-l|--list) | --obsoletes | (-p|--provides) |- --recommends | (-r|--requires) | --requires-pre |- --sourcerpm | --suggests | --supplements |- --location | (-i|--info) |+ (--whatobsoletes|--wo ARG) |+ (--whatprovides|--wp ARG) | --whatrecommends ARG |+ (--whatrequires|--wr ARG) | --whatsuggests ARG |+ --whatsupplements ARG | --conflicts | --depends |+ --enhances | --files | (-l|--list) | --obsoletes |+ (-p|--provides) | --recommends | (-r|--requires) |+ --requires-pre | --sourcerpm | --suggests |+ --supplements | --location | (-i|--info) | (--changelog|--changelogs) | --querytags |- (--qf|--queryformat ARG)]+ (--qf|--queryformat ARG) |+ (--whatrequires-source|--wrsrc)] [[RELEASE]... [REPOQUERY_OPTS]... [PKGSPECIFIER]...]] where RELEASE is {fN or N (fedora), 'rawhide', epelN, epel10.x, epel9-next, cN- (centos stream), 'eln'}, with N the release version number.+ (centos stream), 'eln'}, with N the release version number. Queryformat+ supports abbrevs: n,nv,nvr,nvra,envra,default,s,srpm. <https://github.com/juhp/fedora-repoquery#readme> Available options:@@ -167,9 +181,11 @@ -F,--all-fedora Query all current Fedora releases -E,--all-epel Query all current EPEL releases --all-releases Query all current releases+ --all-centos Query all Centos Stream releases+ --minor Query active epel minor releases -s,--source Query source repos -A,--all-archs Query all arch repos- -a,--repo-arch ARCH Specify repo arch [default: x86_64]+ -a,--basearch ARCH Specify repo arch [default: x86_64] -t,--testing Fedora updates-testing -D,--debug Show some debug output -z,--cache-size Show total dnf repo metadata cache disksize
fedora-repoquery.cabal view
@@ -1,5 +1,5 @@ name: fedora-repoquery-version: 0.9.1+version: 1.0 synopsis: Fedora release repos package query tool description: A CLI tool for repoquerying Fedora and Centos Stream release packages:
src/BodhiRelease.hs view
@@ -7,6 +7,7 @@ activeEPELMinorRelease, activeBodhiFedoraReleases, activeBodhiEPELReleases,+ activeBodhiEPELMinorReleases, activeBodhiReleases, rawhideFedoraRelease )@@ -113,3 +114,12 @@ actives <- activeBodhiFedoraReleases let pending = map releaseVersion (filter (\r -> releaseState r == "pending") actives) return $ read $ maximum (delete "eln" pending)++activeBodhiEPELMinorReleases :: Natural -> IO [BodhiRelease]+activeBodhiEPELMinorReleases n =+ if n < 10+ then return []+ else filter (\r -> show n == (majorVer . releaseVersion $ r)) <$>+ activeBodhiEPELReleases+ where+ majorVer = takeWhile (/= '.')
src/Main.hs view
@@ -13,13 +13,14 @@ #endif ) #endif-import Control.Monad (forM_, unless, when)+import Control.Monad.Extra (concatMapM, forM_, unless, void, when) import Data.Either (partitionEithers)+import Data.List.Extra (delete, elemIndices, word1) import Data.Maybe (isNothing) #if !MIN_VERSION_base(4,11,0) import Data.Semigroup ((<>)) #endif-import Options.Applicative (flag', long, short, strOption,+import Options.Applicative (flag', long, option, short, Mod, OptionFields, #if !MIN_VERSION_simple_cmd_args(0,1,7) eitherReader #endif@@ -34,14 +35,14 @@ import List (listVersionsCmd) import Paths_fedora_repoquery (version) import Query-import Release (activeFedoraReleases, activeEPELReleases, activeReleases,- downloadServer, showReleaseCmd)+import Release (activeCentosReleases, activeFedoraReleases, activeEPELReleases,+ activeReleases, downloadServer, mapMinors, showReleaseCmd) import Types (Mirror(..), RepoSource(..), Verbosity(..), eitherRelease) data Command = Query [DnfOption] [String] | CacheSize | CacheEmpties | DnfHelp | ReleaseList -data AllReleases = AllFedora | AllEPEL | AllReleases+data AllReleases = AllFedora | AllEPEL | AllReleases | AllCentos main :: IO () main = do@@ -56,7 +57,8 @@ sysarch <- getSystemArch simpleCmdArgs (Just version) "fedora-repoquery tool for querying Fedora repos for packages." ("where RELEASE is {fN or N (fedora), 'rawhide', epelN, epel10.x, epel9-next, cN (centos stream), 'eln'}, with N the release version number." +-+- "<https://github.com/juhp/fedora-repoquery#readme>") $+ "Queryformat supports abbrevs: n,nv,nvr,nvra,envra,default,s,srpm."+ +-+ "<https://github.com/juhp/fedora-repoquery#readme>") $ runMain sysarch <$> switchWith '4' "dnf4" "Use dnf4 instead of dnf5 (if available)" <*> (flagWith' Quiet 'q' "quiet" "Avoid output to stderr" <|>@@ -70,10 +72,12 @@ flagWith DownloadFpo DlFpo 'd' "dl" "Use dl.fp.o")) <*> optional (flagWith' AllFedora 'F' "all-fedora" "Query all current Fedora releases" <|> flagWith' AllEPEL 'E' "all-epel" "Query all current EPEL releases" <|>- flagLongWith' AllReleases "all-releases" "Query all current releases")+ flagLongWith' AllReleases "all-releases" "Query all current releases" <|>+ flagLongWith' AllCentos "all-centos" "Query all Centos Stream releases")+ <*> switchLongWith "minor" "Query active epel minor releases" <*> (flagWith' [Source] 's' "source" "Query source repos" <|> flagWith' allArchs 'A' "all-archs" "Query all arch repos" <|>- many (optionWith (eitherReader eitherArch) 'a' "repo-arch" "ARCH" ("Specify repo arch [default:" +-+ showArch sysarch ++ "]")))+ many (optionWith (eitherReader eitherArch) 'a' "basearch" "ARCH" ("Specify repo arch [default:" +-+ showArch sysarch ++ "]"))) <*> switchWith 't' "testing" "Fedora updates-testing" <*> switchWith 'D' "debug" "Show some debug output" <*> (flagWith' CacheSize 'z' "cache-size" "Show total dnf repo metadata cache disksize"@@ -85,15 +89,24 @@ -- man 8 dnf-repoquery (dnf5-5.2.17.0-2.fc44) -- https://github.com/rpm-software-management/dnf5/blob/main/doc/commands/repoquery.8.rst +strOption' :: Mod OptionFields String -> Parser String+strOption' = option noLeadingDash+ where+ noLeadingDash :: ReadM String+ noLeadingDash = eitherReader $ \s ->+ case s of+ ('-' : _) -> Left "Value cannot start with '-'"+ _ -> Right s+ dnfFlag, dnfOption :: String -> Parser DnfOption dnfFlag o = flag' (DnfFlag o) (long o)-dnfOption o = DnfOption o <$> strOption (long o)+dnfOption o = DnfOption o <$> strOption' (long o) dnfFlag', dnfOption' :: Char -> String -> Parser DnfOption dnfFlag' s l = flag' (DnfFlag l) (short s <> long l)-dnfOption' s l = DnfOption l <$> strOption (short s <> long l)-dnfFlag'', dnfOption'' :: String -> String -> Parser DnfOption+dnfOption' s l = DnfOption l <$> strOption' (short s <> long l)+dnfFlag'', dnfOption'':: String -> String -> Parser DnfOption dnfFlag'' s l = flag' (DnfFlag l) (long s <> long l)-dnfOption'' s l = DnfOption l <$> strOption (long s <> long l)+dnfOption'' s l = DnfOption l <$> strOption' (long s <> long l) queryOptions :: Parser DnfOption queryOptions =@@ -128,7 +141,7 @@ <|> dnfOption "whatconflicts" <|> dnfOption'' "wd" "whatdepends" <|> dnfOption "whatenhances"- <|> dnfOption "whatobsoletes"+ <|> dnfOption'' "wo" "whatobsoletes" <|> dnfOption'' "wp" "whatprovides" <|> dnfOption "whatrecommends" <|> dnfOption'' "wr" "whatrequires"@@ -153,10 +166,13 @@ <|> dnfFlag'' "changelog" "changelogs" <|> dnfFlag "querytags" <|> dnfOption'' "qf" "queryformat"+ -- Custom+ <|> dnfFlag'' "wrsrc" "whatrequires-source" runMain :: Arch -> Bool -> Verbosity -> Bool -> Bool -> RepoSource- -> Maybe AllReleases -> [Arch] -> Bool -> Bool -> Command -> IO ()-runMain sysarch dnf4 verbose dynredir time reposource mallreleases archs testing debug command = do+ -> Maybe AllReleases -> Bool -> [Arch] -> Bool -> Bool -> Command+ -> IO ()+runMain sysarch dnf4 verbose dynredir time reposource mallreleases minor archs testing debug command = do case command of CacheSize -> cacheSize CacheEmpties -> cleanEmptyCaches@@ -168,9 +184,13 @@ in do unless (null releases || isNothing mallreleases) $ error' "cannot specify releases and --all-{fedora,epel}"- when (null releases && isNothing mallreleases) $+ unless (not minor || isNothing mallreleases) $+ warning "ignoring: --minor with --all-{epel,fedora,releases}"+ when (null releases && isNothing mallreleases) $ do+ unless (null archs) $+ error' "--basearch only works with a specified release" when (verbose == Verbose || debug) $- warning "(using system repos)"+ warning "(using system repos)" releaselist <- if null releases then@@ -181,13 +201,34 @@ AllFedora -> activeFedoraReleases AllEPEL -> activeEPELReleases AllReleases -> activeReleases+ AllCentos -> activeCentosReleases Nothing -> return [Nothing]- else return $ map Just releases+ else+ if minor+ then map Just <$> concatMapM mapMinors releases+ else return $ map Just releases forM_ releaselist $ \mrelease -> if null args && null opts then if null archs then showReleaseCmd debug dynredir reposource mrelease sysarch Nothing testing else forM_ archs $ \arch -> showReleaseCmd debug dynredir reposource mrelease sysarch (Just arch) testing else- let multiple = length releaselist > 1 || length archs > 1- in repoqueryCmd dnf4 debug verbose multiple dynredir time mrelease reposource sysarch archs testing opts args+ case length $ elemIndices (DnfFlag "whatrequires-source") opts of+ 0 ->+ let multiple = length releaselist > 1 || length archs > 1+ in+ forM_ (if null archs then [sysarch] else archs) $ \arch ->+ void $ repoqueryCmd dnf4 debug verbose True multiple dynredir time mrelease reposource sysarch arch testing opts args+ 1 -> do+ -- handle "--wrsrc"+ let opts' = delete (DnfFlag "whatrequires-source") opts+ multiple = length releaselist > 1 || length archs > 1+ srcprovs <- repoqueryCmd dnf4 debug verbose False multiple dynredir time mrelease reposource sysarch Source testing (DnfFlag "provides" : opts') args+ let prvpkg = fst . word1+ subpkgs = map prvpkg srcprovs+ -- FIXME handle (other) archs+ provides <- repoqueryCmd dnf4 debug verbose False multiple dynredir time mrelease reposource sysarch sysarch testing (DnfFlag "provides" : opts') subpkgs+ let prvs = map prvpkg provides+ forM_ (if null archs then [Source,sysarch] else archs) $ \arch ->+ void $ repoqueryCmd dnf4 debug verbose True multiple dynredir time mrelease reposource sysarch arch testing (opts' ++ map (DnfOption "whatrequires") prvs) []+ _ -> error' "more than one --whatrequires-source option"
src/Query.hs view
@@ -6,7 +6,7 @@ ) where import Control.Monad.Extra-import qualified Data.ByteString.Lazy as B+import qualified Data.ByteString.Lazy.Char8 as B import Data.Char (isSpace) import Data.List.Extra import Data.Maybe (fromMaybe, isJust, isNothing)@@ -49,15 +49,15 @@ "list", "location", "source",+ "sourcerpm", "queryformat", "changelogs" ] -repoqueryCmd :: Bool -> Bool -> Verbosity -> Bool -> Bool -> Bool- -> Maybe Release -> RepoSource -> Arch -> [Arch] -> Bool- -> [DnfOption] -> [String] -> IO ()-repoqueryCmd dnf4 debug verbose multiple dynredir checkdate mrelease reposource sysarch archs testing opts args = do- forM_ (if null archs then [sysarch] else archs) $ \arch -> do+repoqueryCmd :: Bool -> Bool -> Verbosity -> Bool -> Bool -> Bool -> Bool+ -> Maybe Release -> RepoSource -> Arch -> Arch -> Bool+ -> [DnfOption] -> [String] -> IO [String]+repoqueryCmd dnf4 debug verbose output multiple dynredir checkdate mrelease reposource sysarch arch testing opts args = do repoConfigs <- case mrelease of Nothing -> return []@@ -91,8 +91,10 @@ unless (B.null err) $ B.putStr err unless (B.null out) $ do unless (not checkdate || isNothing mrelease || multiple) $ warning ""- B.putStr out+ when output $+ B.putStr out unless (ok == ExitSuccess) exitFailure+ return $ map B.unpack . B.lines $ out where queryFormatAllowed = not $ any (`elem` map DnfFlag noQueryFormatOptions) opts@@ -119,6 +121,8 @@ "envr" -> "%{epoch}:" ++ expandQf "nvr" "envra" -> "%{epoch}:" ++ expandQf "nvra" "default" -> "%{full_nevra}"+ "s" -> "%{source_name}"+ "srpm" -> "%{sourcerpm}" _ -> qf renderRepoConfig :: (String, URL) -> [String]
src/Release.hs view
@@ -6,7 +6,9 @@ activeFedoraReleases, activeEPELReleases, activeReleases,- downloadServer+ activeCentosReleases,+ downloadServer,+ mapMinors ) where @@ -386,6 +388,12 @@ (_,_) -> dropWhileEnd (== '/') s ++ '/' : dropWhile (== '/') t #endif +mapMinors :: Release -> IO [Release]+mapMinors (EPEL n) | n >= 10 = do+ minors <- activeBodhiEPELMinorReleases n+ return $ map releaseBranch minors+mapMinors rel = return [rel]+ activeFedoraReleases :: IO [Release] activeFedoraReleases = sortReleases <$> activeBodhiFedoraReleases@@ -401,3 +409,8 @@ sortReleases :: [BodhiRelease] -> [Release] sortReleases = sortOn Down . map releaseBranch++-- FIXME hardcorded+activeCentosReleases :: IO [Release]+activeCentosReleases =+ return [Centos 10, Centos 9, Centos 8]
src/Types.hs view
@@ -1,5 +1,6 @@ {-# LANGUAGE OverloadedStrings #-} +-- FIXME split by types module Types ( Mirror(..), Natural,
test/tests.hs view
@@ -2,8 +2,8 @@ import Control.Monad (unless) import SimpleCmd -fdrq :: ([String],Maybe String) -> IO ()-fdrq (args,mpkg) = do+frpq :: ([String],Maybe String) -> IO ()+frpq (args,mpkg) = do putStrLn "" putStrLn $ "# " ++ unwords args +-+ fromMaybe "" mpkg let debug = False@@ -18,7 +18,7 @@ -- copied from dl-fedora branched :: Int-branched = 44+branched = 45 current, previous, prevprev, rawhide :: String current = show branched previous = show (branched - 1)@@ -34,7 +34,8 @@ ,([previous], Nothing) ,(["eln"], Nothing) ,(["epel10"], Nothing)- ,(["epel10.2"], Nothing)+ ,(["epel10.3"], Nothing)+ ,(["epel10", "--minor"], Nothing) ,(["epel9"], Nothing) ,(["epel8"], Nothing) ,(["epel7"], Nothing)@@ -59,17 +60,18 @@ ,(["epel8"], Just "ghc") ,(["epel9"], Just "ghc") ,(["epel10"], Just "ghc")+ ,(["epel10.3"], Just "ghc-srpm-macros") ,(["epel10.2"], Just "ghc-srpm-macros")- ,(["epel10.1"], Just "ghc-srpm-macros") ,(["c10"], Just "bash") ,(["c9"], Just "kernel") ,(["c8"], Just "bash") ,(["c7"], Just "gcc") ,(["c6"], Just "gcc") ,(["rawhide", "--whatprovides"], Just "perl(Regexp::Pattern::License)")+ ,(["rawhide", "--wrsrc"], Just "perl-Regexp-Pattern-License") ] main :: IO () main = do- mapM_ fdrq tests+ mapM_ frpq tests putStrLn $ show (length tests) ++ " tests ran"