packages feed

fedora-repoquery 0.1.0 → 0.2

raw patch · 8 files changed

+105/−61 lines, 8 files

Files

ChangeLog.md view
@@ -1,4 +1,12 @@ # Revision history for fedora-repoquery +## 0.2 (2023-05-12)+- support fedora and epel testing repos+- fix fedora archive urls+- support querying epel6 and older archives+- support fedora-secondary urls for ppc64le and s390x including archive+- rename --test to --test-channel and --centos-devel to --devel-channel+- expand help to cover RELEASE and add readme url+ ## 0.1.0 (2023-05-07) - initial release with support for fedora releases, epel, eln and centos stream
README.md view
@@ -1,28 +1,37 @@ # fedora-repoquery -A work-in-progress wrapper for dnf repoquery.+A work-in-progress wrapper for dnf repoquery,+which caches repodata separately per release.  ## Usage Usage examples:  `fdrq rawhide firefox` -`fdrq f38 --requires podman`+`fdrq 38 --requires podman` +`fdrq epel9 ghc`++`fdrq c9 bash`++`fdrq eln kernel`+ etc  ```shellsession $ fdrq --version-0.1.0+0.2 $ fdrq --help-Fedora repoquery tool+fedora-repoquery tool for querying Fedora repos for packages.  Usage: fdrq [--version] [(-q|--quiet) | (-v|--verbose)] [-K|--koji]-            [--centos-devel | --test] [(-m|--mirror URL) | (-D|--dl)]-            [(-s|--source) | (-a|--arch ARCH)] [-d|--debug]+            [--devel-channel | --test-channel] [(-m|--mirror URL) | (-D|--dl)]+            [(-s|--source) | (-a|--arch ARCH)] [-t|--testing] [-d|--debug]             ((-z|--cache-size) | (-e|--cache-clean-empty) | (-l|--list) |               RELEASE [[REPOQUERY_OPTS] [PACKAGE]...])-  Tool for querying Fedora repos for packages.+  where RELEASE is {fN or N (fedora), 'rawhide', epelN, epelN-next, cN (centos+  stream), 'eln'}, with N the release version number.+  https://github.com/juhp/fedora-repoquery#readme  Available options:   -h,--help                Show this help text@@ -30,13 +39,14 @@   -q,--quiet               Avoid output to stderr   -v,--verbose             Show stderr from dnf repoquery   -K,--koji                Use Koji buildroot-  --centos-devel           Use centos-stream development compose-  --test                   Use centos-stream test compose [default: production]+  --devel-channel          Use eln development compose+  --test-channel           Use eln test compose [default: production]   -m,--mirror URL          Fedora mirror [default:                            https://download.fedoraproject.org/pub]   -D,--dl                  Use dl.fp.o   -s,--source              Query source repos   -a,--arch ARCH           Specify 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   -e,--cache-clean-empty   Remove empty dnf caches@@ -48,8 +58,12 @@ [copr](https://copr.fedorainfracloud.org/coprs/petersen/fedora-repoquery/)  ## Building from source-Use `stack install` or `cabal install`.+Use `stack install fedora-repoquery` or `cabal install fedora-repoquery`+to build the latest release. -## Contributing+To build from git: `stack install` or `cabal install`. +## Contributing fedora-repoquery is distributed under the GPL license version 3 or later.++<https://github.com/juhp/fedora-repoquery>
fedora-repoquery.cabal view
@@ -1,5 +1,5 @@ name:                fedora-repoquery-version:             0.1.0+version:             0.2 synopsis:            Fedora repoquery tool description:         CLI tool for querying the location and version of Fedora packages@@ -15,7 +15,12 @@ extra-doc-files:     README.md                      ChangeLog.md cabal-version:       2.0-tested-with:         GHC == 8.4.4, GHC == 8.6.5, GHC == 8.8.4, GHC == 8.10.7+tested-with:         GHC == 8.4+                     ||  == 8.6+                     ||  == 8.8+                     ||  == 9.0+                     ||  == 9.2+                     ||  == 9.4  source-repository head   type:                git
src/List.hs view
@@ -23,7 +23,7 @@ listVersionsCmd verbose reposource = do   mgr <- httpManager   -- FIXME handle non-fedora versions (eg epel)-  (url,_) <- getFedoraServer False mgr reposource fedoraTop ["releases"]+  (url,_) <- getFedoraServer False mgr reposource (fedoraTop X86_64) ["releases"]   let rurl = renderUrl url   unless (verbose == Quiet) $ warning $! "<" ++ rurl ++ ">"   -- FIXME filter very old releases
src/Main.hs view
@@ -16,6 +16,7 @@ #if !MIN_VERSION_simple_cmd_args(0,1,7) import Options.Applicative (eitherReader, maybeReader, ReadM) #endif+import SimpleCmd ((+-+)) import SimpleCmdArgs import System.IO (BufferMode(NoBuffering), hSetBuffering, stdout) @@ -32,18 +33,20 @@ main :: IO () main = do   hSetBuffering stdout NoBuffering-  simpleCmdArgs' (Just version) "Fedora repoquery tool"-    "Tool for querying Fedora repos for packages." $+  simpleCmdArgs' (Just version) "fedora-repoquery tool for querying Fedora repos for packages."+    ("where RELEASE is {fN or N (fedora), 'rawhide', epelN, epelN-next, cN (centos stream), 'eln'}, with N the release version number." +-++     "https://github.com/juhp/fedora-repoquery#readme") $     runMain     <$> (flagWith' Quiet 'q' "quiet" "Avoid output to stderr" <|> flagWith Normal Verbose 'v' "verbose" "Show stderr from dnf repoquery")     <*> (RepoSource           <$> switchWith 'K' "koji" "Use Koji buildroot"-          <*> (flagLongWith' CentosDevel "centos-devel" "Use centos-stream development compose" <|>-               flagLongWith CentosProd CentosTest "test" "Use centos-stream test compose [default: production]")+          <*> (flagLongWith' ChanDevel "devel-channel" "Use eln development compose" <|>+               flagLongWith ChanProd ChanTest "test-channel" "Use eln test compose [default: production]")           <*> ((Mirror <$> strOptionWith 'm' "mirror" "URL" ("Fedora mirror [default: " ++ downloadServer ++ "]")) <|>                flagWith DownloadFpo DlFpo 'D' "dl" "Use dl.fp.o"))     <*> (flagWith' Source 's' "source" "Query source repos" <|>          optionalWith (eitherReader readArch) 'a' "arch" "ARCH" "Specify arch [default: x86_64]" X86_64)+    <*> 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"          <|> flagWith' CacheEmpties 'e' "cache-clean-empty" "Remove empty dnf caches"@@ -53,13 +56,13 @@     releaseM :: ReadM Release     releaseM = maybeReader readRelease -runMain :: Verbosity -> RepoSource -> Arch -> Bool -> Command -> IO ()-runMain verbose reposource arch debug command = do+runMain :: Verbosity -> RepoSource -> Arch -> Bool -> Bool -> Command -> IO ()+runMain verbose reposource arch testing debug command = do   case command of     CacheSize -> cacheSize     CacheEmpties -> cleanEmptyCaches     List -> listVersionsCmd verbose reposource     Query release args -> do       if null args-      then showReleaseCmd debug reposource release arch-      else repoqueryCmd debug verbose release reposource arch args+      then showReleaseCmd debug reposource release arch testing+      else repoqueryCmd debug verbose release reposource arch testing args
src/Query.hs view
@@ -26,14 +26,14 @@ import Types import URL -showReleaseCmd :: Bool -> RepoSource -> Release  -> Arch -> IO ()-showReleaseCmd debug reposource release arch =-  void $ showRelease debug Normal False reposource release arch+showReleaseCmd :: Bool -> RepoSource -> Release  -> Arch -> Bool -> IO ()+showReleaseCmd debug reposource release arch testing =+  void $ showRelease debug Normal False reposource release arch testing -repoqueryCmd :: Bool -> Verbosity -> Release -> RepoSource -> Arch -> [String]-             -> IO ()-repoqueryCmd debug verbose release reposource arch args = do-  repoConfigs <- showRelease debug verbose True reposource release arch+repoqueryCmd :: Bool -> Verbosity -> Release -> RepoSource -> Arch -> Bool+             -> [String] -> IO ()+repoqueryCmd debug verbose release reposource arch testing args = do+  repoConfigs <- showRelease debug verbose True reposource release arch testing   let qfAllowed = not $ any (`elem` ["-i","--info","-l","--list","-s","--source","--nvr","--nevra","--envra","-qf","--queryformat"]) args       queryformat = "%{name}-%{version}-%{release}.%{arch} (%{repoid})"   -- LANG=C.utf8@@ -64,7 +64,8 @@   case release of     Centos _ -> '-':repo     ELN -> '-':repo-    Fedora _ | repo == "updates" -> '-':repo+    EPEL _ -> if repo == "epel-testing" then "-testing" else ""+    Fedora _ | repo /= "releases" -> '-':repo     _ -> ""  repoConfigArgs :: RepoSource -> Arch -> Release@@ -83,9 +84,9 @@         case release of           Centos _ -> [repo, showArch arch] ++ (if arch == Source then ["tree"] else ["os"])           ELN -> [repo, showArch arch] ++ (if arch == Source then ["tree"] else ["os"])-          EPEL _n -> ["Everything", showArch arch]+          EPEL n -> (if n >= 7 then ("Everything" :) else id) [showArch arch]           EPELNext _n -> ["Everything", showArch arch]-          Fedora _ -> ["Everything", showArch arch] ++ (if arch == Source then ["tree"] else ["os" | repo /= "updates"])+          Fedora _ -> ["Everything", showArch arch] ++ (if arch == Source then ["tree"] else ["os" | repo == "releases"])           Rawhide -> ["Everything", showArch arch, if arch == Source then "tree" else "os"]   in (reponame, (url, path)) -- koji@@ -107,10 +108,10 @@   ["--repofrompath", name ++ "," ++ renderUrl url, "--repo", name]  showRelease :: Bool -> Verbosity -> Bool -> RepoSource -> Release -> Arch-            -> IO [(String, URL)]-showRelease debug verbose warn reposource@(RepoSource koji _chan _mirror) release arch = do+            -> Bool -> IO [(String, URL)]+showRelease debug verbose warn reposource@(RepoSource koji _chan _mirror) release arch testing = do   mgr <- httpManager-  (url,path) <- getURL debug mgr reposource release+  (url,path) <- getURL debug mgr reposource release arch   let urlpath = url +//+ path   when debug $ putStrLn $ renderUrl urlpath   repos <-@@ -124,9 +125,12 @@         return $           if pending           then [("development", urlpath)]-          else [("releases", urlpath),-                ("updates", url +//+ ["updates",show n])]-      EPEL _n -> return [("epel",urlpath)]+          else ("releases", urlpath) :+               ("updates", url +//+ ["updates",show n]) :+               [("updates-testing", url +//+ ["updates","testing",show n]) | testing]+      EPEL n -> return $+                 ("epel",urlpath) :+                 [("epel-testing",url +//+ ["testing", show n]) | testing]       EPELNext _n -> return [("epelnext",urlpath)]   forM repos $ \repourl -> do     let (reponame,(url',path')) = repoConfigArgs reposource arch release repourl@@ -149,7 +153,8 @@                     EPEL _ -> url' +//+ ["Everything", "state"]                     EPELNext _ -> url' +//+ ["Everything", "state"]                     Fedora _ -> url' +//+-                                if "updates" `L.isSuffixOf` reponame+                                if "updates" `L.isSuffixOf` reponame ||+                                   "updates-testing" `L.isSuffixOf` reponame                                 then ["Everything", "state"]                                 else ["COMPOSE_ID"]                     Rawhide -> url' +//+ ["COMPOSE_ID"]@@ -168,14 +173,18 @@ downloadServer :: String downloadServer = "https://download.fedoraproject.org/pub" -fedoraTop :: [String]-fedoraTop = ["fedora", "linux"]+fedoraTop :: Arch -> [String]+fedoraTop arch =+  -- FIXME support older archs+  if arch `elem` [PPC64LE, S390X]+  then ["fedora-secondary"]+  else ["fedora", "linux"]  epelTop :: [String] epelTop = ["epel"] -getURL :: Bool -> Manager -> RepoSource -> Release -> IO (URL,[String])-getURL debug mgr reposource@(RepoSource koji chan _mirror) release =+getURL :: Bool -> Manager -> RepoSource -> Release -> Arch -> IO (URL,[String])+getURL debug mgr reposource@(RepoSource koji chan _mirror) release arch =   case release of     Centos 9 ->       let url = URL $@@ -188,17 +197,21 @@     Centos _ -> error' "old Centos is not supported yet"     ELN ->       return (URL "https://odcs.fedoraproject.org/composes", [channel chan, "latest-Fedora-ELN", "compose"])+    EPEL n | n < 7 ->+               return+               (URL "https://archives.fedoraproject.org/pub/archive/epel", [show n])+    EPEL n -> getFedoraServer debug mgr reposource epelTop [show n]+    EPELNext n -> getFedoraServer debug mgr reposource (epelTop ++ ["next"]) [show n]     -- FIXME hardcoded     Fedora n | n < 36 ->                return-               (URL "https://archives.fedoraproject.org/pub/archive/fedora/linux/releases", [show n])-    Rawhide -> getFedoraServer debug mgr reposource fedoraTop ["development", "rawhide"]+               (URL "https://archives.fedoraproject.org/pub/archive" +//+ fedoraTop arch, ["releases", show n])+    -- FIXME handle rawhide version     Fedora n -> do       pending <- pendingFedoraRelease n-      getFedoraServer debug mgr reposource fedoraTop+      getFedoraServer debug mgr reposource (fedoraTop arch)         [if pending then "development" else "releases", show n]-    EPEL n -> getFedoraServer debug mgr reposource epelTop [show n]-    EPELNext n -> getFedoraServer debug mgr reposource (epelTop ++ ["next"]) [show n]+    Rawhide -> getFedoraServer debug mgr reposource (fedoraTop arch) ["development", "rawhide"]  pendingFedoraRelease :: Natural -> IO Bool pendingFedoraRelease n = do
src/Types.hs view
@@ -7,7 +7,7 @@   Mirror(..),   Natural,   RepoSource(..),-  CentosChannel(..),+  Channel(..),   channel,   Verbosity(..),   Release(..),@@ -57,21 +57,21 @@   deriving Eq  -- True for koji-data RepoSource = RepoSource Bool CentosChannel Mirror+data RepoSource = RepoSource Bool Channel Mirror   deriving Eq -data CentosChannel = CentosDevel | CentosTest | CentosProd+data Channel = ChanDevel | ChanTest | ChanProd   deriving Eq -channel :: CentosChannel -> String-channel CentosDevel = "development"-channel CentosTest = "test"-channel CentosProd = "production"+channel :: Channel -> String+channel ChanDevel = "development"+channel ChanTest = "test"+channel ChanProd = "production" -instance Show CentosChannel where-  show CentosDevel = "devel"-  show CentosTest = "test"-  show CentosProd = "prod"+instance Show Channel where+  show ChanDevel = "devel"+  show ChanTest = "test"+  show ChanProd = "prod"  data Release = EPEL Natural | EPELNext Natural | Centos Natural | Fedora Natural | ELN | Rawhide   deriving (Eq, Ord)
test/tests.hs view
@@ -4,7 +4,7 @@ fdrq :: [String] -> IO () fdrq args = do   putStrLn ""-  putStrLn $ "# " ++ head args+  putStrLn $ "# " ++ unwords args   let debug = False   (ok, out, err) <- cmdFull "fdrq" (["-d" | debug] ++ args) ""   if null err@@ -18,7 +18,8 @@ tests :: [[String]] tests =   [["rawhide", "coreutils"]-  ,["37", "fontconfig"]+  ,["38", "fontconfig"]+  ,["-t", "37", "podman"]   ,["eln", "ibus"]   ,["epel9", "ghc"]   ,["c9", "kernel"]