fedora-repoquery 0.3 → 0.3.1
raw patch · 6 files changed
+57/−34 lines, 6 files
Files
- ChangeLog.md +4/−0
- README.md +5/−3
- fedora-repoquery.cabal +3/−2
- src/Main.hs +10/−6
- src/Query.hs +30/−22
- src/Types.hs +5/−1
ChangeLog.md view
@@ -1,5 +1,9 @@ # Revision history for fedora-repoquery +## 0.3.1 (2024-02-12)+- use dnf5 when available+- add --all-archs to query across all 64bit architectures+ ## 0.3 (2023-11-09) - Query: no --qf with --changelog - small OS versions now map to centos-stream
README.md view
@@ -8,7 +8,7 @@ - `fdrq rawhide firefox` -- `fdrq 38 --requires podman`+- `fdrq 39 --requires podman` - `fdrq epel9 ghc` @@ -20,7 +20,7 @@ `$ fdrq --version` ```-0.2+0.3.1 ``` `$ fdrq --help` ```@@ -28,7 +28,8 @@ Usage: fdrq [--version] [(-q|--quiet) | (-v|--verbose)] [-K|--koji] [--devel-channel | --test-channel] [(-m|--mirror URL) | (-D|--dl)] - [(-s|--source) | (-a|--arch ARCH)] [-t|--testing] [-d|--debug] + [(-s|--source) | (-A|--all-archs) | [-a|--arch ARCH]] [-t|--testing]+ [-d|--debug] ((-z|--cache-size) | (-e|--cache-clean-empty) | (-l|--list) | RELEASE [[REPOQUERY_OPTS] [PACKAGE]...]) @@ -48,6 +49,7 @@ https://download.fedoraproject.org/pub] -D,--dl Use dl.fp.o -s,--source Query source repos+ -A,--all-archs Query all (64 bit) arch repos -a,--arch ARCH Specify arch [default: x86_64] -t,--testing Fedora updates-testing -d,--debug Show some debug output
fedora-repoquery.cabal view
@@ -1,5 +1,5 @@ name: fedora-repoquery-version: 0.3+version: 0.3.1 synopsis: Fedora repoquery tool description: CLI tool for querying the location and version of Fedora packages@@ -7,7 +7,7 @@ license-file: COPYING author: Jens Petersen <juhpetersen@gmail.com> maintainer: Jens Petersen <juhpetersen@gmail.com>-copyright: 2021-2023 Jens Petersen <juhpetersen@gmail.com>+copyright: 2021-2024 Jens Petersen <juhpetersen@gmail.com> category: Utility homepage: https://github.com/juhp/fedora-repoquery bug-reports: https://github.com/juhp/fedora-repoquery/issues@@ -21,6 +21,7 @@ || == 9.0 || == 9.2 || == 9.4+ || == 9.6 source-repository head type: git
src/Main.hs view
@@ -13,6 +13,7 @@ #endif ) #endif+import Control.Monad (forM_) #if !MIN_VERSION_simple_cmd_args(0,1,7) import Options.Applicative (eitherReader, maybeReader, ReadM) #endif@@ -45,8 +46,9 @@ 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"))- <*> optional (flagWith' Source 's' "source" "Query source repos" <|>- optionWith (eitherReader eitherArch) 'a' "arch" "ARCH" ("Specify arch [default:" +-+ showArch sysarch ++ "]"))+ <*> (flagWith' [Source] 's' "source" "Query source repos" <|>+ flagWith' allArchs 'A' "all-archs" "Query all (64 bit) arch repos" <|>+ many (optionWith (eitherReader eitherArch) 'a' "arch" "ARCH" ("Specify 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"@@ -57,13 +59,15 @@ releaseM :: ReadM Release releaseM = maybeReader readRelease -runMain :: Arch -> Verbosity -> RepoSource -> Maybe Arch -> Bool -> Bool -> Command -> IO ()-runMain sysarch verbose reposource march testing debug command = do+runMain :: Arch -> Verbosity -> RepoSource -> [Arch] -> Bool -> Bool -> Command -> IO ()+runMain sysarch verbose reposource archs testing debug command = do case command of CacheSize -> cacheSize CacheEmpties -> cleanEmptyCaches List -> listVersionsCmd verbose reposource sysarch Query release args -> do if null args- then showReleaseCmd debug reposource release sysarch march testing- else repoqueryCmd debug verbose release reposource sysarch march testing args+ then if null archs+ then showReleaseCmd debug reposource release sysarch Nothing testing+ else forM_ archs $ \arch -> showReleaseCmd debug reposource release sysarch (Just arch) testing+ else repoqueryCmd debug verbose release reposource sysarch archs testing args
src/Query.hs view
@@ -20,7 +20,8 @@ import Network.HTTP.Directory import SimpleCmd import System.Cached.JSON-import System.Directory (doesFileExist)+import System.Directory (doesFileExist, findExecutable)+import System.FilePath (takeBaseName) import Text.Regex #if !MIN_VERSION_simple_cmd(0,2,0)@@ -34,28 +35,35 @@ showReleaseCmd debug reposource release sysarch march testing = void $ showRelease debug Normal False reposource release sysarch march testing +-- FIXME --no-redirect? repoqueryCmd :: Bool -> Verbosity -> Release -> RepoSource -> Arch- -> Maybe Arch -> Bool -> [String] -> IO ()-repoqueryCmd debug verbose release reposource sysarch march testing args = do- repoConfigs <- showRelease debug verbose True reposource release sysarch march testing- let qfAllowed = not $ any (`elem` ["-i","--info","-l","--list","-s","--source","--nvr","--nevra","--envra","-qf","--queryformat", "--changelog"]) args- queryformat = "%{name}-%{version}-%{release}.%{arch} (%{repoid})"- -- LANG=C.utf8- rhsm <- doesFileExist "/etc/dnf/plugins/subscription-manager.conf"- let cmdargs = "repoquery" :- ["--quiet" | verbose /= Verbose] ++- -- https://bugzilla.redhat.com/show_bug.cgi?id=1876828- ["--disableplugin=subscription-manager" | rhsm] ++- (if qfAllowed then ["--qf", queryformat] else []) ++- ["--setopt=module_platform_id=platform:" ++ show release] ++- concatMap renderRepoConfig repoConfigs ++- args- when debug $- warning $ unwords $ "\ndnf" : map show cmdargs- res <- cmdLines "dnf" cmdargs- unless (null res) $ do- unless (verbose == Quiet) $ warning ""- putStrLn $ L.intercalate "\n" res+ -> [Arch] -> Bool -> [String] -> IO ()+repoqueryCmd debug verbose release reposource sysarch archs testing args = do+ forM_ (if null archs then [sysarch] else archs) $ \arch -> do+ repoConfigs <- showRelease debug verbose True reposource release sysarch (Just arch) testing+ let qfAllowed = not $ any (`elem` ["-i","--info","-l","--list","-s","--source","--nvr","--nevra","--envra","-qf","--queryformat", "--changelog"]) args+ mdnf5 <- findExecutable "dnf5"+ let queryformat =+ "%{name}-%{version}-%{release}.%{arch} (%{repoid})" +++ if isJust mdnf5 then "\n" else ""+ -- LANG=C.utf8+ rhsm <- doesFileExist "/etc/dnf/plugins/subscription-manager.conf"+ let cmdargs = "repoquery" :+ ["--quiet" | verbose /= Verbose] +++ -- https://bugzilla.redhat.com/show_bug.cgi?id=1876828+ ["--disableplugin=subscription-manager" | rhsm] +++ (if qfAllowed then ["--qf", queryformat] else []) +++ -- drop modules for F39++ ["--setopt=module_platform_id=platform:" ++ show release] +++ concatMap renderRepoConfig repoConfigs +++ args+ let dnf = fromMaybe "/usr/bin/dnf" mdnf5+ when debug $+ warning $ unwords $ ('\n' : takeBaseName dnf) : map show cmdargs+ res <- cmdLines dnf cmdargs+ unless (null res) $ do+ unless (verbose == Quiet) $ warning ""+ putStrLn $ L.intercalate "\n" res -- majorVersion :: Release -> String -- majorVersion (Fedora n) = show n
src/Types.hs view
@@ -2,6 +2,7 @@ module Types ( Arch(..),+ allArchs, eitherArch, readArch, showArch,@@ -29,10 +30,13 @@ | X86_64 | AARCH64 | ARMV7HL- | S390X | PPC64LE+ | S390X | I386 deriving Eq++allArchs :: [Arch]+allArchs = [X86_64, AARCH64, PPC64LE, S390X] eitherArch :: String -> Either String Arch eitherArch s =